1 /***************************************
4 C Cross Referencing & Documentation tool. Version 1.4.
5 ******************/ /******************
6 Written by Andrew M. Bishop
8 This file Copyright 1995,96 Andrew M. Bishop
9 It may be distributed under the GNU Public License, version 2, or
10 any higher version. See section COPYING of the GNU Public license
11 for conditions under which this file may be redistributed.
12 ***************************************/
18 #include "../memory.h"
19 #include "../datatype.h"
23 /*+ The command line switch that sets the amount of cross referencing to do. +*/
26 /*+ The command line switch for the output name, +*/
27 char *option_odir
=".", /*+ The directory to use. +*/
28 *option_name
="cxref"; /*+ The base part of the name. +*/
30 File
*files
=NULL
; /*+ The files that are queried. +*/
31 int n_files
=0; /*+ The number of files referenced. +*/
33 Function
*functions
=NULL
; /*+ The functions that are queried. +*/
34 int n_functions
=0; /*+ The number of functions referenced. +*/
36 Variable
*variables
=NULL
; /*+ The variables that are queried. +*/
37 int n_variables
=0; /*+ The number of variables referenced. +*/
39 Typedef
*typedefs
=NULL
; /*+ The type definitions that are queried. +*/
40 int n_typedefs
=0; /*+ The number of typedefs referenced. +*/
43 /*++++++++++++++++++++++++++++++++++++++
44 The main function that does it all.
46 int main Returns the status, zero for normal termination, else an error.
48 int argc The command line number of arguments.
50 char** argv The actual command line arguments
51 ++++++++++++++++++++++++++++++++++++++*/
53 int main(int argc
,char** argv
)
59 fputs("Usage: cxref-query [name [ ... name]] ; Names of objects to query.\n"
60 " [-Odirname] ; Use dirname as the input directory\n"
61 " [-Nbasename] ; Use basename.* as the input filenames\n"
62 " [-xref[-all][-file][-func][-var][-type]] ; Use cross reference files (default -xref-all).\n"
69 if(!strncmp(argv
[i
],"-O",2))
75 {fprintf(stderr
,"cxref-query: The -O option requires a following argument.\n");return(1);}
79 option_odir
=&argv
[i
][2];
84 if(!strncmp(argv
[i
],"-N",2))
90 {fprintf(stderr
,"cxref-query: The -N option requires a following argument.\n");return(1);}
94 option_name
=&argv
[i
][2];
99 if(!strncmp(argv
[i
],"-xref",5))
104 option_xref
=XREF_ALL
;
108 if(!strncmp(p
,"-all" ,4)) {option_xref
|=XREF_ALL
; p
=&p
[4]; continue;}
109 if(!strncmp(p
,"-file",5)) {option_xref
|=XREF_FILE
; p
=&p
[5]; continue;}
110 if(!strncmp(p
,"-func",5)) {option_xref
|=XREF_FUNC
; p
=&p
[5]; continue;}
111 if(!strncmp(p
,"-var" ,4)) {option_xref
|=XREF_VAR
; p
=&p
[4]; continue;}
112 if(!strncmp(p
,"-type",5)) {option_xref
|=XREF_TYPE
; p
=&p
[5]; continue;}
115 argv
[i
]=NULL
;continue;
119 if(!strncmp(argv
[i
],"./",2))
130 printf("cxref-query> %s\n\n",argv
[i
]);
131 OutputCrossRef(argv
[i
]);
139 printf("cxref-query> ");
140 if(!fgets(input
,128,stdin
))
141 {printf("\n\n");break;}
144 input
[strlen(input
)-1]=0;
145 OutputCrossRef(input
);
149 PrintMemoryStatistics();