-
-
Notifications
You must be signed in to change notification settings - Fork 288
/
main.c
53 lines (43 loc) · 1.37 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/****************************************************************************
*
* MODULE: g.findetc
* AUTHOR(S): William Kyngesburye
* PURPOSE: Searches for GRASS support files
* COPYRIGHT: (C) 2007 by the GRASS Development Team
*
* This program is free software under the GNU General Public
* License (>=v2). Read the file COPYING that comes with GRASS
* for details.
*
*****************************************************************************/
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <grass/gis.h>
#include <grass/glocale.h>
int main(int argc, char *argv[])
{
char name[200];
char *fpath;
struct GModule *module;
struct Option *opt1;
module = G_define_module();
G_add_keyword(_("general"));
G_add_keyword(_("map management"));
G_add_keyword(_("scripts"));
module->description = "Searches for GRASS support files.";
G_gisinit(argv[0]);
/* Define the different options */
opt1 = G_define_option();
opt1->key = "file";
opt1->type = TYPE_STRING;
opt1->required = YES;
opt1->description = "Name of an file or directory";
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
strcpy(name, opt1->answer);
fpath = G_find_etc(name);
if (fpath)
fprintf(stdout, "%s\n", fpath);
exit(fpath ? EXIT_SUCCESS : EXIT_FAILURE);
}