Port the SB128 code to AROS.
[AROS.git] / tools / genmodule / writeincproto.c
bloba8abc8d5e2dea70b8fba127a14338ca4e3cd9d19
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
4 Desc: Function to write proto/modulename.h. Part of genmodule.
5 */
6 #include "genmodule.h"
8 void writeincproto(struct config *cfg)
10 FILE *out;
11 char line[256], define[256], *banner;
12 struct linelist *linelistit;
14 snprintf(line, 255, "%s/proto/%s.h", cfg->gendir, cfg->modulename);
15 out = fopen(line, "w");
17 if (out == NULL)
19 perror(line);
20 exit(20);
23 banner = getBanner(cfg);
24 fprintf(out,
25 "#ifndef PROTO_%s_H\n"
26 "#define PROTO_%s_H\n"
27 "\n"
28 "%s"
29 "\n"
30 "#include <exec/types.h>\n"
31 "#include <aros/system.h>\n"
32 "\n"
33 "#include <clib/%s_protos.h>\n"
34 "\n"
35 "#if !defined(%s) && !defined(__NOLIBBASE__) && !defined(__%s_NOLIBBASE__)\n"
36 " #ifdef __%s_STDLIBBASE__\n"
37 " extern struct Library *%s;\n"
38 " #else\n"
39 " extern %s%s;\n"
40 " #endif\n"
41 "#endif\n"
42 "\n",
43 cfg->modulenameupper, cfg->modulenameupper, banner,
44 cfg->modulename,
45 cfg->libbase, cfg->modulenameupper,
46 cfg->modulenameupper,
47 cfg->libbase,
48 cfg->libbasetypeptrextern, cfg->libbase
50 freeBanner(banner);
52 // define name must not start with a digit
53 // this solves a problem with proto/8svx.h
54 if (isdigit(cfg->modulenameupper[0]))
56 snprintf(define, sizeof define, "X%s", cfg->modulenameupper);
58 else
60 strncpy(define, cfg->modulenameupper, sizeof define);
63 fprintf(out,
64 "#if !defined(NOLIBINLINE) && !defined(%s_NOLIBINLINE)\n"
65 "# include <inline/%s.h>\n"
66 "#elif !defined(NOLIBDEFINES) && !defined(%s_NOLIBDEFINES)\n"
67 "# include <defines/%s.h>\n"
68 "#endif\n"
69 "\n"
70 "#endif /* PROTO_%s_H */\n",
71 define, cfg->modulename,
72 define, cfg->modulename,
73 cfg->modulenameupper
75 fclose(out);