root/tcl-8.0/trunk/generic/tcl2c.c @ 1091

Revision 1091, 2.7 KB (checked in by ucaccsp, 16 years ago)

Changes to allow stand-alone operation, with no external references.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/*
2        Netvideo version 3.2
3        Written by Ron Frederick <frederick@parc.xerox.com>
4
5        Simple hack to translate a Tcl/Tk init file into a C string constant
6*/
7
8/*
9 * Copyright (c) Xerox Corporation 1992. All rights reserved.
10 * 
11 * License is granted to copy, to use, and to make and to use derivative
12 * works for research and evaluation purposes, provided that Xerox is
13 * acknowledged in all documentation pertaining to any such copy or derivative
14 * work. Xerox grants no other licenses expressed or implied. The Xerox trade
15 * name should not be used in any advertising without its written permission.
16 * 
17 * XEROX CORPORATION MAKES NO REPRESENTATIONS CONCERNING EITHER THE
18 * MERCHANTABILITY OF THIS SOFTWARE OR THE SUITABILITY OF THIS SOFTWARE
19 * FOR ANY PARTICULAR PURPOSE.  The software is provided "as is" without
20 * express or implied warranty of any kind.
21 * 
22 * These notices must be retained in any copies of any part of this software.
23 */
24
25#include <stdio.h>
26#include <stdlib.h>
27
28#ifndef TRUE 
29#define TRUE  1
30#define FALSE 0
31#endif
32
33#ifndef WIN32
34
35int
36main(int argc, char **argv)
37{
38    int c, newline = TRUE;;
39
40    if (argc < 2) {
41        fprintf(stderr, "Usage: %s stringname\n", argv[0]);
42        exit(1);
43    }
44
45    printf("/* This file is automatically generated by tcl2c, do NOT edit by hand! */\n");
46    printf("char %s[] = \"\\\n", argv[1]);
47    while ((c = getchar()) != EOF) {
48            if (newline == TRUE && (isspace(c) || c == '#')) {
49                    if (c == '#') {
50                            do {
51                                    c = getchar();
52                            } while(c != EOF && c != '\n');
53                    }
54            } else {
55                    newline = FALSE;
56                    switch (c) {
57                    case '\n':
58                            printf("\\n\\\n");
59                            newline = TRUE;
60                            break;
61                    case '\"':
62                            printf("\\\"");
63                            break;
64                    case '\\':
65                            printf("\\\\");
66                            break;
67                    default:
68                            putchar(c);
69                    }
70            }
71    }
72    printf("\";\n");
73    exit(0);
74    /*NOTREACHED*/
75    return 0;
76}
77
78#else /* WIN32 */
79
80int
81main(int argc, char **argv)
82{
83    int c, n;
84
85    if (argc < 2) {
86        fprintf(stderr, "Usage: %s stringname\n", argv[0]);
87        exit(1);
88    }
89
90    printf("/* This file is automatically generated by tcl2c, do NOT edit by hand! */\n");
91    printf("char %s[] = {\n", argv[1]);
92    for (n = 0; (c = getchar()) != EOF;)
93        printf("%u,%c", c, ((++n & 0xf) == 0) ? '\n' : ' ');
94
95    printf("};\n");
96    return 0; 
97}
98
99#endif /* WIN32 */
Note: See TracBrowser for help on using the browser.