This is docgen.c in view mode; [Download] [Up]
/* docgen Objective C Document Generator Copyright (C) 1995 Bill Bereza. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Email: berezaw@river.it.gvsu.edu S-mail: Bill Bereza 9526 Judson Rd. Ravenna, MI 49451-9427 */ /* docgen Objective C Document Generator * Copyright (c) 1994 Bill Bereza * * $Log: docgen.c,v $ * Revision 1.28 96/01/07 01:28:05 berezaw * debugging output for fgetpos status * * Revision 1.27 95/07/26 22:52:19 berezaw * *** empty log message *** * * Revision 1.26 95/07/26 21:46:14 berezaw * *** empty log message *** * * Revision 1.25 95/07/26 17:50:16 berezaw * *** empty log message *** * * Revision 1.24 95/07/26 16:17:23 berezaw * 0.3.1 * * Revision 1.23 95/07/23 19:24:59 berezaw * add kludges * * Revision 1.22 95/07/23 16:31:53 berezaw * *** empty log message *** * * Revision 1.21 95/07/23 15:49:13 berezaw * using objc_loadModules * * Revision 1.20 95/07/23 14:38:14 berezaw * *** empty log message *** * * Revision 1.19 95/07/23 14:33:19 berezaw * added NXBundle stuff * * Revision 1.18 95/07/23 02:31:05 berezaw * adding dynamic module loading for Formatting Classes * * Revision 1.17 95/07/23 01:20:48 berezaw * in the last few version I've been trying to get objc_lookUpClass to * work with the NeXT runtime and the GNU runtime. * * There still may be problems, esp. with the fact that * the Class type is different on NeXT and GNU * and that the class lookup seems to work a little * differently on the two runtimes. * * This version of docgen.c or the very next should work perfectly. * * Now I need to add the dynamic loading for both runtimes. * * Revision 1.10 95/07/21 01:58:23 berezaw * added ObjC stuff * * Revision 1.9 95/03/02 03:44:39 berezaw * using GNU regex library * rewrote recmp() as docgen_recmp() * added GPL stuff to each file * increase rev. to 0.1.9 * * Revision 1.8 95/02/01 18:49:47 berezaw * * 0.1.6 * * Revision 1.7 95/01/31 18:28:33 berezaw * * added 0.1.5 stuff * * Revision 1.6 95/01/30 13:32:07 berezaw * added -F * * Revision 1.5 95/01/29 01:50:18 berezaw * changes started for 0.1.4 * * Revision 1.4 95/01/27 00:31:19 berezaw * added '-x' option to hide methods beginning with '_' * * Revision 1.3 95/01/26 05:34:29 berezaw * added global variables GLOB_decdir and GLOB_sort * * * $Id: docgen.c,v 1.28 96/01/07 01:28:05 berezaw Exp $ */ #include "docgen.h" #ifdef OBJC #ifdef HAVE_OBJC_OBJC_RUNTIME_H #ifdef HAVE_OBJC_OBJC_LOAD_H #define NXMODULES #define DYNAMIC_LOADING #import <objc/objc-load.h> #define BUNEXT "o" #endif /* HAVE_OBJC_OBC_LOAD_H */ #include <objc/objc-runtime.h> #else #ifdef HAVE_OBJC_OBJC_API_H #include <objc/objc-api.h> #define objc_lookUpClass(name) objc_lookup_class(name) #endif /* HAVE_OBJC_OBJC_API_H */ #endif /* HAVE_OBJC_OBJC_RUNTIME_H */ #endif /* OBJC */ #define USING "%-15s: %s\n%-15s: %s\n%-15s: %s\n%-15s: %d\n%-15s: %s\n%-15s: %d\n",\ "checkdir",checkdir, "outlib",outlib, "hdir",hdir, "verbo",verbo, "GLOB_sep",GLOB_sep,\ "GLOB_recurs",GLOB_recurs int verbo=DEFVERBO; bool GLOB_recurs=DEFRECURS, GLOB_defaults=no; char *GLOB_sep=NULL; char *GLOB_decdir=NULL; bool GLOB_sort=no; bool GLOB_undoc=no; DSTRING *GLOB_istring=NULL; bool GLOB_fancy=yes; bool GLOB_firstcomm=no; bool GLOB_autodoc=no; bool GLOB_before=no; bool GLOB_after=no; #ifdef OBJC id myForm; #endif #define cat(x,y) x ## y #define xcat(x,y) cat(x,y) int main(int argc, char *argv[]) { id kludge1, kludge2, kludge3; char *checkdir, *outlib, *hdir, *formatName, *userBundir; char defdir[]=DEFSTARTDIR, deflib[]=DEFODIR, defhdirs[]=DEFISEARCH; char defsep[]=DEFSEP; char defform[]=DEFFORMAT; DSTRING *dhdir=NULL; char *bunPath[]=DEFBUNDLES; #ifdef MALLOC_DEBUG malloc_debug(8); #endif kludge1=[[RTFFormatter alloc] init]; kludge2=[[HTMLFormatter alloc] init]; kludge3=[[TXTFormatter alloc] init]; /* The two if statements before getdocopts() will depend on DEFVERBO */ #ifndef NODEBUG if(V_USELESS) fprintf(stderr,"main(%d, char *argv[])\n", argc); if(V_USELESS) fprintf(stderr,"about to getopt\n"); #endif if(getdocopts(argc, argv, &checkdir, &outlib, &hdir, &formatName, &userBundir)) { fprintf(stderr, USAGE); exit(2); } #ifndef NODEBUG if(V_USELESS) fprintf(stderr,"gotopt\n"); #endif if(GLOB_defaults) { /* print out some useful values and exit */ fprintf(stderr,"\t#define DOCGEN_VERSION \"%s\"\n\n",DOCGEN_VERSION); fprintf(stderr,"docgen.o compiled on: %s %s\n",__TIME__, __DATE__); #ifdef HAVE_CONFIG_H fprintf(stderr,"Compiled with a config.h file.\n"); #endif #ifdef STDC_HEADERS fprintf(stderr,"Compiled using the standard C headers.\n"); #endif #ifdef HAVE_STRSTR fprintf(stderr,"Using standard strstr() function.\n"); #else fprintf(stderr,"Using a custom strstr() function.\n"); #endif #ifdef HAVE_GETOPT fprintf(stderr,"Using standard getopt() function.\n"); #else fprintf(stderr,"Using a custom getopt() function.\n"); #endif #ifdef HAVE_FGETPOS fprintf(stderr,"Using standard fgetpos() function.\n"); #else fprintf(stderr,"Using a custom fgetpos() function.\n"); #endif #if HAVE_DIRENT_H fprintf(stderr,"Using <dirent.h>.\nNAMLEN is #define'd as 'NAMELEN(dirent) strlen((dirent)->d_name)\n"); #else fprintf(stderr,"<dirent.h> was not available.\ndirent is #define'd as direct.\nNAMLEN is #define'd as NAMELEN(dirent) (dirent)->d_namelen.\n"); # if HAVE_SYS_NDIR_H fprintf(stderr,"Using <sys/ndir.h>\n"); # endif # if HAVE_SYS_DIR_H fprintf(stderr,"Using <sys/dir.h>\n"); # endif # if HAVE_NDIR_H fprintf(stderr,"Using <ndir.h>\n"); # endif #endif #ifdef HAVE_BSD_LIBC_H fprintf(stderr,"Compiled with <bsd/libc.h> available.\n"); #endif #ifdef HAVE_UNISTD_H fprintf(stderr,"Compiled with <unistd.h> available.\n"); #endif #ifdef HAVE_OBJC_OBJECT_H fprintf(stderr,"<objc/Object.h> was available.\nWe assume this means that Objective C was used.\nMultiple document output formats are available.\n"); #endif #ifdef HAVE_OBJC_OBJC_RUNTIME_H fprintf(stderr,"<objc/objc-runtime.h> was available for objc_lookUpClass().\n"); #else #ifdef HAVE_OBJC_OBJC_API_H fprintf(stderr,"No <objc/objc-runtime.h> available. \nWe're using <objc/objc-api.h> from GNU ObjC.\nobjc_lookUpClass() is #define'd as objc_lookup_class().\n"); #endif #endif /* HAVE_OBJC_OBJC_RUNTIME_H */ #ifdef HAVE_OBJC_OBJC_LOAD_H fprintf(stderr,"<objc/objc-load.h was available for objc_loadModules().\n"); #endif #ifdef DYNAMIC_LOADING fprintf(stderr,"Dynamic loading of modules is available from "); #ifdef NXMODULES fprintf(stderr,"NeXT runtime functions.\n"); #endif #else fprintf(stderr,"Dynamic loading is NOT available.\n"); #endif /* DYNAMIC_LOADING */ #ifdef NODEBUG fprintf(stderr,"\t#define NODEBUG \t/* Debugging output has been compiled out. */\n"); #else fprintf(stderr,"Debugging output is available.\n"); #endif fprintf(stderr,"[-d]\t#define DEFSTARTDIR \"%s\"\n", DEFSTARTDIR); fprintf(stderr,"[-l]\t#define DEFODIR \"%s\"\n", DEFODIR); fprintf(stderr,"[-I]\t#define DEFISEARCH \"%s\"\n", DEFISEARCH); fprintf(stderr,"[-v]\t#define DEFVERBO %d\n", DEFVERBO); #if DEFRECURS==no fprintf(stderr,"[-R]\t#define DEFRECURS no\n"); #else fprintf(stderr,"[-R]\t#define DEFRECURS yes\n"); #endif fprintf(stderr,"[-s]\t#define DEFSEP \"%s\"\n", DEFSEP); fprintf(stderr," \t#define DEFITAL \"%s\"\n", DEFITAL); exit(0); } if(!formatName) formatName=defform; #ifdef OBJC { char extra[strlen(formatName)+15]; id Format=[objc_lookUpClass(formatName) class]; sprintf(extra,"%sFormatter", formatName); /* Try adding 'Formatter' to the name */ if(!Format) { Format=[objc_lookUpClass(extra) class]; } #ifdef NXMODULES /* Try loading a bundle. */ if(!Format) { char *bunDir; char bPath[2048]; char *mods[]={bPath,NULL}; long loadRet=1; int bunCount=0; if(userBundir) { bunDir=userBundir; sprintf(bPath,"%s/%s.%s",bunDir, formatName, BUNEXT); loadRet=objc_loadModules(mods,NULL,NULL,NULL,NULL); if(loadRet) { sprintf(bPath,"%s/%s.%s",bunDir,extra, BUNEXT); loadRet=objc_loadModules(mods,NULL,NULL,NULL,NULL); } if(loadRet) { sprintf(bPath,"%s/%s",bunDir,formatName); loadRet=objc_loadModules(mods,NULL,NULL,NULL,NULL); } if(loadRet) { sprintf(bPath,"%s/%s",bunDir,extra); loadRet=objc_loadModules(mods,NULL,NULL,NULL,NULL); } } bunDir=bunPath[bunCount]; while(loadRet && bunDir) { sprintf(bPath,"%s/%s.%s",bunDir, formatName, BUNEXT); loadRet=objc_loadModules(mods,NULL,NULL,NULL,NULL); if(loadRet) { sprintf(bPath,"%s/%s.%s",bunDir,extra, BUNEXT); loadRet=objc_loadModules(mods,NULL,NULL,NULL,NULL); } if(loadRet) { sprintf(bPath,"%s/%s",bunDir,formatName); loadRet=objc_loadModules(mods,NULL,NULL,NULL,NULL); } if(loadRet) { sprintf(bPath,"%s/%s",bunDir,extra); loadRet=objc_loadModules(mods,NULL,NULL,NULL,NULL); } bunCount++; bunDir=bunPath[bunCount]; } Format=objc_lookUpClass(formatName); if(!Format) Format=objc_lookUpClass(extra); } /* We don't care if Format is nil at this point. It will be caught below. */ #endif /* NXMODULES */ if([[Format class] conformsTo:@protocol(Formatting)]) myForm=[[[Format class] alloc] init]; else { if(V_BADERR) if(Format) fprintf(stderr,"docgen:%s is not a conforming Formatting class\n",formatName); else fprintf(stderr,"docgen:%s is not available as a Class\n",formatName); exit(2); } } #endif /* OBJC */ if(checkdir==NULL) checkdir=defdir; if(outlib==NULL) outlib=deflib; if(GLOB_sep==NULL) GLOB_sep=defsep; dhdir=dstrarr(checkdir); if(hdir==NULL) { hdir=defhdirs; dstrarrcat(dhdir,":"); dstrarrcat(dhdir,hdir); } else { dstrarrcat(dhdir,":"); dstrarrcat(dhdir,hdir); dstrarrcat(dhdir,":"); dstrarrcat(dhdir,defhdirs); } hdir=arrdstr(dhdir); freedstr(dhdir); if(V_STAT) fprintf(stderr, USING); #ifndef NODEBUG if(V_USELESS) fprintf(stderr, "about to walk the dirs\n"); #endif dirwalk(checkdir, procfile, outlib, hdir); free(hdir); #ifdef OBJC [myForm free]; #endif #ifndef NODEBUG if(V_USELESS) fprintf(stderr, "main: exiting\n\nHave a good day.\n"); #endif exit(0); }
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.