~ubuntu-branches/ubuntu/wily/grass/wily

« back to all changes in this revision

Viewing changes to raster/r.support/modhead/ask_format.c

Tags: 7.0.0~rc1+ds1-1~exp1
* New upstream release candidate.
* Repack upstream tarball, remove precompiled Python objects.
* Add upstream metadata.
* Update gbp.conf and Vcs-Git URL to use the experimental branch.
* Update watch file for GRASS 7.0.
* Drop build dependencies for Tcl/Tk, add build dependencies:
  python-numpy, libnetcdf-dev, netcdf-bin, libblas-dev, liblapack-dev
* Update Vcs-Browser URL to use cgit instead of gitweb.
* Update paths to use grass70.
* Add configure options: --with-netcdf, --with-blas, --with-lapack,
  remove --with-tcltk-includes.
* Update patches for GRASS 7.
* Update copyright file, changes:
  - Update copyright years
  - Group files by license
  - Remove unused license sections
* Add patches for various typos.
* Fix desktop file with patch instead of d/rules.
* Use minimal dh rules.
* Bump Standards-Version to 3.9.6, no changes.
* Use dpkg-maintscript-helper to replace directories with symlinks.
  (closes: #776349)
* Update my email to use @debian.org address.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include <stdlib.h>
2
 
#include <string.h>
3
 
#include <limits.h>
4
 
#include <grass/gis.h>
5
 
#include <grass/glocale.h>
6
 
#include <grass/vask.h>
7
 
#include "local_proto.h"
8
 
 
9
 
/*
10
 
 * ask_format()
11
 
 *
12
 
 * RETURN: 0 success : -1 failure
13
 
 */
14
 
int ask_format(char *name, struct Cell_head *cellhd, off_t filesize)
15
 
{
16
 
    RASTER_MAP_TYPE maptype;
17
 
    char title[80];
18
 
    char buf[80];
19
 
    char no_zeros[80];
20
 
 
21
 
    G_zero(no_zeros, (int)sizeof(no_zeros));
22
 
    maptype = G_raster_map_type(name, G_mapset());
23
 
 
24
 
    G_snprintf(title, sizeof(title), _("Please enter the following "
25
 
                                       "information for [%s]:"), name);
26
 
 
27
 
    V_clear();
28
 
    V_line(0, title);
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")));
34
 
 
35
 
    if (cellhd->compressed)
36
 
        V_const(&cellhd->rows, 'i', 2, 1, 5);
37
 
    else
38
 
        V_ques(&cellhd->rows, 'i', 2, 1, 5);
39
 
 
40
 
    V_ques(&cellhd->cols, 'i', 3, 1, 5);
41
 
 
42
 
    if (maptype == CELL_TYPE)
43
 
        V_ques(&cellhd->format, 'i', 4, 1, 5);
44
 
 
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) {
48
 
 
49
 
        if (sizeof(off_t) > sizeof(long) && filesize > ULONG_MAX)
50
 
            filesize = 0;
51
 
        G_snprintf(buf, sizeof(buf), _("rows * cols * bytes per cell "
52
 
                                       "must be same as file size (%lu)"),
53
 
                   (unsigned long)filesize);
54
 
        V_line(6, buf);
55
 
        V_line(7, _("If you need help figuring them out, just hit ESC"));
56
 
    }
57
 
    V_line(10, no_zeros);
58
 
 
59
 
    while (1) {
60
 
        V_intrpt_ok();
61
 
        if (!V_call())
62
 
            return -1;
63
 
 
64
 
        G_zero(no_zeros, (int)sizeof(no_zeros));
65
 
        if (maptype == CELL_TYPE && cellhd->rows > 0 &&
66
 
            cellhd->cols > 0 && cellhd->format > 0)
67
 
            break;
68
 
 
69
 
        if (maptype != CELL_TYPE && cellhd->rows > 0 && cellhd->cols > 0)
70
 
            break;
71
 
 
72
 
        if (!cellhd->compressed) {
73
 
            if (cellhd->rows >= 0 && cellhd->cols >= 0 && cellhd->format >= 0)
74
 
                break;
75
 
 
76
 
            strcpy(no_zeros, _("** Negative values not allowed!"));
77
 
        }
78
 
        else
79
 
            strcpy(no_zeros, _("** Positive values only please!"));
80
 
    }
81
 
 
82
 
    return EXIT_SUCCESS;
83
 
}