~ifolder-dev/simias/trunk-packaging

« back to all changes in this revision

Viewing changes to tools/gsoap/gsoap-linux-2.7/src/.svn/text-base/soapcpp2_lex.l.svn-base

  • Committer: Jorge O. Castro
  • Date: 2007-12-03 06:56:46 UTC
  • Revision ID: jorge@ubuntu.com-20071203065646-mupcnjcwgm5mnhyt
* Remove a bunch of .svn directories we no longer need.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 
3
 
soapcpp2_lex.l
4
 
 
5
 
Flex/Lex tokenizer.
6
 
 
7
 
gSOAP XML Web services tools
8
 
Copyright (C) 2000-2007, Robert van Engelen, Genivia Inc. All Rights Reserved.
9
 
This part of the software is released under one of the following licenses:
10
 
GPL, the gSOAP public license, or Genivia's license for commercial use.
11
 
--------------------------------------------------------------------------------
12
 
gSOAP public license.
13
 
 
14
 
The contents of this file are subject to the gSOAP Public License Version 1.3
15
 
(the "License"); you may not use this file except in compliance with the
16
 
License. You may obtain a copy of the License at
17
 
http://www.cs.fsu.edu/~engelen/soaplicense.html
18
 
Software distributed under the License is distributed on an "AS IS" basis,
19
 
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20
 
for the specific language governing rights and limitations under the License.
21
 
 
22
 
The Initial Developer of the Original Code is Robert A. van Engelen.
23
 
Copyright (C) 2000-2007 Robert A. van Engelen, Genivia inc. All Rights Reserved.
24
 
--------------------------------------------------------------------------------
25
 
GPL license.
26
 
 
27
 
This program is free software; you can redistribute it and/or modify it under
28
 
the terms of the GNU General Public License as published by the Free Software
29
 
Foundation; either version 2 of the License, or (at your option) any later
30
 
version.
31
 
 
32
 
This program is distributed in the hope that it will be useful, but WITHOUT ANY
33
 
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
34
 
PARTICULAR PURPOSE. See the GNU General Public License for more details.
35
 
 
36
 
You should have received a copy of the GNU General Public License along with
37
 
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
38
 
Place, Suite 330, Boston, MA 02111-1307 USA
39
 
 
40
 
Author contact information:
41
 
engelen@genivia.com / engelen@acm.org
42
 
--------------------------------------------------------------------------------
43
 
A commercial use license is available from Genivia, Inc., contact@genivia.com
44
 
--------------------------------------------------------------------------------
45
 
*/
46
 
 
47
 
%{
48
 
#include "soapcpp2.h"
49
 
 
50
 
#ifdef HAVE_CONFIG_H
51
 
#include "soapcpp2_yacc.h"
52
 
#else
53
 
#include "soapcpp2_yacc.tab.h"
54
 
#endif
55
 
 
56
 
#ifdef WITH_BISON
57
 
YYSTYPE yylval;
58
 
#undef YY_INPUT
59
 
#define YY_INPUT(buf, result, max_size) \
60
 
        { \
61
 
        int c = getc(yyin); \
62
 
        result = (c == EOF) ? YY_NULL : (buf[0] = c, 1); \
63
 
        }
64
 
#endif
65
 
 
66
 
#ifndef WITH_LEX
67
 
#define MAX_IMPORT_DEPTH 16
68
 
static struct importlist { struct importlist *next; char name[1]; } *importlist = NULL;
69
 
static char fnstk[MAX_IMPORT_DEPTH][1024];
70
 
static int lnstk[MAX_IMPORT_DEPTH];
71
 
static char *imstk[MAX_IMPORT_DEPTH];
72
 
static YY_BUFFER_STATE instk[MAX_IMPORT_DEPTH];
73
 
#endif
74
 
int imports = 0;
75
 
char *imported = NULL;
76
 
static Token install_id();
77
 
static Token install_int();
78
 
static Token install_hex();
79
 
static Token install_num();
80
 
static Token install_chr();
81
 
static Token install_str();
82
 
static Token install_pragma();
83
 
static void directive(), option();
84
 
static Token error_chr();
85
 
static Token error_str();
86
 
static int convchar(int*);
87
 
static int hexchar(int*);
88
 
static int octchar(int*);
89
 
static void module(const char *name, const char *fullname);
90
 
static void import(const char *file);
91
 
static int magic(const char *name);
92
 
%}
93
 
ws              [ \t\v\n\f\r\x1A\xA0]
94
 
digit           [0-9]
95
 
alpha           [a-zA-Z_]
96
 
id              {alpha}({alpha}|{digit}|::|:{alpha})*
97
 
int             {digit}+
98
 
hex             0[xX][0-9a-fA-F]+
99
 
num             {int}(\.{int}([Ee][+-]?{int})?|(\.{int})?[Ee][+-]?{int})
100
 
chr             '(\\'|[^'\n])*'
101
 
str             \"(\\\"|\\\n|[^"])*\"
102
 
module          #module{ws}+.*\n
103
 
import          #import{ws}+.*\n
104
 
%x MLCOMMENT
105
 
%%
106
 
{ws}                    { /* skip white space */ }
107
 
"/*"                    { BEGIN(MLCOMMENT); }
108
 
<MLCOMMENT>.|\n         { }
109
 
<MLCOMMENT>"*/"         { BEGIN(INITIAL); }
110
 
<MLCOMMENT><<EOF>>      { execerror("Unclosed multiline comment at the end of file"); }
111
 
"//gsoapopt".*\n        { option(); }
112
 
"//gsoap".*\n           { directive(); }
113
 
"//".*\n                { /* skip single line comment */ }
114
 
"+="                    { return PA; }
115
 
"-="                    { return NA; }
116
 
"*="                    { return TA; }
117
 
"/="                    { return DA; }
118
 
"%="                    { return MA; }
119
 
"&="                    { return AA; }
120
 
"^="                    { return XA; }
121
 
"|="                    { return OA; }
122
 
"<<="                   { return LA; }
123
 
">>="                   { return RA; }
124
 
"||"                    { return OR; }
125
 
"&&"                    { return AN; }
126
 
"=="                    { return EQ; }
127
 
"!="                    { return NE; }
128
 
"<="                    { return LE; }
129
 
">="                    { return GE; }
130
 
"<<"                    { return LS; }
131
 
">>"                    { return RS; }
132
 
"++"                    { return PP; }
133
 
"--"                    { return NN; }
134
 
"->"                    { return AR; }
135
 
[;,:=|^&<>+\-*/%!?~(){}\[\].@]  { return yytext[0]; }
136
 
{id}                    { return install_id(); }
137
 
{int}                   { return install_int(); }
138
 
{hex}                   { return install_hex(); }
139
 
{num}                   { return install_num(); }
140
 
{chr}                   { return install_chr(); }
141
 
{str}                   { return install_str(); }
142
 
{module}                { char *s, *t, buf[1024];
143
 
                          s = strchr(yytext, '"');
144
 
                          strcpy(buf, s+1);
145
 
                          s = strchr(buf, '"');
146
 
                          *s = '\0';
147
 
                          t = strchr(s+1, '"');
148
 
                          if (t)
149
 
                          { t++;
150
 
                            s = strchr(t+1, '"');
151
 
                            *s = '\0';
152
 
                          }
153
 
                          module(buf, t);
154
 
                        }
155
 
{import}                { char *s, buf[1024];
156
 
                          s = strchr(yytext, '"');
157
 
                          strcpy(buf, s+1);
158
 
                          s = strchr(buf, '"');
159
 
                          *s = '\0';
160
 
                          import(buf);
161
 
                        }
162
 
#.*\n                   { return install_pragma(); }
163
 
'[^'\n]*/\n             { return error_chr(); }
164
 
\"[^"\n]*/\n            { return error_str(); }
165
 
.                       { lexerror("Skipping unknown symbol"); }
166
 
<<EOF>>                 { /* when Lex complains: remove this line and below */
167
 
#ifndef WITH_LEX
168
 
                          if (--imports < 0)
169
 
                            yyterminate();
170
 
                          else
171
 
                          { yy_delete_buffer(YY_CURRENT_BUFFER);
172
 
                            yy_switch_to_buffer(instk[imports]);
173
 
                            strcpy(filename, fnstk[imports]);
174
 
                            yylineno = lnstk[imports];
175
 
                            imported = imstk[imports];
176
 
                          }
177
 
#endif
178
 
                        }
179
 
%%
180
 
 
181
 
/*
182
 
        install_id - lookup identifier in symbol table. If found, return token
183
 
        and symbol table entry. If not found, create entry in symbol table and
184
 
        return ID token.
185
 
*/ 
186
 
static Token
187
 
install_id()
188
 
{       Symbol *p = lookup(yytext);
189
 
        if (!p)
190
 
                p = install(yytext, ID);
191
 
        yylval.sym = p;
192
 
        return p->token;
193
 
}
194
 
 
195
 
/*
196
 
        install_int - convert digits to integer and return LNG token.
197
 
*/
198
 
static Token
199
 
install_int()
200
 
{
201
 
        sscanf(yytext, SOAP_ULONG_FORMAT, &yylval.i);
202
 
        return LNG;
203
 
}
204
 
 
205
 
/*
206
 
        install_hex - convert hexadecimal digits to integer and return LNG
207
 
*/
208
 
static Token
209
 
install_hex()
210
 
{
211
 
        sscanf(yytext, SOAP_XLONG_FORMAT, &yylval.i);
212
 
        return LNG;
213
 
}
214
 
 
215
 
/*
216
 
        install_num - convert digits to floating point number and return DBL
217
 
*/
218
 
static Token
219
 
install_num()
220
 
{       sscanf(yytext, "%lf", &yylval.r);
221
 
        return DBL;
222
 
}
223
 
 
224
 
/*
225
 
        install_chr - convert character constant and return CHR.
226
 
*/
227
 
static Token
228
 
install_chr()
229
 
{       int i = 2;
230
 
        if (yytext[1] == '\\')
231
 
                yylval.c = convchar(&i);
232
 
        else    yylval.c = yytext[i-1];
233
 
        if (yytext[i] != '\'')
234
 
                lexerror("Illegal character constant");
235
 
        return CHR;
236
 
}
237
 
 
238
 
/*
239
 
        install_str - convert and store string in memory. Return STR.
240
 
*/
241
 
static Token
242
 
install_str()
243
 
{       int i, j = 0;
244
 
        yylval.s = emalloc(yyleng-1);   /* yyleng = length(yytext) */
245
 
        for (i = 1; i < yyleng-1; i++)
246
 
                if (yytext[i] == '\\')
247
 
                {       if (yytext[++i] != '\n')
248
 
                        {       yylval.s[j++] = convchar(&i);
249
 
                                i--;
250
 
                        }
251
 
                }
252
 
                else
253
 
                        yylval.s[j++] = yytext[i];
254
 
        yylval.s[j] = '\0';
255
 
        return STR;
256
 
}
257
 
 
258
 
/*
259
 
        install_pragma - store pragma in string. Return PRAGMA.
260
 
*/
261
 
static Token
262
 
install_pragma()
263
 
{       yylval.s = emalloc(yyleng);     /* yyleng = length(yytext) */
264
 
        strncpy(yylval.s, yytext, strlen(yytext)-1);
265
 
        yylval.s[strlen(yytext)-1] = '\0';
266
 
        return PRAGMA;
267
 
}
268
 
 
269
 
static void directive()
270
 
{       int i, j, k;
271
 
        char *s;
272
 
        Service *sp;
273
 
        Method *m;
274
 
        Data *d;
275
 
        int service;
276
 
        for (i = 7; yytext[i]; i++)
277
 
                if (yytext[i] > 32)
278
 
                        break;
279
 
        for (j = i; yytext[j]; j++)
280
 
                if (yytext[j] <= 32)
281
 
                        break;
282
 
        if (i == j)
283
 
                return;
284
 
        s = (char*)emalloc(j-i+1);
285
 
        for (k = 0; k < j-i; k++)
286
 
        { s[k] = yytext[k+i];
287
 
          if (s[k] == '_')
288
 
            s[k] = '-';
289
 
        }
290
 
        s[k] = '\0';
291
 
        for (sp = services; sp; sp = sp->next)
292
 
                if (!strcmp(sp->ns, s))
293
 
                        break;
294
 
        if (!sp)
295
 
        {       sp = (Service*)emalloc(sizeof(Service));
296
 
                sp->next = services;
297
 
                sp->ns = s;
298
 
                sp->name = NULL;
299
 
                sp->porttype = NULL;
300
 
                sp->portname = NULL;
301
 
                sp->binding = NULL;
302
 
                sp->definitions = NULL;
303
 
                sp->transport = NULL;
304
 
                sp->URL = NULL;
305
 
                sp->URI = NULL;
306
 
                sp->WSDL = NULL;
307
 
                sp->style = NULL;
308
 
                sp->encoding = NULL;
309
 
                sp->elementForm = NULL;
310
 
                sp->attributeForm = NULL;
311
 
                sp->executable = NULL;
312
 
                sp->import = NULL;
313
 
                sp->documentation = NULL;
314
 
                sp->list = NULL;
315
 
                sp->data = NULL;
316
 
                services = sp;
317
 
        }
318
 
        for (i = j; yytext[i]; i++)
319
 
                if (yytext[i] > 32)
320
 
                        break;
321
 
        if (!strncmp(yytext+i, "service", 7) || !strncmp(yytext+i, "schema", 6))
322
 
        {       service = strncmp(yytext+i, "schema", 6);
323
 
                for (i += 7; yytext[i]; i++)
324
 
                        if (yytext[i] > 32)
325
 
                                break;
326
 
                for (j = i; yytext[j]; j++)
327
 
                        if (yytext[j] <= 32)
328
 
                                break;
329
 
                for (; yytext[j]; j++)
330
 
                        if (yytext[j] > 32)
331
 
                                break;
332
 
                for (k = j; yytext[k]; k++)
333
 
                        if (yytext[k] <= 32)
334
 
                                break;
335
 
                /*
336
 
                if (j == k)
337
 
                        return;
338
 
                */
339
 
                s = (char*)emalloc(k-j+1);
340
 
                strncpy(s, yytext+j, k-j);
341
 
                s[k-j] = '\0';
342
 
                if (!strncmp(yytext+i, "name:", 5))
343
 
                {       sp->name = s;
344
 
                        for (j = k; yytext[j]; j++)
345
 
                                if (yytext[j] > 32)
346
 
                                        break;
347
 
                        for (k = j; yytext[k]; k++)
348
 
                                if (yytext[k] == 10 || yytext[k] == 13)
349
 
                                        break;
350
 
                        if (j == k)
351
 
                                return;
352
 
                        s = (char*)emalloc(k-j+1);
353
 
                        strncpy(s, yytext+j, k-j);
354
 
                        s[k-j] = '\0';
355
 
                        sp->documentation = s;
356
 
                }
357
 
                else if (!strncmp(yytext+i, "type:", 5))
358
 
                        sp->porttype = s;
359
 
                else if (!strncmp(yytext+i, "portType:", 9))
360
 
                        sp->porttype = s;
361
 
                else if (!strncmp(yytext+i, "portName:", 9))
362
 
                        sp->portname = s;
363
 
                else if (!strncmp(yytext+i, "binding:", 8))
364
 
                        sp->binding = s;
365
 
                else if (!strncmp(yytext+i, "definitions:", 12))
366
 
                        sp->definitions = s;
367
 
                else if (!strncmp(yytext+i, "documentation:", 14))
368
 
                {       for (k = j; yytext[k]; k++)
369
 
                                if (yytext[k] == 10 || yytext[k] == 13)
370
 
                                        break;
371
 
                        if (j == k)
372
 
                                return;
373
 
                        s = (char*)emalloc(k-j+1);
374
 
                        strncpy(s, yytext+j, k-j);
375
 
                        s[k-j] = '\0';
376
 
                        sp->documentation = s;
377
 
                }
378
 
                else if (!strncmp(yytext+i, "transport:", 10))
379
 
                        sp->transport = s;
380
 
                else if (!strncmp(yytext+i, "location:", 9) || !strncmp(yytext+i, "port:", 5))
381
 
                {       sp->URL = s;
382
 
                        if (!service)
383
 
                                sp->import = s;
384
 
                }
385
 
                else if (!strncmp(yytext+i, "executable:", 11))
386
 
                        sp->executable = s;
387
 
                else if (!strncmp(yytext+i, "namespace:", 10))
388
 
                {       if (service)
389
 
                        {       if (!sp->URI)
390
 
                                        sp->URI = s;
391
 
                                sp->WSDL = s;
392
 
                        }
393
 
                        else if (!strcmp(sp->ns, "SOAP-ENV"))
394
 
                                sp->URI = envURI = s;
395
 
                        else if (!strcmp(sp->ns, "SOAP-ENC"))
396
 
                                sp->URI = encURI = s;
397
 
                        else
398
 
                                sp->URI = s;
399
 
                }
400
 
                else if (!strncmp(yytext+i, "form:", 5))
401
 
                {       sp->elementForm = s;
402
 
                        sp->attributeForm = s;
403
 
                }
404
 
                else if (!strncmp(yytext+i, "elementForm:", 12))
405
 
                        sp->elementForm = s;
406
 
                else if (!strncmp(yytext+i, "attributeForm:", 14))
407
 
                        sp->attributeForm = s;
408
 
                else if (!strncmp(yytext+i, "import:", 7))
409
 
                {       if (!sp->URI)
410
 
                                sp->URI = s;
411
 
                        sp->import = s;
412
 
                }
413
 
                else if (!strncmp(yytext+i, "encoding:", 9))
414
 
                {       if (!strcmp(s, "encoded"))
415
 
                                sp->encoding = "";
416
 
                        else
417
 
                                sp->encoding = s;
418
 
                }
419
 
                else if (!strncmp(yytext+i, "style:", 6))
420
 
                        sp->style = s;
421
 
                else if (!strncmp(yytext+i, "method-style:", 13))
422
 
                {       m = (Method*)emalloc(sizeof(Method));
423
 
                        m->name = s;
424
 
                        m->mess = STYLE;
425
 
                        m->part = NULL;
426
 
                        m->next = sp->list;
427
 
                        sp->list = m;
428
 
                        for (j = k; yytext[j]; j++)
429
 
                                if (yytext[j] > 32)
430
 
                                        break;
431
 
                        for (k = j; yytext[k]; k++)
432
 
                                if (yytext[k] == 10 || yytext[k] == 13)
433
 
                                        break;
434
 
                        if (j == k)
435
 
                                return;
436
 
                        s = (char*)emalloc(k-j+1);
437
 
                        strncpy(s, yytext+j, k-j);
438
 
                        s[k-j] = '\0';
439
 
                        m->part = s;
440
 
                }
441
 
                else if (!strncmp(yytext+i, "method-encoding:", 16))
442
 
                {       m = (Method*)emalloc(sizeof(Method));
443
 
                        m->name = s;
444
 
                        m->mess = ENCODING;
445
 
                        m->part = NULL;
446
 
                        m->next = sp->list;
447
 
                        sp->list = m;
448
 
                        for (j = k; yytext[j]; j++)
449
 
                                if (yytext[j] > 32)
450
 
                                        break;
451
 
                        for (k = j; yytext[k]; k++)
452
 
                                if (yytext[k] == 10 || yytext[k] == 13)
453
 
                                        break;
454
 
                        if (j == k)
455
 
                                return;
456
 
                        s = (char*)emalloc(k-j+1);
457
 
                        strncpy(s, yytext+j, k-j);
458
 
                        s[k-j] = '\0';
459
 
                        if (strcmp(s, "encoded"))
460
 
                                m->part = s;
461
 
                        else
462
 
                                m->part = "";
463
 
                }
464
 
                else if (!strncmp(yytext+i, "method-response-encoding:", 25))
465
 
                {       m = (Method*)emalloc(sizeof(Method));
466
 
                        m->name = s;
467
 
                        m->mess = RESPONSE_ENCODING;
468
 
                        m->part = NULL;
469
 
                        m->next = sp->list;
470
 
                        sp->list = m;
471
 
                        for (j = k; yytext[j]; j++)
472
 
                                if (yytext[j] > 32)
473
 
                                        break;
474
 
                        for (k = j; yytext[k]; k++)
475
 
                                if (yytext[k] == 10 || yytext[k] == 13)
476
 
                                        break;
477
 
                        if (j == k)
478
 
                                return;
479
 
                        s = (char*)emalloc(k-j+1);
480
 
                        strncpy(s, yytext+j, k-j);
481
 
                        s[k-j] = '\0';
482
 
                        if (strcmp(s, "encoded"))
483
 
                                m->part = s;
484
 
                        else
485
 
                                m->part = "";
486
 
                }
487
 
                else if (!strncmp(yytext+i, "method-documentation:", 21))
488
 
                {       m = (Method*)emalloc(sizeof(Method));
489
 
                        m->name = s;
490
 
                        m->mess = COMMENT;
491
 
                        m->part = NULL;
492
 
                        m->next = sp->list;
493
 
                        sp->list = m;
494
 
                        for (j = k; yytext[j]; j++)
495
 
                                if (yytext[j] > 32)
496
 
                                        break;
497
 
                        for (k = j; yytext[k]; k++)
498
 
                                if (yytext[k] == 10 || yytext[k] == 13)
499
 
                                        break;
500
 
                        if (j == k)
501
 
                                return;
502
 
                        s = (char*)emalloc(k-j+1);
503
 
                        strncpy(s, yytext+j, k-j);
504
 
                        s[k-j] = '\0';
505
 
                        m->part = s;
506
 
                }
507
 
                else if (!strncmp(yytext+i, "method-action:", 14))
508
 
                {       m = (Method*)emalloc(sizeof(Method));
509
 
                        m->name = s;
510
 
                        m->mess = ACTION;
511
 
                        m->part = NULL;
512
 
                        m->next = sp->list;
513
 
                        sp->list = m;
514
 
                        for (j = k; yytext[j]; j++)
515
 
                                if (yytext[j] > 32)
516
 
                                        break;
517
 
                        for (k = j; yytext[k]; k++)
518
 
                                if (yytext[k] <= 32)
519
 
                                        break;
520
 
                        if (j == k)
521
 
                                return;
522
 
                        s = (char*)emalloc(k-j+1);
523
 
                        strncpy(s, yytext+j, k-j);
524
 
                        s[k-j] = '\0';
525
 
                        m->part = s;
526
 
                }
527
 
                else if (!strncmp(yytext+i, "method-mime-type:", 17))
528
 
                {       m = (Method*)emalloc(sizeof(Method));
529
 
                        m->name = s;
530
 
                        m->mess = MIMEIN | MIMEOUT;
531
 
                        m->part = NULL;
532
 
                        m->next = sp->list;
533
 
                        sp->list = m;
534
 
                        for (j = k; yytext[j]; j++)
535
 
                                if (yytext[j] > 32)
536
 
                                        break;
537
 
                        for (k = j; yytext[k]; k++)
538
 
                                if (yytext[k] <= 32)
539
 
                                        break;
540
 
                        if (j == k)
541
 
                                return;
542
 
                        s = (char*)emalloc(k-j+1);
543
 
                        strncpy(s, yytext+j, k-j);
544
 
                        s[k-j] = '\0';
545
 
                        m->part = s;
546
 
                }
547
 
                else if (!strncmp(yytext+i, "method-input-mime-type:", 23))
548
 
                {       m = (Method*)emalloc(sizeof(Method));
549
 
                        m->name = s;
550
 
                        m->mess = MIMEIN;
551
 
                        m->part = NULL;
552
 
                        m->next = sp->list;
553
 
                        sp->list = m;
554
 
                        for (j = k; yytext[j]; j++)
555
 
                                if (yytext[j] > 32)
556
 
                                        break;
557
 
                        for (k = j; yytext[k]; k++)
558
 
                                if (yytext[k] <= 32)
559
 
                                        break;
560
 
                        if (j == k)
561
 
                                return;
562
 
                        s = (char*)emalloc(k-j+1);
563
 
                        strncpy(s, yytext+j, k-j);
564
 
                        s[k-j] = '\0';
565
 
                        m->part = s;
566
 
                }
567
 
                else if (!strncmp(yytext+i, "method-output-mime-type:", 24))
568
 
                {       m = (Method*)emalloc(sizeof(Method));
569
 
                        m->name = s;
570
 
                        m->mess = MIMEOUT;
571
 
                        m->part = NULL;
572
 
                        m->next = sp->list;
573
 
                        sp->list = m;
574
 
                        for (j = k; yytext[j]; j++)
575
 
                                if (yytext[j] > 32)
576
 
                                        break;
577
 
                        for (k = j; yytext[k]; k++)
578
 
                                if (yytext[k] <= 32)
579
 
                                        break;
580
 
                        if (j == k)
581
 
                                return;
582
 
                        s = (char*)emalloc(k-j+1);
583
 
                        strncpy(s, yytext+j, k-j);
584
 
                        s[k-j] = '\0';
585
 
                        m->part = s;
586
 
                }
587
 
                else if (!strncmp(yytext+i, "method-header-part:", 19))
588
 
                {       m = (Method*)emalloc(sizeof(Method));
589
 
                        m->name = s;
590
 
                        m->mess = HDRIN | HDROUT;
591
 
                        m->part = NULL;
592
 
                        m->next = sp->list;
593
 
                        sp->list = m;
594
 
                        for (j = k; yytext[j]; j++)
595
 
                                if (yytext[j] > 32)
596
 
                                        break;
597
 
                        for (k = j; yytext[k]; k++)
598
 
                                if (yytext[k] <= 32)
599
 
                                        break;
600
 
                        if (j == k)
601
 
                                return;
602
 
                        s = (char*)emalloc(k-j+1);
603
 
                        strncpy(s, yytext+j, k-j);
604
 
                        s[k-j] = '\0';
605
 
                        m->part = s;
606
 
                }
607
 
                else if (!strncmp(yytext+i, "method-input-header-part:", 25))
608
 
                {       m = (Method*)emalloc(sizeof(Method));
609
 
                        m->name = s;
610
 
                        m->mess = HDRIN;
611
 
                        m->part = NULL;
612
 
                        m->next = sp->list;
613
 
                        sp->list = m;
614
 
                        for (j = k; yytext[j]; j++)
615
 
                                if (yytext[j] > 32)
616
 
                                        break;
617
 
                        for (k = j; yytext[k]; k++)
618
 
                                if (yytext[k] <= 32)
619
 
                                        break;
620
 
                        if (j == k)
621
 
                                return;
622
 
                        s = (char*)emalloc(k-j+1);
623
 
                        strncpy(s, yytext+j, k-j);
624
 
                        s[k-j] = '\0';
625
 
                        m->part = s;
626
 
                }
627
 
                else if (!strncmp(yytext+i, "method-output-header-part:", 26))
628
 
                {       m = (Method*)emalloc(sizeof(Method));
629
 
                        m->name = s;
630
 
                        m->mess = HDROUT;
631
 
                        m->part = NULL;
632
 
                        m->next = sp->list;
633
 
                        sp->list = m;
634
 
                        for (j = k; yytext[j]; j++)
635
 
                                if (yytext[j] > 32)
636
 
                                        break;
637
 
                        for (k = j; yytext[k]; k++)
638
 
                                if (yytext[k] <= 32)
639
 
                                        break;
640
 
                        if (j == k)
641
 
                                return;
642
 
                        s = (char*)emalloc(k-j+1);
643
 
                        strncpy(s, yytext+j, k-j);
644
 
                        s[k-j] = '\0';
645
 
                        m->part = s;
646
 
                }
647
 
                else if (!strncmp(yytext+i, "method-fault:", 13))
648
 
                {       m = (Method*)emalloc(sizeof(Method));
649
 
                        m->name = s;
650
 
                        m->mess = FAULT;
651
 
                        m->part = NULL;
652
 
                        m->next = sp->list;
653
 
                        sp->list = m;
654
 
                        for (j = k; yytext[j]; j++)
655
 
                                if (yytext[j] > 32)
656
 
                                        break;
657
 
                        for (k = j; yytext[k]; k++)
658
 
                                if (yytext[k] <= 32)
659
 
                                        break;
660
 
                        if (j == k)
661
 
                                return;
662
 
                        s = (char*)emalloc(k-j+1);
663
 
                        strncpy(s, yytext+j, k-j);
664
 
                        s[k-j] = '\0';
665
 
                        m->part = s;
666
 
                }
667
 
                else if (!strncmp(yytext+i, "type-documentation:", 19))
668
 
                {       d = (Data*)emalloc(sizeof(Data));
669
 
                        d->name = s;
670
 
                        d->part = NULL;
671
 
                        d->next = sp->data;
672
 
                        sp->data = d;
673
 
                        for (j = k; yytext[j]; j++)
674
 
                                if (yytext[j] > 32)
675
 
                                        break;
676
 
                        for (k = j; yytext[k]; k++)
677
 
                                if (yytext[k] == 10 || yytext[k] == 13)
678
 
                                        break;
679
 
                        if (j == k)
680
 
                                return;
681
 
                        s = (char*)emalloc(k-j+1);
682
 
                        strncpy(s, yytext+j, k-j);
683
 
                        s[k-j] = '\0';
684
 
                        d->part = s;
685
 
                }
686
 
                else
687
 
                {       sprintf(errbuf, "unrecognized gsoap directive: %s", yytext+i);
688
 
                        semwarn(errbuf);
689
 
                }
690
 
        }
691
 
        else
692
 
        {       sprintf(errbuf, "unrecognized gsoap directive: %s", yytext);
693
 
                semwarn(errbuf);
694
 
        }
695
 
}
696
 
 
697
 
static void option()
698
 
{       int i;
699
 
        if (imports)
700
 
        {       sprintf(errbuf, "options directive: %s ignored in imported file(s)", yytext);
701
 
                semwarn(errbuf);
702
 
                return;
703
 
        }
704
 
        for (i = 10; yytext[i]; i++)
705
 
                if (yytext[i] > 32)
706
 
                        break;
707
 
        for (; yytext[i]; i++)
708
 
                switch (yytext[i])
709
 
                {       case 'c':
710
 
                                cflag = 1;
711
 
                                break;
712
 
                        case 'e':
713
 
                                eflag = 1;
714
 
                                break;
715
 
                        case 'n':
716
 
                                nflag = 1;
717
 
                                break;
718
 
                        case 'l':
719
 
                                lflag = 1;
720
 
                                break;
721
 
                        case 't':
722
 
                                tflag = 1;
723
 
                                break;
724
 
                        case 'w':
725
 
                                wflag = 1;
726
 
                                break;
727
 
                        default:
728
 
                                if (yytext[i] <= 32)
729
 
                                        return;
730
 
                }
731
 
}
732
 
 
733
 
/*
734
 
        error_chr - lexical error in character constant. Return character 0 to
735
 
        allow parsing to continue
736
 
*/
737
 
static Token
738
 
error_chr()
739
 
{       lexerror("Ending-' missing in character constant");
740
 
        yylval.c = '\0';
741
 
        return CHR;
742
 
}
743
 
 
744
 
/*
745
 
        error_str - lexical error in string. Return empty string to allow
746
 
        parsing to continue
747
 
*/
748
 
static Token
749
 
error_str()
750
 
{       lexerror("Ending-\" missing in string");
751
 
        yylval.s = "";
752
 
        return STR;
753
 
}
754
 
 
755
 
/*
756
 
        Character conversion functions
757
 
*/
758
 
static int
759
 
convchar(int *p)
760
 
{       switch (yytext[(*p)++])
761
 
        {       case 'a':       return '\a';
762
 
                case 'b':       return '\b';
763
 
                case 'f':       return '\f';
764
 
                case 'n':       return '\n';
765
 
                case 'r':       return '\r';
766
 
                case 't':       return '\t';
767
 
                case 'v':       return '\v';
768
 
                case 'x':       return hexchar(p);
769
 
                case '0':
770
 
                case '1':
771
 
                case '2':
772
 
                case '3':
773
 
                case '4':
774
 
                case '5':
775
 
                case '6':
776
 
                case '7':       (*p)--;
777
 
                                return octchar(p);
778
 
                default:        return yytext[*p-1];
779
 
        }
780
 
}
781
 
 
782
 
static int
783
 
hexchar(int *p)
784
 
{       int i, d, c = 0;
785
 
        for (i = 0; isxdigit(d = yytext[*p]) && i < 2; i++)
786
 
        {       c = (c << 4) + (d <= '9' ? d - '0' : toupper(d) - '7');
787
 
                (*p)++;
788
 
        }
789
 
        return c;
790
 
}
791
 
 
792
 
static int
793
 
octchar(int *p)
794
 
{       int i, d, c = 0;
795
 
        for (i = 0; (d = yytext[*p]) >= '0' && d <= '7' && i < 3; i++)
796
 
        {       c = (c << 3) + d - '0';
797
 
                (*p)++;
798
 
        }
799
 
        return c;
800
 
}
801
 
 
802
 
static void module(const char *name, const char *fullname)
803
 
{ if (!fullname)
804
 
    fullname = name;
805
 
  if (imports)
806
 
  { Pragma **pp;
807
 
    char *s = emalloc(strlen(fullname)+15);
808
 
    sprintf(s, "#include \"%sH.h\"", fullname);
809
 
    for (pp = &pragmas; *pp; pp = &(*pp)->next)
810
 
      if (!strcmp((*pp)->pragma, s))
811
 
        break;
812
 
    if (!*pp)
813
 
    { *pp = (Pragma*)emalloc(sizeof(Pragma));
814
 
      (*pp)->pragma = s;
815
 
      (*pp)->next = NULL;
816
 
    }
817
 
    imported = (char*)emalloc(strlen(fullname)+1);
818
 
    strcpy(imported, fullname);
819
 
    fprintf(stderr, "Importing module '%s'\n\n", fullname);
820
 
  }
821
 
  else
822
 
  { lflag = 1;
823
 
    typeNO = magic(name);
824
 
    prefix = (char*)emalloc(strlen(fullname)+1);
825
 
    strcpy(prefix, fullname);
826
 
    fprintf(stderr, "Compiling module '%s' (magic number = %d)\n\n", fullname, typeNO);
827
 
  }
828
 
}
829
 
 
830
 
static int magic(const char *name)
831
 
{ size_t i;
832
 
  int n;
833
 
  if (strlen(name) > 4)
834
 
    semerror("#module name length must not exceed four characters");
835
 
  n = 0;
836
 
  for (i = 0; i < strlen(name); i++)
837
 
    if (name[i] >= 'a' && name[i] <= 'z')
838
 
      n = 26*n + name[i] - 'a';
839
 
    else if (name[i] >= 'A' && name[i] <= 'Z')
840
 
      n = 26*n + name[i] - 'A';
841
 
    else
842
 
      semerror("#module name must be alphabetic and the length must not exceed four characters.\nUse '#module name longname' for longer names.");
843
 
  return 4699*n + 153424;
844
 
}
845
 
 
846
 
#ifdef WITH_LEX
847
 
static void import(const char *file)
848
 
{ execerror("Cannot #import: soapcpp2 not compiled with flex");
849
 
}
850
 
#else
851
 
static void import(const char *file)
852
 
{ char buf[1024];
853
 
  struct importlist *p;
854
 
  for (p = importlist; p; p = p->next)
855
 
    if (!strcmp(p->name, file))
856
 
      return;
857
 
  if (imports >= MAX_IMPORT_DEPTH)
858
 
    execerror("Imports nested too deep");
859
 
  instk[imports] = YY_CURRENT_BUFFER;
860
 
  strcpy(fnstk[imports], filename);
861
 
  lnstk[imports] = yylineno;
862
 
  imstk[imports] = imported;
863
 
  /* imported = NULL; this is useful to change the semantics of #import to NOT consider non-module imports to be part of the current module */
864
 
  imports++;
865
 
  if (!(yyin = fopen(file, "r")))
866
 
  { if (importpath)
867
 
    { char *s, *t;
868
 
      s = importpath;
869
 
      do
870
 
      { t = strstr(s, SOAP_PATHSEP);
871
 
        if (t)
872
 
        { if (t - s >= sizeof(buf))
873
 
            t = s + sizeof(buf) - 1;
874
 
          strncpy(buf, s, t - s);
875
 
          buf[t - s] = '\0';
876
 
          s = t + sizeof(SOAP_PATHSEP) - 1;
877
 
        }
878
 
        else
879
 
        { strcpy(buf, s);
880
 
          s = NULL;
881
 
        }
882
 
        strcat(buf, "/");
883
 
        strcat(buf, file);
884
 
        yyin = fopen(buf, "r");
885
 
      }
886
 
      while (s && !yyin);
887
 
    }
888
 
    if (!yyin)
889
 
    { sprintf(errbuf, "#import: Cannot open file \"%s\" for reading.\nHint: use option -I<path> (you can define multiple paths separated with '"SOAP_PATHSEP"')", file);
890
 
      execerror(errbuf);
891
 
    }
892
 
  }
893
 
  p = (struct importlist*)malloc(sizeof(struct importlist) + strlen(file)); /* has already + 1 byte size */
894
 
  strcpy(p->name, file);
895
 
  p->next = importlist;
896
 
  importlist = p;
897
 
  strcpy(filename, file);
898
 
  yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE));
899
 
}
900
 
#endif