1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
/*
* This file is part of tk707.
*
* Copyright (C) 2000, 2001, 2002, 2003, 2004 Chris Willing and Pierre Saramito
*
* tk707 is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Foobar is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Foobar; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
Netvideo version 3.2
Written by Ron Frederick <frederick@parc.xerox.com>
Simple hack to translate a Tcl/Tk init file into a C string constant
Extra hacks added by mhandley based on idea from vic
*/
/*
* Copyright (c) Xerox Corporation 1992. All rights reserved.
*
* License is granted to copy, to use, and to make and to use derivative
* works for research and evaluation purposes, provided that Xerox is
* acknowledged in all documentation pertaining to any such copy or derivative
* work. Xerox grants no other licenses expressed or implied. The Xerox trade
* name should not be used in any advertising without its written permission.
*
* XEROX CORPORATION MAKES NO REPRESENTATIONS CONCERNING EITHER THE
* MERCHANTABILITY OF THIS SOFTWARE OR THE SUITABILITY OF THIS SOFTWARE
* FOR ANY PARTICULAR PURPOSE. The software is provided "as is" without
* express or implied warranty of any kind.
*
* These notices must be retained in any copies of any part of this software.
*/
#include <stdio.h>
int
main(int argc, char **argv)
{
int c, n;
FILE* in = stdin;
FILE* out = stdout;
int genstrings = 1;
const char* prog = argv[0];
if (argc > 1 && strcmp(argv[1], "-c") == 0) {
--argc;
++argv;
genstrings = 0;
}
if (argc < 2) {
fprintf(stderr, "Usage: %s [-c] stringname\n", prog);
exit(1);
}
if (genstrings) {
fprintf(out, "char %s[] = \"\\\n", argv[1]);
while ((c = getc(in)) != EOF) {
switch (c) {
case '\n':
fprintf(out, "\\n\\\n");
break;
case '\"':
fprintf(out, "\\\"");
break;
case '\\':
fprintf(out, "\\\\");
break;
default:
putc(c, out);
break;
}
}
fprintf(out, "\";\n");
} else {
fprintf(out, "static char %s[] = {\n", argv[1]);
for (n = 0; (c = getc(in)) != EOF;)
fprintf(out, "%u,%c", c, ((++n & 0xf) == 0) ? '\n' : ' ');
fprintf(out, "0\n};\n");
}
fclose(out);
exit(0);
/*NOTREACHED*/
}
|