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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
.\" Man page generated from reStructuredText.
.
.
.nr rst2man-indent-level 0
.
.de1 rstReportMargin
\\$1 \\n[an-margin]
level \\n[rst2man-indent-level]
level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
-
\\n[rst2man-indent0]
\\n[rst2man-indent1]
\\n[rst2man-indent2]
..
.de1 INDENT
.\" .rstReportMargin pre:
. RS \\$1
. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
. nr rst2man-indent-level +1
.\" .rstReportMargin post:
..
.de UNINDENT
. RE
.\" indent \\n[an-margin]
.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
.nr rst2man-indent-level -1
.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
..
.TH "BLOB2C" 1 "2024-07-12" "0.2.1" "Urchlay's Atari 8-bit Tools"
.SH NAME
blob2c \- Create C source and header files from a binary file
.\" RST source for blob2c(1) man page. Convert with:
.
.\" rst2man.py blob2c.rst > blob2c.1
.
.\" rst2man.py comes from the SBo development/docutils package.
.
.SH SYNOPSIS
.sp
blob2c \fIblobfile\fP > \fIoutput.c\fP 2> \fIoutput.h\fP
.SH DESCRIPTION
.sp
\fBblob2c\fP prints a C source file to standard output, containing
\fIan unsigned char\fP array, initialized to the contents of \fIblobfile\fP,
and an \fIint\fP, initialized to the length of \fIblobfile\fP in bytes.
.sp
The name of the array is based on the input filename, with
non\-alphanumeric characters replaced by underscores. The name of the
int is the array name, plus the string \fB_len\fP\&.
.sp
Also, a header file containing a pair of extern declarations is
printed to standard error output. This header may be included multiple
times in the same translation unit, since it contains "guard"
preprocessor code to prevent multiple declarations.
.sp
\fBblob2c\fP takes no options, and requires exactly one argument (the
input filename \fIblobfile\fP).
.sp
Exit status is zero for success and non\-zero for failure. Error
messages are printed to standard error output as preprocessor
\fB#error\fP directives, since standard error is expected to be
redirected to a header file. The \fB#error\fP directives will cause the
error messages to be printed when the header file is compiled.
.sp
Although it\(aqs distributed with the author\(aqs Atari 8\-bit
utilities, there\(aqs nothing Atari\-specific about \fBblob2c\fP\&. It could be
useful for any situation where you need to include a file\(aqs contents
as an array in a C program.
.SH EXAMPLE
.INDENT 0.0
.INDENT 3.5
.sp
.nf
.ft C
$ echo "Hello, World." > hello.bin
$ blob2c hello.bin >hello.c 2>hello.h
## check exit status (0=success)
$ echo $?
0
$ cat hello.h
/* C header created by blob2c from input file hello.bin */
#ifndef hello_bin_H
#define hello_bin_H
extern unsigned char hello_bin[];
extern int hello_bin_len;
#endif /* hello_bin_H */
$ cat hello.c
/* C source created by blob2c from input file hello.bin */
unsigned char hello_bin[] = {
/* 0 */ 0x48,0x65,0x6c,0x6c,0x6f,0x2c,0x20,0x57, /* Hello, W */
/* 8 */ 0x6f,0x72,0x6c,0x64,0x2e,0x0a /* orld.. */
}; /* hello_bin */
int hello_bin_len = 14;
.ft P
.fi
.UNINDENT
.UNINDENT
.SH COPYRIGHT
.sp
WTFPL. See \fI\%http://www.wtfpl.net/txt/copying/\fP for details.
.SH AUTHOR
.INDENT 0.0
.IP B. 3
Watson <\fI\%urchlay@slackware.uk\fP>; Urchlay on irc.libera.chat \fI##atari\fP\&.
.UNINDENT
.SH SEE ALSO
.sp
\fBa8cat\fP(1),
\fBa8eol\fP(1),
\fBa8xd\fP(1),
\fBatr2xfd\fP(1),
\fBatrsize\fP(1),
\fBaxe\fP(1),
\fBblob2c\fP(1),
\fBblob2xex\fP(1),
\fBcart2xex\fP(1),
\fBcxrefbas\fP(1),
\fBdasm2atasm\fP(1),
\fBdiffbas\fP(1),
\fBdumpbas\fP(1),
\fBf2toxex\fP(1),
\fBfenders\fP(1),
\fBlistbas\fP(1),
\fBprotbas\fP(1),
\fBrenumbas\fP(1),
\fBrom2cart\fP(1),
\fBunmac65\fP(1),
\fBunprotbas\fP(1),
\fBvxrefbas\fP(1),
\fBwhichbas\fP(1),
\fBxex1to2\fP(1),
\fBxexamine\fP(1),
\fBxexcat\fP(1),
\fBxexsplit\fP(1),
\fBxfd2atr\fP(1),
\fBxex\fP(5),
\fBatascii\fP(7).
.sp
Any good Atari 8\-bit book: \fIDe Re Atari\fP, \fIThe Atari BASIC Reference
Manual\fP, the \fIOS Users\(aq Guide\fP, \fIMapping the Atari\fP, etc.
.\" Generated by docutils manpage writer.
.
|