-
file signature
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
-
Re: file signature
"Bill Cunningham" <nospam@nspam.invalid> wrote in message
news:48dac89f$0$5476$bbae4d71@news.suddenlink.net...[color=blue]
> 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[/color]
I have a feeling elf.h is going to be needed here.
B
-
Re: file signature
"Bill Cunningham" <nospam@nspam.invalid> writes:
[color=blue]
> 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[/color]
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!)
-
Re: file signature
"Bill Cunningham" <nospam@nspam.invalid> writes:
[color=blue]
> 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?[/color]
I'm sorry -- what are you talking about? You can write anything you
want to any file you want. If you want to start your file with the
string "Bill Cunningham's File Format" you're more than welcome to do
that. I've got no idea what this has to do with lynx, and less what
you mean you say 7f is the signature for linux.
-
Re: file signature
"Joe Pfeiffer" <pfeiffer@cs.nmsu.edu> wrote in message
news:1bprmtt36z.fsf@snowball.wb.pfeifferfamily.net...
[color=blue]
> I'm sorry -- what are you talking about? You can write anything you
> want to any file you want. If you want to start your file with the
> string "Bill Cunningham's File Format" you're more than welcome to do
> that. I've got no idea what this has to do with lynx, and less what
> you mean you say 7f is the signature for linux.[/color]
Yes yes sorry. I said lynx and not linux. Lynx is a web browser. I mean
in the OS's internals. STDC is higher level than what I want and this is
what this group is supposed to be about.
Bill
-
Re: file signature
"Bill Cunningham" <nospam@nspam.invalid> writes:
[color=blue]
> "Joe Pfeiffer" <pfeiffer@cs.nmsu.edu> wrote in message
> news:1bprmtt36z.fsf@snowball.wb.pfeifferfamily.net...
>[color=green]
>> I'm sorry -- what are you talking about? You can write anything you
>> want to any file you want. If you want to start your file with the
>> string "Bill Cunningham's File Format" you're more than welcome to do
>> that. I've got no idea what this has to do with lynx, and less what
>> you mean you say 7f is the signature for linux.[/color]
>
> Yes yes sorry. I said lynx and not linux. Lynx is a web browser. I mean
> in the OS's internals. STDC is higher level than what I want and this is
> what this group is supposed to be about.[/color]
I'm still confused -- when you say "stdc", do you mean the standard C
library, aka libc? It doesn't get much lower level than the write()
system call. And I still don't know what "7C is the signature for
linux" would mean.
-
Re: file signature
Bill Cunningham wrote:[color=blue]
> "Joe Pfeiffer" <pfeiffer@cs.nmsu.edu> wrote in message
> news:1bprmtt36z.fsf@snowball.wb.pfeifferfamily.net...
>[color=green]
>> I'm sorry -- what are you talking about? You can write anything you
>> want to any file you want. If you want to start your file with the
>> string "Bill Cunningham's File Format" you're more than welcome to do
>> that. I've got no idea what this has to do with lynx, and less what
>> you mean you say 7f is the signature for linux.[/color]
>
> Yes yes sorry. I said lynx and not linux. Lynx is a web browser. I mean
> in the OS's internals. STDC is higher level than what I want and this is
> what this group is supposed to be about.[/color]
IIUC you want your file to have a specific signature that lets you
identify *your* files?
I don't know anything about the details, but ELF has .note sections that
you might be able to use for your purpose. Then there is also the
..comment section that looks promising, too.
Oh, and BTW the magic for ELF is four bytes: { 0x7f, 'E', 'L', 'F' }!
--
These are my personal views and not those of Fujitsu Siemens Computers!
Josef Möllers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize (T. Pratchett)
Company Details: [url]http://www.fujitsu-siemens.com/imprint.html[/url]
-
Re: file signature
"Josef Moellers" <josef.moellers@fujitsu-siemens.com> wrote in message
news:gbi141$ble$1@nntp.fujitsu-siemens.com...
[color=blue]
> IIUC you want your file to have a specific signature that lets you
> identify *your* files?
> I don't know anything about the details, but ELF has .note sections that
> you might be able to use for your purpose. Then there is also the .comment
> section that looks promising, too.
>
> Oh, and BTW the magic for ELF is four bytes: { 0x7f, 'E', 'L', 'F' }!
>[/color]
Where can I put meta-data for my own format? Would that come after the
elf header?
Bill
-
Re: file signature
Bill Cunningham wrote:[color=blue]
> "Josef Moellers" <josef.moellers@fujitsu-siemens.com> wrote in message
> news:gbi141$ble$1@nntp.fujitsu-siemens.com...
>[color=green]
>> IIUC you want your file to have a specific signature that lets you
>> identify *your* files?
>> I don't know anything about the details, but ELF has .note sections that
>> you might be able to use for your purpose. Then there is also the .comment
>> section that looks promising, too.
>>
>> Oh, and BTW the magic for ELF is four bytes: { 0x7f, 'E', 'L', 'F' }!
>>[/color]
> Where can I put meta-data for my own format? Would that come after the
> elf header?[/color]
You need to consult the ELF spec. The ELF header contains file offsets
to various tables (e.g. section header table):
typedef struct {
unsigned char e_ident[EI_NIDENT];
uint16_t e_type;
uint16_t e_machine;
uint32_t e_version;
ElfN_Addr e_entry;
ElfN_Off e_phoff;
ElfN_Off e_shoff; <<< section header offset
uint32_t e_flags;
uint16_t e_ehsize;
uint16_t e_phentsize;
uint16_t e_phnum;
uint16_t e_shentsize;
uint16_t e_shnum;
uint16_t e_shstrndx;
} ElfN_Ehdr;
e_shoff This member holds the section header table’s file offset in
bytes. If the file has no section header table this
member
holds zero.
(from "man elf")
You would need to read an ELF file without a .note section and write one
with a .note section.
There are at least two libraries that will assist you in doing this:
libelf and libbfd.
There are also two programs that help you understand the file format:
readelf and objdump.
Josef
--
These are my personal views and not those of Fujitsu Siemens Computers!
Josef Möllers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize (T. Pratchett)
Company Details: [url]http://www.fujitsu-siemens.com/imprint.html[/url]
-
Re: file signature
"Josef Moellers" <josef.moellers@fujitsu-siemens.com> wrote in message
news:gbpvtp$253$1@nntp.fujitsu-siemens.com...[color=blue]
> You need to consult the ELF spec. The ELF header contains file offsets to
> various tables (e.g. section header table):
>
> typedef struct {
> unsigned char e_ident[EI_NIDENT];
> uint16_t e_type;
> uint16_t e_machine;
> uint32_t e_version;
> ElfN_Addr e_entry;
> ElfN_Off e_phoff;
> ElfN_Off e_shoff; <<< section header offset
> uint32_t e_flags;
> uint16_t e_ehsize;
> uint16_t e_phentsize;
> uint16_t e_phnum;
> uint16_t e_shentsize;
> uint16_t e_shnum;
> uint16_t e_shstrndx;
> } ElfN_Ehdr;
>
> e_shoff This member holds the section header table’s file offset in
> bytes. If the file has no section header table this
> member
> holds zero.
> (from "man elf")
>
> You would need to read an ELF file without a .note section and write one
> with a .note section.
>
> There are at least two libraries that will assist you in doing this:
> libelf and libbfd.
>
> There are also two programs that help you understand the file format:
> readelf and objdump.
>
> Josef[/color]
Thanks much Josef.