]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.bin/file2c/file2c.1
This commit was generated by cvs2svn to compensate for changes in r157571,
[FreeBSD/FreeBSD.git] / usr.bin / file2c / file2c.1
1 .\"----------------------------------------------------------------------------
2 .\" "THE BEER-WARE LICENSE" (Revision 42):
3 .\" <phk@FreeBSD.org> wrote this file.  As long as you retain this notice, you
4 .\" can do whatever you want with this file. If we meet some day, and you think
5 .\" this stuff is worth it, you can buy me a beer in return.  Poul-Henning Kamp
6 .\" ---------------------------------------------------------------------------
7 .\"
8 .\" $FreeBSD$
9 .\"
10 .Dd May 14, 2005
11 .Dt FILE2C 1
12 .Os
13 .Sh NAME
14 .Nm file2c
15 .Nd convert file to c-source
16 .Sh SYNOPSIS
17 .Nm
18 .Op Fl n Ar count
19 .Op Fl x
20 .Op Ar prefix Op Ar suffix
21 .Sh DESCRIPTION
22 The
23 .Nm
24 utility reads a file from stdin and writes it to stdout, converting each
25 byte to its decimal or hexadecimal representation on the fly.
26 The byte values are separated by a comma.
27 This also means that the last byte value is not followed by a comma.
28 By default the byte values are printed in decimal, but when the
29 .Fl x
30 option is given, the values will be printed in hexadecimal.
31 .Pp
32 If more than 70 characters are printed on the same line, that line is
33 ended and the output continues on the next line.
34 With the
35 .Fl n
36 option this can be made to happen after the specified number of
37 byte values have been printed.
38 The length of the line will not be considered anymore.
39 To have all the byte values printed on the same line, give the
40 .Fl n
41 option a negative number.
42 .Pp
43 A prefix and suffix strings can be printed before and after the byte values
44 (resp.)
45 If a suffix is to be printed, a prefix must also be specified.
46 The first non-option word is the prefix, which may optionally be followed
47 by a word that is to be used as the suffix.
48 .Pp
49 This program is typically used to embed binary files into C source files.
50 The prefix is used to define an array type and the suffix is used to end
51 the C statement.
52 The
53 .Fl x
54 and
55 .Fl n
56 options are useful when the binary data represents a bitmap and the output
57 needs to remain readable and/or editable.
58 Fonts, for example, are a good example of this.
59 .Sh EXAMPLES
60 The command:
61 .Bd -literal -offset indent
62 date | file2c 'const char date[] = {' ',0};'
63 .Ed
64 .Pp
65 will produce:
66 .Bd -literal -offset indent
67 const char date[] = {
68 83,97,116,32,74,97,110,32,50,56,32,49,54,58,50,56,58,48,53,
69 32,80,83,84,32,49,57,57,53,10
70 ,0};
71 .Ed