/* +---------------------- Copyright notice -------------------------------+ */ /* | Copyright (C) 1995, Guy Barrand, LAL Orsay, (barrand@lal.in2p3.fr) | */ /* | Permission to use, copy, modify, and distribute this software | */ /* | and its documentation for any purpose and without fee is hereby | */ /* | granted, provided that the above copyright notice appear in all | */ /* | copies and that both that copyright notice and this permission | */ /* | notice appear in supporting documentation. This software is | */ /* | provided "as is" without express or implied warranty. | */ /* +---------------------- Copyright notice -------------------------------+ */ /* This program is a tool to build .def file used by lib.exe to build the DLL on Windows. It takes the output of a "dumpbin" over an archive library and produces the .def file for this library. For example : DOS> dumpbin /out:tmp /symbols MyLib.arc DOS> obuild_windef.exe MyLib < tmp > MyLib.def Note that obuild_windef is a standalone program that can be easily reconstructed with : DOS> cl /Foobuild_windef.exe obuild_windef.c */ #include #include #include char** GetWords (char*,char*,int*); /*****************************************************************************/ int main ( int aArgn ,char** aArgs ) /*****************************************************************************/ { #define MAX_STRING 2048 char buffer[MAX_STRING+1]; int length; /*EXETYPE WINDOWS\n\ */ printf("\ LIBRARY %s\n\ EXPORTS\n",aArgs[1]); while(1){ if(fgets(buffer,MAX_STRING,stdin)==NULL) return EXIT_FAILURE; /* On some system (NT) editors when saving binary files put \r\n at place of \n ; we then look for \r\n. */ length = strlen(buffer); if( (length>=2) && (buffer[length-2]=='\r') && (buffer[length-1]=='\n') ) { buffer[length-2] = '\0'; length--; length--; } else if((length>=1) && (buffer[length-1]=='\n')) { buffer[length-1] = '\0'; length--; } if(strstr(buffer,"SECT")==NULL) continue; if(strstr(buffer,"External")==NULL) continue; if(strstr(buffer,"??_")!=NULL) { if(strstr(buffer,"operator/=")==NULL) continue; /* Keep operator /= */ } { char** words; int wordn; words = GetWords (buffer," ",&wordn); if(wordn>=8) { int iword = 7; int offset = 0; if(strcmp(words[4],"()")==0) { iword = 7; } else if(strcmp(words[4],"External")==0) { iword = 6; } /* FIXME : in cmt_generator.cxx else return; */ if(words[iword][0]=='_') offset = 1; if( (iword==6) && ( (strstr(buffer,": static")!=NULL) || (strstr(buffer,"(class")!=NULL) ) ){ /* static data members are not DATA */ /* extern objects are not DATA */ printf(" %s\n",words[iword]+offset); } else if(iword==6) { /* DATA */ printf(" %s\tDATA\n",words[iword]+offset); } else { /* code */ printf(" %s\n",words[iword]+offset); } } {int count; for(count=0;count=nline) { nline +=16; list = (char**)realloc(list,nline*sizeof(char*)); if(list==NULL) return NULL; } list[iline] = token; iline++; } token = pos + strlen(a_limiter); } else { /*last word*/ if(*token!='\0') { if(iline>=nline) { nline += 16; list = (char**)realloc(list,nline*sizeof(char*)); if(list==NULL) return NULL; } list[iline] = token; iline++; } break; } } for(count=0;count