kolibrios/programs/develop/ktcc/trunk/libc.obj/samples/defgen.c
turbocat 0d9c69c2a0 libc.obj:
- Unified stdcall and cdecl;
 - Fixed clayer to use def format;
 - Fixed build examples.


git-svn-id: svn://kolibrios.org@9620 a494cfbc-eb01-0410-851d-a64ba20cac60
2022-01-12 18:09:37 +00:00

50 lines
917 B
C

#include "stddef.h"
#include <stdio.h>
#include <stdlib.h>
#include <libgen.h>
#include <string.h>
#include <sys/ksys.h>
#define ARGC_VALID 3
enum ARGV_FILE {
IN = 1,
OUT = 2
};
void show_help(void){
puts("Usage: defgen [lib.obj] [lib.def]");
}
int main(int argc, char** argv){
if(argc!=ARGC_VALID){
show_help();
return 0;
}
ksys_dll_t *obj_dll = _ksys_dlopen(argv[IN]);
FILE* outfile = fopen(argv[OUT], "w");
if(!obj_dll){
printf("File '%s' not found!\n", argv[IN]);
return 1;
}
if(!outfile){
printf("Unable to create file:'%s'!\n", argv[OUT]);
return 2;
}
fprintf(outfile, "LIBRARY %s\n\n", basename(argv[IN]));
fputs("EXPORTS\n", outfile);
int i=0;
while(obj_dll[i].func_name){
fprintf(outfile,"%s\n", obj_dll[i].func_name);
i++;
}
fclose(outfile);
return 0;
}