/* */
This source file includes following definitions.
- defined
1 /*
2 * Copyright (c) 1998, 1999, 2000, 2001
3 * Tama Communications Corporation
4 *
5 * This file is part of GNU GLOBAL.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #ifdef HAVE_CONFIG_H
22 #include <config.h>
23 #endif
24 #ifdef STDC_HEADERS
25 #include <stdlib.h>
26 #endif
27
28 #include "die.h"
29 #include "dbop.h"
30 #include "defined.h"
31 #include "makepath.h"
32
33 static DBOP *dbop = NULL;
34
35 /**
36 * Tag command that supports referenced tag must call this function
37 * to decide whether or not the tag is defined.
38 */
39 int
40 defined(const char *name)
41 {
42 if (dbop == NULL) {
43 const char *dbpath;
44
45 /*
46 * gtags(1) set GTAGSDBPATH to the path GTAGS exist.
47 */
48 if (!(dbpath = getenv("GTAGSDBPATH")))
49 dbpath = ".";
50 dbop = dbop_open(makepath(dbpath, "GTAGS", NULL), 0, 0, 0);
51 if (dbop == NULL)
52 die("'GTAGS' not found.");
53 }
54 if (dbop_get(dbop, name))
55 return 1;
56 return 0;
57 }
/* */