diff --git a/estruct.h b/estruct.h index 63e9f2b..9b514f9 100644 --- a/estruct.h +++ b/estruct.h @@ -7,6 +7,6 @@ #define LICENSE "BSD-3-Clause" /* Default SPDX-License-Identifier */ #define QAUTHOR 0 /* Force use the default author option */ -#define AUTHOR "fSD" /* Default author*/ +#define AUTHOR "fSD" /* Default author */ #endif /* ESTRUCT_H_ */ diff --git a/proj.c b/proj.c index 35db282..c3732f9 100644 --- a/proj.c +++ b/proj.c @@ -52,6 +52,7 @@ int makeproj(char *src) { #include \n\ \n\ #include \"version.h\"\n\ +#include \"estruct.h\"\n\ \n\ void usage(int status)\n\ {\n\ @@ -77,7 +78,7 @@ int main(int argc, char **argv)\n\ }\n\ }\n\ \n\ - puts(\"Hello, World!\");\n\ + puts(MESSAGE);\n\ \n\ return 0;\n\ }", src, author, src, src); @@ -218,5 +219,46 @@ release: $(PROGRAM)\n\ $(E) \" CC \" $@\n\ $(Q) $(CC) $(CFLAGS) $(DEFINES) -c $< -o $@", src, src); + ffwrite("usage.h", "\ +#ifndef USAGE_H_\n\ +#define USAGE_H_\n\ +\n\ +void die(const char* err, ...);\n\ +\n\ +#endif /* USAGE_H_ */"); + ffwrite("usage.c", "\ +#include \"usage.h\"\n\ +\n\ +#include \n\ +#include \n\ +#include \n\ +\n\ +static void report(const char* prefix, const char *err, va_list params)\n\ +{\n\ + char msg[4096];\n\ + vsnprintf(msg, sizeof(msg), err, params);\n\ + fprintf(stderr, \"%%s%%s\\n\", prefix, msg);\n\ +}\n\ +\n\ +void die(const char* err, ...)\n\ +{\n\ + va_list params;\n\ +\n\ + va_start(params, err);\n\ + report(\"fatal: \", err, params);\n\ + va_end(params);\n\ + exit(128);\n\ +}"); + + ffwrite("estruct.h", "\ +#ifndef ESTRUCT_H_\n\ +#define ESTRUCT_H_\n\ +\n\ +/* Configuration options */\n\ +\n\ +#define MESSAGE \"Hello, World!\" /* Default greeting */\n\ +\n\ +#endif /* ESTRUCT_H_ */"); + return 0; }