Go to the documentation of this file.00001
00002
00003 #ifdef _WIN32
00004
00005
00006 #pragma warning ( disable : 4273 )
00007 #define popen _popen
00008 #define pclose _pclose
00009 #define fileno _fileno
00010 #include <stdlib.h>
00011 #endif
00012
00013
00014 #include <vector>
00015 #include <string>
00016 #include <iostream>
00017 #include <fstream>
00018 #include "LibSymbolInfo.h"
00019
00020 using namespace std;
00021
00022 namespace windef {
00023 void usage(){
00024 cerr << "Usage: genwindef [-l <dllname>] [-o <output-file> | exports.def] <obj or lib filenames>" << endl;
00025 exit(1);
00026 }
00027 }
00028
00029
00030 int main ( int argc, char** argv )
00031
00032 {
00033 string outfile("exports.def");
00034 string library("UnknownLib");
00035 string objfiles;
00036 bool debug(false);
00037
00038 int arg;
00039 if (argc < 3) windef::usage();
00040 arg = 1;
00041 while (argv[arg][0] == '-') {
00042 if (strcmp(argv[arg], "--") == 0) {
00043 windef::usage();
00044 }
00045 else if (strcmp(argv[arg], "-l") == 0) {
00046 arg++;
00047 if (arg == argc) windef::usage();
00048 library = argv[arg];
00049 }
00050 else if (strcmp(argv[arg], "-o") == 0) {
00051 arg++;
00052 if (arg == argc) windef::usage();
00053 outfile = argv[arg];
00054 }
00055 arg++;
00056 }
00057 if (arg == argc) windef::usage();
00058 for (arg; arg < argc; arg++) {
00059 objfiles += argv[arg];
00060 if( arg+1 < argc) objfiles += " ";
00061 }
00062
00063 CLibSymbolInfo libsymbols;
00064 ofstream out(outfile.c_str());
00065 if(out.fail()) {
00066 cerr << "windef: Error opening file " << outfile << endl;
00067 return 1;
00068 }
00069 out << "LIBRARY " << library << endl;
00070 out << "EXPORTS" << endl;
00071
00072 libsymbols.DumpSymbols(const_cast<char*>(objfiles.c_str()), out);
00073
00074 out.close();
00075
00076
00077 return 0;
00078 }
00079
00080
00081