1 /******************************************************************************
3 KPP - The Kinetic PreProcessor
4 Builds simulation code for chemical kinetic systems
6 Copyright (C) 1995-1996 Valeriu Damian and Adrian Sandu
7 Copyright (C) 1997-2005 Adrian Sandu
9 KPP is free software; you can redistribute it and/or modify it under the
10 terms of the GNU General Public License as published by the Free Software
11 Foundation (http://www.gnu.org/copyleft/gpl.html); either version 2 of the
12 License, or (at your option) any later version.
14 KPP is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
19 You should have received a copy of the GNU General Public License along
20 with this program; if not, consult http://www.gnu.org/copyleft/gpl.html or
21 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA.
25 Computer Science Department
26 Virginia Polytechnic Institute and State University
28 E-mail: sandu@cs.vt.edu
30 ******************************************************************************/
41 #define MAX_BUFFER 200
43 void ScanError( char *fmt
, ... )
46 char buf
[ MAX_BUFFER
];
48 Va_start( args
, fmt
);
49 vsprintf( buf
, fmt
, args
);
51 fprintf( stdout
, "Error :%s:%d: %s\n", crt_filename
, crt_line_no
, buf
);
55 void ParserError( char *fmt
, ... )
58 char buf
[ MAX_BUFFER
];
60 Va_start( args
, fmt
);
61 vsprintf( buf
, fmt
, args
);
63 fprintf( stdout
, "Error :%s:%d: %s\n", crtFile
, crtLine
, buf
);
67 void ScanWarning( char *fmt
, ... )
70 char buf
[ MAX_BUFFER
];
72 Va_start( args
, fmt
);
73 vsprintf( buf
, fmt
, args
);
75 fprintf( stdout
, "Warning :%s:%d: %s\n", crt_filename
, crt_line_no
, buf
);
79 void ParserWarning( char *fmt
, ... )
82 char buf
[ MAX_BUFFER
];
84 Va_start( args
, fmt
);
85 vsprintf( buf
, fmt
, args
);
87 fprintf( stdout
, "Warning :%s:%d: %s\n", crtFile
, crtLine
, buf
);
91 void Error( char *fmt
, ... )
94 char buf
[ MAX_BUFFER
];
96 Va_start( args
, fmt
);
97 vsprintf( buf
, fmt
, args
);
99 fprintf( stdout
, "Error : %s\n", buf
);
103 void Warning( char *fmt
, ... )
106 char buf
[ MAX_BUFFER
];
108 Va_start( args
, fmt
);
109 vsprintf( buf
, fmt
, args
);
111 fprintf( stdout
, "Warning : %s\n", buf
);
115 void Message( char *fmt
, ... )
118 char buf
[ MAX_BUFFER
];
120 Va_start( args
, fmt
);
121 vsprintf( buf
, fmt
, args
);
123 fprintf( stdout
, " Message :%s:%d: %s\n", crt_filename
, crt_line_no
, buf
);
126 void FatalError( int status
, char *fmt
, ... )
129 char buf
[ MAX_BUFFER
];
131 Va_start( args
, fmt
);
132 vsprintf( buf
, fmt
, args
);
134 fprintf( stdout
, "\nFatal error : %s\nProgram aborted\n", buf
);
138 char * FileName( char *fname
, char *env
, char *dir
, char *ext
)
140 static char pathname
[MAX_PATH
];
145 static char name
[MAX_PATH
];
149 p
= name
+ strlen(name
);
156 if( *p
== '/' ) break;
160 if( noext
) strcat(name
, ext
);
162 fp
= fopen(name
,"r");
173 if( isspace(*crtpath
) ) {
177 if((*crtpath
== ':')||(*crtpath
==0)) {
179 sprintf(pathname
,"%s/%s",pathname
,name
);
180 fp
= fopen(pathname
,"r");
185 if (*crtpath
==0) break;
194 sprintf(pathname
, "%s/%s/%s", Home
, dir
, name
);
195 fp
= fopen(pathname
,"r");