4 * Generate Sapphire headers automatically
6 * © 1994-1998 Straylight
9 /*----- Licensing note ----------------------------------------------------*
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2, or (at your option)
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, write to the Free Software Foundation,
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
34 static void swi(int s,_kernel_swi_regs *r)
36 _kernel_oserror *e=_kernel_swi(s,r,r);
39 fprintf(stderr,"Arrghh -- %s\n",e->errmess);
44 static char *getline(char **p,char *b)
53 static void headergen(char *buff,char *infile,char *outfile)
58 char *leaf=strrchr(infile,'.');
65 if (fp=fopen(outfile,"w"),!fp)
67 fprintf(stderr,"Couldn't open output\n");
71 /* --- Do the header (this bit's a little fragile) --- */
77 fprintf(fp,"%sh\n",b);
83 if (p[-1]==')' && p[-5]=='(')
99 fprintf(fp,";----- Licensing note -------------------------------------------------------\n"
101 "; This file is part of Straylight's Sapphire library.\n"
103 "; Sapphire is free software; you can redistribute it and/or modify\n"
104 "; it under the terms of the GNU General Public License as published by\n"
105 "; the Free Software Foundation; either version 2, or (at your option)\n"
106 "; any later version.\n"
108 "; Sapphire is distributed in the hope that it will be useful,\n"
109 "; but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
110 "; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
111 "; GNU General Public License for more details.\n"
113 "; You should have received a copy of the GNU General Public License\n"
114 "; along with Sapphire. If not, write to the Free Software Foundation,\n"
115 "; 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\n"
117 ";----- Overview -------------------------------------------------------------\n"
119 "; Functions provided:\n"
122 /* --- Search for all EXPORTs and output them in the overview --- */
129 if (!memcmp(b,"\t\tEXPORT",8))
132 while (!isalnum(*p) && !(*p=='_'))
135 while (isalnum(*p) || *p=='_')
140 while (memcmp(b,"\t\tEND",5));
144 fprintf(fp,"\t\t[\t:LNOT::DEF:%s__dfn\n"
145 "\t\tGBLL\t%s__dfn\n"
149 /* --- Now output the block comments etc. --- */
155 char *ocm=(char *)0x80000000;
163 else if (*b!=';' && cm)
168 if (!memcmp(b,"\t\tEXPORT",8))
172 fprintf(fp,"\t\tIMPORT\t%s\n\n",b+9);
176 while (memcmp(b,"\t\tEND",5));
181 ";----- That's all, folks ----------------------------------------------------\n"
188 int main(int argc,char *argv[])
192 fprintf(stderr,"Syntax: headerGen <input> <output>\n");
196 /* --- Load input file into mondo buffer --- */
204 if (fb=malloc(r.r[4]),!fb)
206 fprintf(stderr,"No memory -- buy some more\n");
214 headergen(fb,argv[1],argv[2]);