File: ask_cell.c

package info (click to toggle)
grass 6.0.2-6
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 40,044 kB
  • ctags: 31,303
  • sloc: ansic: 321,125; tcl: 25,676; sh: 11,176; cpp: 10,098; makefile: 5,025; fortran: 1,846; yacc: 493; lex: 462; perl: 133; sed: 1
file content (125 lines) | stat: -rw-r--r-- 2,633 bytes parent folder | download | duplicates (2)
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/*
 *************************************************************************
 *   char *
 *   G_ask_cell_new(prompt, name)) 
 *       asks user to input name of a new cell file
 *
 *   char *
 *   G_ask_cell_old(prompt, name) 
 *       asks user to input name of an existing cell file
 *
 *   char *
 *   G_ask_cell_in_mapset(prompt, name)
 *       asks user to input name of an existing cell file in current mapset
 *
 *   char *
 *   G_ask_cell_any(prompt, name)
 *       asks user to input name of a new or existing cell file in
 *       the current mapset. Warns user about (possible) overwrite
 *       if cell file already exists
 *
 *   parms:
 *      char *prompt    optional prompt for user
 *      char *name      buffer to hold name of map found
 *
 *   returns:
 *      char *pointer to a string with name of mapset
 *       where file was found, or NULL if not found
 *
 *   note:
 *      rejects all names that begin with .
 **********************************************************************/
#include <stdlib.h>
#include <string.h>
#include "gis.h"
#include "glocale.h"

static int lister(char *,char *,char *);


/*!
 * \brief prompt for new raster file
 *
 * Asks the user to enter a name for a raster file which does not
 * exist in the current mapset.
 *
 *  \param prompt
 *  \param name
 *  \return char * 
 */

char *
G_ask_cell_new (prompt,name)

	char *prompt;
	char *name;
{

	return G_ask_new_ext (prompt, name, "cell", "raster", _("with titles"), lister);
}


/*!
 * \brief prompt for existing raster file
 *
 * Asks the user to enter the name of an existing raster
 * file in any mapset in the database.
 *
 *  \param prompt
 *  \param name
 *  \return char * 
 */

char *
G_ask_cell_old (prompt,name)

	char *prompt;
	char *name;
{
	return G_ask_old_ext (prompt, name, "cell", "raster", _("with titles"), lister);
}


/*!
 * \brief prompt for existing raster file
 *
 * Asks the user to enter the name of an existing raster
 * file in the current mapset.
 *
 *  \param prompt
 *  \param name
 *  \return char * 
 */

char *
G_ask_cell_in_mapset (prompt,name)

	char *prompt;
	char *name;
{
	return G_ask_in_mapset_ext (prompt, name, "cell", "raster", _("with titles"), lister);
}

char *
G_ask_cell_any (prompt,name)

	char *prompt;
	char *name;
{
	return G_ask_any_ext (prompt, name, "cell", "raster", 1, _("with titles"), lister);
}

static int lister(char *name,char *mapset,char *buf)
{
    char *title;

    *buf = 0;
    if (*name == 0) return 0;

    strcpy (buf, title = G_get_cell_title (name, mapset));
    if (*buf == 0)
	strcpy (buf, _("(no title)"));
    free (title);

    return 0;
}