1 /**
2    main.c
3 
4 
5    Copyright (C) 1999-2000 RTFM, Inc.
6    All Rights Reserved
7 
8    This package is a SSLv3/TLS protocol analyzer written by Eric Rescorla
9    <ekr@rtfm.com> and licensed by RTFM, Inc.
10 
11    Redistribution and use in source and binary forms, with or without
12    modification, are permitted provided that the following conditions
13    are met:
14    1. Redistributions of source code must retain the above copyright
15       notice, this list of conditions and the following disclaimer.
16    2. Redistributions in binary form must reproduce the above copyright
17       notice, this list of conditions and the following disclaimer in the
18       documentation and/or other materials provided with the distribution.
19    3. All advertising materials mentioning features or use of this software
20       must display the following acknowledgement:
21 
22       This product includes software developed by Eric Rescorla for
23       RTFM, Inc.
24 
25    4. Neither the name of RTFM, Inc. nor the name of Eric Rescorla may be
26       used to endorse or promote products derived from this
27       software without specific prior written permission.
28 
29    THIS SOFTWARE IS PROVIDED BY ERIC RESCORLA AND RTFM, INC. ``AS IS'' AND
30    ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32    ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
33    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34    DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
35    OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36    HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37    LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
38    OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY SUCH DAMAGE.
39 
40    $Id: main.c,v 1.2 2000/10/17 16:10:01 ekr Exp $
41 
42 
43    ekr@rtfm.com  Mon Jan 18 16:28:43 1999
44  */
45 
46 
47 static char *RCSSTRING="$Id: main.c,v 1.2 2000/10/17 16:10:01 ekr Exp $";
48 
49 #include <stdarg.h>
50 #include <r_common.h>
51 
52 extern int yydebug;
53 
54 FILE *doth,*dotc;
55 
verr_exit(char * fmt,...)56 int verr_exit(char *fmt,...)
57   {
58     va_list ap;
59 
60     va_start(ap,fmt);
61     vfprintf(stderr,fmt,ap);
62     exit(1);
63   }
64 
65 
main(argc,argv)66 int main(argc,argv)
67   int argc;
68   char **argv;
69   {
70     char name[100];
71     FILE *in;
72 
73     if(!(in=freopen(argv[1],"r",stdin)))
74       verr_exit("Couldn't open input file %s\n",argv[1]);
75 
76     sprintf(name,"%s.c",argv[1]);
77     dotc=fopen(name,"w");
78     sprintf(name,"%s.h",argv[1]);
79     doth=fopen(name,"w");
80 
81     fprintf(dotc,"#include \"network.h\"\n#include \"ssl_h.h\"\n#include \"sslprint.h\"\n#include \"sslxprint.h\"\n#ifdef OPENSSL\n#include <openssl/ssl.h>\n#endif\n");
82     fprintf(dotc,"#include \"%s\"\n",name);
83 
84     yyparse();
85   }
86 
87 
88 extern int yylineno;
89 
yywrap()90 int yywrap()
91 {
92 ;}
93 
yyerror(s)94 int yyerror(s)
95   char *s;
96   {
97     printf("Parse error %s at line %d\n",s,yylineno);
98     exit(1);
99   }
100