1 /* static char Copyright[] = "Copyright Robert J. Amstadt, 1993"; */
12 #if defined(__NetBSD__) || defined(__FreeBSD__)
16 /* ELF symbols do not have an underscore in front */
23 #define VARTYPE_BYTE 0
24 #define VARTYPE_SIGNEDWORD 0
25 #define VARTYPE_WORD 1
26 #define VARTYPE_LONG 2
27 #define VARTYPE_FARPTR 3
29 #define FUNCTYPE_PASCAL_16 15
30 #define FUNCTYPE_PASCAL 16
32 #define FUNCTYPE_REG 19
34 #define EQUATETYPE_ABS 18
35 #define TYPE_RETURN 20
37 /*#define MAX_ORDINALS 1024*/
38 #define MAX_ORDINALS 1299
40 #define PUSH_0 "\tpushl\t$0\n"
41 #define PUSH_SS "\tpushw\t$0\n\tpushw\t%%ss\n"
42 #define PUSH_ESP "\tpushl\t%%esp\n"
43 #define PUSH_EFL "\tpushfl\n"
44 #define PUSH_CS "\tpushw\t$0\n\tpushw\t%%cs\n"
45 #define PUSH_EIP "\tpushl\t$0\n"
46 #define PUSH_DS "\tpushw\t$0\n\tpushw\t%%ds\n"
47 #define PUSH_ES "\tpushw\t$0\n\tpushw\t%%es\n"
48 #define PUSH_FS "\tpushw\t$0\n\tpushw\t%%fs\n"
49 #define PUSH_GS "\tpushw\t$0\n\tpushw\t%%gs\n"
50 #define PUSH_EAX "\tpushl\t%%eax\n"
51 #define PUSH_ECX "\tpushl\t%%ecx\n"
52 #define PUSH_EDX "\tpushl\t%%edx\n"
53 #define PUSH_EBX "\tpushl\t%%ebx\n"
54 #define PUSH_EBP "\tpushl\t%%ebp\n"
55 #define PUSH_ESI "\tpushl\t%%esi\n"
56 #define PUSH_EDI "\tpushl\t%%edi\n"
58 #define POP_0 "\tadd\t$4,%%esp\n"
59 #define POP_SS "\tpopw\t%%ss\n\tadd\t$2,%%esp\n"
60 #define POP_ESP "\tpopl\t%%esp\n"
61 #define POP_EFL "\tpopl\t%%gs:return_value\n"
62 #define POP_CS "\tpopw\t%%cs\n\tadd\t$2,%%esp\n"
63 #define POP_EIP "\tpopl\t$0\n"
64 #define POP_DS "\tpopw\t%%ds\n\tadd\t$2,%%esp\n"
65 #define POP_ES "\tpopw\t%%es\n\tadd\t$2,%%esp\n"
66 #define POP_FS "\tpopw\t%%fs\n\tadd\t$2,%%esp\n"
67 #define POP_GS "\tpopw\t%%gs\n\tadd\t$2,%%esp\n"
68 #define POP_EAX "\tpopl\t%%eax\n"
69 #define POP_ECX "\tpopl\t%%ecx\n"
70 #define POP_EDX "\tpopl\t%%edx\n"
71 #define POP_EBX "\tpopl\t%%ebx\n"
72 #define POP_EBP "\tpopl\t%%ebp\n"
73 #define POP_ESI "\tpopl\t%%esi\n"
74 #define POP_EDI "\tpopl\t%%edi\n"
76 char **context_strings
;
78 int n_context_strings
;
80 typedef struct ordinal_definition_s
85 void *additional_data
;
88 typedef struct ordinal_variable_definition_s
94 typedef struct ordinal_function_definition_s
98 int arg_16_offsets
[16];
100 char internal_name
[80];
102 int arg_indices_32
[16];
105 typedef struct ordinal_return_definition_s
111 ORDDEF OrdinalDefinitions
[MAX_ORDINALS
];
113 char LowerDLLName
[80];
114 char UpperDLLName
[80];
119 char *ParseBuffer
= NULL
;
124 int IsNumberString(char *s
)
133 char *strlower(char *s
)
137 for(p
= s
; *p
!= '\0'; p
++)
143 char *strupper(char *s
)
147 for(p
= s
; *p
!= '\0'; p
++)
153 int stricmp(char *s1
, char *s2
)
155 if (strlen(s1
) != strlen(s2
))
171 if (ParseNext
!= ParseBuffer
)
173 if (ParseSaveChar
== '\0')
175 *ParseNext
= ParseSaveChar
;
179 * Remove initial white space.
181 for (p
= ParseNext
; isspace(*p
); p
++)
191 if (*token
!= '(' && *token
!= ')')
192 while (*p
!= '\0' && *p
!= '(' && *p
!= ')' && !isspace(*p
))
207 if (ParseBuffer
== NULL
)
209 ParseBuffer
= malloc(512);
210 ParseNext
= ParseBuffer
;
214 if (fgets(ParseBuffer
, 511, SpecFp
) == NULL
)
216 if (ParseBuffer
[0] != '#')
221 while ((token
= GetTokenInLine()) == NULL
)
223 ParseNext
= ParseBuffer
;
227 if (fgets(ParseBuffer
, 511, SpecFp
) == NULL
)
229 if (ParseBuffer
[0] != '#')
238 ParseVariable(int ordinal
, int type
)
242 char export_name
[80];
247 int value_array_size
;
249 strcpy(export_name
, GetToken());
254 fprintf(stderr
, "%d: Expected '(' got '%s'\n", Line
, token
);
259 value_array_size
= 25;
260 value_array
= malloc(sizeof(*value_array
) * value_array_size
);
262 while ((token
= GetToken()) != NULL
)
267 value_array
[n_values
++] = strtol(token
, &endptr
, 0);
268 if (n_values
== value_array_size
)
270 value_array_size
+= 25;
271 value_array
= realloc(value_array
,
272 sizeof(*value_array
) * value_array_size
);
275 if (endptr
== NULL
|| *endptr
!= '\0')
277 fprintf(stderr
, "%d: Expected number value, got '%s'\n", Line
,
285 fprintf(stderr
, "%d: End of file in variable declaration\n", Line
);
289 if (ordinal
>= MAX_ORDINALS
)
291 fprintf(stderr
, "%d: Ordinal number too large\n", Line
);
295 odp
= &OrdinalDefinitions
[ordinal
];
298 strcpy(odp
->export_name
, export_name
);
300 vdp
= malloc(sizeof(*vdp
));
301 odp
->additional_data
= vdp
;
303 vdp
->n_values
= n_values
;
304 vdp
->values
= realloc(value_array
, sizeof(*value_array
) * n_values
);
310 ParseExportFunction(int ordinal
, int type
)
320 if (ordinal
>= MAX_ORDINALS
)
322 fprintf(stderr
, "%d: Ordinal number too large\n", Line
);
326 odp
= &OrdinalDefinitions
[ordinal
];
327 strcpy(odp
->export_name
, GetToken());
330 fdp
= malloc(sizeof(*fdp
));
331 odp
->additional_data
= fdp
;
336 fprintf(stderr
, "%d: Expected '(' got '%s'\n", Line
, token
);
340 fdp
->arg_16_size
= 0;
341 for (i
= 0; i
< 16; i
++)
347 if (stricmp(token
, "byte") == 0 || stricmp(token
, "word") == 0)
349 fdp
->arg_types_16
[i
] = VARTYPE_WORD
;
350 fdp
->arg_16_size
+= 2;
351 fdp
->arg_16_offsets
[i
] = 2;
353 else if (stricmp(token
, "s_byte") == 0 ||
354 stricmp(token
, "s_word") == 0)
356 fdp
->arg_types_16
[i
] = VARTYPE_SIGNEDWORD
;
357 fdp
->arg_16_size
+= 2;
358 fdp
->arg_16_offsets
[i
] = 2;
360 else if (stricmp(token
, "long") == 0 || stricmp(token
, "s_long") == 0)
362 fdp
->arg_types_16
[i
] = VARTYPE_LONG
;
363 fdp
->arg_16_size
+= 4;
364 fdp
->arg_16_offsets
[i
] = 4;
366 else if (stricmp(token
, "ptr") == 0)
368 fdp
->arg_types_16
[i
] = VARTYPE_FARPTR
;
369 fdp
->arg_16_size
+= 4;
370 fdp
->arg_16_offsets
[i
] = 4;
374 fprintf(stderr
, "%d: Unknown variable type '%s'\n", Line
, token
);
380 if (type
== FUNCTYPE_PASCAL_16
|| type
== FUNCTYPE_PASCAL
||
381 type
== FUNCTYPE_REG
)
384 for (i
--; i
>= 0; i
--)
386 arg_size
= fdp
->arg_16_offsets
[i
];
387 fdp
->arg_16_offsets
[i
] = current_offset
;
388 current_offset
+= arg_size
;
394 for (i
= 0; i
< fdp
->n_args_16
; i
++)
396 arg_size
= fdp
->arg_16_offsets
[i
];
397 fdp
->arg_16_offsets
[i
] = current_offset
;
398 current_offset
+= arg_size
;
402 strcpy(fdp
->internal_name
, GetToken());
406 fprintf(stderr
, "%d: Expected '(' got '%s'\n", Line
, token
);
409 for (i
= 0; i
< 16; i
++)
415 fdp
->arg_indices_32
[i
] = atoi(token
);
416 if (fdp
->arg_indices_32
[i
] < 1 ||
417 fdp
->arg_indices_32
[i
] > fdp
->n_args_16
)
419 fprintf(stderr
, "%d: Bad argument index %d\n", Line
,
420 fdp
->arg_indices_32
[i
]);
430 ParseEquate(int ordinal
)
437 if (ordinal
>= MAX_ORDINALS
)
439 fprintf(stderr
, "%d: Ordinal number too large\n", Line
);
443 odp
= &OrdinalDefinitions
[ordinal
];
444 strcpy(odp
->export_name
, GetToken());
447 value
= strtol(token
, &endptr
, 0);
448 if (endptr
== NULL
|| *endptr
!= '\0')
450 fprintf(stderr
, "%d: Expected number value, got '%s'\n", Line
,
456 odp
->type
= EQUATETYPE_ABS
;
457 odp
->additional_data
= (void *) value
;
463 ParseReturn(int ordinal
)
470 if (ordinal
>= MAX_ORDINALS
)
472 fprintf(stderr
, "%d: Ordinal number too large\n", Line
);
476 rdp
= malloc(sizeof(*rdp
));
478 odp
= &OrdinalDefinitions
[ordinal
];
479 strcpy(odp
->export_name
, GetToken());
481 odp
->type
= TYPE_RETURN
;
482 odp
->additional_data
= rdp
;
485 rdp
->arg_size
= strtol(token
, &endptr
, 0);
486 if (endptr
== NULL
|| *endptr
!= '\0')
488 fprintf(stderr
, "%d: Expected number value, got '%s'\n", Line
,
494 rdp
->ret_value
= strtol(token
, &endptr
, 0);
495 if (endptr
== NULL
|| *endptr
!= '\0')
497 fprintf(stderr
, "%d: Expected number value, got '%s'\n", Line
,
506 ParseOrdinal(int ordinal
)
513 fprintf(stderr
, "%d: Expected type after ordinal\n", Line
);
517 if (stricmp(token
, "byte") == 0)
518 return ParseVariable(ordinal
, VARTYPE_BYTE
);
519 else if (stricmp(token
, "word") == 0)
520 return ParseVariable(ordinal
, VARTYPE_WORD
);
521 else if (stricmp(token
, "long") == 0)
522 return ParseVariable(ordinal
, VARTYPE_LONG
);
523 else if (stricmp(token
, "c") == 0)
524 return ParseExportFunction(ordinal
, FUNCTYPE_C
);
525 else if (stricmp(token
, "p") == 0)
526 return ParseExportFunction(ordinal
, FUNCTYPE_PASCAL
);
527 else if (stricmp(token
, "pascal") == 0)
528 return ParseExportFunction(ordinal
, FUNCTYPE_PASCAL
);
529 else if (stricmp(token
, "pascal16") == 0)
530 return ParseExportFunction(ordinal
, FUNCTYPE_PASCAL_16
);
531 else if (stricmp(token
, "register") == 0)
532 return ParseExportFunction(ordinal
, FUNCTYPE_REG
);
533 else if (stricmp(token
, "equate") == 0)
534 return ParseEquate(ordinal
);
535 else if (stricmp(token
, "return") == 0)
536 return ParseReturn(ordinal
);
540 "%d: Expected type after ordinal, found '%s' instead\n",
551 while ((token
= GetToken()) != NULL
)
553 if (stricmp(token
, "name") == 0)
555 strcpy(LowerDLLName
, GetToken());
556 strlower(LowerDLLName
);
558 strcpy(UpperDLLName
, LowerDLLName
);
559 strupper(UpperDLLName
);
561 else if (stricmp(token
, "id") == 0)
564 if (!IsNumberString(token
))
566 fprintf(stderr
, "%d: Expected number after id\n", Line
);
572 else if (stricmp(token
, "length") == 0)
575 if (!IsNumberString(token
))
577 fprintf(stderr
, "%d: Expected number after length\n", Line
);
583 else if (IsNumberString(token
))
588 ordinal
= atoi(token
);
589 if ((rv
= ParseOrdinal(ordinal
)) < 0)
595 "%d: Expected name, id, length or ordinal\n", Line
);
606 struct sigcontext_struct context
;
609 n_context_strings
= sizeof(context
) / 4;
610 context_strings
= (char **) malloc(n_context_strings
* sizeof(char **));
611 pop_strings
= (char **) malloc(n_context_strings
* sizeof(char **));
612 for (i
= 0; i
< n_context_strings
; i
++)
614 context_strings
[i
] = PUSH_0
;
615 pop_strings
[i
] = POP_0
;
618 i
= n_context_strings
- 1 + ((int) &context
- (int) &context
.sc_esp
) / 4;
619 context_strings
[i
] = PUSH_ESP
;
621 i
= n_context_strings
- 1 + ((int) &context
- (int) &context
.sc_ebp
) / 4;
622 context_strings
[i
] = PUSH_EBP
;
623 pop_strings
[n_context_strings
- 1 - i
] = POP_EBP
;
625 i
= n_context_strings
- 1 + ((int) &context
- (int) &context
.sc_eip
) / 4;
626 context_strings
[i
] = PUSH_EIP
;
629 i
= n_context_strings
- 1 + ((int) &context
- (int)&context
.sc_eflags
) / 4;
631 i
= n_context_strings
- 1 + ((int) &context
- (int)&context
.sc_efl
) / 4;
633 context_strings
[i
] = PUSH_EFL
;
634 pop_strings
[n_context_strings
- 1 - i
] = POP_EFL
;
636 i
= n_context_strings
- 1 + ((int) &context
- (int) &context
.sc_es
) / 4;
637 context_strings
[i
] = PUSH_ES
;
638 pop_strings
[n_context_strings
- 1 - i
] = POP_ES
;
640 i
= n_context_strings
- 1 + ((int) &context
- (int) &context
.sc_ds
) / 4;
641 context_strings
[i
] = PUSH_DS
;
642 pop_strings
[n_context_strings
- 1 - i
] = POP_DS
;
644 i
= n_context_strings
- 1 + ((int) &context
- (int) &context
.sc_cs
) / 4;
645 context_strings
[i
] = PUSH_CS
;
647 i
= n_context_strings
- 1 + ((int) &context
- (int) &context
.sc_ss
) / 4;
648 context_strings
[i
] = PUSH_SS
;
650 i
= n_context_strings
- 1 + ((int) &context
- (int) &context
.sc_edi
) / 4;
651 context_strings
[i
] = PUSH_EDI
;
652 pop_strings
[n_context_strings
- 1 - i
] = POP_EDI
;
654 i
= n_context_strings
- 1 + ((int) &context
- (int) &context
.sc_esi
) / 4;
655 context_strings
[i
] = PUSH_ESI
;
656 pop_strings
[n_context_strings
- 1 - i
] = POP_ESI
;
658 i
= n_context_strings
- 1 + ((int) &context
- (int) &context
.sc_ebx
) / 4;
659 context_strings
[i
] = PUSH_EBX
;
660 pop_strings
[n_context_strings
- 1 - i
] = POP_EBX
;
662 i
= n_context_strings
- 1 + ((int) &context
- (int) &context
.sc_edx
) / 4;
663 context_strings
[i
] = PUSH_EDX
;
664 pop_strings
[n_context_strings
- 1 - i
] = POP_EDX
;
666 i
= n_context_strings
- 1 + ((int) &context
- (int) &context
.sc_ecx
) / 4;
667 context_strings
[i
] = PUSH_ECX
;
668 pop_strings
[n_context_strings
- 1 - i
] = POP_ECX
;
670 i
= n_context_strings
- 1 + ((int) &context
- (int) &context
.sc_eax
) / 4;
671 context_strings
[i
] = PUSH_EAX
;
672 pop_strings
[n_context_strings
- 1 - i
] = POP_EAX
;
676 OutputVariableCode(FILE *fp
, char *storage
, ORDDEF
*odp
)
681 vdp
= odp
->additional_data
;
682 for (i
= 0; i
< vdp
->n_values
; i
++)
685 fprintf(fp
, "\t%s\t", storage
);
687 fprintf(fp
, "%d", vdp
->values
[i
]);
689 if ((i
& 7) == 7 || i
== vdp
->n_values
- 1)
697 int main(int argc
, char **argv
)
704 int i
, ci
, add_count
;
708 fprintf(stderr
, "usage: build SPECNAME\n build -p\n");
714 if (strcmp("-p", argv
[1]) == 0)
716 fp
= fopen("pop.h", "w");
718 for (i
= 0; i
< n_context_strings
; i
++)
720 if (strncmp(pop_strings
[i
], "\tadd\t", 5) == 0)
722 add_count
+= atoi(pop_strings
[i
] + 6);
728 fprintf(fp
, "\tadd\t$%d,%%esp\n", add_count
);
732 fprintf(fp
, pop_strings
[i
]);
737 fprintf(fp
, "\tadd\t$%d,%%esp\n", add_count
);
739 fprintf(fp
, "\tpushl\t%%gs:return_value\n\tpopfl\n");
745 SpecFp
= fopen(argv
[1], "r");
748 fprintf(stderr
, "Could not open specification file, '%s'\n", argv
[1]);
754 sprintf(filename
, "dll_%s.S", LowerDLLName
);
755 fp
= fopen(filename
, "w");
757 fprintf(fp
, "\t.globl " PREFIX
"%s_Dispatch\n", UpperDLLName
);
758 fprintf(fp
, PREFIX
"%s_Dispatch:\n", UpperDLLName
);
759 fprintf(fp
, "\tandl\t$0x0000ffff,%%esp\n");
760 fprintf(fp
, "\tandl\t$0x0000ffff,%%ebp\n");
761 fprintf(fp
, "\torl\t$0x%08x,%%eax\n", DLLId
<< 16);
762 fprintf(fp
, "\tjmp\t" PREFIX
"CallTo32\n\n");
764 fprintf(fp
, "\t.globl " PREFIX
"%s_Dispatch_16\n", UpperDLLName
);
765 fprintf(fp
, PREFIX
"%s_Dispatch_16:\n", UpperDLLName
);
766 fprintf(fp
, "\tandl\t$0x0000ffff,%%esp\n");
767 fprintf(fp
, "\tandl\t$0x0000ffff,%%ebp\n");
768 fprintf(fp
, "\torl\t$0x%08x,%%eax\n", DLLId
<< 16);
769 fprintf(fp
, "\tjmp\t" PREFIX
"CallTo32_16\n\n");
771 odp
= OrdinalDefinitions
;
772 for (i
= 0; i
<= Limit
; i
++, odp
++)
774 fprintf(fp
, "\t.globl " PREFIX
"%s_Ordinal_%d\n", UpperDLLName
, i
);
778 fprintf(fp
, PREFIX
"%s_Ordinal_%d:\n", UpperDLLName
, i
);
779 fprintf(fp
, "\tmovl\t$%d,%%eax\n", i
);
780 fprintf(fp
, "\tpushw\t$0\n");
781 fprintf(fp
, "\tjmp\t" PREFIX
"%s_Dispatch\n\n", UpperDLLName
);
785 fdp
= odp
->additional_data
;
786 rdp
= odp
->additional_data
;
791 fprintf(fp
, PREFIX
"%s_Ordinal_%d = %d\n\n",
792 UpperDLLName
, i
, (int) odp
->additional_data
);
796 fprintf(fp
, PREFIX
"%s_Ordinal_%d:\n", UpperDLLName
, i
);
797 OutputVariableCode(fp
, ".byte", odp
);
801 fprintf(fp
, PREFIX
"%s_Ordinal_%d:\n", UpperDLLName
, i
);
802 OutputVariableCode(fp
, ".word", odp
);
806 fprintf(fp
, PREFIX
"%s_Ordinal_%d:\n", UpperDLLName
, i
);
807 OutputVariableCode(fp
, ".long", odp
);
811 fprintf(fp
, PREFIX
"%s_Ordinal_%d:\n", UpperDLLName
, i
);
812 fprintf(fp
, "\tmovw\t$%d,%%ax\n", rdp
->ret_value
& 0xffff);
813 fprintf(fp
, "\tmovw\t$%d,%%dx\n",
814 (rdp
->ret_value
>> 16) & 0xffff);
815 fprintf(fp
, "\t.byte\t0x66\n");
816 if (rdp
->arg_size
!= 0)
817 fprintf(fp
, "\tlret\t$%d\n", rdp
->arg_size
);
819 fprintf(fp
, "\tlret\n");
823 fprintf(fp
, PREFIX
"%s_Ordinal_%d:\n", UpperDLLName
, i
);
824 fprintf(fp
, "\tandl\t$0x0000ffff,%%esp\n");
825 fprintf(fp
, "\tandl\t$0x0000ffff,%%ebp\n");
827 for (ci
= 0; ci
< n_context_strings
; ci
++)
828 fprintf(fp
, context_strings
[ci
]);
830 fprintf(fp
, "\tmovl\t%%ebp,%%eax\n");
831 fprintf(fp
, "\tmovw\t%%esp,%%ebp\n");
832 fprintf(fp
, "\tpushl\t%d(%%ebp)\n",
833 sizeof(struct sigcontext_struct
));
834 fprintf(fp
, "\tmovl\t%%eax,%%ebp\n");
835 fprintf(fp
, "\tmovl\t$%d,%%eax\n", i
);
836 fprintf(fp
, "\tpushw\t$%d\n",
837 sizeof(struct sigcontext_struct
) + 4);
838 fprintf(fp
, "\tjmp\t" PREFIX
"%s_Dispatch\n\n", UpperDLLName
);
841 case FUNCTYPE_PASCAL
:
842 fprintf(fp
, PREFIX
"%s_Ordinal_%d:\n", UpperDLLName
, i
);
843 fprintf(fp
, "\tmovl\t$%d,%%eax\n", i
);
844 fprintf(fp
, "\tpushw\t$%d\n", fdp
->arg_16_size
);
845 fprintf(fp
, "\tjmp\t" PREFIX
"%s_Dispatch\n\n", UpperDLLName
);
848 case FUNCTYPE_PASCAL_16
:
849 fprintf(fp
, PREFIX
"%s_Ordinal_%d:\n", UpperDLLName
, i
);
850 fprintf(fp
, "\tmovl\t$%d,%%eax\n", i
);
851 fprintf(fp
, "\tpushw\t$%d\n", fdp
->arg_16_size
);
852 fprintf(fp
, "\tjmp\t" PREFIX
"%s_Dispatch_16\n\n", UpperDLLName
);
857 fprintf(fp
, PREFIX
"%s_Ordinal_%d:\n", UpperDLLName
, i
);
858 fprintf(fp
, "\tmovl\t$%d,%%eax\n", i
);
859 fprintf(fp
, "\tpushw\t$0\n");
860 fprintf(fp
, "\tjmp\t" PREFIX
"%s_Dispatch\n\n", UpperDLLName
);
869 sprintf(filename
, "dll_%s_tab.c", LowerDLLName
);
871 sprintf(filename
, "dtb_%s.c", LowerDLLName
);
873 fp
= fopen(filename
, "w");
875 fprintf(fp
, "#include <stdio.h>\n");
876 fprintf(fp
, "#include <stdlib.h>\n");
877 fprintf(fp
, "#include \042dlls.h\042\n\n");
879 for (i
= 0; i
<= Limit
; i
++)
881 fprintf(fp
, "extern void %s_Ordinal_%d();\n", UpperDLLName
, i
);
884 odp
= OrdinalDefinitions
;
885 for (i
= 0; i
<= Limit
; i
++, odp
++)
888 (odp
->type
== FUNCTYPE_PASCAL
|| odp
->type
== FUNCTYPE_PASCAL_16
||
889 odp
->type
== FUNCTYPE_REG
|| odp
->type
== FUNCTYPE_C
))
891 fdp
= odp
->additional_data
;
892 fprintf(fp
, "extern int %s();\n", fdp
->internal_name
);
896 fprintf(fp
, "\nstruct dll_table_entry_s %s_table[%d] =\n",
897 UpperDLLName
, Limit
+ 1);
899 odp
= OrdinalDefinitions
;
900 for (i
= 0; i
<= Limit
; i
++, odp
++)
902 fdp
= odp
->additional_data
;
909 case FUNCTYPE_PASCAL
:
910 case FUNCTYPE_PASCAL_16
:
912 fprintf(fp
, " { 0x%x, %s_Ordinal_%d, ", UTEXTSEL
, UpperDLLName
, i
);
913 fprintf(fp
, "\042%s\042, ", odp
->export_name
);
914 fprintf(fp
, "%s, DLL_HANDLERTYPE_PASCAL, ", fdp
->internal_name
);
918 fprintf(fp
, "%d, ", fdp
->n_args_32
);
919 if (fdp
->n_args_32
> 0)
923 fprintf(fp
, "\n {\n");
924 for (argnum
= 0; argnum
< fdp
->n_args_32
; argnum
++)
926 fprintf(fp
, " { %d, %d },\n",
927 fdp
->arg_16_offsets
[fdp
->arg_indices_32
[argnum
]-1],
928 fdp
->arg_types_16
[argnum
]);
930 fprintf(fp
, " }\n ");
932 fprintf(fp
, "}, \n");
936 fprintf(fp
, " { 0x%x, %s_Ordinal_%d, ", UTEXTSEL
, UpperDLLName
, i
);
937 fprintf(fp
, "\042%s\042, ", odp
->export_name
);
938 fprintf(fp
, "%s, DLL_HANDLERTYPE_C, ", fdp
->internal_name
);
942 fprintf(fp
, "%d, ", fdp
->n_args_32
);
943 if (fdp
->n_args_32
> 0)
947 fprintf(fp
, "\n {\n");
948 for (argnum
= 0; argnum
< fdp
->n_args_32
; argnum
++)
950 fprintf(fp
, " { %d, %d },\n",
951 fdp
->arg_16_offsets
[fdp
->arg_indices_32
[argnum
]-1],
952 fdp
->arg_types_16
[argnum
]);
954 fprintf(fp
, " }\n ");
956 fprintf(fp
, "}, \n");
960 fprintf(fp
, " { 0x%x, %s_Ordinal_%d, \042\042, NULL },\n",
961 UTEXTSEL
, UpperDLLName
, i
);