void dofile() { (void)printf("(This file must be converted; you knew that already.)\n"); (void)printf("\n"); pos_ptr = 1; state = 0; rep_char = -1; rep_count = 0; outchar(':'); doheader(); dofork(data_fork, data_size); dofork(rsrc_fork, rsrc_size); finish(); (void)putchar(':'); (void)putchar('\n'); }
void print_module() { int n; struct table_point *tempentry; int index; if(bResourceOnly) return; /* Create new array out of linked list of entry points. */ /* Check that there will be sufficient space in final array to contain both numbered and unnumbered entry points. */ if (currentnum + 1 > max) max = currentnum + 1; functions=(char **)calloc(max+1,sizeof(char *)); /* Set the default entry point name for libraries. */ if ( *libentry_name == '\0' ) strcpy(libentry_name, "LibMain"); if (build_app_module) strcpy(libentry_name, "LibMainStub"); /* Initialize table. */ for(n=0;n<=max;n++) functions[n]=NULL; tempentry=entrytable; /* Save copy of entrytable head before traversing. */ /* Fill in numbered entries. */ while(entrytable) { if((entrytable->index)>0) functions[entrytable->index]= entrytable->name; entrytable=entrytable->next; } entrytable=tempentry; /* Restore head of list. */ /* Fill in non-numbered entries. */ while(entrytable) { if((entrytable->index)<0) { n=max; while(functions[n]) n--; functions[n]=entrytable->name; } entrytable=entrytable->next; } if (build_app_module) { n=max; while(functions[n]) n--; functions[n]=malloc(strlen(modulename) + 9); strcpy(functions[n], modulename); strcat(functions[n], "_WinMain"); } /* Print the .def.c header. */ time(&now); doheader(); /* Print out prototypes for entry points. */ for(n=1;n<max+1;n++) if(functions[n] && strlen(functions[n])) COUTPUT(("extern long int %s(); \n",functions[n])); /* Print out actual entry point table. */ if (IsLibrary) { COUTPUT(("\n#include \"twindll.h\"\n\n")); COUTPUT(("long int %s();\n", libentry_name)); } else if (build_app_module) { COUTPUT(("\n#include \"twindll.h\"\n\n")); COUTPUT(("long int %s() {return 0;}\n", libentry_name)); } else COUTPUT(("int PASCAL WinMain(HINSTANCE, HINSTANCE, LPSTR, int);\n")); COUTPUT(("\nstatic ENTRYTAB entry_tab_default[] = \n{\n")); if (!description) description = modulename?modulename:"TWIN Application"; if (build_app_module) description = libentry_name; COUTPUT(("\t/* 000 */ { \"%s\",0,0,%s},\n", description, (IsLibrary||build_app_module)?libentry_name:"(void *)WinMain")); index = 8; for(n = 1;n<max+1;n++) { if((functions[n] == 0) || (strlen(functions[n]) == 0)) COUTPUT(("\t/* %3.3x */\t{ \"\",0,0,0 },\n",n)); else { COUTPUT(("\t/* %3.3x */\t{ \"%s\",0x%4.4x,0x%4.4x,%s },\n", n,functions[n],8,index,functions[n])); EOUTPUT(("%s\n", functions[n])); } index += 8; } COUTPUT(("\t/* end */ { 0, 0, 0, 0 }\n};\n\n")); if(bSegmentTable) COUTPUT(("extern SEGTAB %s%s[];\n", "SegmentTable",modulename?modulename:"")); /* Print out remaining "standard" .def.c stuff. */ COUTPUT(("static MODULEDSCR mod_dscr = \n")); COUTPUT(("{ \"%s\",\n",modulename?modulename:"")); COUTPUT(("\tentry_tab_default,\n")); /* put out a segment table, with option modulename */ if(bSegmentTable) COUTPUT(("\t%s%s,\n","SegmentTable",modulename?modulename:"")); else COUTPUT(("\t0,\n")); COUTPUT(("\t(long *) &hsmt_resource_table\n};\n\n")); if(IsLibrary||build_app_module) DoLibraryInfo(); else { DoApplication(); } /* Clean up allocated memory. */ for(n=0;n<=max;n++) free(functions[n]); entrytable=tempentry; while(entrytable) { tempentry=entrytable->next; free(entrytable); entrytable=tempentry; } } /* domodule */