86 #include <grass/gis.h> 
   87 #include <grass/glocale.h> 
  107 static char *ask_return_msg = 0;
 
  108 static char clear_return_msg = 0;
 
  109 static int (*no_lister) () = 0;
 
  110 static int parselist(
const char *, 
int, 
char *);
 
  111 static char *ask(
const char *, 
char *, 
char *, 
char *, 
char *, 
int (*)(),
 
  134     return ask(prompt, name, element, desc, (
char *)
NULL, no_lister, 
NEW);
 
  138                     char *option, 
int (*lister) ())
 
  140     return ask(prompt, name, element, desc, option, lister, 
NEW);
 
  161 char *
G_ask_old(
const char *prompt, 
char *name, 
char *element, 
char *desc)
 
  163     return ask(prompt, name, element, desc, (
char *)
NULL, no_lister, 
OLD);
 
  166 char *
G_ask_old_ext(
const char *prompt, 
char *name, 
char *element, 
char *desc,
 
  167                     char *option, 
int (*lister) ())
 
  169     return ask(prompt, name, element, desc, option, lister, 
OLD);
 
  190 char *
G_ask_any(
const char *prompt, 
char *name, 
char *element, 
char *desc,
 
  193     return ask(prompt, name, element, desc, (
char *)
NULL, no_lister,
 
  197 char *
G_ask_any_ext(
const char *prompt, 
char *name, 
char *element, 
char *desc,
 
  198                     int warn, 
char *option, 
int (*lister) ())
 
  200     return ask(prompt, name, element, desc, option, lister,
 
  225     return ask(prompt, name, element, desc, (
char *)
NULL, no_lister, 
PRJ);
 
  229                           char *desc, 
char *option, 
int (*lister) ())
 
  231     return ask(prompt, name, element, desc, option, lister, 
PRJ);
 
  251     return ask(prompt, name, element, desc, (
char *)
NULL, no_lister,
 
  286     return ask(prompt, name, element, desc, (
char *)
NULL, no_lister,
 
  321     clear_return_msg = 0;
 
  339     static char none[80];
 
  341     strcpy(none, _(
"to cancel request"));
 
  342     return (ask_return_msg == 
NULL ? none : ask_return_msg);
 
  345 static char *ask(
const char *prompt,
 
  348                  char *desc, 
char *option, 
int (*lister) (), 
int type)
 
  350     char tmapset[GMAPSET_MAX];
 
  352     int name_is_qualified;
 
  363     if (clear_return_msg) {
 
  367     clear_return_msg = ask_return_msg ? 1 : 0;
 
  370     if (lister && (option == 0 || *option == 0))
 
  380     if (desc == 0 || *desc == 0)
 
  386     if (prompt == 0 || *prompt == 0) {
 
  390             sprintf(tprompt, _(
"Enter a new %s file name"), desc);
 
  396             sprintf(tprompt, _(
"Enter the name of an existing %s file"),
 
  401             sprintf(tprompt, _(
"Enter %s file name"), desc);
 
  417             fprintf(stderr, 
"\n%s\n", prompt);
 
  421                         _(
"Enter 'list' for a list of existing %s files\n"),
 
  424                 fprintf(stderr, _(
"Enter 'list -f' for "));
 
  425                 if (option && *option)
 
  426                     fprintf(stderr, _(
"a list %s"), option);
 
  428                     fprintf(stderr, _(
"an extended list"));
 
  429                 fprintf(stderr, 
"\n");
 
  433             fprintf(stderr, 
"> ");
 
  438         fprintf(stderr, 
"<%s>\n", input);
 
  450             exist = (access(input, 0) == 0);
 
  452                 fprintf(stderr, _(
"\n** %s - not found **\n"), input);
 
  459                         _(
"\n** %s exists. ok to overwrite? "), input);
 
  460                 if (!
G_yes(question, 0))
 
  478         switch (parselist(input, lister ? 1 : 0, tmapset)) {
 
  496             fprintf(stderr, 
"** illegal request **\n");
 
  500         if ((name_is_qualified =
 
  506             fprintf(stderr, _(
"\n**<%s> illegal name **\n"), input);
 
  516             if (name_is_qualified) {
 
  517                 if (strcmp(cur_mapset, xmapset) != 0) {
 
  518                     fprintf(stderr, _(
"\n** %s - illegal request **\n"),
 
  522                 strcpy(input, xname);
 
  533                         _(
"\n** %s - exists, select another name **\n"),
 
  540                 if (mapset && type == 
ANY) {
 
  544                             _(
"\n** %s exists. ok to overwrite? "), input);
 
  545                     if (!
G_yes(question, 0))
 
  557                 fprintf(stderr, _(
"\n** %s - not found **\n"), input);
 
  571                 if (name_is_qualified)
 
  577             fprintf(stderr, _(
"\n** %s - not found **\n"), input);
 
  584 static int parselist(
const char *input, 
int option, 
char *mapset)
 
  586     char list[GNAME_MAX];
 
  587     char f1[GMAPSET_MAX];
 
  588     char f2[GMAPSET_MAX];
 
  589     char f3[GMAPSET_MAX];
 
  592     *list = *f1 = *f2 = 0;
 
  593     count = sscanf(input, 
"%s%s%s%s", list, f1, f2, f3);
 
  596     if (strcmp(list, 
"list") != 0)
 
  607         if (f1[1] == 0 || f1[1] != 
'f' || f1[2] != 0)
 
char * G_mapset(void)
current mapset name 
 
sprintf(buf2,"%s", G3D_CATS_ELEMENT)
 
void G_free(void *buf)
Free allocated memory. 
 
char * G_store(const char *s)
Copy string to allocated memory. 
 
int G_yes(const char *question, int dflt)
Ask a yes/no question. 
 
char * G_ask_in_mapset(const char *prompt, char *name, char *element, char *desc)
prompt for existing database file 
 
int G_set_ask_return_msg(const char *msg)
set Hit RETURN msg 
 
char * G_get_ask_return_msg()
get Hit RETURN msg 
 
char * G_ask_new(const char *prompt, char *name, char *element, char *desc)
prompt for new database file 
 
char * G_ask_old_ext(const char *prompt, char *name, char *element, char *desc, char *option, int(*lister)())
 
int G_list_element(const char *element, const char *desc, const char *mapset, int(*lister)(const char *, const char *, const char *))
General purpose list function. 
 
char * G_ask_old(const char *prompt, char *name, char *element, char *desc)
prompt for existing database file 
 
int G_strip(char *buf)
Removes all leading and trailing white space from string. 
 
char * G_ask_any(const char *prompt, char *name, char *element, char *desc, int warn)
prompt for any valid file name 
 
char * G_ask_new_file(const char *prompt, char *name, char *element, char *desc)
prompt for new file 
 
char * G_ask_old_file(const char *prompt, char *name, char *element, char *desc)
prompt for existing file 
 
char * G_find_file(const char *element, char *name, const char *mapset)
searches for a file from the mapset search list or in a specified mapset. returns the mapset name whe...
 
char * G_ask_in_mapset_ext(const char *prompt, char *name, char *element, char *desc, char *option, int(*lister)())
 
int G__check_gisinit(void)
Checks to see if GIS engine is initialized. 
 
int G_fatal_error(const char *msg,...)
Print a fatal error message to stderr. 
 
char * G_ask_any_ext(const char *prompt, char *name, char *element, char *desc, int warn, char *option, int(*lister)())
 
int G_legal_filename(const char *s)
Check for legal database file name. 
 
char * G_ask_new_ext(const char *prompt, char *name, char *element, char *desc, char *option, int(*lister)())
 
int G__name_is_fully_qualified(const char *fullname, char *name, char *mapset)
Check if map name is fully qualified (map @ mapset)