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

« back to all changes in this revision

Viewing changes to lib/g3d/g3dintio.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 <stdio.h>
2
 
#include <stdlib.h>
3
 
#include <sys/types.h>
4
 
#include <unistd.h>
5
 
#include <rpc/types.h>
6
 
#include <rpc/xdr.h>
7
 
#include "G3d_intern.h"
8
 
 
9
 
/*---------------------------------------------------------------------------*/
10
 
 
11
 
int G3d_writeInts(int fd, int useXdr, const int *i, int nofNum)
12
 
{
13
 
    int firstTime = 1;
14
 
    XDR xdrEncodeStream;
15
 
    char xdrIntBuf[G3D_XDR_INT_LENGTH * 1024];
16
 
    u_int n;
17
 
 
18
 
    if (nofNum <= 0)
19
 
        G3d_fatalError("G3d_writeInts: nofNum out of range");
20
 
 
21
 
    if (useXdr == G3D_NO_XDR) {
22
 
        if (write(fd, i, sizeof(int) * nofNum) != sizeof(int) * nofNum) {
23
 
            G3d_error("G3d_writeInts: writing to file failed");
24
 
            return 0;
25
 
        }
26
 
        else {
27
 
            return 1;
28
 
        }
29
 
    }
30
 
 
31
 
    if (firstTime) {
32
 
        xdrmem_create(&xdrEncodeStream, xdrIntBuf, G3D_XDR_INT_LENGTH * 1024,
33
 
                      XDR_ENCODE);
34
 
        firstTime = 1;
35
 
    }
36
 
 
37
 
    do {
38
 
        n = nofNum % 1024;
39
 
        if (n == 0)
40
 
            n = 1024;
41
 
 
42
 
        if (!xdr_setpos(&xdrEncodeStream, 0)) {
43
 
            G3d_error("G3d_writeInts: positioning xdr failed");
44
 
            return 0;
45
 
        }
46
 
 
47
 
        if (!xdr_vector(&xdrEncodeStream, (char *)i, n, sizeof(int),
48
 
                        (xdrproc_t) xdr_int)) {
49
 
            G3d_error("G3d_writeInts: writing xdr failed");
50
 
            return 0;
51
 
        }
52
 
 
53
 
        if (write(fd, xdrIntBuf, G3D_XDR_INT_LENGTH * n) !=
54
 
            G3D_XDR_INT_LENGTH * n) {
55
 
            G3d_error("G3d_writeInts: writing xdr to file failed");
56
 
            return 0;
57
 
        }
58
 
 
59
 
        nofNum -= n;
60
 
        i += n;
61
 
    } while (nofNum);
62
 
 
63
 
    return 1;
64
 
}
65
 
 
66
 
/*---------------------------------------------------------------------------*/
67
 
 
68
 
int G3d_readInts(int fd, int useXdr, int *i, int nofNum)
69
 
{
70
 
    int firstTime = 1;
71
 
    XDR xdrDecodeStream;
72
 
    char xdrIntBuf[G3D_XDR_INT_LENGTH * 1024];
73
 
    u_int n;
74
 
 
75
 
    if (nofNum <= 0)
76
 
        G3d_fatalError("G3d_readInts: nofNum out of range");
77
 
 
78
 
    if (useXdr == G3D_NO_XDR) {
79
 
        if (read(fd, i, sizeof(int) * nofNum) != sizeof(int) * nofNum) {
80
 
            G3d_error("G3d_readInts: reading from file failed");
81
 
            return 0;
82
 
        }
83
 
        else {
84
 
            return 1;
85
 
        }
86
 
    }
87
 
 
88
 
    if (firstTime) {
89
 
        xdrmem_create(&xdrDecodeStream, xdrIntBuf, G3D_XDR_INT_LENGTH * 1024,
90
 
                      XDR_DECODE);
91
 
        firstTime = 1;
92
 
    }
93
 
 
94
 
    do {
95
 
        n = nofNum % 1024;
96
 
        if (n == 0)
97
 
            n = 1024;
98
 
 
99
 
        if (read(fd, xdrIntBuf, G3D_XDR_INT_LENGTH * n) !=
100
 
            G3D_XDR_INT_LENGTH * n) {
101
 
            G3d_error("G3d_readInts: reading xdr from file failed");
102
 
            return 0;
103
 
        }
104
 
 
105
 
        if (!xdr_setpos(&xdrDecodeStream, 0)) {
106
 
            G3d_error("G3d_readInts: positioning xdr failed");
107
 
            return 0;
108
 
        }
109
 
 
110
 
        if (!xdr_vector(&xdrDecodeStream, (char *)i, n, sizeof(int),
111
 
                        (xdrproc_t) xdr_int)) {
112
 
            G3d_error("G3d_readInts: reading xdr failed");
113
 
            return 0;
114
 
        }
115
 
 
116
 
        nofNum -= n;
117
 
        i += n;
118
 
    } while (nofNum);
119
 
 
120
 
    return 1;
121
 
}