Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Annotation of /sml/trunk/src/runtime/config/gen-common.c
ViewVC logotype

Annotation of /sml/trunk/src/runtime/config/gen-common.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (view) (download) (as text)

1 : monnier 2 /* gen-common.c
2 :     *
3 :     * COPYRIGHT (c) 1994 by AT&T Bell Laboratories.
4 :     *
5 :     * Common code for generating header files.
6 :     */
7 :    
8 :     #include <stdio.h>
9 :     #include "gen.h"
10 :    
11 :     /* OpenFile:
12 :     *
13 :     * Open a generated file, and generate its header comment.
14 :     */
15 :     FILE *OpenFile (char *fname, char *flag)
16 :     {
17 :     FILE *f;
18 :    
19 :     if ((f = fopen(fname, "w")) == NULL) {
20 :     fprintf (stderr, "unable to open file \"%s\"\n", fname);
21 :     exit (1);
22 :     }
23 :    
24 :     fprintf (f, "/* %s\n", fname);
25 :     fprintf (f, " *\n");
26 :     fprintf (f, " * COPYRIGHT (c) 1995 by AT&T Bell Laboratories.\n");
27 :     fprintf (f, " *\n");
28 :     fprintf (f, " * NOTE: this file is generated --- do not edit!!!\n");
29 :     fprintf (f, " */\n");
30 :     fprintf (f, "\n");
31 :     if (flag != (char *)0) {
32 :     fprintf (f, "#ifndef %s\n", flag);
33 :     fprintf (f, "#define %s\n", flag);
34 :     fprintf (f, "\n");
35 :     }
36 :    
37 :     return f;
38 :    
39 :     } /* end of OpenFile */
40 :    
41 :    
42 :     /* CloseFile:
43 :     *
44 :     * Generate the file trailer, and close the generated file.
45 :     */
46 :     void CloseFile (FILE *f, char *flag)
47 :     {
48 :     if (flag != (char *)0) {
49 :     fprintf (f, "\n");
50 :     fprintf (f, "#endif /* !%s */\n", flag);
51 :     }
52 :    
53 :     fclose (f);
54 :    
55 :     } /* CloseFile */

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0