2002-07-16 05:20:45 +02:00
|
|
|
/*
|
|
|
|
* IDL Compiler
|
|
|
|
*
|
|
|
|
* Copyright 2002 Ove Kaaven
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
%option stack
|
|
|
|
%option never-interactive
|
|
|
|
|
|
|
|
nl \r?\n
|
|
|
|
ws [ \f\t\r]
|
|
|
|
cident [a-zA-Z_][0-9a-zA-Z_]*
|
|
|
|
int [0-9]+
|
|
|
|
hexd [0-9a-fA-F]
|
|
|
|
hex 0x{hexd}+
|
|
|
|
uuid {hexd}{8}-{hexd}{4}-{hexd}{4}-{hexd}{4}-{hexd}{12}
|
|
|
|
|
|
|
|
%x QUOTE
|
2003-03-17 00:52:24 +01:00
|
|
|
%x pp_line
|
2002-07-16 05:20:45 +02:00
|
|
|
|
|
|
|
%{
|
|
|
|
|
2002-08-17 20:28:43 +02:00
|
|
|
#include "config.h"
|
|
|
|
|
2002-07-16 05:20:45 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <assert.h>
|
2002-08-17 20:28:43 +02:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
2002-07-16 05:20:45 +02:00
|
|
|
|
|
|
|
#include "widl.h"
|
|
|
|
#include "utils.h"
|
|
|
|
#include "parser.h"
|
2003-05-01 05:16:21 +02:00
|
|
|
#include "wine/wpp.h"
|
2002-07-16 05:20:45 +02:00
|
|
|
|
2005-09-28 20:17:08 +02:00
|
|
|
#include "parser.tab.h"
|
2002-07-16 05:20:45 +02:00
|
|
|
|
|
|
|
#define YY_USE_PROTOS
|
|
|
|
#define YY_NO_UNPUT
|
|
|
|
#define YY_NO_TOP_STATE
|
|
|
|
|
|
|
|
extern char *temp_name;
|
|
|
|
|
|
|
|
static void addcchar(char c);
|
|
|
|
static char *get_buffered_cstring(void);
|
|
|
|
|
|
|
|
static char *cbuffer;
|
|
|
|
static int cbufidx;
|
|
|
|
static int cbufalloc = 0;
|
|
|
|
|
|
|
|
static int kw_token(const char *kw);
|
|
|
|
|
|
|
|
#define MAX_IMPORT_DEPTH 10
|
|
|
|
struct {
|
|
|
|
YY_BUFFER_STATE state;
|
2003-03-17 00:52:24 +01:00
|
|
|
char *input_name;
|
|
|
|
int line_number;
|
2002-07-16 05:20:45 +02:00
|
|
|
char *temp_name;
|
|
|
|
} import_stack[MAX_IMPORT_DEPTH];
|
|
|
|
int import_stack_ptr = 0;
|
|
|
|
|
|
|
|
static void pop_import(void);
|
|
|
|
|
2002-12-15 02:13:18 +01:00
|
|
|
static UUID* parse_uuid(const char*u)
|
2002-11-12 03:12:35 +01:00
|
|
|
{
|
2002-12-15 02:13:18 +01:00
|
|
|
UUID* uuid = xmalloc(sizeof(UUID));
|
2002-11-12 03:12:35 +01:00
|
|
|
char b[3];
|
|
|
|
/* it would be nice to use UuidFromStringA */
|
2002-12-03 20:12:07 +01:00
|
|
|
uuid->Data1 = strtoul(u, NULL, 16);
|
|
|
|
uuid->Data2 = strtoul(u+9, NULL, 16);
|
|
|
|
uuid->Data3 = strtoul(u+14, NULL, 16);
|
2002-11-12 03:12:35 +01:00
|
|
|
b[2] = 0;
|
2002-12-03 20:12:07 +01:00
|
|
|
memcpy(b, u+19, 2); uuid->Data4[0] = strtoul(b, NULL, 16);
|
|
|
|
memcpy(b, u+21, 2); uuid->Data4[1] = strtoul(b, NULL, 16);
|
|
|
|
memcpy(b, u+24, 2); uuid->Data4[2] = strtoul(b, NULL, 16);
|
|
|
|
memcpy(b, u+26, 2); uuid->Data4[3] = strtoul(b, NULL, 16);
|
|
|
|
memcpy(b, u+28, 2); uuid->Data4[4] = strtoul(b, NULL, 16);
|
|
|
|
memcpy(b, u+30, 2); uuid->Data4[5] = strtoul(b, NULL, 16);
|
|
|
|
memcpy(b, u+32, 2); uuid->Data4[6] = strtoul(b, NULL, 16);
|
|
|
|
memcpy(b, u+34, 2); uuid->Data4[7] = strtoul(b, NULL, 16);
|
2002-11-12 03:12:35 +01:00
|
|
|
return uuid;
|
|
|
|
}
|
|
|
|
|
2002-07-16 05:20:45 +02:00
|
|
|
%}
|
|
|
|
|
|
|
|
/*
|
|
|
|
**************************************************************************
|
|
|
|
* The flexer starts here
|
|
|
|
**************************************************************************
|
|
|
|
*/
|
|
|
|
%%
|
2003-03-17 00:52:24 +01:00
|
|
|
<INITIAL>^{ws}*\#{ws}* yy_push_state(pp_line);
|
|
|
|
<pp_line>[^\n]* {
|
|
|
|
int lineno;
|
|
|
|
char *cptr, *fname;
|
|
|
|
yy_pop_state();
|
|
|
|
lineno = (int)strtol(yytext, &cptr, 10);
|
|
|
|
if(!lineno)
|
|
|
|
yyerror("Malformed '#...' line-directive; invalid linenumber");
|
|
|
|
fname = strchr(cptr, '"');
|
|
|
|
if(!fname)
|
|
|
|
yyerror("Malformed '#...' line-directive; missing filename");
|
|
|
|
fname++;
|
|
|
|
cptr = strchr(fname, '"');
|
|
|
|
if(!cptr)
|
|
|
|
yyerror("Malformed '#...' line-directive; missing terminating \"");
|
|
|
|
*cptr = '\0';
|
|
|
|
line_number = lineno - 1; /* We didn't read the newline */
|
|
|
|
free( input_name );
|
|
|
|
input_name = xstrdup(fname);
|
|
|
|
}
|
2002-07-16 05:20:45 +02:00
|
|
|
\" yy_push_state(QUOTE); cbufidx = 0;
|
|
|
|
<QUOTE>\" {
|
|
|
|
yy_pop_state();
|
|
|
|
yylval.str = get_buffered_cstring();
|
|
|
|
return aSTRING;
|
|
|
|
}
|
|
|
|
<QUOTE>\\\\ |
|
|
|
|
<QUOTE>\\\" addcchar(yytext[1]);
|
|
|
|
<QUOTE>\\. addcchar('\\'); addcchar(yytext[1]);
|
|
|
|
<QUOTE>. addcchar(yytext[0]);
|
2002-11-12 03:12:35 +01:00
|
|
|
{uuid} {
|
|
|
|
yylval.uuid = parse_uuid(yytext);
|
|
|
|
return aUUID;
|
|
|
|
}
|
2002-11-30 02:49:46 +01:00
|
|
|
{hex} {
|
2003-09-03 21:31:14 +02:00
|
|
|
yylval.num = strtoul(yytext, NULL, 0);
|
2002-11-30 02:49:46 +01:00
|
|
|
return aHEXNUM;
|
|
|
|
}
|
2002-11-12 03:12:35 +01:00
|
|
|
{int} {
|
2003-09-03 21:31:14 +02:00
|
|
|
yylval.num = strtoul(yytext, NULL, 0);
|
2002-11-12 03:12:35 +01:00
|
|
|
return aNUM;
|
|
|
|
}
|
2002-07-16 05:20:45 +02:00
|
|
|
{cident} return kw_token(yytext);
|
2003-03-17 00:52:24 +01:00
|
|
|
\n line_number++;
|
2002-07-16 05:20:45 +02:00
|
|
|
{ws}
|
|
|
|
\<\< return SHL;
|
|
|
|
\>\> return SHR;
|
|
|
|
. return yytext[0];
|
|
|
|
<<EOF>> {
|
2002-11-21 01:02:38 +01:00
|
|
|
if (import_stack_ptr) {
|
|
|
|
pop_import();
|
|
|
|
return aEOF;
|
|
|
|
}
|
2002-07-16 05:20:45 +02:00
|
|
|
else yyterminate();
|
|
|
|
}
|
|
|
|
%%
|
|
|
|
|
|
|
|
#ifndef yywrap
|
|
|
|
int yywrap(void)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2002-11-30 02:49:46 +01:00
|
|
|
static struct keyword {
|
2002-07-16 05:20:45 +02:00
|
|
|
const char *kw;
|
|
|
|
int token;
|
|
|
|
int val;
|
|
|
|
} keywords[] = {
|
|
|
|
{"__cdecl", tCDECL},
|
|
|
|
{"__int64", tINT64},
|
|
|
|
{"__stdcall", tSTDCALL},
|
|
|
|
{"_stdcall", tSTDCALL},
|
|
|
|
{"aggregatable", tAGGREGATABLE},
|
|
|
|
{"allocate", tALLOCATE},
|
|
|
|
{"appobject", tAPPOBJECT},
|
|
|
|
{"arrays", tARRAYS},
|
|
|
|
{"async", tASYNC},
|
|
|
|
{"async_uuid", tASYNCUUID},
|
|
|
|
{"auto_handle", tAUTOHANDLE},
|
|
|
|
{"bindable", tBINDABLE},
|
|
|
|
{"boolean", tBOOLEAN},
|
|
|
|
{"broadcast", tBROADCAST},
|
|
|
|
{"byte", tBYTE},
|
|
|
|
{"byte_count", tBYTECOUNT},
|
|
|
|
{"call_as", tCALLAS},
|
|
|
|
{"callback", tCALLBACK},
|
|
|
|
{"case", tCASE},
|
|
|
|
{"char", tCHAR},
|
|
|
|
{"coclass", tCOCLASS},
|
|
|
|
{"code", tCODE},
|
|
|
|
{"comm_status", tCOMMSTATUS},
|
|
|
|
{"const", tCONST},
|
|
|
|
{"context_handle", tCONTEXTHANDLE},
|
|
|
|
{"context_handle_noserialize", tCONTEXTHANDLENOSERIALIZE},
|
|
|
|
{"context_handle_serialize", tCONTEXTHANDLENOSERIALIZE},
|
|
|
|
{"control", tCONTROL},
|
|
|
|
{"cpp_quote", tCPPQUOTE},
|
|
|
|
/* ... */
|
|
|
|
{"default", tDEFAULT},
|
2005-01-03 15:26:17 +01:00
|
|
|
{"defaultvalue", tDEFAULTVALUE},
|
2002-07-16 05:20:45 +02:00
|
|
|
/* ... */
|
2004-01-07 05:21:27 +01:00
|
|
|
{"dispinterface", tDISPINTERFACE},
|
|
|
|
/* ... */
|
2005-12-16 12:40:17 +01:00
|
|
|
{"displaybind", tDISPLAYBIND},
|
2004-01-07 05:21:27 +01:00
|
|
|
{"dllname", tDLLNAME},
|
2002-07-16 05:20:45 +02:00
|
|
|
{"double", tDOUBLE},
|
2004-01-07 05:21:27 +01:00
|
|
|
{"dual", tDUAL},
|
2002-07-16 05:20:45 +02:00
|
|
|
/* ... */
|
2004-04-27 01:29:59 +02:00
|
|
|
{"endpoint", tENDPOINT},
|
2004-01-07 05:21:27 +01:00
|
|
|
{"entry", tENTRY},
|
2002-07-16 05:20:45 +02:00
|
|
|
{"enum", tENUM},
|
2002-12-03 20:12:07 +01:00
|
|
|
{"error_status_t", tERRORSTATUST},
|
2005-02-23 21:31:07 +01:00
|
|
|
{"explicit_handle", tEXPLICITHANDLE},
|
2002-07-16 05:20:45 +02:00
|
|
|
{"extern", tEXTERN},
|
|
|
|
/* ... */
|
|
|
|
{"float", tFLOAT},
|
2002-12-03 20:12:07 +01:00
|
|
|
/* ... */
|
2004-04-20 01:08:22 +02:00
|
|
|
{"handle", tHANDLE},
|
2002-12-03 20:12:07 +01:00
|
|
|
{"handle_t", tHANDLET},
|
2002-07-16 05:20:45 +02:00
|
|
|
/* ... */
|
2005-01-10 17:08:36 +01:00
|
|
|
{"helpcontext", tHELPCONTEXT},
|
|
|
|
{"helpfile", tHELPFILE},
|
2004-01-07 05:21:27 +01:00
|
|
|
{"helpstring", tHELPSTRING},
|
2005-01-10 17:08:36 +01:00
|
|
|
{"helpstringcontext", tHELPSTRINGCONTEXT},
|
|
|
|
{"helpstringdll", tHELPSTRINGDLL},
|
2002-12-03 20:12:07 +01:00
|
|
|
/* ... */
|
2005-01-09 18:59:44 +01:00
|
|
|
{"hidden", tHIDDEN},
|
2004-01-07 05:21:27 +01:00
|
|
|
{"hyper", tHYPER},
|
|
|
|
{"id", tID},
|
2002-12-03 20:12:07 +01:00
|
|
|
{"idempotent", tIDEMPOTENT},
|
2002-07-16 05:20:45 +02:00
|
|
|
/* ... */
|
|
|
|
{"iid_is", tIIDIS},
|
|
|
|
/* ... */
|
2005-02-23 21:31:07 +01:00
|
|
|
{"implicit_handle", tIMPLICITHANDLE},
|
2002-07-16 05:20:45 +02:00
|
|
|
{"import", tIMPORT},
|
|
|
|
{"importlib", tIMPORTLIB},
|
|
|
|
{"in", tIN},
|
|
|
|
{"include", tINCLUDE},
|
|
|
|
{"in_line", tINLINE},
|
2004-02-12 00:57:58 +01:00
|
|
|
{"input_sync", tINPUTSYNC},
|
2002-07-16 05:20:45 +02:00
|
|
|
{"int", tINT},
|
|
|
|
/* ... */
|
|
|
|
{"interface", tINTERFACE},
|
|
|
|
/* ... */
|
|
|
|
{"length_is", tLENGTHIS},
|
2004-01-07 05:21:27 +01:00
|
|
|
{"library", tLIBRARY},
|
2002-07-16 05:20:45 +02:00
|
|
|
/* ... */
|
|
|
|
{"local", tLOCAL},
|
|
|
|
{"long", tLONG},
|
2004-01-07 05:21:27 +01:00
|
|
|
/* ... */
|
|
|
|
{"methods", tMETHODS},
|
|
|
|
/* ... */
|
|
|
|
{"module", tMODULE},
|
2002-07-16 05:20:45 +02:00
|
|
|
/* ... */
|
2005-02-03 14:34:28 +01:00
|
|
|
{"noncreatable", tNONCREATABLE},
|
2002-07-16 05:20:45 +02:00
|
|
|
{"object", tOBJECT},
|
|
|
|
{"odl", tODL},
|
|
|
|
{"oleautomation", tOLEAUTOMATION},
|
|
|
|
/* ... */
|
2005-01-03 15:26:17 +01:00
|
|
|
{"optional", tOPTIONAL},
|
2002-07-16 05:20:45 +02:00
|
|
|
{"out", tOUT},
|
|
|
|
/* ... */
|
|
|
|
{"pointer_default", tPOINTERDEFAULT},
|
|
|
|
/* ... */
|
2004-01-07 05:21:27 +01:00
|
|
|
{"properties", tPROPERTIES},
|
2004-10-05 04:14:54 +02:00
|
|
|
{"propget", tPROPGET},
|
|
|
|
{"propput", tPROPPUT},
|
2005-02-01 19:48:25 +01:00
|
|
|
{"propputref", tPROPPUTREF},
|
2005-09-12 22:13:40 +02:00
|
|
|
{"ptr", tPTR},
|
2004-01-07 05:21:27 +01:00
|
|
|
/* ... */
|
|
|
|
{"public", tPUBLIC},
|
2005-09-12 22:13:40 +02:00
|
|
|
{"range", tRANGE},
|
2004-01-07 05:21:27 +01:00
|
|
|
/* ... */
|
|
|
|
{"readonly", tREADONLY},
|
2002-07-16 05:20:45 +02:00
|
|
|
{"ref", tREF},
|
2004-01-07 05:21:27 +01:00
|
|
|
/* ... */
|
2005-01-09 18:59:44 +01:00
|
|
|
{"restricted", tRESTRICTED},
|
2004-01-07 05:21:27 +01:00
|
|
|
{"retval", tRETVAL},
|
2002-07-16 05:20:45 +02:00
|
|
|
/* ... */
|
|
|
|
{"short", tSHORT},
|
|
|
|
{"signed", tSIGNED},
|
2005-03-28 12:01:13 +02:00
|
|
|
{"single", tSINGLE},
|
2002-07-16 05:20:45 +02:00
|
|
|
{"size_is", tSIZEIS},
|
|
|
|
{"sizeof", tSIZEOF},
|
2005-09-12 22:13:40 +02:00
|
|
|
{"small", tSMALL},
|
2002-07-16 05:20:45 +02:00
|
|
|
/* ... */
|
2004-01-07 05:21:27 +01:00
|
|
|
{"source", tSOURCE},
|
|
|
|
/* ... */
|
2002-07-16 05:20:45 +02:00
|
|
|
{"string", tSTRING},
|
|
|
|
{"struct", tSTRUCT},
|
|
|
|
{"switch", tSWITCH},
|
|
|
|
{"switch_is", tSWITCHIS},
|
|
|
|
{"switch_type", tSWITCHTYPE},
|
|
|
|
/* ... */
|
2004-04-27 01:29:59 +02:00
|
|
|
{"transmit_as", tTRANSMITAS},
|
2002-07-16 05:20:45 +02:00
|
|
|
{"typedef", tTYPEDEF},
|
|
|
|
{"union", tUNION},
|
|
|
|
/* ... */
|
|
|
|
{"unique", tUNIQUE},
|
|
|
|
{"unsigned", tUNSIGNED},
|
|
|
|
/* ... */
|
|
|
|
{"uuid", tUUID},
|
|
|
|
{"v1_enum", tV1ENUM},
|
|
|
|
/* ... */
|
2005-01-03 15:26:17 +01:00
|
|
|
{"vararg", tVARARG},
|
2002-07-16 05:20:45 +02:00
|
|
|
{"version", tVERSION},
|
|
|
|
{"void", tVOID},
|
|
|
|
{"wchar_t", tWCHAR},
|
2002-11-30 02:49:46 +01:00
|
|
|
{"wire_marshal", tWIREMARSHAL}
|
2002-07-16 05:20:45 +02:00
|
|
|
};
|
2002-11-30 02:49:46 +01:00
|
|
|
#define NKEYWORDS (sizeof(keywords)/sizeof(keywords[0]))
|
2004-12-06 21:43:55 +01:00
|
|
|
#define KWP(p) ((const struct keyword *)(p))
|
2002-11-30 02:49:46 +01:00
|
|
|
|
|
|
|
static int kw_cmp_func(const void *s1, const void *s2)
|
|
|
|
{
|
|
|
|
return strcmp(KWP(s1)->kw, KWP(s2)->kw);
|
|
|
|
}
|
2002-07-16 05:20:45 +02:00
|
|
|
|
2002-11-30 02:49:46 +01:00
|
|
|
#define KW_BSEARCH
|
2002-07-16 05:20:45 +02:00
|
|
|
static int kw_token(const char *kw)
|
|
|
|
{
|
2002-11-30 02:49:46 +01:00
|
|
|
struct keyword key, *kwp;
|
|
|
|
key.kw = kw;
|
|
|
|
#ifdef KW_BSEARCH
|
|
|
|
kwp = bsearch(&key, keywords, NKEYWORDS, sizeof(keywords[0]), kw_cmp_func);
|
|
|
|
#else
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (kwp=NULL, i=0; i < NKEYWORDS; i++)
|
|
|
|
if (!kw_cmp_func(&key, &keywords[i])) {
|
|
|
|
kwp = &keywords[i];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2002-12-03 20:12:07 +01:00
|
|
|
if (kwp) {
|
|
|
|
yylval.str = (char*)kwp->kw;
|
|
|
|
return kwp->token;
|
|
|
|
}
|
2002-07-16 05:20:45 +02:00
|
|
|
yylval.str = xstrdup(kw);
|
|
|
|
return is_type(kw) ? aKNOWNTYPE : aIDENTIFIER;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void addcchar(char c)
|
|
|
|
{
|
|
|
|
if(cbufidx >= cbufalloc)
|
|
|
|
{
|
|
|
|
cbufalloc += 1024;
|
|
|
|
cbuffer = xrealloc(cbuffer, cbufalloc * sizeof(cbuffer[0]));
|
|
|
|
if(cbufalloc > 65536)
|
|
|
|
yywarning("Reallocating string buffer larger than 64kB");
|
|
|
|
}
|
|
|
|
cbuffer[cbufidx++] = c;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *get_buffered_cstring(void)
|
|
|
|
{
|
|
|
|
addcchar(0);
|
|
|
|
return xstrdup(cbuffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void pop_import(void)
|
|
|
|
{
|
|
|
|
int ptr = import_stack_ptr-1;
|
|
|
|
|
|
|
|
fclose(yyin);
|
|
|
|
yy_delete_buffer( YY_CURRENT_BUFFER );
|
|
|
|
yy_switch_to_buffer( import_stack[ptr].state );
|
|
|
|
if (temp_name) {
|
|
|
|
unlink(temp_name);
|
|
|
|
free(temp_name);
|
|
|
|
}
|
|
|
|
temp_name = import_stack[ptr].temp_name;
|
2003-03-17 00:52:24 +01:00
|
|
|
free( input_name );
|
|
|
|
input_name = import_stack[ptr].input_name;
|
|
|
|
line_number = import_stack[ptr].line_number;
|
2002-07-16 05:20:45 +02:00
|
|
|
import_stack_ptr--;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct imports {
|
|
|
|
char *name;
|
|
|
|
struct imports *next;
|
|
|
|
} *first_import;
|
|
|
|
|
2002-11-30 02:49:46 +01:00
|
|
|
int do_import(char *fname)
|
2002-07-16 05:20:45 +02:00
|
|
|
{
|
|
|
|
FILE *f;
|
2003-03-17 00:52:24 +01:00
|
|
|
char *hname, *path, *p;
|
2002-07-16 05:20:45 +02:00
|
|
|
struct imports *import;
|
|
|
|
int ptr = import_stack_ptr;
|
|
|
|
int ret;
|
|
|
|
|
2005-01-26 20:40:47 +01:00
|
|
|
if (!parse_only && do_header) {
|
2002-07-16 05:20:45 +02:00
|
|
|
hname = dup_basename(fname, ".idl");
|
2003-03-17 00:52:24 +01:00
|
|
|
p = hname + strlen(hname) - 2;
|
|
|
|
if (p <= hname || strcmp( p, ".h" )) strcat(hname, ".h");
|
2002-07-16 05:20:45 +02:00
|
|
|
|
2003-09-03 21:31:14 +02:00
|
|
|
fprintf(header, "#include <%s>\n", hname);
|
2002-07-16 05:20:45 +02:00
|
|
|
free(hname);
|
|
|
|
}
|
|
|
|
|
|
|
|
import = first_import;
|
|
|
|
while (import && strcmp(import->name, fname))
|
|
|
|
import = import->next;
|
2002-11-30 02:49:46 +01:00
|
|
|
if (import) return 0; /* already imported */
|
2002-07-16 05:20:45 +02:00
|
|
|
|
|
|
|
import = xmalloc(sizeof(struct imports));
|
|
|
|
import->name = xstrdup(fname);
|
|
|
|
import->next = first_import;
|
|
|
|
first_import = import;
|
|
|
|
|
2005-10-10 20:06:50 +02:00
|
|
|
if (!(path = wpp_find_include( fname, input_name )))
|
2002-07-16 05:20:45 +02:00
|
|
|
yyerror("Unable to open include file %s", fname);
|
|
|
|
|
|
|
|
import_stack[ptr].temp_name = temp_name;
|
2003-03-17 00:52:24 +01:00
|
|
|
import_stack[ptr].input_name = input_name;
|
|
|
|
import_stack[ptr].line_number = line_number;
|
2002-07-16 05:20:45 +02:00
|
|
|
import_stack_ptr++;
|
2003-03-17 00:52:24 +01:00
|
|
|
input_name = path;
|
|
|
|
line_number = 1;
|
2002-07-16 05:20:45 +02:00
|
|
|
|
2002-08-28 00:29:26 +02:00
|
|
|
ret = wpp_parse_temp( path, NULL, &temp_name );
|
2002-07-16 05:20:45 +02:00
|
|
|
if (ret) exit(1);
|
|
|
|
|
|
|
|
if((f = fopen(temp_name, "r")) == NULL)
|
|
|
|
yyerror("Unable to open %s", temp_name);
|
|
|
|
|
|
|
|
import_stack[ptr].state = YY_CURRENT_BUFFER;
|
|
|
|
yy_switch_to_buffer(yy_create_buffer(f, YY_BUF_SIZE));
|
2002-11-30 02:49:46 +01:00
|
|
|
return 1;
|
2002-07-16 05:20:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void abort_import(void)
|
|
|
|
{
|
|
|
|
int ptr;
|
|
|
|
|
|
|
|
for (ptr=0; ptr<import_stack_ptr; ptr++)
|
|
|
|
unlink(import_stack[ptr].temp_name);
|
|
|
|
}
|