Re: file signature

Discussion in 'C Programming' started by Richard, Sep 25, 2008.

  1. Richard

    Richard Guest

    "Bill Cunningham" <> 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!)
    Richard, Sep 25, 2008
    #1
    1. Advertising

  2. On 25 Sep, 01:56, Richard<> wrote:
    > "Bill Cunningham" <> 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
    Nick Keighley, Sep 25, 2008
    #2
    1. Advertising

  3. Richard

    Richard Guest

    Nick Keighley <> writes:

    > On 25 Sep, 01:56, Richard<> wrote:
    >> "Bill Cunningham" <> 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 ....
    Richard, Sep 25, 2008
    #3
  4. "Nick Keighley" <> wrote in message
    news:...
    On 25 Sep, 01:56, Richard<> wrote:
    > "Bill Cunningham" <> 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
    Bill Cunningham, Sep 25, 2008
    #4
  5. "Bill Cunningham" <> writes:
    > "Nick Keighley" <> wrote in message
    > news:...
    > > On 25 Sep, 01:56, Richard<> wrote:
    > >> "Bill Cunningham" <> 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.ghoti.net/~kst>
    Nokia
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
    Keith Thompson, Sep 26, 2008
    #5
  6. "Keith Thompson" <> wrote in message
    news:...

    > 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
    Bill Cunningham, Sep 26, 2008
    #6
  7. On 25 Sep, 16:53, Richard Heathfield <> wrote:
    > Nick Keighleysaid:
    >
    > > On 25 Sep, 01:56, Richard<> wrote:
    > >> "Bill Cunningham" <> 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
    Nick Keighley, Sep 26, 2008
    #7
  8. "Bill Cunningham" <> writes:
    > "Keith Thompson" <> wrote in message
    > news:...
    >> 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) <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"
    Keith Thompson, Sep 26, 2008
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. JJBW
    Replies:
    1
    Views:
    10,139
    Joerg Jooss
    Apr 24, 2004
  2. Gilles Lenfant

    PKCS7 file signature checking.

    Gilles Lenfant, Sep 3, 2003, in forum: Python
    Replies:
    0
    Views:
    425
    Gilles Lenfant
    Sep 3, 2003
  3. 22.at
    Replies:
    1
    Views:
    370
    James Kanze
    Nov 14, 2008
  4. Gustavo Narea
    Replies:
    14
    Views:
    864
    Gustavo Narea
    Feb 16, 2009
  5. Hans

    Read signature as img file problem

    Hans, Mar 1, 2006, in forum: ASP .Net Mobile
    Replies:
    1
    Views:
    103
Loading...

Share This Page