4 * Entry point and things for the DLL Binder
6 * © 1994-1998 Straylight
9 /*----- Licensing note ----------------------------------------------------*
11 * This file is part of Straylight's Dynamic Linking System (SDLS)
13 * SDLS is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2, or (at your option)
18 * SDLS is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with SDLS. If not, write to the Free Software Foundation,
25 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
34 #include "hashtable.h"
43 static void cdll_readSymbols(char *p,void *handle)
48 static void cdll_writeName(char *p,void *handle)
51 fprintf(fp," %s\n",p);
54 static void cdll_notsubset(char *p)
59 int main(int argc,char *argv[])
73 char *deffile=0; /* Name of definition file */
74 char *stubfile=0; /* Name of stublib file */
75 char *bindfile=0; /* Name of binding file */
76 char *extfile=0; /* Name of external veneer file */
77 char *dllfile=0; /* Name of DLL file to use */
78 int helped=0; /* Have we given help? */
79 hashtable objfiles; /* Names of objects specified */
80 hashtable symbols; /* Symbols defined in deffile */
81 hashtable objsym; /* Symbols defined in objects */
82 hashtable veneered; /* Private symbols to veneer */
83 int createdef=0; /* Do we create the def file? */
84 int whatnext=DEF; /* What thing do we read next */
85 int override=NOWT; /* What was the override tag? */
86 int done=NOWT; /* What things we've done */
87 int i; /* Loop counter */
88 int process=1; /* Do we process this time? */
89 int apptbl=0; /* Is this for app extension? */
91 error_setProgName(argv[0]); /* Set up the program name */
93 objfiles=hash_create();
94 symbols=hash_create();
95 veneered=hash_create();
97 if (!objfiles || !symbols || !objsym)
102 if (!cistrcmp(argv[i],"-help"))
108 "Straylight Dynamic Link Library building system\n"
114 " For a reminder of command syntax:\n"
117 " To create a definition file from object files:\n"
118 " %s [[-def] <deffile>] -obj <objfile> [<objfile>]...\n"
120 " To create stub libraries and DLL headers:\n"
121 " %s [[-def] <deffile>] [[-stub] <stublib>] [[-hdr] <header>]\n"
122 " [-file <dllpath>]\n"
124 " To create application entry tables and extension stubs:\n"
125 " %s -app [[-def] <deffile>] [[-stub] <stublib>] [[-hdr] <header>]\n"
127 " To create external function entry points for module tasks:\n"
128 " %s [[-def] <deffile>] [-ext <extstub>]\n"
130 " All option switches may be abbreviated to single characters except\n"
144 else if (argv[i][0]=='-') /* Is it an option tag? */
146 switch (argv[i][1]) /* Find second character */
170 error(BADTAG,argv[i]);
175 error(DUPOPT,argv[i]);
182 switch (override==NOWT ? whatnext : override)
185 error(SILLYOPT,argv[i]);
228 if (bindfile || stubfile)
240 if (!hash_add(objfiles,argv[i]))
255 else if (!(done & STUB))
257 else if (!(done & BINDING))
268 if (!createdef && !bindfile && !stubfile && !extfile && !helped)
277 FILE *fp=fopen(deffile,"w");
279 error(NOOPENOUT,deffile);
282 hash_enumerate(objfiles,cdll_readSymbols,objsym);
284 "; cdll definition file for <name>\n"
289 " author \"<author>\"\n"
291 "; --- Exported symbols ---\n"
295 hash_enumerate(objsym,cdll_writeName,fp);
298 "; --- Object files ---\n"
302 hash_enumerate(objfiles,cdll_writeName,fp);
316 hash_enumerate(objfiles,cdll_readSymbols,objsym);
317 hash_subset(objsym,symbols,cdll_notsubset);
318 hash_subset(objsym,veneered,cdll_notsubset);
320 binding(bindfile,&i,objsym);
322 cstub(stubfile,&i,objsym);
324 extentry(extfile,&i,objsym);
327 return (error_returnCode());