annotate GEMBASSY-1.0.3/gsoap/src/error2.c @ 1:84a17b3fad1f draft

Uploaded
author ktnyt
date Fri, 26 Jun 2015 05:20:29 -0400
parents 8300eb051bea
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1 /*
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2 error2.c
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
3
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
4 Error handling.
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
5
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
6 gSOAP XML Web services tools
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
7 Copyright (C) 2000-2008, Robert van Engelen, Genivia Inc. All Rights Reserved.
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
8 This part of the software is released under one of the following licenses:
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
9 GPL or Genivia's license for commercial use.
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
10 --------------------------------------------------------------------------------
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
11 GPL license.
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
12
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
13 This program is free software; you can redistribute it and/or modify it under
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
14 the terms of the GNU General Public License as published by the Free Software
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
15 Foundation; either version 2 of the License, or (at your option) any later
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
16 version.
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
17
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
18 This program is distributed in the hope that it will be useful, but WITHOUT ANY
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
19 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
20 PARTICULAR PURPOSE. See the GNU General Public License for more details.
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
21
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
22 You should have received a copy of the GNU General Public License along with
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
23 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
24 Place, Suite 330, Boston, MA 02111-1307 USA
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
25
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
26 Author contact information:
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
27 engelen@genivia.com / engelen@acm.org
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
28
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
29 This program is released under the GPL with the additional exemption that
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
30 compiling, linking, and/or using OpenSSL is allowed.
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
31 --------------------------------------------------------------------------------
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
32 A commercial use license is available from Genivia, Inc., contact@genivia.com
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
33 --------------------------------------------------------------------------------
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
34 */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
35
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
36 #include "soapcpp2.h"
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
37
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
38 #ifdef HAVE_CONFIG_H
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
39 #include "soapcpp2_yacc.h"
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
40 #else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
41 #include "soapcpp2_yacc.tab.h"
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
42 #endif
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
43
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
44 #define MAXERR 10
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
45
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
46 extern char yytext[]; /* lexeme found by the lexical analyzer */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
47
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
48 static int lexerrno = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
49 static int synerrno = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
50 static int semerrno = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
51 static int semwarno = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
52
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
53 char errbuf[1024]; /* to hold error messages */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
54
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
55 /*
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
56 yyerror - called by parser from an error production with nonterminal `error'
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
57 */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
58 void yyerror(char *s)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
59 { fprintf(stderr, "%s(%d): %s\n", filename, yylineno, s);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
60 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
61
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
62 /*
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
63 lexerror - called by lexical analyzer upon failure to recognize a token
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
64 */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
65 void lexerror(const char *s)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
66 { fprintf(stderr, "%s(%d): %s: %s\n", filename, yylineno, s, yytext);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
67 if (lexerrno++ >= MAXERR)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
68 execerror("too many syntactic errors, bailing out");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
69 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
70
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
71 /*
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
72 synerror - called by a semantic action in the yacc grammar
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
73 */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
74 void synerror(const char *s)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
75 { fprintf(stderr, "%s(%d): Syntax error: %s\n", filename, yylineno-1, s);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
76 if (synerrno++ >= MAXERR)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
77 execerror("too many syntactic errors, bailing out");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
78 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
79
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
80 /*
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
81 semerror - report semantic error from static checking
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
82 */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
83 void semerror(const char *s)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
84 { fprintf(stderr, "\n%s(%d): **ERROR**: %s\n\n", filename, yylineno, s);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
85 if (semerrno++ >= MAXERR)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
86 execerror("too many semantic errors, bailing out");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
87 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
88
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
89 /*
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
90 semwarn - report semantic warning from static checking
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
91 */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
92 void semwarn(const char *s)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
93 { fprintf(stderr, "\n%s(%d): *WARNING*: %s\n\n", filename, yylineno, s);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
94 semwarno++;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
95 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
96
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
97 /*
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
98 compliancewarn - report compliance warning
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
99 */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
100 void compliancewarn(const char *s)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
101 { fprintf(stderr, "Compliance warning: %s\n", s);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
102 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
103
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
104 /*
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
105 typerror - report type error (a semantic error)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
106 */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
107 void typerror(const char *s)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
108 { fprintf(stderr, "%s(%d): Type error: %s\n", filename, yylineno, s);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
109 if (semerrno++ >= MAXERR)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
110 execerror("too many semantic errors, bailing out");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
111 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
112
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
113 /*
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
114 execerror - print error message and terminate execution
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
115 */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
116 void execerror(const char *s)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
117 { fprintf(stderr, "Critical error: %s\n", s);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
118 exit(1);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
119 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
120
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
121 /*
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
122 progerror - called when check(expr) failed, i.e. upon programming error
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
123 */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
124 void progerror(const char *s, const char *f, int l)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
125 { fprintf(stderr, "Program failure: %s in file %s line %d\n", s, f, l);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
126 exit(1);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
127 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
128
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
129 /*
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
130 errstat - show error statistics
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
131 */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
132 int errstat(void)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
133 { if (!lexerrno && !synerrno && !semerrno)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
134 { fprintf(stderr, "\nCompilation successful ");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
135 if (semwarno)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
136 fprintf(stderr, "(%d warning%s)\n\n", semwarno, semwarno>1?"s":"");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
137 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
138 fprintf(stderr, "\n\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
139 return 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
140 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
141 fprintf(stderr, "\nThere were errors:\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
142 if (lexerrno)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
143 fprintf(stderr, "%d lexical error%s\n", lexerrno, lexerrno>1?"s":"");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
144 if (synerrno)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
145 fprintf(stderr, "%d syntax error%s\n", synerrno, synerrno>1?"s":"");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
146 if (semerrno)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
147 fprintf(stderr, "%d semantic error%s\n", semerrno, semerrno>1?"s":"");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
148 if (semwarno)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
149 fprintf(stderr, "%d warning%s\n", semwarno, semwarno>1?"s":"");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
150 fprintf(stderr, "\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
151 return -1;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
152 }