/* * Copyright (C) 1996-1998 Ilya Ryzhenkov (orangy@inetlab.com) */ #include "helpdefs.h" #include "dlmstr.h" static char *Copyright="Copyright (C) 1996-1998 Ilya Ryzhenkov (orangy@inetlab.com)"; int Argc; char **Argv,*token; char *infile=0,*ename=0,*ecname=0,*dump=0,*cname=0,*sexpr=0,*stub; char wr=0,*exp=0,*dumpexp=0,*dumpimp=0,*dumpexpdlm=0,*dallst=0,*dalout=0; char quite=0; int exist(const char *fname) { return __file_exists(fname); } int valid(const char *fname) { int h=open(fname, O_RDONLY | O_CREAT, S_IWUSR | S_IRUSR); if (h==-1) return 0; close(h); return 1; } void next_screen() { puts("\n Press any key for next screen of help."); getchar(); } void Usage() { puts("\nDLM Manager (c)1996 by Ilya P. Ryzhenkov"); puts("DLMMAN [-option, ...]"); puts(" -q print only fatal messages"); puts(" -e create executable from given DLM"); puts(" -ec create executable from given obj"); puts(" -d dump DLM structure to "); puts(" -dx generate list of import symbols"); puts(" -di generate list of export symbols"); puts(" -da append list of export with DLM name to file"); puts(" -dl [,] generate DAL - list of needed DLMs"); puts(" uses DLM's import and file as input data"); puts(" -c convert object file to DLM"); puts(" -s = add extra symbol to DLM with the contents of file"); puts(" -rs remove extra symbol"); puts(" -a use alternate stubfile"); puts(" -l |<&dalname> add an Auto-Load DLM"); puts(" & at begining of filename means file contains list"); puts(" -rl remove an Auto-Load DLM"); puts(" -u use export list file instead of implicit rules"); next_screen(); puts("\nIf name is not specified, output file name will be the same as input with"); puts("the following extensions for the options :"); puts(" .DLM for -c and -s"); puts(" .EXE for -ec and -e"); puts(" .DMP for -d"); puts(" .EXP for -u and -dx"); puts(" .IMP for -di"); puts(" .LST for -da"); puts(" .DAL for -dl (DAL stands for Dlm Autoload List)"); puts("\nExamples :"); puts(" DLMMAN test.dlm -e test.exe -s _txt=t.txt"); puts(" - Create test.exe from test.dlm with added symbol '_txt'"); puts(" which has content of file 't.txt'"); puts(" Leading underscore must be present in symbol name"); puts(" DLMMAN test.o -ec test.exe -c test.dlm -a altsub.exe"); puts(" - Create both test.exe and test.dlm from object file"); puts(" test.o, using 'altstub.exe' as stub for test.exe"); puts(""); puts(" To contact author : e-mail to ilya@spy.isp.nsc.ru"); exit(1); } void Errf(char *fmt,char *s) { printf(fmt,s); puts("\nRun DLMMAN without parameters for help."); exit(1); } void Err(char *fmt) { printf(fmt); puts("\nRun DLMMAN without parameters for help."); exit(1); } char *DupFilename(char *filename, char *newext) { char *file; int x; //file=(char*)malloc(strlen(filename)+1); file=strdup(filename); x=strrchr(file,'.')-file; // index of last dot file=(char*)realloc(file,x+strlen(newext)+3); strcpy(file+x+1,newext); file[x+strlen(newext)+1]=0; return file; } int CheckIdent(char *name) { if (!name) return 0; else if (*name!='_') printf("Warning! No initial underscore for symbol '%s'\n",name); if (!name[strspn(name, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789$" )]) return 1; else return 0; } #define PARM(str) if (!strcmp(Argv[i],str)) void ParseParm() { int i; if (Argv[1][0]=='-') Err("Input file name missed\n"); else if (!exist(Argv[1])) Errf("Illegal input file name '%s'\n",Argv[1]); else infile=strdup(Argv[1]); for (i=2; ifilename=cname; else dlm->filename=infile; ProcessExpressions(dlm); if (exp) { if (!quite) printf("Updating EXPORT information...\n"); UpdateExport(dlm,exp); wr=1; } if (dump) { if (!quite) printf("Dumping DLM information ...\n"); DumpDlm(dlm,dump); } if (dumpexp) { if (!quite) printf("Dumping EXPORT information ...\n"); DumpExport(dlm,dumpexp); } if (dumpexpdlm) { if (!quite) printf("Dumping EXPORT information with DLM name ...\n"); DumpExportWithDLM(dlm,dumpexpdlm); } if (dallst) { if (!quite) printf("Generating DLM Autoload List (DAL) ...\n"); GenerateDAL(dlm,dalout,dallst); } if (dumpimp) { if (!quite) printf("Dumping IMPORT information ...\n"); DumpImport(dlm,dumpimp); } if (cname) { if (!quite) printf("Writing DLM file '%s' ...\n",cname); WriteDlm(dlm,cname,0); } if (ename) { if (!quite) printf("Writing EXE file '%s' ...\n",ename); MakeExe(dlm,ename,stub); } if (wr && !cname && !ename) { if (!quite) printf("Writing DLM file '%s' ...\n",infile); WriteDlm(dlm,infile,0); } return 0; }