Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Re: file signature

Reply
Thread Tools

Re: file signature

 
 
Richard
Guest
Posts: n/a
 
      09-25-2008

"Bill Cunningham" <(E-Mail Removed)> writes:

> I can't use stdc to write a file signature for a file format can I?
> Wouldn't I have to get into the sys calls and maybe even kernel internals to
> do this with lynx. I am going to write a parser soon. But I want to parser
> to have a unique signature in it's header somewhere. 0x7f is I believe the
> signature for linux. I will write a 128 unique number generator in C with
> linux to get the number so it will not conflict with other file types like
> adobe's .pdf and so on. Can anyone suggest any source code to create a file
> signature and what else I might need to do?
>
> Bill


By stdc do you mean "standard c" Bill?

I think you should ask in c.l.c : they are always willing to help people
with their parsers and 128 unique number generators there!

Enjoy!

9/10

Crosspost & Followup-To: comp.lang.c

(ps not bad - almost as good as the one where you were telling the lads
in linux development how you were about to write a device driver!)
 
Reply With Quote
 
 
 
 
Nick Keighley
Guest
Posts: n/a
 
      09-25-2008
On 25 Sep, 01:56, Richard<(E-Mail Removed)> wrote:
> "Bill Cunningham" <(E-Mail Removed)> writes:


> > * * I can't use stdc to write a file signature for a file format can I?


what's a file signature? Do you want a way of deducing the file type
by reading some sort of meta-data? comp.programming is probably
the place to go. This sort of file signature stuff is highly OS
dependent.

Windows: use the file extension
old Mac OS: stick something in the resource fork of the file
(yes you would need "kernel" calls for that!)
unix: uses something called "magic" which is essentially
stuff at the front of the file

> > Wouldn't I have to get into the sys calls and maybe even kernel internals to
> > do this with lynx.


lynx?
wiki: "The LynxOS RTOS is a Unix-like real-time operating system from
LynuxWorks (formerly "Lynx Real-Time Systems"). Sometimes known as the
Lynx Operating System, LynxOS features full POSIX conformance and,
more recently,
Linux compatibility. LynxOS is mostly used in real-time embedded
systems, in applications for avionics, aerospace, the military,
industrial process
control and telecommunications."

I bet you didn't mean that

> > I am going to write a parser soon.


<giggle>

> > But I want to parser
> > to have a unique signature in it's header somewhere. 0x7f is I believe the
> > signature for linux.


no

> > I will write a 128 unique number generator in C with
> > linux to get the number so it will not conflict with other file types like
> > adobe's .pdf and so on. Can anyone suggest any source code to create a file
> > signature and what else I might need to do?


the simplest think to do on Unix-like system is to put
some fairly simple text on the first line and hide it
in a comment. Suppose I was posting something that used ;
as a comment I could tag my file like this

;!/bin/nil

The perl programming langauge often tags its programs with

#!/opt/perl5/perl

the ! sequence tells the shell (the Operating System in effect)
where to find the correct reader for that file type. Ask on a Unix ng
for details.


--
Nick Keighley
 
Reply With Quote
 
 
 
 
Richard
Guest
Posts: n/a
 
      09-25-2008
Nick Keighley <(E-Mail Removed)> writes:

> On 25 Sep, 01:56, Richard<(E-Mail Removed)> wrote:
>> "Bill Cunningham" <(E-Mail Removed)> writes:

>
>> > * * I can't use stdc to write a file signature for a file format can I?

>
> what's a file signature? Do you want a way of deducing the file type
> by reading some sort of meta-data? comp.programming is probably
> the place to go. This sort of file signature stuff is highly OS
> dependent.


You did notice that I somewhat mischievously cross posted this from the
linux application development group didn't you?

>
>> > I am going to write a parser soon.

>
> <giggle>


And that's why ....
 
Reply With Quote
 
Bill Cunningham
Guest
Posts: n/a
 
      09-25-2008

"Nick Keighley" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
On 25 Sep, 01:56, Richard<(E-Mail Removed)> wrote:
> "Bill Cunningham" <(E-Mail Removed)> writes:


> > I can't use stdc to write a file signature for a file format can I?


what's a file signature? Do you want a way of deducing the file type
by reading some sort of meta-data? comp.programming is probably
the place to go. This sort of file signature stuff is highly OS
dependent.

I believe I want to insert a magic number in an ELF header. Did I post
this here? I remember comp.prog and col groups I posted it. This is here by
mistake.

Bill


 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      09-25-2008
"Bill Cunningham" <(E-Mail Removed)> writes:
> "Nick Keighley" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > On 25 Sep, 01:56, Richard<(E-Mail Removed)> wrote:
> >> "Bill Cunningham" <(E-Mail Removed)> writes:

> >
> >> > I can't use stdc to write a file signature for a file format can I?

> >
> > what's a file signature? Do you want a way of deducing the file type
> > by reading some sort of meta-data? comp.programming is probably
> > the place to go. This sort of file signature stuff is highly OS
> > dependent.

>
> I believe I want to insert a magic number in an ELF header. Did I post
> this here? I remember comp.prog and col groups I posted it. This is here by
> mistake.


You posted in comp.os.linux.development.system. This is here because
Richard Nolastname deliberately cross-posted and redirected followups
to comp.lang.c.

But as long as it's here, judging by the way you've struggled with the
most elementary C programs, I suspect what you're attempting is beyond
your abilities.

--
Keith Thompson (The_Other_Keith) http://www.velocityreviews.com/forums/(E-Mail Removed) <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
 
Reply With Quote
 
Bill Cunningham
Guest
Posts: n/a
 
      09-26-2008

"Keith Thompson" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

> But as long as it's here, judging by the way you've struggled with the
> most elementary C programs, I suspect what you're attempting is beyond
> your abilities.


Your quite probably right. I know you are without some kind of tutorial.
elf.h used data types called uint_t for unsigned ints. I hope it is
understood what I am wanting to attempt.

Bill


 
Reply With Quote
 
Nick Keighley
Guest
Posts: n/a
 
      09-26-2008
On 25 Sep, 16:53, Richard Heathfield <(E-Mail Removed)> wrote:
> Nick Keighleysaid:
>
> > On 25 Sep, 01:56, Richard<(E-Mail Removed)> wrote:
> >> "Bill Cunningham" <(E-Mail Removed)> writes:

>
> >> > I can't use stdc to write a file signature for a file format can I?

>
> > what's a file signature? Do you want a way of deducing the file type
> > by reading some sort of meta-data? comp.programming is probably
> > the place to go. This sort of file signature stuff is highly OS
> > dependent.

>
> > Windows: use the file extension

>
> No, don't do that.


I rather meant- that was often what happened. I'm not particularly
fond of it.

--
Nick Keighley
 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      09-26-2008
"Bill Cunningham" <(E-Mail Removed)> writes:
> "Keith Thompson" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> But as long as it's here, judging by the way you've struggled with the
>> most elementary C programs, I suspect what you're attempting is beyond
>> your abilities.

>
> Your quite probably right. I know you are without some kind of tutorial.
> elf.h used data types called uint_t for unsigned ints.


No, elf.h (at least on my system) doesn't use anything called uint_t.
It does use uint16_t, uint32_t, and uint64_t, all of which are
declared in the standard header <stdint.h>.

> I hope it is
> understood what I am wanting to attempt.


I have no idea what you're attempting.

--
Keith Thompson (The_Other_Keith) (E-Mail Removed) <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Turning a signature-changing decorator into a signature-preservingone Gustavo Narea Python 14 02-16-2009 04:58 PM
7-Zip 4.31 file does not have a valid digital signature Jack Computer Support 2 12-07-2005 10:58 PM
UTF-8 with signature & UTF-8 without signature JJBW ASP .Net 1 04-24-2004 10:21 AM
Signature file Olena Firefox 8 04-06-2004 09:20 PM
PKCS7 file signature checking. Gilles Lenfant Python 0 09-03-2003 12:20 PM



Advertisments