/* load all specified resource files */ static void load_resources( char *argv[], DLLSPEC *spec ) { int i; char **ptr, **last; switch (spec->type) { case SPEC_WIN16: for (i = 0; i < nb_res_files; i++) load_res16_file( res_files[i], spec ); break; case SPEC_WIN32: for (i = 0; i < nb_res_files; i++) { if (!load_res32_file( res_files[i], spec )) fatal_error( "%s is not a valid Win32 resource file\n", res_files[i] ); } /* load any resource file found in the remaining arguments */ for (ptr = last = argv; *ptr; ptr++) { if (!load_res32_file( *ptr, spec )) *last++ = *ptr; /* not a resource file, keep it in the list */ } *last = NULL; break; } }
/******************************************************************* * ParseTopLevel * * Parse a spec file. */ SPEC_TYPE ParseTopLevel( FILE *file ) { const char *token; input_file = file; current_line = 1; while ((token = GetToken(1)) != NULL) { if (strcmp(token, "name") == 0) { strcpy(DLLName, GetToken(0)); } else if (strcmp(token, "file") == 0) { strcpy(DLLFileName, GetToken(0)); } else if (strcmp(token, "type") == 0) { token = GetToken(0); if (!strcmp(token, "win16" )) SpecType = SPEC_WIN16; else if (!strcmp(token, "win32" )) SpecType = SPEC_WIN32; else fatal_error( "Type must be 'win16' or 'win32'\n" ); } else if (strcmp(token, "mode") == 0) { token = GetToken(0); if (!strcmp(token, "dll" )) SpecMode = SPEC_MODE_DLL; else if (!strcmp(token, "guiexe" )) SpecMode = SPEC_MODE_GUIEXE; else if (!strcmp(token, "cuiexe" )) SpecMode = SPEC_MODE_CUIEXE; else if (!strcmp(token, "guiexe_unicode" )) SpecMode = SPEC_MODE_GUIEXE_UNICODE; else if (!strcmp(token, "cuiexe_unicode" )) SpecMode = SPEC_MODE_CUIEXE_UNICODE; else fatal_error( "Mode must be 'dll', 'guiexe', 'cuiexe', 'guiexe_unicode' or 'cuiexe_unicode'\n" ); } else if (strcmp(token, "heap") == 0) { token = GetToken(0); if (!IsNumberString(token)) fatal_error( "Expected number after heap\n" ); DLLHeapSize = atoi(token); } else if (strcmp(token, "stack") == 0) { token = GetToken(0); if (!IsNumberString(token)) fatal_error( "Expected number after stack\n" ); stack_size = atoi(token); } else if (strcmp(token, "imagesize") == 0) { token = GetToken(0); if (!IsNumberString(token)) fatal_error( "Expected number after imagesize\n" ); size_of_image = atoi(token); } else if (strcmp(token, "init") == 0) { if (SpecType == SPEC_WIN16) fatal_error( "init cannot be used for Win16 spec files\n" ); init_func = xstrdup( GetToken(0) ); } else if (strcmp(token, "DelayElfInitialization") == 0) { delay_initialization = 1; } else if (strcmp(token, "import") == 0) { const char* name; int delay = 0; if (SpecType != SPEC_WIN32) fatal_error( "Imports not supported for Win16\n" ); name = GetToken(0); if (*name == '-') { name = GetToken(0); if (!strcmp(name, "delay")) { name = GetToken(0); #ifndef __PPC__ delay = 1; #else warning( "The 'delay' option is not yet supported on the PPC. 'delay' will be ignored.\n"); #endif /* __PPC__ */ } else fatal_error( "Unknown option '%s' for import directive\n", name ); } add_import_dll( name, delay ); } else if (strcmp(token, "rsrc") == 0) { if (SpecType != SPEC_WIN16) load_res32_file( GetToken(0) ); else load_res16_file( GetToken(0) ); } else if (strcmp(token, "owner") == 0) { if (SpecType != SPEC_WIN16) fatal_error( "Owner only supported for Win16 spec files\n" ); strcpy( owner_name, GetToken(0) ); } else if (strcmp(token, "debug_channels") == 0) { if (SpecType != SPEC_WIN32) fatal_error( "debug channels only supported for Win32 spec files\n" ); ParseDebug(); } else if (strcmp(token, "ignore") == 0) { if (SpecType != SPEC_WIN32) fatal_error( "'ignore' only supported for Win32 spec files\n" ); ParseIgnore(); } else if (strcmp(token, "@") == 0) { if (SpecType != SPEC_WIN32) fatal_error( "'@' ordinals not supported for Win16\n" ); ParseOrdinal( -1 ); } else if (IsNumberString(token)) { ParseOrdinal( atoi(token) ); } else fatal_error( "Expected name, id, length or ordinal\n" ); } if (SpecType == SPEC_WIN32) { extern void imports_debugchannels( ); imports_debugchannels( ); } if (!DLLFileName[0]) { if (SpecMode == SPEC_MODE_DLL) { strcpy( DLLFileName, DLLName ); /* Append .dll to name if no extension present */ if (!strrchr( DLLFileName, '.')) strcat( DLLFileName, ".dll" ); } else sprintf( DLLFileName, "%s.exe", DLLName ); } if (SpecType == SPEC_INVALID) fatal_error( "Missing 'type' declaration\n" ); if (SpecType == SPEC_WIN16 && !owner_name[0]) fatal_error( "'owner' not specified for Win16 dll\n" ); current_line = 0; /* no longer parsing the input file */ sort_names(); return SpecType; }