8 int main(int argc
, char **argv
) {
14 char ident
[MAX_IDENT
];
18 printf("usage: ./errors <error_ident>|<create>\n");
22 if(strncmp( argv
[1], "create", strlen("create"))==0)
27 if((db
= fopen("errors.db", "rb")) <=0) {
33 puts("#include <stdarg.h>\n"
35 "char not_found[0xff];\n"
38 " char *ident, *body, *vars;\n"
41 "error_t errors[] = {");
45 if((dat= fgetc(db))<0) \
46 if(feof(db)!=0) goto done;
50 if( dat
== '^' && prev
!= '\\') {
56 if(this_is_it
== 1) break;
57 if((cap
>0) && phase
== 1) {
59 if(strncmp(ident
, argv
[1], MAX_IDENT
)==0)
93 if(cap
>=MAX_IDENT
-1) cap
= 0;
117 " { (char *)0, (char *)0, (char *)0} \n"
120 "char *get_error(char *ident, ... ) { \n"
122 " char *body, *vars; \n"
123 " for(i=0;;i++) { \n"
124 " if(errors[i].ident == 0) break; \n"
125 " if(strncmp( errors[i].ident, ident, strlen(ident))==0) break; \n"
127 " if(errors[i].ident == 0) {\n"
128 " snprintf(not_found, 0xff, \n"
129 " \"There is no error-text for this in errors.db, I suggest you put something there.\\n\"\n"
130 " \"The ident string is \\\"%s\\\"\", ident);\n"
131 " return not_found;\n"
133 " return errors[i].body;\n"
138 printf("There is no error-text for this in errors.db, I suggest you put something in there.\n"
139 "The ident string is \"%s\"\n", argv
[1]);