/* */
1 /*===========================================================================
2 Copyright (c) 1998-2000, The Santa Cruz Operation
3 All rights reserved.
4
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7
8 *Redistributions of source code must retain the above copyright notice,
9 this list of conditions and the following disclaimer.
10
11 *Redistributions in binary form must reproduce the above copyright notice,
12 this list of conditions and the following disclaimer in the documentation
13 and/or other materials provided with the distribution.
14
15 *Neither name of The Santa Cruz Operation nor the names of its contributors
16 may be used to endorse or promote products derived from this software
17 without specific prior written permission.
18
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
20 IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
23 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 INTERRUPTION)
27 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
30 DAMAGE.
31 =========================================================================*/
32
33 /* $Id: global-cscope.h,v 1.4 2012/10/13 07:02:06 shigio Exp $ */
34
35 /** @file
36 * global type, data, and function definitions
37 *
38 * cscope - interactive C symbol cross-reference
39 */
40
41 #ifndef CSCOPE_GLOBAL_H
42 #define CSCOPE_GLOBAL_H
43
44 #include "config.h"
45 #include <unistd.h>
46 #include <sys/types.h>
47 #include <ctype.h> /* isalpha, isdigit, etc. */
48 #include <signal.h> /* SIGINT and SIGQUIT */
49 #include <stdio.h> /* standard I/O package */
50 #include <stdlib.h> /* standard library functions */
51
52 /* A special "magic" header file required by HP/Compaq NSK (Non-Stop
53 * Kernel) to present a more Unix-ish environment ... */
54 #ifdef HAVE_FLOSS_H
55 # include <floss.h>
56 #endif
57
58 /* Replace most of the #if BSD stuff. Taken straight from the autoconf
59 * manual, with an extension for handling memset(). */
60 #if STDC_HEADERS
61 # include <string.h> /* string functions */
62 #else
63 # ifndef HAVE_STRCHR
64 # define strchr index
65 # define strrchr rindex
66 # endif
67 char *strchr (), *strrchr ();
68 # ifndef HAVE_MEMCPY
69 # define memcpy(d, s, n) bcopy ((s), (d), (n))
70 # define memmove(d, s, n) bcopy ((s), (d), (n))
71 # endif
72 # ifndef HAVE_MEMSET
73 # ifndef HAVE_MEMORY_H
74 char *memset();
75 # else
76 # include <memory.h> /* memset */
77 # endif /*V9*/
78 # endif /* HAVE_MEMSET */
79 #endif /* STDC_HEADERS */
80
81 #include "constants.h" /* misc. constants */
82 #include "library.h" /* library function return values */
83
84 /* Fallback, in case 'configure' failed to do its part of the job */
85 #ifndef RETSIGTYPE
86 #if SVR2 || BSD && !sun
87 #define RETSIGTYPE int
88 #else
89 #define RETSIGTYPE void
90 #endif
91 #endif /* RETSIGTYPE */
92
93 #ifndef HAVE_SIGHANDLER_T
94 typedef RETSIGTYPE (*sighandler_t)(int);
95 #endif
96
97 /* FIXME: this testing for platforms is foolish. Stop it! */
98 #if BSD
99 # undef tolower /* BSD toupper and tolower don't test the character */
100 # undef toupper
101 # define tolower(c) (isupper(c) ? (c) - 'A' + 'a' : (c))
102 # define toupper(c) (islower(c) ? (c) - 'a' + 'A' : (c))
103 # if !sun
104 # if !__FreeBSD__
105 /* in traditional BSD, *printf() doesn't return the number of bytes
106 * written */
107 # define PRINTF_RETVAL_BROKEN 1
108 # endif /* !FreeBSD */
109 # endif /* !sun */
110 #endif
111
112 /* Un-comment this if you're on a filesystem that doesn't support
113 * filenames longer than 14 characters */
114 /* HBB FIXME 20030302: should have an autoconf test for this: */
115 /* #define SHORT_NAMES_ONLY */
116
117 /* Just in case autoconf didn't correctly flag HAVE_FIXKEYPAD */
118 #ifndef HAVE_FIXKEYPAD
119 # if SVR2 && !BSD && !V9 && !u3b2 && !sun
120 # define HAVE_FIXKEYPAD
121 # endif
122 #endif
123
124 /* HBB 20020728: if <fcntl.h> is there, #include it here, since that's
125 * where the system definitions of O_TEXT should be coming from */
126 #ifdef HAVE_FCNTL_H
127 # include <fcntl.h>
128 #endif
129
130 /* HBB 20020103: Need to force text or binary mode opens on Cygwins,
131 * because of their "binary/text mode mount" silliness :-( */
132 #ifndef O_TEXT
133 # ifdef _O_TEXT
134 # define O_TEXT _O_TEXT
135 # else
136 # define O_TEXT 0x00
137 # endif
138 #endif
139 /* Same for binary mode --- moved here from vp.h */
140 #ifndef O_BINARY
141 # ifdef _O_BINARY
142 # define O_BINARY _O_BINARY
143 # else
144 # define O_BINARY 0x00
145 # endif
146 #endif
147
148 #undef SETMODE
149 #if O_BINARY || O_TEXT
150 /* OK, looks like we are on an MSDOS-ish platform ---> define SETMODE
151 * to actually do something */
152 # ifdef HAVE_SETMODE
153 # define SETMODE(fildes, mode) setmode(fildes,mode)
154 # else
155 # ifdef HAVE__SETMODE
156 # define SETMODE(fildes, mode) _setmode(fildes,mode)
157 # endif
158 # endif
159 #endif
160
161 /* access(2) parameters. Only make assumptions about their values if
162 * <unistd.h> fails to define them. */
163 #ifdef R_OK
164 # define READ R_OK
165 #else
166 # define READ 4
167 #endif
168 #ifdef W_OK
169 # define WRITE W_OK
170 #else
171 # define WRITE 2
172 #endif
173
174 /* This can happen on only vaguely Unix-ish platforms... */
175 #ifndef HAVE_LSTAT
176 # define lstat(file,buf) stat(file,buf)
177 #endif
178
179 typedef enum { /** boolean data type */
180 NO,
181 YES
182 } BOOL;
183
184 typedef enum { /** findinit return code */
185 NOERROR,
186 NOTSYMBOL,
187 REGCMPERROR
188 } FINDINIT;
189
190 typedef struct { /** mouse action */
191 int button;
192 int percent;
193 int x1;
194 int y1;
195 int x2;
196 int y2;
197 } MOUSE;
198
199 struct cmd { /** command history struct */
200 struct cmd *prev, *next; /**< list ptrs */
201 int field; /**< input field number */
202 char *text; /**< input field text */
203 };
204
205 /** @name main.c global data */
206 /** @{ */
207 extern char *editor, *home, *shell, *lineflag; /**< environment variables */
208 extern char *global_command; /**< @FILE{global} by default */
209 extern char *gtags_command; /**< @FILE{gtags} by default */
210 extern char *home; /**< Home directory */
211 extern BOOL lineflagafterfile;
212 extern char *argv0; /**< command name */
213 extern int dispcomponents; /**< file path components to display */
214 #if CCS
215 extern BOOL displayversion; /**< display the C Compilation System version */
216 #endif
217 extern BOOL editallprompt; /**< prompt between editing files */
218 extern BOOL incurses; /**< in @NAME{curses} */
219 extern BOOL isuptodate; /**< consider the crossref up-to-date */
220 extern BOOL linemode; /**< use line oriented user interface */
221 extern BOOL absolutepath; /**< print absolute path name */
222 extern BOOL verbosemode; /**< print extra information on line mode */
223 extern BOOL ogs; /**< display OGS book and subsystem names */
224 extern char *prependpath; /**< prepend path to file names */
225 extern FILE *refsfound; /**< references found file */
226 extern char temp1[]; /**< temporary file name */
227 extern char temp2[]; /**< temporary file name */
228 extern char tempstring[TEMPSTRING_LEN + 1]; /**< global dummy string buffer */
229 extern char *tmpdir; /**< temporary directory */
230 /** @} */
231
232 /** @name command.c global data */
233 /** @{ */
234 extern BOOL caseless; /**< ignore letter case when searching */
235 extern BOOL *change; /**< change this line */
236 extern BOOL changing; /**< changing text */
237 extern int selecting;
238 extern unsigned int curdispline;
239 extern char newpat[]; /**< new pattern */
240 extern char Pattern[]; /**< symbol or text pattern */
241 /** @} */
242
243 /** @name display.c global data */
244 /** @{ */
245 extern int booklen; /**< OGS book name display field length */
246 extern int *displine; /**< screen line of displayed reference */
247 extern unsigned int disprefs; /**< displayed references */
248 extern int fcnlen; /**< function name display field length */
249 extern int field; /**< input field */
250 extern int filelen; /**< file name display field length */
251 extern unsigned fldcolumn; /**< input field column */
252 extern unsigned int mdisprefs; /**< maximum displayed references */
253 extern unsigned int nextline; /**< next line to be shown */
254 extern int numlen; /**< line number display field length */
255 extern unsigned int topline; /**< top line of page */
256 extern int bottomline; /**< bottom line of page */
257 extern long searchcount; /**< count of files searched */
258 extern int subsystemlen; /**< OGS subsystem name display field length */
259 extern unsigned int totallines; /**< total reference lines */
260 extern const char dispchars[]; /**< display chars for jumping to lines */
261 /** @} */
262
263 /** @name mouse.c global data */
264 /** @{ */
265 extern BOOL mouse; /**< mouse interface */
266 /** @} */
267
268 #if UNIXPC
269 extern BOOL unixpcmouse; /**< UNIX PC mouse interface */
270 #endif
271
272 /* cscope functions called from more than one function or between files */
273
274 char *filepath(char *file);
275 char *findcalledby(char *pattern);
276 char *findcalling(char *pattern);
277 char *findallfcns(char *dummy);
278 char *finddef(char *pattern);
279 char *findfile(char *dummy);
280 char *findinclude(char *pattern);
281 char *findsymbol(char *pattern);
282 char *findregexp(char *egreppat);
283 char *findstring(char *pattern);
284 char *pathcomponents(char *path, int components);
285
286 void addcmd(int f, char *s);
287 void addsrcfile(char *path);
288 void askforchar(void);
289 void askforreturn(void);
290 void atchange(void);
291 void atfield(void);
292 void cannotwrite(char *file);
293 void cannotopen(char *file);
294 void clearmsg(void);
295 void clearmsg2(void);
296 void countrefs(void);
297 void crossref(char *srcfile);
298 void dispinit(void);
299 void display(void);
300 void drawscrollbar(int top, int bot);
301 void edit(char *file, char *linenum);
302 void editall(void);
303 void editref(int);
304 void entercurses(void);
305 void exitcurses(void);
306 void findcleanup(void);
307 void freesrclist(void);
308 void freeinclist(void);
309 void freecrossref(void);
310 void freefilelist(void);
311 void help(void);
312 void incfile(char *file, char *type);
313 void includedir(char *_dirname);
314 void initsymtab(void);
315 void makefilelist(void);
316 void mousecleanup(void);
317 void mousemenu(void);
318 void mouseinit(void);
319 void mousereinit(void);
320 void myexit(int sig);
321 void myperror(char *text);
322 void ogsnames(char *file, char **subsystem, char **book);
323 void progress(char *what, long current, long max);
324 void putfilename(char *srcfile);
325 void postmsg(char *msg);
326 void postmsg2(char *msg);
327 void posterr(char *msg,...);
328 void postfatal(const char *msg,...);
329 void putposting(char *term, int type);
330 void fetch_string_from_dbase(char *, size_t);
331 void resetcmd(void);
332 void seekline(unsigned int line);
333 void setfield(void);
334 void shellpath(char *out, int limit, char *in);
335 void sourcedir(char *dirlist);
336 void myungetch(int c);
337 void warning(char *text);
338 void writestring(char *s);
339
340 BOOL command(int commandc);
341 BOOL readrefs(char *filename);
342 BOOL search(void);
343 BOOL writerefsfound(void);
344
345 MOUSE *getmouseaction(char leading_char);
346 struct cmd *currentcmd(void);
347 struct cmd *prevcmd(void);
348 struct cmd *nextcmd(void);
349
350 int egrep(char *file, FILE *output, char *format);
351 int mygetline(char p[], char s[], unsigned size, int firstchar, BOOL iscaseless);
352 int mygetch(void);
353 int execute(char *a, ...);
354
355 #endif /* CSCOPE_GLOBAL_H */
/* */