-
Notifications
You must be signed in to change notification settings - Fork 0
/
bcc.1
104 lines (104 loc) · 2.58 KB
/
bcc.1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
.\"
.\" Copyright (c) 2020-2024 David Demelier <markand@malikania.fr>
.\"
.\" Permission to use, copy, modify, and/or distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd April 13, 2021
.Dt BCC 1
.Os
.\" NAME
.Sh NAME
.Nm bcc
.Nd binary to C/C++ arrays converter
.\" SYNOPSIS
.Sh SYNOPSIS
.Nm bcc
.Op Fl 0cs
.Op Fl I Ar tab-num
.Op Fl i Ar space-num
.Op Fl t Ar type
.Ar filename
.Ar variable
.\" DESCRIPTION
.Sh DESCRIPTION
The
.Nm
utility converts the
.Ar input
file into a C or C++ array named
.Ar variable
that can be embedded as-is in the source code. A special
.Ar -
value can be passed as input which will read standard input instead.
.Pp
The
.Ar variable
can contain any character but only ones that are allowed in the C standard will
be kept, other will be replaced with a
.Dq _ .
Also, the extension (by finding the first .) is removed as well. This can be
handy when generating a lots of file based on their names during a build
process.
.Pp
Note: you must still not start a variable name with digits.
.Pp
The following options are available:
.Bl -tag -width space-num-xxx
.It Fl 0
Terminate the generated array with a trailing NUL.
.It Fl c
Generates a
.Em const
array.
.It Fl I Ar tab-num
Use
.Ar tab-num
count as leading tab indents.
.It Fl i Ar space-num
Use
.Ar space-num
count as leading space indents.
.It Fl s
Generates a
.Em static
array.
.It Fl t Ar type
Changes the array char type to store the data content which defaults to
.Ar unsigned char .
.El
.\" EXAMPLES
.Sh EXAMPLES
Create a static const array from an image.
.Bd -literal -offset indent
bcc -sc image.png image > image.h
.Ed
.Pp
Create a modifiable char NUL-terminated array from a text file
.Bd -literal -offset indent
bcc -0 -t char text.txt text > text.h
.Ed
.\" HISTORY
.Sh HISTORY
The
.Nm
tool is inspired by
.Nm xxd
utility but offers more flexibility over the the generated code.
.\" SEE ALSO
.Sh SEE ALSO
.Xr xxd 1
.Sh AUTHORS
The
.Nm
utility was written by
.An David Demelier Aq Mt markand@malikania.fr .