This is a small little program used to execute a bad practice a clean way :-)
It will read a file on stdin and write it as decimal integers on stdout,
this is useful for embedding files in c-sources.
There are a few places where this is needed, and this is a better way than
the current practice of hand-editing the sources.
The command:
date | file2c 'const char date[] = {' ',0};'
will produce:
const char date[] = {
83,97,116,32,74,97,110,32,50,56,32,49,54,58,52,55,58,51,51,32,80,83,84,
32,49,57,57,53,10
,0};
The manual page is 2 lines longer than the source :-)
1995-01-29 00:49:57 +00:00
|
|
|
.\"----------------------------------------------------------------------------
|
|
|
|
.\" "THE BEER-WARE LICENSE" (Revision 42):
|
2001-08-13 16:33:00 +00:00
|
|
|
.\" <phk@FreeBSD.org> wrote this file. As long as you retain this notice, you
|
This is a small little program used to execute a bad practice a clean way :-)
It will read a file on stdin and write it as decimal integers on stdout,
this is useful for embedding files in c-sources.
There are a few places where this is needed, and this is a better way than
the current practice of hand-editing the sources.
The command:
date | file2c 'const char date[] = {' ',0};'
will produce:
const char date[] = {
83,97,116,32,74,97,110,32,50,56,32,49,54,58,52,55,58,51,51,32,80,83,84,
32,49,57,57,53,10
,0};
The manual page is 2 lines longer than the source :-)
1995-01-29 00:49:57 +00:00
|
|
|
.\" can do whatever you want with this file. If we meet some day, and you think
|
|
|
|
.\" this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
|
|
|
|
.\" ---------------------------------------------------------------------------
|
|
|
|
.\"
|
1999-08-28 01:08:13 +00:00
|
|
|
.\" $FreeBSD$
|
This is a small little program used to execute a bad practice a clean way :-)
It will read a file on stdin and write it as decimal integers on stdout,
this is useful for embedding files in c-sources.
There are a few places where this is needed, and this is a better way than
the current practice of hand-editing the sources.
The command:
date | file2c 'const char date[] = {' ',0};'
will produce:
const char date[] = {
83,97,116,32,74,97,110,32,50,56,32,49,54,58,52,55,58,51,51,32,80,83,84,
32,49,57,57,53,10
,0};
The manual page is 2 lines longer than the source :-)
1995-01-29 00:49:57 +00:00
|
|
|
.\"
|
2005-05-15 06:26:59 +00:00
|
|
|
.Dd May 14, 2005
|
This is a small little program used to execute a bad practice a clean way :-)
It will read a file on stdin and write it as decimal integers on stdout,
this is useful for embedding files in c-sources.
There are a few places where this is needed, and this is a better way than
the current practice of hand-editing the sources.
The command:
date | file2c 'const char date[] = {' ',0};'
will produce:
const char date[] = {
83,97,116,32,74,97,110,32,50,56,32,49,54,58,52,55,58,51,51,32,80,83,84,
32,49,57,57,53,10
,0};
The manual page is 2 lines longer than the source :-)
1995-01-29 00:49:57 +00:00
|
|
|
.Dt FILE2C 1
|
|
|
|
.Os
|
|
|
|
.Sh NAME
|
|
|
|
.Nm file2c
|
1997-07-02 06:30:51 +00:00
|
|
|
.Nd convert file to c-source
|
This is a small little program used to execute a bad practice a clean way :-)
It will read a file on stdin and write it as decimal integers on stdout,
this is useful for embedding files in c-sources.
There are a few places where this is needed, and this is a better way than
the current practice of hand-editing the sources.
The command:
date | file2c 'const char date[] = {' ',0};'
will produce:
const char date[] = {
83,97,116,32,74,97,110,32,50,56,32,49,54,58,52,55,58,51,51,32,80,83,84,
32,49,57,57,53,10
,0};
The manual page is 2 lines longer than the source :-)
1995-01-29 00:49:57 +00:00
|
|
|
.Sh SYNOPSIS
|
1997-07-02 06:30:51 +00:00
|
|
|
.Nm
|
2005-05-15 06:26:59 +00:00
|
|
|
.Op Fl n Ar count
|
|
|
|
.Op Fl x
|
|
|
|
.Op Ar prefix Op Ar suffix
|
This is a small little program used to execute a bad practice a clean way :-)
It will read a file on stdin and write it as decimal integers on stdout,
this is useful for embedding files in c-sources.
There are a few places where this is needed, and this is a better way than
the current practice of hand-editing the sources.
The command:
date | file2c 'const char date[] = {' ',0};'
will produce:
const char date[] = {
83,97,116,32,74,97,110,32,50,56,32,49,54,58,52,55,58,51,51,32,80,83,84,
32,49,57,57,53,10
,0};
The manual page is 2 lines longer than the source :-)
1995-01-29 00:49:57 +00:00
|
|
|
.Sh DESCRIPTION
|
|
|
|
The
|
1997-07-02 06:30:51 +00:00
|
|
|
.Nm
|
This is a small little program used to execute a bad practice a clean way :-)
It will read a file on stdin and write it as decimal integers on stdout,
this is useful for embedding files in c-sources.
There are a few places where this is needed, and this is a better way than
the current practice of hand-editing the sources.
The command:
date | file2c 'const char date[] = {' ',0};'
will produce:
const char date[] = {
83,97,116,32,74,97,110,32,50,56,32,49,54,58,52,55,58,51,51,32,80,83,84,
32,49,57,57,53,10
,0};
The manual page is 2 lines longer than the source :-)
1995-01-29 00:49:57 +00:00
|
|
|
utility reads a file from stdin and writes it to stdout, converting each
|
2005-05-15 06:26:59 +00:00
|
|
|
byte to its decimal or hexadecimal representation on the fly.
|
2005-07-31 03:30:48 +00:00
|
|
|
The byte values are separated by a comma.
|
2005-05-15 06:26:59 +00:00
|
|
|
This also means that the last byte value is not followed by a comma.
|
|
|
|
By default the byte values are printed in decimal, but when the
|
|
|
|
.Fl x
|
|
|
|
option is given, the values will be printed in hexadecimal.
|
This is a small little program used to execute a bad practice a clean way :-)
It will read a file on stdin and write it as decimal integers on stdout,
this is useful for embedding files in c-sources.
There are a few places where this is needed, and this is a better way than
the current practice of hand-editing the sources.
The command:
date | file2c 'const char date[] = {' ',0};'
will produce:
const char date[] = {
83,97,116,32,74,97,110,32,50,56,32,49,54,58,52,55,58,51,51,32,80,83,84,
32,49,57,57,53,10
,0};
The manual page is 2 lines longer than the source :-)
1995-01-29 00:49:57 +00:00
|
|
|
.Pp
|
2005-05-15 06:26:59 +00:00
|
|
|
If more than 70 characters are printed on the same line, that line is
|
|
|
|
ended and the output continues on the next line.
|
|
|
|
With the
|
|
|
|
.Fl n
|
|
|
|
option this can be made to happen after the specified number of
|
|
|
|
byte values have been printed.
|
|
|
|
The length of the line will not be considered anymore.
|
|
|
|
To have all the byte values printed on the same line, give the
|
|
|
|
.Fl n
|
|
|
|
option a negative number.
|
This is a small little program used to execute a bad practice a clean way :-)
It will read a file on stdin and write it as decimal integers on stdout,
this is useful for embedding files in c-sources.
There are a few places where this is needed, and this is a better way than
the current practice of hand-editing the sources.
The command:
date | file2c 'const char date[] = {' ',0};'
will produce:
const char date[] = {
83,97,116,32,74,97,110,32,50,56,32,49,54,58,52,55,58,51,51,32,80,83,84,
32,49,57,57,53,10
,0};
The manual page is 2 lines longer than the source :-)
1995-01-29 00:49:57 +00:00
|
|
|
.Pp
|
2005-05-15 06:26:59 +00:00
|
|
|
A prefix and suffix strings can be printed before and after the byte values
|
|
|
|
(resp.)
|
|
|
|
If a suffix is to be printed, a prefix must also be specified.
|
|
|
|
The first non-option word is the prefix, which may optionally be followed
|
|
|
|
by a word that is to be used as the suffix.
|
|
|
|
.Pp
|
|
|
|
This program is typically used to embed binary files into C source files.
|
|
|
|
The prefix is used to define an array type and the suffix is used to end
|
|
|
|
the C statement.
|
|
|
|
The
|
|
|
|
.Fl x
|
|
|
|
and
|
|
|
|
.Fl n
|
|
|
|
options are useful when the binary data represents a bitmap and the output
|
|
|
|
needs to remain readable and/or editable.
|
|
|
|
Fonts, for example, are a good example of this.
|
2000-11-17 11:44:16 +00:00
|
|
|
.Sh EXAMPLES
|
This is a small little program used to execute a bad practice a clean way :-)
It will read a file on stdin and write it as decimal integers on stdout,
this is useful for embedding files in c-sources.
There are a few places where this is needed, and this is a better way than
the current practice of hand-editing the sources.
The command:
date | file2c 'const char date[] = {' ',0};'
will produce:
const char date[] = {
83,97,116,32,74,97,110,32,50,56,32,49,54,58,52,55,58,51,51,32,80,83,84,
32,49,57,57,53,10
,0};
The manual page is 2 lines longer than the source :-)
1995-01-29 00:49:57 +00:00
|
|
|
The command:
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
date | file2c 'const char date[] = {' ',0};'
|
|
|
|
.Ed
|
|
|
|
.Pp
|
|
|
|
will produce:
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
const char date[] = {
|
|
|
|
83,97,116,32,74,97,110,32,50,56,32,49,54,58,50,56,58,48,53,
|
|
|
|
32,80,83,84,32,49,57,57,53,10
|
|
|
|
,0};
|
|
|
|
.Ed
|