diff options
Diffstat (limited to 'blob2c.1')
-rw-r--r-- | blob2c.1 | 137 |
1 files changed, 137 insertions, 0 deletions
diff --git a/blob2c.1 b/blob2c.1 new file mode 100644 index 0000000..6553931 --- /dev/null +++ b/blob2c.1 @@ -0,0 +1,137 @@ +.\" 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 "2022-08-27" "0.2.0" "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 +\fBa8eol\fP(1), +\fBa8utf8\fP(1), +\fBatr2xfd\fP(1), +\fBatrsize\fP(1), +\fBaxe\fP(1), +\fBblob2c\fP(1), +\fBcart2xex\fP(1), +\fBdasm2atasm\fP(1), +\fBfenders\fP(1), +\fBrom2cart\fP(1), +\fBunmac65\fP(1), +\fBxexcat\fP(1), +\fBxexsplit\fP(1), +\fBxfd2atr\fP(1). +.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. +. |