Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. #include "stddef.h"
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <libgen.h>
  5. #include <string.h>
  6. #include <sys/ksys.h>
  7.  
  8. #define ARGC_VALID 3
  9.  
  10. enum ARGV_FILE {
  11.     IN = 1,
  12.     OUT = 2
  13. };
  14.  
  15. void show_help(void){
  16.     puts("Usage: defgen [lib.obj] [lib.def]");
  17. }
  18.  
  19. int main(int argc, char** argv){
  20.  
  21.     if(argc!=ARGC_VALID){
  22.         show_help();
  23.         return 0;
  24.     }
  25.  
  26.     ksys_dll_t *obj_dll = _ksys_dlopen(argv[IN]);
  27.     FILE* outfile = fopen(argv[OUT], "w");
  28.  
  29.     if(!obj_dll){
  30.         printf("File '%s' not found!\n", argv[IN]);
  31.         return 1;
  32.     }
  33.  
  34.     if(!outfile){
  35.         printf("Unable to create file:'%s'!\n", argv[OUT]);
  36.         return 2;
  37.     }
  38.  
  39.     fprintf(outfile, "LIBRARY %s\n\n", basename(argv[IN]));
  40.     fputs("EXPORTS\n", outfile);
  41.    
  42.     int i=0;
  43.     while(obj_dll[i].func_name){
  44.         fprintf(outfile,"%s\n", obj_dll[i].func_name);
  45.         i++;
  46.     }
  47.     fclose(outfile);  
  48.     return 0;
  49. }
  50.