4 * Copyright 2002 Ove Kaaven
5 * based on WRC code by Bertho Stultiens
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "wine/port.h"
46 /* future options to reserve characters for: */
47 /* A = ACF input filename */
48 /* J = do not search standard include path */
49 /* w = select win16/win32 output (?) */
51 static const char usage
[] =
52 "Usage: widl [options...] infile.idl\n"
53 " or: widl [options...] --dlldata-only name1 [name2...]\n"
54 " -app_config Ignored, present for midl compatibility\n"
55 " -b arch Set the target architecture\n"
56 " -c Generate client stub\n"
57 " -d n Set debug level to 'n'\n"
58 " -D id[=val] Define preprocessor identifier id=val\n"
59 " -E Preprocess only\n"
60 " --help Display this help and exit\n"
61 " -h Generate headers\n"
62 " -H file Name of header file (default is infile.h)\n"
63 " -I path Set include search dir to path (multiple -I allowed)\n"
64 " --local-stubs=file Write empty stubs for call_as/local methods to file\n"
65 " -m32, -m64 Set the kind of typelib to build (Win32 or Win64)\n"
66 " -N Do not preprocess input\n"
67 " --oldnames Use old naming conventions\n"
68 " -o, --output=NAME Set the output file name\n"
69 " -Otype Type of stubs to generate (-Os, -Oi, -Oif)\n"
70 " -p Generate proxy\n"
71 " --prefix-all=p Prefix names of client stubs / server functions with 'p'\n"
72 " --prefix-client=p Prefix names of client stubs with 'p'\n"
73 " --prefix-server=p Prefix names of server functions with 'p'\n"
74 " -r Generate registration script\n"
75 " --winrt Enable Windows Runtime mode\n"
76 " --ns_prefix Prefix namespaces with ABI namespace\n"
77 " -s Generate server stub\n"
78 " -t Generate typelib\n"
79 " -u Generate interface identifiers file\n"
80 " -V Print version and exit\n"
81 " -W Enable pedantic warnings\n"
82 " --win32 Only generate 32-bit code\n"
83 " --win64 Only generate 64-bit code\n"
84 " --win32-align n Set win32 structure alignment to 'n'\n"
85 " --win64-align n Set win64 structure alignment to 'n'\n"
86 "Debug level 'n' is a bitmask with following meaning:\n"
87 " * 0x01 Tell which resource is parsed (verbose mode)\n"
88 " * 0x02 Dump internal structures\n"
89 " * 0x04 Create a parser trace (yydebug=1)\n"
90 " * 0x08 Preprocessor messages\n"
91 " * 0x10 Preprocessor lex messages\n"
92 " * 0x20 Preprocessor yacc trace\n"
95 static const char version_string
[] = "Wine IDL Compiler version " PACKAGE_VERSION
"\n"
96 "Copyright 2002 Ove Kaaven\n";
98 int debuglevel
= DEBUGLEVEL_NONE
;
99 int parser_debug
, yy_flex_debug
;
102 int do_everything
= 1;
103 static int preprocess_only
= 0;
109 int do_regscript
= 0;
112 static int no_preprocess
= 0;
116 int win32_packing
= 8;
117 int win64_packing
= 8;
119 int use_abi_namespace
= 0;
120 static enum stub_mode stub_mode
= MODE_Os
;
123 char *input_idl_name
;
125 char *local_stubs_name
;
135 char *regscript_name
;
136 char *regscript_token
;
137 static char *idfile_name
;
139 const char *prefix_client
= "";
140 const char *prefix_server
= "";
146 unsigned int pointer_size
= 0;
147 syskind_t typelib_kind
= sizeof(void*) == 8 ? SYS_WIN64
: SYS_WIN32
;
152 OLDNAMES_OPTION
= CHAR_MAX
+ 1,
157 PREFIX_CLIENT_OPTION
,
158 PREFIX_SERVER_OPTION
,
169 static const char short_options
[] =
170 "b:cC:d:D:EhH:I:m:No:O:pP:rsS:tT:uU:VW";
171 static const struct option long_options
[] = {
172 { "dlldata", 1, NULL
, DLLDATA_OPTION
},
173 { "dlldata-only", 0, NULL
, DLLDATA_ONLY_OPTION
},
174 { "help", 0, NULL
, PRINT_HELP
},
175 { "local-stubs", 1, NULL
, LOCAL_STUBS_OPTION
},
176 { "ns_prefix", 0, NULL
, RT_NS_PREFIX
},
177 { "oldnames", 0, NULL
, OLDNAMES_OPTION
},
178 { "output", 0, NULL
, 'o' },
179 { "prefix-all", 1, NULL
, PREFIX_ALL_OPTION
},
180 { "prefix-client", 1, NULL
, PREFIX_CLIENT_OPTION
},
181 { "prefix-server", 1, NULL
, PREFIX_SERVER_OPTION
},
182 { "winrt", 0, NULL
, RT_OPTION
},
183 { "win32", 0, NULL
, WIN32_OPTION
},
184 { "win64", 0, NULL
, WIN64_OPTION
},
185 { "win32-align", 1, NULL
, WIN32_ALIGN_OPTION
},
186 { "win64-align", 1, NULL
, WIN64_ALIGN_OPTION
},
187 { "app_config", 0, NULL
, APP_CONFIG_OPTION
},
191 static void rm_tempfile(void);
193 enum stub_mode
get_stub_mode(void)
195 /* old-style interpreted stubs are not supported on 64-bit */
196 if (stub_mode
== MODE_Oi
&& pointer_size
== 8) return MODE_Oif
;
200 static char *make_token(const char *name
)
206 slash
= strrchr(name
, '/');
208 slash
= strrchr(name
, '\\');
210 if (slash
) name
= slash
+ 1;
212 token
= xstrdup(name
);
213 for (i
=0; token
[i
]; i
++) {
214 if (!isalnum(token
[i
])) token
[i
] = '_';
215 else token
[i
] = tolower(token
[i
]);
220 /* duplicate a basename into a valid C token */
221 static char *dup_basename_token(const char *name
, const char *ext
)
223 char *p
, *ret
= dup_basename( name
, ext
);
224 /* map invalid characters to '_' */
225 for (p
= ret
; *p
; p
++) if (!isalnum(*p
)) *p
= '_';
229 static void add_widl_version_define(void)
231 unsigned int version
;
232 const char *p
= PACKAGE_VERSION
;
235 version
= atoi(p
) * 0x10000;
241 version
+= atoi(p
+ 1) * 0x100;
242 p
= strchr(p
+ 1, '.');
247 version
+= atoi(p
+ 1);
251 char version_str
[11];
252 snprintf(version_str
, sizeof(version_str
), "0x%x", version
);
253 wpp_add_define("__WIDL__", version_str
);
256 wpp_add_define("__WIDL__", NULL
);
259 /* set the target platform */
260 static void set_target( const char *target
)
268 { "i386", SYS_WIN32
},
269 { "i486", SYS_WIN32
},
270 { "i586", SYS_WIN32
},
271 { "i686", SYS_WIN32
},
272 { "i786", SYS_WIN32
},
273 { "amd64", SYS_WIN64
},
274 { "x86_64", SYS_WIN64
},
275 { "powerpc", SYS_WIN32
},
276 { "arm", SYS_WIN32
},
277 { "aarch64", SYS_WIN64
}
281 char *p
, *spec
= xstrdup( target
);
283 /* target specification is in the form CPU-MANUFACTURER-OS or CPU-MANUFACTURER-KERNEL-OS */
285 if (!(p
= strchr( spec
, '-' ))) error( "Invalid target specification '%s'\n", target
);
287 for (i
= 0; i
< sizeof(cpu_names
)/sizeof(cpu_names
[0]); i
++)
289 if (!strcmp( cpu_names
[i
].name
, spec
))
291 typelib_kind
= cpu_names
[i
].kind
;
296 error( "Unrecognized CPU '%s'\n", spec
);
299 /* clean things up when aborting on a signal */
300 static void exit_on_signal( int sig
)
302 exit(1); /* this will call the atexit functions */
305 static void set_everything(int x
)
317 void start_cplusplus_guard(FILE *fp
)
319 fprintf(fp
, "#ifdef __cplusplus\n");
320 fprintf(fp
, "extern \"C\" {\n");
321 fprintf(fp
, "#endif\n\n");
324 void end_cplusplus_guard(FILE *fp
)
326 fprintf(fp
, "#ifdef __cplusplus\n");
328 fprintf(fp
, "#endif\n\n");
337 static void add_filename_node(struct list
*list
, const char *name
)
339 filename_node_t
*node
= xmalloc(sizeof *node
);
340 node
->filename
= dup_basename( name
, ".idl" );
341 list_add_tail(list
, &node
->link
);
344 static void free_filename_nodes(struct list
*list
)
346 filename_node_t
*node
, *next
;
347 LIST_FOR_EACH_ENTRY_SAFE(node
, next
, list
, filename_node_t
, link
) {
348 list_remove(&node
->link
);
349 free(node
->filename
);
354 static void write_dlldata_list(struct list
*filenames
, int define_proxy_delegation
)
357 filename_node_t
*node
;
359 dlldata
= fopen(dlldata_name
, "w");
361 error("couldn't open %s: %s\n", dlldata_name
, strerror(errno
));
363 fprintf(dlldata
, "/*** Autogenerated by WIDL %s ", PACKAGE_VERSION
);
364 fprintf(dlldata
, "- Do not edit ***/\n\n");
365 if (define_proxy_delegation
)
366 fprintf(dlldata
, "#define PROXY_DELEGATION\n");
367 fprintf(dlldata
, "#include <objbase.h>\n");
368 fprintf(dlldata
, "#include <rpcproxy.h>\n\n");
369 start_cplusplus_guard(dlldata
);
371 LIST_FOR_EACH_ENTRY(node
, filenames
, filename_node_t
, link
)
372 fprintf(dlldata
, "EXTERN_PROXY_FILE(%s)\n", node
->filename
);
374 fprintf(dlldata
, "\nPROXYFILE_LIST_START\n");
375 fprintf(dlldata
, "/* Start of list */\n");
376 LIST_FOR_EACH_ENTRY(node
, filenames
, filename_node_t
, link
)
377 fprintf(dlldata
, " REFERENCE_PROXY_FILE(%s),\n", node
->filename
);
378 fprintf(dlldata
, "/* End of list */\n");
379 fprintf(dlldata
, "PROXYFILE_LIST_END\n\n");
381 fprintf(dlldata
, "DLLDATA_ROUTINES(aProxyFileList, GET_DLL_CLSID)\n\n");
382 end_cplusplus_guard(dlldata
);
386 static char *eat_space(char *s
)
388 while (isspace((unsigned char) *s
))
393 void write_dlldata(const statement_list_t
*stmts
)
395 struct list filenames
= LIST_INIT(filenames
);
396 int define_proxy_delegation
= 0;
397 filename_node_t
*node
;
400 if (!do_dlldata
|| !need_proxy_file(stmts
))
403 define_proxy_delegation
= need_proxy_delegation(stmts
);
405 dlldata
= fopen(dlldata_name
, "r");
407 static const char marker
[] = "REFERENCE_PROXY_FILE";
408 static const char delegation_define
[] = "#define PROXY_DELEGATION";
412 while (widl_getline(&line
, &len
, dlldata
)) {
414 start
= eat_space(line
);
415 if (strncmp(start
, marker
, sizeof marker
- 1) == 0) {
416 start
= eat_space(start
+ sizeof marker
- 1);
419 end
= start
= eat_space(start
+ 1);
420 while (*end
&& *end
!= ')')
424 while (isspace((unsigned char) end
[-1]))
428 add_filename_node(&filenames
, start
);
429 }else if (!define_proxy_delegation
&& strncmp(start
, delegation_define
, sizeof(delegation_define
)-1)) {
430 define_proxy_delegation
= 1;
435 error("couldn't read from %s: %s\n", dlldata_name
, strerror(errno
));
441 LIST_FOR_EACH_ENTRY(node
, &filenames
, filename_node_t
, link
)
442 if (strcmp(proxy_token
, node
->filename
) == 0) {
443 /* We're already in the list, no need to regenerate this file. */
444 free_filename_nodes(&filenames
);
448 add_filename_node(&filenames
, proxy_token
);
449 write_dlldata_list(&filenames
, define_proxy_delegation
);
450 free_filename_nodes(&filenames
);
453 static void write_id_guid(FILE *f
, const char *type
, const char *guid_prefix
, const char *name
, const UUID
*uuid
)
456 fprintf(f
, "MIDL_DEFINE_GUID(%s, %s_%s, 0x%08x, 0x%04x, 0x%04x, 0x%02x,0x%02x, 0x%02x,"
457 "0x%02x,0x%02x,0x%02x,0x%02x,0x%02x);\n",
458 type
, guid_prefix
, name
, uuid
->Data1
, uuid
->Data2
, uuid
->Data3
, uuid
->Data4
[0],
459 uuid
->Data4
[1], uuid
->Data4
[2], uuid
->Data4
[3], uuid
->Data4
[4], uuid
->Data4
[5],
460 uuid
->Data4
[6], uuid
->Data4
[7]);
463 static void write_id_data_stmts(const statement_list_t
*stmts
)
465 const statement_t
*stmt
;
466 if (stmts
) LIST_FOR_EACH_ENTRY( stmt
, stmts
, const statement_t
, entry
)
468 if (stmt
->type
== STMT_TYPE
)
470 const type_t
*type
= stmt
->u
.type
;
471 if (type_get_type(type
) == TYPE_INTERFACE
)
474 if (!is_object(type
) && !is_attr(type
->attrs
, ATTR_DISPINTERFACE
))
476 uuid
= get_attrp(type
->attrs
, ATTR_UUID
);
477 write_id_guid(idfile
, "IID", is_attr(type
->attrs
, ATTR_DISPINTERFACE
) ? "DIID" : "IID",
480 else if (type_get_type(type
) == TYPE_COCLASS
)
482 const UUID
*uuid
= get_attrp(type
->attrs
, ATTR_UUID
);
483 write_id_guid(idfile
, "CLSID", "CLSID", type
->name
, uuid
);
486 else if (stmt
->type
== STMT_LIBRARY
)
488 const UUID
*uuid
= get_attrp(stmt
->u
.lib
->attrs
, ATTR_UUID
);
489 write_id_guid(idfile
, "IID", "LIBID", stmt
->u
.lib
->name
, uuid
);
490 write_id_data_stmts(stmt
->u
.lib
->stmts
);
495 void write_id_data(const statement_list_t
*stmts
)
497 if (!do_idfile
) return;
499 idfile
= fopen(idfile_name
, "w");
501 error("Could not open %s for output\n", idfile_name
);
505 fprintf(idfile
, "/*** Autogenerated by WIDL %s ", PACKAGE_VERSION
);
506 fprintf(idfile
, "from %s - Do not edit ***/\n\n", input_idl_name
);
507 fprintf(idfile
, "#include <rpc.h>\n");
508 fprintf(idfile
, "#include <rpcndr.h>\n\n");
510 fprintf(idfile
, "#ifdef _MIDL_USE_GUIDDEF_\n\n");
512 fprintf(idfile
, "#ifndef INITGUID\n");
513 fprintf(idfile
, "#define INITGUID\n");
514 fprintf(idfile
, "#include <guiddef.h>\n");
515 fprintf(idfile
, "#undef INITGUID\n");
516 fprintf(idfile
, "#else\n");
517 fprintf(idfile
, "#include <guiddef.h>\n");
518 fprintf(idfile
, "#endif\n\n");
520 fprintf(idfile
, "#define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \\\n");
521 fprintf(idfile
, " DEFINE_GUID(name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8)\n\n");
523 fprintf(idfile
, "#else\n\n");
525 fprintf(idfile
, "#define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \\\n");
526 fprintf(idfile
, " const type name = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}}\n\n");
528 fprintf(idfile
, "#endif\n\n");
529 start_cplusplus_guard(idfile
);
531 write_id_data_stmts(stmts
);
533 fprintf(idfile
, "\n");
534 end_cplusplus_guard(idfile
);
535 fprintf(idfile
, "#undef MIDL_DEFINE_GUID\n" );
540 int main(int argc
,char *argv
[])
545 char *output_name
= NULL
;
547 signal( SIGTERM
, exit_on_signal
);
548 signal( SIGINT
, exit_on_signal
);
550 signal( SIGHUP
, exit_on_signal
);
555 while((optc
= getopt_long_only(argc
, argv
, short_options
, long_options
, &opti
)) != EOF
) {
558 dlldata_name
= xstrdup(optarg
);
560 case DLLDATA_ONLY_OPTION
:
564 case LOCAL_STUBS_OPTION
:
566 local_stubs_name
= xstrdup(optarg
);
568 case OLDNAMES_OPTION
:
571 case PREFIX_ALL_OPTION
:
572 prefix_client
= xstrdup(optarg
);
573 prefix_server
= xstrdup(optarg
);
575 case PREFIX_CLIENT_OPTION
:
576 prefix_client
= xstrdup(optarg
);
578 case PREFIX_SERVER_OPTION
:
579 prefix_server
= xstrdup(optarg
);
582 fprintf(stderr
, "%s", usage
);
588 use_abi_namespace
= 1;
598 case WIN32_ALIGN_OPTION
:
599 win32_packing
= strtol(optarg
, NULL
, 0);
600 if(win32_packing
!= 2 && win32_packing
!= 4 && win32_packing
!= 8)
601 error("Packing must be one of 2, 4 or 8\n");
603 case WIN64_ALIGN_OPTION
:
604 win64_packing
= strtol(optarg
, NULL
, 0);
605 if(win64_packing
!= 2 && win64_packing
!= 4 && win64_packing
!= 8)
606 error("Packing must be one of 2, 4 or 8\n");
608 case APP_CONFIG_OPTION
:
609 /* widl does not distinguish between app_mode and default mode,
610 but we ignore this option for midl compatibility */
613 set_target( optarg
);
620 client_name
= xstrdup(optarg
);
623 debuglevel
= strtol(optarg
, NULL
, 0);
626 wpp_add_cmdline_define(optarg
);
637 header_name
= xstrdup(optarg
);
640 wpp_add_include_path(optarg
);
643 if (!strcmp( optarg
, "32" )) typelib_kind
= SYS_WIN32
;
644 else if (!strcmp( optarg
, "64" )) typelib_kind
= SYS_WIN64
;
650 output_name
= xstrdup(optarg
);
653 if (!strcmp( optarg
, "s" )) stub_mode
= MODE_Os
;
654 else if (!strcmp( optarg
, "i" )) stub_mode
= MODE_Oi
;
655 else if (!strcmp( optarg
, "ic" )) stub_mode
= MODE_Oif
;
656 else if (!strcmp( optarg
, "if" )) stub_mode
= MODE_Oif
;
657 else if (!strcmp( optarg
, "icf" )) stub_mode
= MODE_Oif
;
658 else error( "Invalid argument '-O%s'\n", optarg
);
665 proxy_name
= xstrdup(optarg
);
676 server_name
= xstrdup(optarg
);
683 typelib_name
= xstrdup(optarg
);
690 idfile_name
= xstrdup(optarg
);
693 printf("%s", version_string
);
699 fprintf(stderr
, "%s", usage
);
704 #ifdef DEFAULT_INCLUDE_DIR
705 wpp_add_include_path(DEFAULT_INCLUDE_DIR
);
708 /* if nothing specified, try to guess output type from the output file name */
709 if (output_name
&& do_everything
&& !do_header
&& !do_typelib
&& !do_proxies
&&
710 !do_client
&& !do_server
&& !do_regscript
&& !do_idfile
&& !do_dlldata
)
713 if (strendswith( output_name
, ".h" )) do_header
= 1;
714 else if (strendswith( output_name
, ".tlb" )) do_typelib
= 1;
715 else if (strendswith( output_name
, "_p.c" )) do_proxies
= 1;
716 else if (strendswith( output_name
, "_c.c" )) do_client
= 1;
717 else if (strendswith( output_name
, "_s.c" )) do_server
= 1;
718 else if (strendswith( output_name
, "_i.c" )) do_idfile
= 1;
719 else if (strendswith( output_name
, "_r.res" )) do_regscript
= 1;
720 else if (strendswith( output_name
, "_t.res" )) do_typelib
= 1;
721 else if (strendswith( output_name
, "dlldata.c" )) do_dlldata
= 1;
722 else do_everything
= 1;
726 set_everything(TRUE
);
729 if (!output_name
) output_name
= dup_basename(input_name
, ".idl");
731 if (do_header
+ do_typelib
+ do_proxies
+ do_client
+
732 do_server
+ do_regscript
+ do_idfile
+ do_dlldata
== 1)
734 if (do_header
) header_name
= output_name
;
735 else if (do_typelib
) typelib_name
= output_name
;
736 else if (do_proxies
) proxy_name
= output_name
;
737 else if (do_client
) client_name
= output_name
;
738 else if (do_server
) server_name
= output_name
;
739 else if (do_regscript
) regscript_name
= output_name
;
740 else if (do_idfile
) idfile_name
= output_name
;
741 else if (do_dlldata
) dlldata_name
= output_name
;
744 if (!dlldata_name
&& do_dlldata
)
745 dlldata_name
= xstrdup("dlldata.c");
748 if (do_dlldata
&& !do_everything
) {
749 struct list filenames
= LIST_INIT(filenames
);
750 for ( ; optind
< argc
; ++optind
)
751 add_filename_node(&filenames
, argv
[optind
]);
753 write_dlldata_list(&filenames
, 0 /* FIXME */ );
754 free_filename_nodes(&filenames
);
757 else if (optind
!= argc
- 1) {
758 fprintf(stderr
, "%s", usage
);
762 input_idl_name
= input_name
= xstrdup(argv
[optind
]);
765 fprintf(stderr
, "%s", usage
);
771 setbuf(stdout
, NULL
);
772 setbuf(stderr
, NULL
);
775 parser_debug
= debuglevel
& DEBUGLEVEL_TRACE
? 1 : 0;
776 yy_flex_debug
= debuglevel
& DEBUGLEVEL_TRACE
? 1 : 0;
778 wpp_set_debug( (debuglevel
& DEBUGLEVEL_PPLEX
) != 0,
779 (debuglevel
& DEBUGLEVEL_PPTRACE
) != 0,
780 (debuglevel
& DEBUGLEVEL_PPMSG
) != 0 );
783 header_name
= dup_basename(input_name
, ".idl");
784 strcat(header_name
, ".h");
787 if (!typelib_name
&& do_typelib
) {
788 typelib_name
= dup_basename(input_name
, ".idl");
789 strcat(typelib_name
, ".tlb");
792 if (!proxy_name
&& do_proxies
) {
793 proxy_name
= dup_basename(input_name
, ".idl");
794 strcat(proxy_name
, "_p.c");
797 if (!client_name
&& do_client
) {
798 client_name
= dup_basename(input_name
, ".idl");
799 strcat(client_name
, "_c.c");
802 if (!server_name
&& do_server
) {
803 server_name
= dup_basename(input_name
, ".idl");
804 strcat(server_name
, "_s.c");
807 if (!regscript_name
&& do_regscript
) {
808 regscript_name
= dup_basename(input_name
, ".idl");
809 strcat(regscript_name
, "_r.rgs");
812 if (!idfile_name
&& do_idfile
) {
813 idfile_name
= dup_basename(input_name
, ".idl");
814 strcat(idfile_name
, "_i.c");
817 if (do_proxies
) proxy_token
= dup_basename_token(proxy_name
,"_p.c");
818 if (do_client
) client_token
= dup_basename_token(client_name
,"_c.c");
819 if (do_server
) server_token
= dup_basename_token(server_name
,"_s.c");
820 if (do_regscript
) regscript_token
= dup_basename_token(regscript_name
,"_r.rgs");
822 add_widl_version_define();
823 wpp_add_define("_WIN32", NULL
);
828 chat("Starting preprocess\n");
830 if (!preprocess_only
)
834 char *name
= xmalloc( strlen(header_name
) + 8 );
836 strcpy( name
, header_name
);
837 strcat( name
, ".XXXXXX" );
839 if ((fd
= mkstemps( name
, 0 )) == -1)
840 error("Could not generate a temp name from %s\n", name
);
843 if (!(output
= fdopen(fd
, "wt")))
844 error("Could not open fd %s for writing\n", name
);
846 ret
= wpp_parse( input_name
, output
);
851 ret
= wpp_parse( input_name
, stdout
);
855 if(preprocess_only
) exit(0);
856 if(!(parser_in
= fopen(temp_name
, "r"))) {
857 fprintf(stderr
, "Could not open %s for input\n", temp_name
);
862 if(!(parser_in
= fopen(input_name
, "r"))) {
863 fprintf(stderr
, "Could not open %s for input\n", input_name
);
868 header_token
= make_token(header_name
);
871 ret
= parser_parse();
879 /* Everything has been done successfully, don't delete any files. */
880 set_everything(FALSE
);
881 local_stubs_name
= NULL
;
886 static void rm_tempfile(void)
893 if (local_stubs_name
)
894 unlink(local_stubs_name
);
900 unlink(regscript_name
);
906 unlink(typelib_name
);