GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ask_cell.c
Go to the documentation of this file.
1 /*
2  *************************************************************************
3  * char *
4  * G_ask_cell_new(prompt, name))
5  * asks user to input name of a new cell file
6  *
7  * char *
8  * G_ask_cell_old(prompt, name)
9  * asks user to input name of an existing cell file
10  *
11  * char *
12  * G_ask_cell_in_mapset(prompt, name)
13  * asks user to input name of an existing cell file in current mapset
14  *
15  * char *
16  * G_ask_cell_any(prompt, name)
17  * asks user to input name of a new or existing cell file in
18  * the current mapset. Warns user about (possible) overwrite
19  * if cell file already exists
20  *
21  * parms:
22  * const char *prompt optional prompt for user
23  * char *name buffer to hold name of map found
24  *
25  * returns:
26  * char *pointer to a string with name of mapset
27  * where file was found, or NULL if not found
28  *
29  * note:
30  * rejects all names that begin with .
31  **********************************************************************/
32 #include <stdlib.h>
33 #include <string.h>
34 #include <grass/gis.h>
35 #include <grass/glocale.h>
36 
37 static int lister(char *, char *, char *);
38 
39 
51 char *G_ask_cell_new(const char *prompt, char *name)
52 {
53 
54  return G_ask_new_ext(prompt, name, "cell", "raster", _("with titles"),
55  lister);
56 }
57 
58 
70 char *G_ask_cell_old(const char *prompt, char *name)
71 {
72  return G_ask_old_ext(prompt, name, "cell", "raster", _("with titles"),
73  lister);
74 }
75 
76 
88 char *G_ask_cell_in_mapset(const char *prompt, char *name)
89 {
90  return G_ask_in_mapset_ext(prompt, name, "cell", "raster",
91  _("with titles"), lister);
92 }
93 
94 char *G_ask_cell_any(const char *prompt, char *name)
95 {
96  return G_ask_any_ext(prompt, name, "cell", "raster", 1, _("with titles"),
97  lister);
98 }
99 
100 static int lister(char *name, char *mapset, char *buf)
101 {
102  char *title;
103 
104  *buf = 0;
105  if (*name == 0)
106  return 0;
107 
108  strcpy(buf, title = G_get_cell_title(name, mapset));
109  if (*buf == 0)
110  strcpy(buf, _("(no title)"));
111  G_free(title);
112 
113  return 0;
114 }
void G_free(void *buf)
Free allocated memory.
Definition: gis/alloc.c:142
char * G_get_cell_title(const char *name, const char *mapset)
get raster map title
Definition: cell_title.c:27
char * G_ask_cell_any(const char *prompt, char *name)
Definition: ask_cell.c:94
string name
Definition: render.py:1314
char * G_ask_cell_in_mapset(const char *prompt, char *name)
prompt for existing raster map
Definition: ask_cell.c:88
char * G_ask_old_ext(const char *prompt, char *name, char *element, char *desc, char *option, int(*lister)())
Definition: ask.c:166
char * G_ask_cell_old(const char *prompt, char *name)
prompt for existing raster map
Definition: ask_cell.c:70
char * G_ask_cell_new(const char *prompt, char *name)
prompt for new raster map
Definition: ask_cell.c:51
char buf[GNAME_MAX+sizeof(G3D_DIRECTORY)+2]
Definition: g3drange.c:62
char * G_ask_in_mapset_ext(const char *prompt, char *name, char *element, char *desc, char *option, int(*lister)())
Definition: ask.c:228
char * G_ask_any_ext(const char *prompt, char *name, char *element, char *desc, int warn, char *option, int(*lister)())
Definition: ask.c:197
char * G_ask_new_ext(const char *prompt, char *name, char *element, char *desc, char *option, int(*lister)())
Definition: ask.c:137