* Implement a different way to delete a password from the cache.
[alpine.git] / pith / help_h_gen.c
blob8c30b81a1e88c61c50f6a49a017143effa5579b0
1 /*
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 * ========================================================================
15 #include <stdio.h>
16 #include <stdlib.h>
17 #include <string.h>
18 #include <ctype.h>
20 void preamble(FILE *ofp);
21 void body(FILE *ifp, FILE *ofp);
22 void postamble(FILE *ofp);
25 int
26 main(int argc, char **argv)
28 preamble(stdout);
29 body(stdin, stdout);
30 postamble(stdout);
31 exit(0);
35 void
36 preamble(FILE *ofp)
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");
52 void
53 body(FILE *ifp, FILE *ofp)
55 char line[10000];
56 char *space = " ";
57 char *p;
59 while(fgets(line, sizeof(line), ifp) != NULL){
60 if(!strncmp(line, "====", 4)){
61 p = strtok(line, space);
62 if(p){
63 p = strtok(NULL, space);
64 if(p){
65 if(isalpha(*p))
66 fprintf(ofp, "extern char *%s[];\n", p);
67 else{
68 fprintf(ofp, "Error: help input line\n %s\nis bad\n", line);
69 exit(-1);
72 else{
73 fprintf(ofp, "Error: help input\n %scontains ==== without following helpname\n", line);
74 exit(-1);
78 else{
79 fprintf(ofp, "Error: help input\n %scontains ==== without following space\n", line);
80 exit(-1);
87 void
88 postamble(FILE *ofp)
90 fprintf(ofp, "\nextern struct help_texts h_texts[];\n\n\n");
91 fprintf(ofp, "#endif /* PITH_HELPTEXT_INCLUDED */\n");