Rev 9620 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
9766 | turbocat | 1 | #include |
2 | #include |
||
9620 | turbocat | 3 | #include |
4 | #include |
||
5 | #include |
||
6 | #include |
||
7 | |||
8 | #define ARGC_VALID 3 |
||
9 | |||
10 | enum ARGV_FILE { |
||
11 | IN = 1, |
||
12 | OUT = 2 |
||
13 | }; |
||
14 | |||
9766 | turbocat | 15 | void show_help(void) |
16 | { |
||
9620 | turbocat | 17 | puts("Usage: defgen [lib.obj] [lib.def]"); |
18 | } |
||
19 | |||
9766 | turbocat | 20 | int main(int argc, char** argv) |
21 | { |
||
9620 | turbocat | 22 | |
9766 | turbocat | 23 | if (argc != ARGC_VALID) { |
9620 | turbocat | 24 | show_help(); |
25 | return 0; |
||
26 | } |
||
27 | |||
9766 | turbocat | 28 | ksys_dll_t* obj_dll = _ksys_dlopen(argv[IN]); |
9620 | turbocat | 29 | FILE* outfile = fopen(argv[OUT], "w"); |
30 | |||
9766 | turbocat | 31 | if (!obj_dll) { |
9620 | turbocat | 32 | printf("File '%s' not found!\n", argv[IN]); |
33 | return 1; |
||
34 | } |
||
35 | |||
9766 | turbocat | 36 | if (!outfile) { |
9620 | turbocat | 37 | printf("Unable to create file:'%s'!\n", argv[OUT]); |
38 | return 2; |
||
39 | } |
||
40 | |||
41 | fprintf(outfile, "LIBRARY %s\n\n", basename(argv[IN])); |
||
42 | fputs("EXPORTS\n", outfile); |
||
9766 | turbocat | 43 | |
44 | int i = 0; |
||
45 | while (obj_dll[i].func_name) { |
||
46 | fprintf(outfile, "%s\n", obj_dll[i].func_name); |
||
9620 | turbocat | 47 | i++; |
48 | } |
||
9766 | turbocat | 49 | fclose(outfile); |
9620 | turbocat | 50 | return 0; |
51 | } |