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/runtime/config/gen-common.c
ViewVC logotype

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

Parent Directory Parent Directory | Revision Log Revision Log


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

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

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