diff options
author | David Walter Seikel | 2012-01-04 18:41:13 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-01-04 18:41:13 +1000 |
commit | dd7595a3475407a7fa96a97393bae8c5220e8762 (patch) | |
tree | e341e911d7eb911a51684a7412ef7f7c7605d28e /libraries/edje/src/bin/epp/cppmain.c | |
parent | Add the skeleton. (diff) | |
download | SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.zip SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.gz SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.bz2 SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.xz |
Add the base Enlightenment Foundation Libraries - eina, eet, evas, ecore, embryo, and edje.
Note that embryo wont be used, but I'm not sure yet if you can build edje without it.
Diffstat (limited to '')
-rw-r--r-- | libraries/edje/src/bin/epp/cppmain.c | 142 |
1 files changed, 142 insertions, 0 deletions
diff --git a/libraries/edje/src/bin/epp/cppmain.c b/libraries/edje/src/bin/epp/cppmain.c new file mode 100644 index 0000000..45b67b5 --- /dev/null +++ b/libraries/edje/src/bin/epp/cppmain.c | |||
@@ -0,0 +1,142 @@ | |||
1 | /* CPP main program, using CPP Library. | ||
2 | * Copyright (C) 1995 Free Software Foundation, Inc. | ||
3 | * Written by Per Bothner, 1994-95. | ||
4 | * Copyright (C) 2003-2011 Kim Woelders | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify it | ||
7 | * under the terms of the GNU General Public License as published by the | ||
8 | * Free Software Foundation; either version 2, or (at your option) any | ||
9 | * later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | ||
19 | * | ||
20 | * In other words, you are welcome to use, share and improve this program. | ||
21 | * You are forbidden to forbid anyone else to use, share and improve | ||
22 | * what you give them. Help stamp out software-hoarding! */ | ||
23 | |||
24 | #ifdef HAVE_CONFIG_H | ||
25 | # include <config.h> | ||
26 | #endif | ||
27 | |||
28 | #include <stdio.h> | ||
29 | #include <string.h> | ||
30 | #include <stdlib.h> | ||
31 | |||
32 | #include "cpplib.h" | ||
33 | |||
34 | #define EPP_DEBUG 0 | ||
35 | |||
36 | cpp_reader parse_in; | ||
37 | cpp_options options; | ||
38 | |||
39 | int | ||
40 | main(int argc, char **argv) | ||
41 | { | ||
42 | char *p; | ||
43 | int i; | ||
44 | int argi = 1; /* Next argument to handle. */ | ||
45 | struct cpp_options *opts = &options; | ||
46 | enum cpp_token kind; | ||
47 | int got_text; | ||
48 | |||
49 | p = argv[0] + strlen(argv[0]); | ||
50 | #ifndef __EMX__ | ||
51 | while (p != argv[0] && p[-1] != '/') | ||
52 | #else | ||
53 | while (p != argv[0] && p[-1] != '/' && p[-1] != '\\') | ||
54 | #endif | ||
55 | --p; | ||
56 | progname = p; | ||
57 | |||
58 | init_parse_file(&parse_in); | ||
59 | parse_in.data = opts; | ||
60 | |||
61 | init_parse_options(opts); | ||
62 | |||
63 | argi += cpp_handle_options(&parse_in, argc - argi, argv + argi); | ||
64 | if (argi < argc) | ||
65 | cpp_fatal("Invalid option `%s'", argv[argi]); | ||
66 | parse_in.show_column = 1; | ||
67 | |||
68 | i = push_parse_file(&parse_in, opts->in_fname); | ||
69 | if (i != SUCCESS_EXIT_CODE) | ||
70 | return i; | ||
71 | |||
72 | /* Now that we know the input file is valid, open the output. */ | ||
73 | |||
74 | if (!opts->out_fname || !strcmp(opts->out_fname, "")) | ||
75 | opts->out_fname = "stdout"; | ||
76 | else if (!freopen(opts->out_fname, "w", stdout)) | ||
77 | cpp_pfatal_with_name(&parse_in, opts->out_fname); | ||
78 | |||
79 | got_text = 0; | ||
80 | for (i = 0;; i++) | ||
81 | { | ||
82 | kind = cpp_get_token(&parse_in); | ||
83 | #if EPP_DEBUG | ||
84 | fprintf(stderr, "%03d: kind=%d len=%d out=%d text=%d\n", i, | ||
85 | kind, CPP_WRITTEN(&parse_in), !opts->no_output, got_text); | ||
86 | #endif | ||
87 | switch (kind) | ||
88 | { | ||
89 | case CPP_EOF: | ||
90 | goto done; | ||
91 | |||
92 | case CPP_HSPACE: | ||
93 | continue; | ||
94 | |||
95 | case CPP_VSPACE: | ||
96 | break; | ||
97 | |||
98 | default: | ||
99 | case CPP_OTHER: | ||
100 | case CPP_NAME: | ||
101 | case CPP_NUMBER: | ||
102 | case CPP_CHAR: | ||
103 | case CPP_STRING: | ||
104 | case CPP_LPAREN: | ||
105 | case CPP_RPAREN: | ||
106 | case CPP_LBRACE: | ||
107 | case CPP_RBRACE: | ||
108 | case CPP_COMMA: | ||
109 | case CPP_SEMICOLON: | ||
110 | case CPP_3DOTS: | ||
111 | got_text = 1; | ||
112 | continue; | ||
113 | |||
114 | case CPP_COMMENT: | ||
115 | case CPP_DIRECTIVE: | ||
116 | case CPP_POP: | ||
117 | continue; | ||
118 | } | ||
119 | #if EPP_DEBUG | ||
120 | fprintf(stderr, "'"); | ||
121 | fwrite(parse_in.token_buffer, 1, CPP_WRITTEN(&parse_in), stderr); | ||
122 | fprintf(stderr, "'\n"); | ||
123 | #endif | ||
124 | if (!opts->no_output) | ||
125 | { | ||
126 | size_t n; | ||
127 | |||
128 | n = CPP_WRITTEN(&parse_in); | ||
129 | if (fwrite(parse_in.token_buffer, 1, n, stdout) != n) | ||
130 | exit(FATAL_EXIT_CODE); | ||
131 | } | ||
132 | parse_in.limit = parse_in.token_buffer; | ||
133 | got_text = 0; | ||
134 | } | ||
135 | |||
136 | done: | ||
137 | cpp_finish(&parse_in); | ||
138 | |||
139 | if (parse_in.errors) | ||
140 | exit(FATAL_EXIT_CODE); | ||
141 | exit(SUCCESS_EXIT_CODE); | ||
142 | } | ||