Mercurial > repos > ktnyt > gembassy
comparison GEMBASSY-1.0.3/gsoap/src/soapcpp2.c @ 2:8947fca5f715 draft default tip
Uploaded
author | ktnyt |
---|---|
date | Fri, 26 Jun 2015 05:21:44 -0400 |
parents | 84a17b3fad1f |
children |
comparison
equal
deleted
inserted
replaced
1:84a17b3fad1f | 2:8947fca5f715 |
---|---|
1 /* | |
2 soapcpp2.c | |
3 | |
4 Main compiler and code generator batch program. | |
5 | |
6 gSOAP XML Web services tools | |
7 Copyright (C) 2000-2013, Robert van Engelen, Genivia Inc. All Rights Reserved. | |
8 This part of the software is released under one of the following licenses: | |
9 GPL or Genivia's license for commercial use. | |
10 -------------------------------------------------------------------------------- | |
11 GPL license. | |
12 | |
13 This program is free software; you can redistribute it and/or modify it under | |
14 the terms of the GNU General Public License as published by the Free Software | |
15 Foundation; either version 2 of the License, or (at your option) any later | |
16 version. | |
17 | |
18 This program is distributed in the hope that it will be useful, but WITHOUT ANY | |
19 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A | |
20 PARTICULAR PURPOSE. See the GNU General Public License for more details. | |
21 | |
22 You should have received a copy of the GNU General Public License along with | |
23 this program; if not, write to the Free Software Foundation, Inc., 59 Temple | |
24 Place, Suite 330, Boston, MA 02111-1307 USA | |
25 | |
26 Author contact information: | |
27 engelen@genivia.com / engelen@acm.org | |
28 | |
29 This program is released under the GPL with the additional exemption that | |
30 compiling, linking, and/or using OpenSSL is allowed. | |
31 -------------------------------------------------------------------------------- | |
32 A commercial use license is available from Genivia, Inc., contact@genivia.com | |
33 -------------------------------------------------------------------------------- | |
34 */ | |
35 | |
36 #include "soapcpp2.h" | |
37 | |
38 #ifndef SOAPCPP2_IMPORT_PATH | |
39 #define SOAPCPP2_IMPORT_PATH (NULL) | |
40 #endif | |
41 | |
42 extern void init(void); | |
43 extern int yyparse(void); | |
44 extern FILE *yyin; | |
45 | |
46 extern char *ns_cname(char*, char*); | |
47 | |
48 FILE *fmsg; /* fd to flush compiler messages */ | |
49 | |
50 int vflag = 0; /* SOAP version, -1=no SOAP, 0=not set, 1=1.1, 2=1.2 */ | |
51 int wflag = 0; /* when set, don't generate WSDL and schema files */ | |
52 int Cflag = 0; /* when set, generate only files for clients */ | |
53 int cflag = 0; /* when set, generate files with .c extension */ | |
54 int aflag = 0; /* when set, use value of SOAP Action to dispatch method at server side */ | |
55 int Aflag = 0; /* when set, require SOAP Action to dispatch method at server side */ | |
56 int bflag = 0; /* when set, serialize byte arrays char[N] as string */ | |
57 int eflag = 0; /* when set, use SOAP RPC encoding by default */ | |
58 unsigned long fflag = 0;/* multi-file split for each bundle of -fN defs */ | |
59 int iflag = 0; /* when set, generate new style proxy/object classes inherited from soap struct */ | |
60 int jflag = 0; /* when set, generate new style proxy/object classes */ | |
61 int kflag = 0; /* when set, generate data traversal/walker routines */ | |
62 int mflag = 0; /* when set, generate code that requires array/binary classes to explicitly remove malloced array */ | |
63 int nflag = 0; /* when set, names the namespaces global struct '%NAME%_namespaces */ | |
64 int lflag = 0; /* when set, create library */ | |
65 int Lflag = 0; /* when set, don't generate soapClientLib/soapServerLib */ | |
66 int Qflag = 0; /* when set, use C++ namespaces for custom serializers */ | |
67 int sflag = 0; /* when set, generate strict validation checks */ | |
68 int Sflag = 0; /* when set, generate only files for servers */ | |
69 int Tflag = 0; /* when set, generates server auto-test code */ | |
70 int tflag = 0; /* when set, generates typed messsages (with xsi:type attributes) */ | |
71 int uflag = 0; /* when set, uncomment WSDL and schema output */ | |
72 int xflag = 0; /* when set, don't generate sample XML message files */ | |
73 int yflag = 0; /* when set, add C/C++ info in sample XML messages */ | |
74 int zflag = 0; /* when set, use backward compatibility option */ | |
75 | |
76 int stop_flag = 0; | |
77 | |
78 char dirpath[1024]; /* directory path for generated source files */ | |
79 char *prefix = "soap"; /* file name prefix for generated source files */ | |
80 char filename[1024]; /* current file name */ | |
81 char *importpath = SOAPCPP2_IMPORT_PATH; /* default file import path */ | |
82 | |
83 /* | |
84 IMPORTANT: | |
85 | |
86 The terms and conditions of use of this software do not allow for the removal | |
87 of the copyright notice from the main program for visual display. For | |
88 integrations with other software, a similar copyright notice must be produced | |
89 that is visible to users of the software. | |
90 */ | |
91 | |
92 int | |
93 main(int argc, char **argv) | |
94 { int i, g; | |
95 char *a, *s; | |
96 fmsg = stderr; | |
97 strcpy(filename, "<stdin>"); | |
98 for (i = 1; i < argc; i++) | |
99 { a = argv[i]; | |
100 if (*a == '-' | |
101 #ifdef WIN32 | |
102 || *a == '/' | |
103 #endif | |
104 ) | |
105 { g = 1; | |
106 while (g && *++a) | |
107 switch (*a) | |
108 { case 'C': | |
109 Cflag = 1; | |
110 if (Sflag) | |
111 fprintf(stderr, "soapcpp2: using both options -C and -S omits client/server code\n"); | |
112 break; | |
113 case 'c': | |
114 cflag = 1; | |
115 break; | |
116 case 'd': | |
117 a++; | |
118 g = 0; | |
119 if (*a) | |
120 strcpy(dirpath, a); | |
121 else if (i < argc && argv[++i]) | |
122 strcpy(dirpath, argv[i]); | |
123 else | |
124 execerror("Option -d requires a directory path"); | |
125 if (*dirpath && dirpath[strlen(dirpath)-1] != '/' && dirpath[strlen(dirpath)-1] != '\\') | |
126 strcat(dirpath, SOAP_PATHCAT); | |
127 break; | |
128 case 'e': | |
129 eflag = 1; | |
130 break; | |
131 case 'f': | |
132 a++; | |
133 g = 0; | |
134 if (*a) | |
135 fflag = strtoul(a, NULL, 10); | |
136 else if (i < argc && argv[++i]) | |
137 fflag = strtoul(argv[i], NULL, 10); | |
138 if (!fflag) | |
139 execerror("Option -f requires a value"); | |
140 if (fflag < 10) | |
141 fflag = 10; | |
142 break; | |
143 case 'a': | |
144 aflag = 1; | |
145 break; | |
146 case 'A': | |
147 aflag = 1; | |
148 Aflag = 1; | |
149 break; | |
150 case 'b': | |
151 bflag = 1; | |
152 break; | |
153 case '?': | |
154 case 'h': | |
155 fprintf(stderr, "Usage: soapcpp2 [-0|-1|-2] [-C|-S] [-T] [-L] [-a] [-A] [-b] [-c] [-d path] [-e] [-f N] [-h] [-i] [-I path"SOAP_PATHSEP"path"SOAP_PATHSEP"...] [-k] [-l] [-m] [-n] [-p name] [-s] [-t] [-u] [-v] [-w] [-x] [-y] [-z#] [infile]\n\n"); | |
156 fprintf(stderr, "\ | |
157 -1 generate SOAP 1.1 bindings\n\ | |
158 -2 generate SOAP 1.2 bindings\n\ | |
159 -0 remove SOAP bindings, use REST\n\ | |
160 -C generate client-side code only\n\ | |
161 -S generate server-side code only\n\ | |
162 -T generate server auto-test code\n\ | |
163 -L don't generate soapClientLib/soapServerLib\n\ | |
164 -a use SOAPAction with WS-Addressing to invoke server-side operations\n\ | |
165 -A require SOAPAction to invoke server-side operations\n\ | |
166 -b serialize byte arrays char[N] as string\n\ | |
167 -c generate C source code\n\ | |
168 -dpath use path to save files\n\ | |
169 -e generate SOAP RPC encoding style bindings\n\ | |
170 -fN file split of N XML serializer implementations per file (N>=10)\n\ | |
171 -h display help info\n\ | |
172 -Ipath use path(s) for #import (paths separated with '"SOAP_PATHSEP"')\n\ | |
173 -i generate C++ service proxies and objects inherited from soap struct\n\ | |
174 -j generate C++ service proxies and objects that share a soap struct\n\ | |
175 -k generate data structure walkers (experimental)\n\ | |
176 -l generate linkable modules (experimental)\n\ | |
177 -m generate Matlab(tm) code for MEX compiler\n\ | |
178 -n use service name to rename service functions and namespace table\n\ | |
179 -pname save files with new prefix name instead of 'soap'\n\ | |
180 -Qname use name as the C++ namespace for decls, including custom serializers\n\ | |
181 -qname use name as the C++ namespace for decls, excluding custom serializers\n\ | |
182 -s generate deserialization code with strict XML validation checks\n\ | |
183 -t generate code for fully xsi:type typed SOAP/XML messaging\n\ | |
184 -u uncomment comments in WSDL/schema output by suppressing XML comments\n\ | |
185 -v display version info\n\ | |
186 -w don't generate WSDL and schema files\n\ | |
187 -x don't generate sample XML message files\n\ | |
188 -y include C/C++ type access information in sample XML messages\n\ | |
189 -z1 generate deprecated old-style C++ service proxies and objects\n\ | |
190 infile header file to parse (or stdin)\n\ | |
191 \n"); | |
192 exit(0); | |
193 case 'I': | |
194 a++; | |
195 g = 0; | |
196 s = NULL; | |
197 if (*a) | |
198 s = a; | |
199 else if (i < argc && argv[++i]) | |
200 s = argv[i]; | |
201 else | |
202 execerror("Option -I requires an import path"); | |
203 if (importpath && s) | |
204 { char *t = emalloc(strlen(importpath) + strlen(s) + 2); | |
205 strcpy(t, importpath); | |
206 strcat(t, SOAP_PATHSEP); | |
207 strcat(t, s); | |
208 importpath = t; | |
209 } | |
210 else | |
211 importpath = s; | |
212 break; | |
213 case 'i': | |
214 iflag = 1; | |
215 break; | |
216 case 'j': | |
217 jflag = 1; | |
218 break; | |
219 case 'k': | |
220 kflag = 1; | |
221 break; | |
222 case 'm': | |
223 mflag = 1; | |
224 break; | |
225 case 'n': | |
226 nflag = 1; | |
227 break; | |
228 case 'l': | |
229 lflag = 1; | |
230 break; | |
231 case 'L': | |
232 Lflag = 1; | |
233 break; | |
234 case 's': | |
235 sflag = 1; | |
236 break; | |
237 case 'S': | |
238 Sflag = 1; | |
239 if (Cflag) | |
240 fprintf(stderr, "soapcpp2: using both options -C and -S omits client/server code\n"); | |
241 break; | |
242 case 'T': | |
243 Tflag = 1; | |
244 break; | |
245 case 't': | |
246 tflag = 1; | |
247 break; | |
248 case 'u': | |
249 uflag = 1; | |
250 break; | |
251 case 'w': | |
252 wflag = 1; | |
253 break; | |
254 case 'x': | |
255 xflag = 1; | |
256 break; | |
257 case 'y': | |
258 yflag = 1; | |
259 break; | |
260 case 'p': | |
261 a++; | |
262 g = 0; | |
263 if (*a) | |
264 prefix = ns_cname(a, NULL); | |
265 else if (i < argc && argv[++i]) | |
266 prefix = ns_cname(argv[i], NULL); | |
267 else | |
268 execerror("Option -p requires an output file name prefix"); | |
269 break; | |
270 case 'Q': | |
271 Qflag = 1; | |
272 /* fall through */ | |
273 case 'q': | |
274 a++; | |
275 g = 0; | |
276 if (*a) | |
277 namespaceid = ns_cname(a, NULL); | |
278 else if (i < argc && argv[++i]) | |
279 namespaceid = ns_cname(argv[i], NULL); | |
280 else | |
281 execerror("Option -q requires a namespace name"); | |
282 break; | |
283 case '0': | |
284 vflag = -1; | |
285 break; | |
286 case '1': | |
287 vflag = 1; | |
288 envURI = "http://schemas.xmlsoap.org/soap/envelope/"; | |
289 encURI = "http://schemas.xmlsoap.org/soap/encoding/"; | |
290 break; | |
291 case '2': | |
292 vflag = 2; | |
293 envURI = "http://www.w3.org/2003/05/soap-envelope"; | |
294 encURI = "http://www.w3.org/2003/05/soap-encoding"; | |
295 rpcURI = "http://www.w3.org/2003/05/soap-rpc"; | |
296 break; | |
297 case 'v': | |
298 stop_flag = 1; | |
299 break; | |
300 case 'z': | |
301 a++; | |
302 g = 0; | |
303 if (*a) | |
304 zflag = *a - '0'; | |
305 else if (i < argc && argv[++i]) | |
306 zflag = *argv[i] - '0'; | |
307 else | |
308 execerror("Option -z requires a digit"); | |
309 break; | |
310 default: | |
311 fprintf(stderr, "soapcpp2: Unknown option %s\n", a); | |
312 exit(1); | |
313 } | |
314 } | |
315 else if (!(yyin = fopen(argv[i], "r"))) | |
316 { sprintf(errbuf, "Cannot open file \"%s\" for reading", argv[i]); | |
317 execerror(errbuf); | |
318 } | |
319 else | |
320 strcpy(filename, argv[i]); | |
321 } | |
322 fprintf(fmsg, "\n** The gSOAP code generator for C and C++, soapcpp2 release "VERSION"\n** Copyright (C) 2000-2013, Robert van Engelen, Genivia Inc.\n** All Rights Reserved. This product is provided \"as is\", without any warranty.\n** The soapcpp2 tool is released under one of the following licenses:\n** GPL or the commercial license by Genivia Inc.\n\n"); | |
323 if (stop_flag) | |
324 exit(0); | |
325 init(); | |
326 if (yyparse()) | |
327 synerror("skipping the remaining part of the input"); | |
328 return errstat(); | |
329 } |