1 /* static char Copyright[] = "Copyright Robert J. Amstadt, 1993"; */
16 #if defined(__NetBSD__) || defined(__FreeBSD__)
20 /* ELF symbols do not have an underscore in front */
27 #define VARTYPE_BYTE 0
28 #define VARTYPE_SIGNEDWORD 0
29 #define VARTYPE_WORD 1
30 #define VARTYPE_LONG 2
31 #define VARTYPE_FARPTR 3
33 #define FUNCTYPE_PASCAL_16 15
34 #define FUNCTYPE_PASCAL 16
36 #define FUNCTYPE_REG 19
38 #define EQUATETYPE_ABS 18
39 #define TYPE_RETURN 20
41 /*#define MAX_ORDINALS 1024*/
42 #define MAX_ORDINALS 1299
44 #define PUSH_0 "\tpushl\t$0\n"
45 #define PUSH_SS "\tpushw\t$0\n\tpushw\t%%ss\n"
46 #define PUSH_ESP "\tpushl\t%%esp\n"
47 #define PUSH_EFL "\tpushfl\n"
48 #define PUSH_CS "\tpushw\t$0\n\tpushw\t%%cs\n"
49 #define PUSH_EIP "\tpushl\t$0\n"
50 #define PUSH_DS "\tpushw\t$0\n\tpushw\t%%ds\n"
51 #define PUSH_ES "\tpushw\t$0\n\tpushw\t%%es\n"
52 #define PUSH_FS "\tpushw\t$0\n\tpushw\t%%fs\n"
53 #define PUSH_GS "\tpushw\t$0\n\tpushw\t%%gs\n"
54 #define PUSH_EAX "\tpushl\t%%eax\n"
55 #define PUSH_ECX "\tpushl\t%%ecx\n"
56 #define PUSH_EDX "\tpushl\t%%edx\n"
57 #define PUSH_EBX "\tpushl\t%%ebx\n"
58 #define PUSH_EBP "\tpushl\t%%ebp\n"
59 #define PUSH_ESI "\tpushl\t%%esi\n"
60 #define PUSH_EDI "\tpushl\t%%edi\n"
62 #define POP_0 "\tadd\t$4,%%esp\n"
63 #define POP_SS "\tpopw\t%%ss\n\tadd\t$2,%%esp\n"
64 #define POP_ESP "\tpopl\t%%esp\n"
65 #define POP_EFL "\tpopl\t%%gs:return_value\n"
66 #define POP_CS "\tpopw\t%%cs\n\tadd\t$2,%%esp\n"
67 #define POP_EIP "\tpopl\t$0\n"
68 #define POP_DS "\tpopw\t%%ds\n\tadd\t$2,%%esp\n"
69 #define POP_ES "\tpopw\t%%es\n\tadd\t$2,%%esp\n"
70 #define POP_FS "\tpopw\t%%fs\n\tadd\t$2,%%esp\n"
71 #define POP_GS "\tpopw\t%%gs\n\tadd\t$2,%%esp\n"
72 #define POP_EAX "\tpopl\t%%eax\n"
73 #define POP_ECX "\tpopl\t%%ecx\n"
74 #define POP_EDX "\tpopl\t%%edx\n"
75 #define POP_EBX "\tpopl\t%%ebx\n"
76 #define POP_EBP "\tpopl\t%%ebp\n"
77 #define POP_ESI "\tpopl\t%%esi\n"
78 #define POP_EDI "\tpopl\t%%edi\n"
80 char **context_strings;
82 int n_context_strings;
84 typedef struct ordinal_definition_s
89 void *additional_data;
92 typedef struct ordinal_variable_definition_s
98 typedef struct ordinal_function_definition_s
101 int arg_types_16[16];
102 int arg_16_offsets[16];
104 char internal_name[80];
106 int arg_indices_32[16];
109 typedef struct ordinal_return_definition_s
115 ORDDEF OrdinalDefinitions[MAX_ORDINALS];
117 char LowerDLLName[80];
118 char UpperDLLName[80];
123 char *ParseBuffer = NULL;
128 int IsNumberString(char *s)
137 char *strlower(char *s)
141 for(p = s; *p != '\0'; p++)
147 char *strupper(char *s)
151 for(p = s; *p != '\0'; p++)
157 int stricmp(char *s1, char *s2)
159 if (strlen(s1) != strlen(s2))
175 if (ParseNext != ParseBuffer)
177 if (ParseSaveChar == '\0')
179 *ParseNext = ParseSaveChar;
183 * Remove initial white space.
185 for (p = ParseNext; isspace(*p); p++)
195 if (*token != '(' && *token != ')')
196 while (*p != '\0' && *p != '(' && *p != ')' && !isspace(*p))
211 if (ParseBuffer == NULL)
213 ParseBuffer = malloc(512);
214 ParseNext = ParseBuffer;
218 if (fgets(ParseBuffer, 511, SpecFp) == NULL)
220 if (ParseBuffer[0] != '#')
225 while ((token = GetTokenInLine()) == NULL)
227 ParseNext = ParseBuffer;
231 if (fgets(ParseBuffer, 511, SpecFp) == NULL)
233 if (ParseBuffer[0] != '#')
242 ParseVariable(int ordinal, int type)
246 char export_name[80];
251 int value_array_size;
253 strcpy(export_name, GetToken());
258 fprintf(stderr, "%d: Expected '(' got '%s'\n", Line, token);
263 value_array_size = 25;
264 value_array = malloc(sizeof(*value_array) * value_array_size);
266 while ((token = GetToken()) != NULL)
271 value_array[n_values++] = strtol(token, &endptr, 0);
272 if (n_values == value_array_size)
274 value_array_size += 25;
275 value_array = realloc(value_array,
276 sizeof(*value_array) * value_array_size);
279 if (endptr == NULL || *endptr != '\0')
281 fprintf(stderr, "%d: Expected number value, got '%s'\n", Line,
289 fprintf(stderr, "%d: End of file in variable declaration\n", Line);
293 if (ordinal >= MAX_ORDINALS)
295 fprintf(stderr, "%d: Ordinal number too large\n", Line);
299 odp = &OrdinalDefinitions[ordinal];
302 strcpy(odp->export_name, export_name);
304 vdp = malloc(sizeof(*vdp));
305 odp->additional_data = vdp;
307 vdp->n_values = n_values;
308 vdp->values = realloc(value_array, sizeof(*value_array) * n_values);
314 ParseExportFunction(int ordinal, int type)
324 if (ordinal >= MAX_ORDINALS)
326 fprintf(stderr, "%d: Ordinal number too large\n", Line);
330 odp = &OrdinalDefinitions[ordinal];
331 strcpy(odp->export_name, GetToken());
334 fdp = malloc(sizeof(*fdp));
335 odp->additional_data = fdp;
340 fprintf(stderr, "%d: Expected '(' got '%s'\n", Line, token);
344 fdp->arg_16_size = 0;
345 for (i = 0; i < 16; i++)
351 if (stricmp(token, "byte") == 0 || stricmp(token, "word") == 0)
353 fdp->arg_types_16[i] = VARTYPE_WORD;
354 fdp->arg_16_size += 2;
355 fdp->arg_16_offsets[i] = 2;
357 else if (stricmp(token, "s_byte") == 0 ||
358 stricmp(token, "s_word") == 0)
360 fdp->arg_types_16[i] = VARTYPE_SIGNEDWORD;
361 fdp->arg_16_size += 2;
362 fdp->arg_16_offsets[i] = 2;
364 else if (stricmp(token, "long") == 0 || stricmp(token, "s_long") == 0)
366 fdp->arg_types_16[i] = VARTYPE_LONG;
367 fdp->arg_16_size += 4;
368 fdp->arg_16_offsets[i] = 4;
370 else if (stricmp(token, "ptr") == 0)
372 fdp->arg_types_16[i] = VARTYPE_FARPTR;
373 fdp->arg_16_size += 4;
374 fdp->arg_16_offsets[i] = 4;
378 fprintf(stderr, "%d: Unknown variable type '%s'\n", Line, token);
384 if (type == FUNCTYPE_PASCAL_16 || type == FUNCTYPE_PASCAL ||
385 type == FUNCTYPE_REG )
388 for (i--; i >= 0; i--)
390 arg_size = fdp->arg_16_offsets[i];
391 fdp->arg_16_offsets[i] = current_offset;
392 current_offset += arg_size;
398 for (i = 0; i < fdp->n_args_16; i++)
400 arg_size = fdp->arg_16_offsets[i];
401 fdp->arg_16_offsets[i] = current_offset;
402 current_offset += arg_size;
406 strcpy(fdp->internal_name, GetToken());
410 fprintf(stderr, "%d: Expected '(' got '%s'\n", Line, token);
413 for (i = 0; i < 16; i++)
419 fdp->arg_indices_32[i] = atoi(token);
420 if (fdp->arg_indices_32[i] < 1 ||
421 fdp->arg_indices_32[i] > fdp->n_args_16)
423 fprintf(stderr, "%d: Bad argument index %d\n", Line,
424 fdp->arg_indices_32[i]);
434 ParseEquate(int ordinal)
441 if (ordinal >= MAX_ORDINALS)
443 fprintf(stderr, "%d: Ordinal number too large\n", Line);
447 odp = &OrdinalDefinitions[ordinal];
448 strcpy(odp->export_name, GetToken());
451 value = strtol(token, &endptr, 0);
452 if (endptr == NULL || *endptr != '\0')
454 fprintf(stderr, "%d: Expected number value, got '%s'\n", Line,
460 odp->type = EQUATETYPE_ABS;
461 odp->additional_data = (void *) value;
467 ParseReturn(int ordinal)
474 if (ordinal >= MAX_ORDINALS)
476 fprintf(stderr, "%d: Ordinal number too large\n", Line);
480 rdp = malloc(sizeof(*rdp));
482 odp = &OrdinalDefinitions[ordinal];
483 strcpy(odp->export_name, GetToken());
485 odp->type = TYPE_RETURN;
486 odp->additional_data = rdp;
489 rdp->arg_size = strtol(token, &endptr, 0);
490 if (endptr == NULL || *endptr != '\0')
492 fprintf(stderr, "%d: Expected number value, got '%s'\n", Line,
498 rdp->ret_value = strtol(token, &endptr, 0);
499 if (endptr == NULL || *endptr != '\0')
501 fprintf(stderr, "%d: Expected number value, got '%s'\n", Line,
510 ParseOrdinal(int ordinal)
517 fprintf(stderr, "%d: Expected type after ordinal\n", Line);
521 if (stricmp(token, "byte") == 0)
522 return ParseVariable(ordinal, VARTYPE_BYTE);
523 else if (stricmp(token, "word") == 0)
524 return ParseVariable(ordinal, VARTYPE_WORD);
525 else if (stricmp(token, "long") == 0)
526 return ParseVariable(ordinal, VARTYPE_LONG);
527 else if (stricmp(token, "c") == 0)
528 return ParseExportFunction(ordinal, FUNCTYPE_C);
529 else if (stricmp(token, "p") == 0)
530 return ParseExportFunction(ordinal, FUNCTYPE_PASCAL);
531 else if (stricmp(token, "pascal") == 0)
532 return ParseExportFunction(ordinal, FUNCTYPE_PASCAL);
533 else if (stricmp(token, "pascal16") == 0)
534 return ParseExportFunction(ordinal, FUNCTYPE_PASCAL_16);
535 else if (stricmp(token, "register") == 0)
536 return ParseExportFunction(ordinal, FUNCTYPE_REG);
537 else if (stricmp(token, "equate") == 0)
538 return ParseEquate(ordinal);
539 else if (stricmp(token, "return") == 0)
540 return ParseReturn(ordinal);
544 "%d: Expected type after ordinal, found '%s' instead\n",
555 while ((token = GetToken()) != NULL)
557 if (stricmp(token, "name") == 0)
559 strcpy(LowerDLLName, GetToken());
560 strlower(LowerDLLName);
562 strcpy(UpperDLLName, LowerDLLName);
563 strupper(UpperDLLName);
565 else if (stricmp(token, "id") == 0)
568 if (!IsNumberString(token))
570 fprintf(stderr, "%d: Expected number after id\n", Line);
576 else if (stricmp(token, "length") == 0)
579 if (!IsNumberString(token))
581 fprintf(stderr, "%d: Expected number after length\n", Line);
587 else if (IsNumberString(token))
592 ordinal = atoi(token);
593 if ((rv = ParseOrdinal(ordinal)) < 0)
599 "%d: Expected name, id, length or ordinal\n", Line);
610 struct sigcontext_struct context;
613 n_context_strings = sizeof(context) / 4;
614 context_strings = (char **) malloc(n_context_strings * sizeof(char **));
615 pop_strings = (char **) malloc(n_context_strings * sizeof(char **));
616 for (i = 0; i < n_context_strings; i++)
618 context_strings[i] = PUSH_0;
619 pop_strings[i] = POP_0;
622 i = n_context_strings - 1 + ((int) &context - (int) &context.sc_esp) / 4;
623 context_strings[i] = PUSH_ESP;
625 i = n_context_strings - 1 + ((int) &context - (int) &context.sc_ebp) / 4;
626 context_strings[i] = PUSH_EBP;
627 pop_strings[n_context_strings - 1 - i] = POP_EBP;
629 i = n_context_strings - 1 + ((int) &context - (int) &context.sc_eip) / 4;
630 context_strings[i] = PUSH_EIP;
633 i = n_context_strings - 1 + ((int) &context - (int)&context.sc_eflags) / 4;
635 i = n_context_strings - 1 + ((int) &context - (int)&context.sc_efl) / 4;
637 context_strings[i] = PUSH_EFL;
638 pop_strings[n_context_strings - 1 - i] = POP_EFL;
640 i = n_context_strings - 1 + ((int) &context - (int) &context.sc_es) / 4;
641 context_strings[i] = PUSH_ES;
642 pop_strings[n_context_strings - 1 - i] = POP_ES;
644 i = n_context_strings - 1 + ((int) &context - (int) &context.sc_ds) / 4;
645 context_strings[i] = PUSH_DS;
646 pop_strings[n_context_strings - 1 - i] = POP_DS;
648 i = n_context_strings - 1 + ((int) &context - (int) &context.sc_cs) / 4;
649 context_strings[i] = PUSH_CS;
651 i = n_context_strings - 1 + ((int) &context - (int) &context.sc_ss) / 4;
652 context_strings[i] = PUSH_SS;
654 i = n_context_strings - 1 + ((int) &context - (int) &context.sc_edi) / 4;
655 context_strings[i] = PUSH_EDI;
656 pop_strings[n_context_strings - 1 - i] = POP_EDI;
658 i = n_context_strings - 1 + ((int) &context - (int) &context.sc_esi) / 4;
659 context_strings[i] = PUSH_ESI;
660 pop_strings[n_context_strings - 1 - i] = POP_ESI;
662 i = n_context_strings - 1 + ((int) &context - (int) &context.sc_ebx) / 4;
663 context_strings[i] = PUSH_EBX;
664 pop_strings[n_context_strings - 1 - i] = POP_EBX;
666 i = n_context_strings - 1 + ((int) &context - (int) &context.sc_edx) / 4;
667 context_strings[i] = PUSH_EDX;
668 pop_strings[n_context_strings - 1 - i] = POP_EDX;
670 i = n_context_strings - 1 + ((int) &context - (int) &context.sc_ecx) / 4;
671 context_strings[i] = PUSH_ECX;
672 pop_strings[n_context_strings - 1 - i] = POP_ECX;
674 i = n_context_strings - 1 + ((int) &context - (int) &context.sc_eax) / 4;
675 context_strings[i] = PUSH_EAX;
676 pop_strings[n_context_strings - 1 - i] = POP_EAX;
680 OutputVariableCode(FILE *fp, char *storage, ORDDEF *odp)
685 vdp = odp->additional_data;
686 for (i = 0; i < vdp->n_values; i++)
689 fprintf(fp, "\t%s\t", storage);
691 fprintf(fp, "%d", vdp->values[i]);
693 if ((i & 7) == 7 || i == vdp->n_values - 1)
701 int main(int argc, char **argv)
708 int i, ci, add_count;
709 int prev_index; /* Index to previous #define (-1 if none) */
711 /* the difference between last #define and the current */
716 fprintf(stderr, "usage: build SPECNAME\n build -p\n");
722 if (strcmp("-p", argv[1]) == 0)
724 fp = fopen("pop.h", "w");
726 for (i = 0; i < n_context_strings; i++)
728 if (strncmp(pop_strings[i], "\tadd\t", 5) == 0)
730 add_count += atoi(pop_strings[i] + 6);
736 fprintf(fp, "\tadd\t$%d,%%esp\n", add_count);
740 fprintf(fp, pop_strings[i]);
745 fprintf(fp, "\tadd\t$%d,%%esp\n", add_count);
747 fprintf(fp, "\tpushl\t%%gs:return_value\n\tpopfl\n");
753 SpecFp = fopen(argv[1], "r");
756 fprintf(stderr, "Could not open specification file, '%s'\n", argv[1]);
762 sprintf(filename, "dll_%s.S", LowerDLLName);
763 fp = fopen(filename, "w");
765 fprintf (fp, "#define __ASSEMBLY__\n");
766 fprintf (fp, "#include <asm/segment.h>\n");
769 fprintf(fp, "\t.globl " PREFIX "%s_Dispatch\n", UpperDLLName);
770 fprintf(fp, PREFIX "%s_Dispatch:\n", UpperDLLName);
771 fprintf(fp, "\tandl\t$0x0000ffff,%%esp\n");
772 fprintf(fp, "\tandl\t$0x0000ffff,%%ebp\n");
774 fprintf(fp, "\tljmp\t$USER_CS, $" PREFIX "CallTo32\n\n");
776 fprintf(fp, "\tjmp\t_CallTo32\n\n");
779 fprintf(fp, "\t.globl " PREFIX "%s_Dispatch_16\n", UpperDLLName);
780 fprintf(fp, PREFIX "%s_Dispatch_16:\n", UpperDLLName);
781 fprintf(fp, "\tandl\t$0x0000ffff,%%esp\n");
782 fprintf(fp, "\tandl\t$0x0000ffff,%%ebp\n");
784 fprintf(fp, "\tljmp\t$USER_CS, $" PREFIX "CallTo32_16\n\n");
786 fprintf(fp, "\tjmp\t_CallTo32_16\n\n");
790 odp = OrdinalDefinitions;
791 for (i = 0; i <= Limit; i++, odp++)
793 fprintf(fp, "\t.globl " PREFIX "%s_Ordinal_%d\n", UpperDLLName, i);
797 fprintf(fp, PREFIX "%s_Ordinal_%d:\n", UpperDLLName, i);
798 fprintf(fp, "\tmovl\t$0x%08x,%%eax\n", (DLLId << 16) | i);
799 fprintf(fp, "\tpushw\t$0\n");
801 fprintf(fp, "\tljmp\t$USER_CS, $" PREFIX "CallTo32\n\n");
803 fprintf(fp, "\tjmp\t_CallTo32\n\n");
808 fdp = odp->additional_data;
809 rdp = odp->additional_data;
814 fprintf(fp, PREFIX "%s_Ordinal_%d = %d\n\n",
815 UpperDLLName, i, (int) odp->additional_data);
819 fprintf(fp, PREFIX "%s_Ordinal_%d:\n", UpperDLLName, i);
820 OutputVariableCode(fp, ".byte", odp);
824 fprintf(fp, PREFIX "%s_Ordinal_%d:\n", UpperDLLName, i);
825 OutputVariableCode(fp, ".word", odp);
829 fprintf(fp, PREFIX "%s_Ordinal_%d:\n", UpperDLLName, i);
830 OutputVariableCode(fp, ".long", odp);
834 fprintf(fp, PREFIX "%s_Ordinal_%d:\n", UpperDLLName, i);
835 fprintf(fp, "\tmovw\t$%d,%%ax\n", rdp->ret_value & 0xffff);
836 fprintf(fp, "\tmovw\t$%d,%%dx\n",
837 (rdp->ret_value >> 16) & 0xffff);
838 fprintf(fp, "\t.byte\t0x66\n");
839 if (rdp->arg_size != 0)
840 fprintf(fp, "\tlret\t$%d\n", rdp->arg_size);
842 fprintf(fp, "\tlret\n");
846 fprintf(fp, PREFIX "%s_Ordinal_%d:\n", UpperDLLName, i);
847 fprintf(fp, "\tandl\t$0x0000ffff,%%esp\n");
848 fprintf(fp, "\tandl\t$0x0000ffff,%%ebp\n");
850 for (ci = 0; ci < n_context_strings; ci++)
851 fprintf(fp, context_strings[ci]);
853 fprintf(fp, "\tmovl\t%%ebp,%%eax\n");
854 fprintf(fp, "\tmovw\t%%esp,%%ebp\n");
855 fprintf(fp, "\tpushl\t%d(%%ebp)\n",
856 sizeof(struct sigcontext_struct));
857 fprintf(fp, "\tmovl\t%%eax,%%ebp\n");
858 fprintf(fp, "\tmovl\t$0x%08x,%%eax\n", (DLLId << 16) | i);
859 fprintf(fp, "\tpushw\t$%d\n",
860 sizeof(struct sigcontext_struct) + 4);
862 fprintf(fp, "\tljmp\t$USER_CS, $" PREFIX "CallTo32\n\n");
864 fprintf(fp, "\tjmp\t_CallTo32\n\n");
868 case FUNCTYPE_PASCAL:
869 fprintf(fp, PREFIX "%s_Ordinal_%d:\n", UpperDLLName, i);
870 fprintf(fp, "\tmovl\t$0x%08x,%%eax\n", (DLLId << 16) | i);
871 fprintf(fp, "\tpushw\t$%d\n", fdp->arg_16_size);
873 fprintf(fp, "\tljmp\t$USER_CS, $" PREFIX "CallTo32\n\n");
875 fprintf(fp, "\tjmp\t_CallTo32\n\n");
879 case FUNCTYPE_PASCAL_16:
880 fprintf(fp, PREFIX "%s_Ordinal_%d:\n", UpperDLLName, i);
881 fprintf(fp, "\tmovl\t$0x%08x,%%eax\n", (DLLId << 16) | i);
882 fprintf(fp, "\tpushw\t$%d\n", fdp->arg_16_size);
884 fprintf(fp, "\tljmp\t$USER_CS, $" PREFIX "CallTo32_16\n\n");
886 fprintf(fp, "\tjmp\t_CallTo32_16\n\n");
892 fprintf(fp, PREFIX "%s_Ordinal_%d:\n", UpperDLLName, i);
893 fprintf(fp, "\tmovl\t$0x%08x,%%eax\n", (DLLId << 16) | i);
894 fprintf(fp, "\tpushw\t$0\n");
896 fprintf(fp, "\tljmp\t$USER_CS, $" PREFIX "CallTo32\n\n");
898 fprintf(fp, "\tjmp\t_CallTo32\n\n");
908 sprintf(filename, "dll_%s_tab.c", LowerDLLName);
910 sprintf(filename, "dtb_%s.c", LowerDLLName);
912 fp = fopen(filename, "w");
914 fprintf(fp, "#include <stdio.h>\n");
915 fprintf(fp, "#include <stdlib.h>\n");
916 fprintf(fp, "#include \042dlls.h\042\n\n");
918 for (i = 0; i <= Limit; i++)
920 fprintf(fp, "extern void %s_Ordinal_%d();\n", UpperDLLName, i);
923 odp = OrdinalDefinitions;
924 for (i = 0; i <= Limit; i++, odp++)
927 (odp->type == FUNCTYPE_PASCAL || odp->type == FUNCTYPE_PASCAL_16 ||
928 odp->type == FUNCTYPE_REG || odp->type == FUNCTYPE_C ))
930 fdp = odp->additional_data;
931 fprintf(fp, "extern int %s();\n", fdp->internal_name);
934 /******* Michael Veksler 95-2-3 (pointers instead of fixed data) ****/
935 fprintf(fp,"unsigned short %s_offsets[]={\n" , UpperDLLName);
936 prev_index=-1; /* Index to previous #define (-1 if none) */
938 /* the difference between last #define and the current */
941 odp = OrdinalDefinitions;
942 for (i = 0; i <= Limit; i++, odp++)
945 fdp = odp->additional_data;
949 case FUNCTYPE_PASCAL:
950 case FUNCTYPE_PASCAL_16:
952 if (!odp->valid || fdp->n_args_32 <=0 )
955 fprintf(fp,"#\tdefine %s_ref_%d 0\n\t", UpperDLLName, i);
957 fprintf(fp,"#\tdefine %s_ref_%d %s_ref_%d+%d\n\t",
958 UpperDLLName,i, UpperDLLName,prev_index ,prev_n_args);
959 for (argnum = 0; argnum < fdp->n_args_32; argnum++)
961 fdp->arg_16_offsets[fdp->arg_indices_32[argnum]-1]);
964 prev_n_args=fdp->n_args_32;
971 fprintf(fp,"unsigned char %s_types[]={\n" , UpperDLLName);
973 odp = OrdinalDefinitions;
974 for (i = 0; i <= Limit; i++, odp++)
978 fdp = odp->additional_data;
982 case FUNCTYPE_PASCAL:
983 case FUNCTYPE_PASCAL_16:
985 if (!odp->valid || fdp->n_args_32 <=0 )
988 fprintf(fp,"/* %s_%d */\n\t", UpperDLLName, i);
990 for (argnum = 0; argnum < fdp->n_args_32; argnum++)
991 fprintf(fp, "%d, ", fdp->arg_types_16[argnum]);
998 /**************************************************/
999 fprintf(fp, "\nstruct dll_table_entry_s %s_table[%d] =\n",
1000 UpperDLLName, Limit + 1);
1002 odp = OrdinalDefinitions;
1003 for (i = 0; i <= Limit; i++, odp++)
1005 fdp = odp->additional_data;
1012 case FUNCTYPE_PASCAL:
1013 case FUNCTYPE_PASCAL_16:
1015 fprintf(fp, " { 0x%x, %s_Ordinal_%d, ", UTEXTSEL, UpperDLLName, i);
1016 fprintf(fp, "\042%s\042, ", odp->export_name);
1017 fprintf(fp, "%s, DLL_HANDLERTYPE_PASCAL, ", fdp->internal_name);
1018 fprintf(fp, "%d, ", fdp->n_args_32);
1019 if (fdp->n_args_32 > 0)
1020 fprintf(fp,"%s_ref_%d", UpperDLLName, i);
1027 fprintf(fp, "}, \n");
1031 fprintf(fp, " { 0x%x, %s_Ordinal_%d, ", UTEXTSEL, UpperDLLName, i);
1032 fprintf(fp, "\042%s\042, ", odp->export_name);
1033 fprintf(fp, "%s, DLL_HANDLERTYPE_C, ", fdp->internal_name);
1037 fprintf(fp, "%d, ", fdp->n_args_32);
1038 if (fdp->n_args_32 > 0)
1042 fprintf(fp, "\n {\n");
1043 for (argnum = 0; argnum < fdp->n_args_32; argnum++)
1045 fprintf(fp, " { %d, %d },\n",
1046 fdp->arg_16_offsets[fdp->arg_indices_32[argnum]-1],
1047 fdp->arg_types_16[argnum]);
1049 fprintf(fp, " }\n ");
1051 fprintf(fp, "}, \n");
1055 fprintf(fp, " { 0x%x, %s_Ordinal_%d, \042\042, NULL },\n",
1056 UTEXTSEL, UpperDLLName, i);
1060 fprintf(fp, "};\n");