5
#include <grass/glocale.h>
6
#include <grass/vask.h>
7
#include "local_proto.h"
12
* RETURN: 0 success : -1 failure
14
int ask_format(char *name, struct Cell_head *cellhd, off_t filesize)
16
RASTER_MAP_TYPE maptype;
21
G_zero(no_zeros, (int)sizeof(no_zeros));
22
maptype = G_raster_map_type(name, G_mapset());
24
G_snprintf(title, sizeof(title), _("Please enter the following "
25
"information for [%s]:"), name);
29
V_line(2, _(" Number of rows"));
30
V_line(3, _(" Number of cols"));
31
V_line(4, (maptype == CELL_TYPE ?
32
_(" Number of bytes per cell") :
33
_(" Floating point map")));
35
if (cellhd->compressed)
36
V_const(&cellhd->rows, 'i', 2, 1, 5);
38
V_ques(&cellhd->rows, 'i', 2, 1, 5);
40
V_ques(&cellhd->cols, 'i', 3, 1, 5);
42
if (maptype == CELL_TYPE)
43
V_ques(&cellhd->format, 'i', 4, 1, 5);
45
/* If not compressed and filesize mismatch */
46
if (maptype == CELL_TYPE && cellhd->compressed == 0 &&
47
(off_t) cellhd->rows * cellhd->cols * cellhd->format != filesize) {
49
if (sizeof(off_t) > sizeof(long) && filesize > ULONG_MAX)
51
G_snprintf(buf, sizeof(buf), _("rows * cols * bytes per cell "
52
"must be same as file size (%lu)"),
53
(unsigned long)filesize);
55
V_line(7, _("If you need help figuring them out, just hit ESC"));
64
G_zero(no_zeros, (int)sizeof(no_zeros));
65
if (maptype == CELL_TYPE && cellhd->rows > 0 &&
66
cellhd->cols > 0 && cellhd->format > 0)
69
if (maptype != CELL_TYPE && cellhd->rows > 0 && cellhd->cols > 0)
72
if (!cellhd->compressed) {
73
if (cellhd->rows >= 0 && cellhd->cols >= 0 && cellhd->format >= 0)
76
strcpy(no_zeros, _("** Negative values not allowed!"));
79
strcpy(no_zeros, _("** Positive values only please!"));