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

« back to all changes in this revision

Viewing changes to raster/r.surf.contour/cseg_open.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 <unistd.h>
2
 
#include <sys/types.h>
3
 
#include <sys/stat.h>
4
 
#include <fcntl.h>
5
 
#include <grass/gis.h>
6
 
#include "cseg.h"
7
 
 
8
 
int cseg_open(CSEG * cseg, int srows, int scols, int nsegs_in_memory)
9
 
{
10
 
    char *filename;
11
 
    int errflag;
12
 
    int fd;
13
 
 
14
 
    cseg->filename = NULL;
15
 
    cseg->fd = -1;
16
 
    cseg->name = NULL;
17
 
    cseg->mapset = NULL;
18
 
 
19
 
    filename = G_tempfile();
20
 
    if (-1 == (fd = creat(filename, 0666))) {
21
 
        G_warning("cseg_open(): unable to create segment file");
22
 
        return -2;
23
 
    }
24
 
    if (0 >
25
 
        (errflag =
26
 
         segment_format(fd, G_window_rows(), G_window_cols(), srows, scols,
27
 
                        sizeof(CELL)))) {
28
 
        close(fd);
29
 
        unlink(filename);
30
 
        if (errflag == -1) {
31
 
            G_warning("cseg_open(): could not write segment file");
32
 
            return -1;
33
 
        }
34
 
        else {
35
 
            G_warning("cseg_open(): illegal configuration parameter(s)");
36
 
            return -3;
37
 
        }
38
 
    }
39
 
    close(fd);
40
 
    if (-1 == (fd = open(filename, 2))) {
41
 
        unlink(filename);
42
 
        G_warning("cseg_open(): unable to re-open segment file");
43
 
        return -4;
44
 
    }
45
 
    if (0 > (errflag = segment_init(&(cseg->seg), fd, nsegs_in_memory))) {
46
 
        close(fd);
47
 
        unlink(filename);
48
 
        if (errflag == -1) {
49
 
            G_warning("cseg_open(): could not read segment file");
50
 
            return -5;
51
 
        }
52
 
        else {
53
 
            G_warning("cseg_open(): out of memory");
54
 
            return -6;
55
 
        }
56
 
    }
57
 
    cseg->filename = filename;
58
 
    cseg->fd = fd;
59
 
    return 0;
60
 
}