2 * ========================================================================
3 * Copyright 2006-2007 University of Washington
4 * Copyright 2013-2022 Eduardo Chappa
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * ========================================================================
20 void preamble(FILE *ofp
);
21 void body(FILE *ifp
, FILE *ofp
);
22 void postamble(FILE *ofp
);
26 main(int argc
, char **argv
)
38 fprintf(ofp
, "\n\t\t/*\n");
39 fprintf(ofp
, "\t\t * AUTOMATICALLY GENERATED FILE!\n");
40 fprintf(ofp
, "\t\t * DO NOT EDIT!!\n");
41 fprintf(ofp
, "\t\t * See help_h_gen.c.\n\t\t */\n\n\n");
42 fprintf(ofp
, "#ifndef PITH_HELPTEXT_INCLUDED\n");
43 fprintf(ofp
, "#define PITH_HELPTEXT_INCLUDED\n\n\n");
44 fprintf(ofp
, "#define\tHelpType\tchar **\n");
45 fprintf(ofp
, "#define\tNO_HELP\t((char **) NULL)\n\n");
46 fprintf(ofp
, "struct help_texts {\n");
47 fprintf(ofp
, " HelpType help_text;\n");
48 fprintf(ofp
, " char *tag;\n};\n\n");
53 body(FILE *ifp
, FILE *ofp
)
59 while(fgets(line
, sizeof(line
), ifp
) != NULL
){
60 if(!strncmp(line
, "====", 4)){
61 p
= strtok(line
, space
);
63 p
= strtok(NULL
, space
);
66 fprintf(ofp
, "extern char *%s[];\n", p
);
68 fprintf(ofp
, "Error: help input line\n %s\nis bad\n", line
);
73 fprintf(ofp
, "Error: help input\n %scontains ==== without following helpname\n", line
);
79 fprintf(ofp
, "Error: help input\n %scontains ==== without following space\n", line
);
90 fprintf(ofp
, "\nextern struct help_texts h_texts[];\n\n\n");
91 fprintf(ofp
, "#endif /* PITH_HELPTEXT_INCLUDED */\n");