GRASS Programmer's Manual
6.4.2(2012)
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
gisinit.c
Go to the documentation of this file.
1
17
#include <stdio.h>
18
#include <unistd.h>
19
#include <stdlib.h>
20
#include <string.h>
21
#include <sys/stat.h>
22
#include <locale.h>
23
24
#include <grass/gis.h>
25
#include "
G.h
"
26
#include <grass/glocale.h>
27
28
struct
G__
G__
;
29
30
static
int
initialized = 0;
31
static
int
gisinit(
void
);
32
33
44
int
G__gisinit
(
const
char
*
version
,
const
char
*pgm)
45
{
46
char
*mapset;
47
48
if
(initialized)
49
return
0;
50
51
G_set_program_name
(pgm);
52
53
if
(strcmp(version, GIS_H_VERSION) != 0)
54
G_fatal_error
(_(
"Incompatible library version for module. "
55
"You need to rebuild GRASS or untangle multiple installations."
));
56
57
/* Make sure location and mapset are set */
58
G_location_path
();
59
switch
(
G__mapset_permissions
(mapset =
G_mapset
())) {
60
case
1:
61
break
;
62
case
0:
63
G_fatal_error
(_(
"MAPSET %s - permission denied"
), mapset);
64
break
;
65
default
:
66
G_fatal_error
(_(
"MAPSET %s not found"
), mapset);
67
break
;
68
}
69
70
gisinit();
71
72
return
0;
73
}
74
75
84
int
G__no_gisinit
(
const
char
*
version
)
85
{
86
if
(initialized)
87
return
0;
88
89
if
(strcmp(version, GIS_H_VERSION) != 0)
90
G_fatal_error
(_(
"Incompatible library version for module. "
91
"You need to rebuild GRASS or untangle multiple installations."
));
92
93
gisinit();
94
95
return
0;
96
}
97
98
106
int
G__check_gisinit
(
void
)
107
{
108
if
(initialized)
109
return
1;
110
G_warning
(_(
"System not initialized. Programmer forgot to call G_gisinit()."
));
111
G_sleep
(3);
112
exit(EXIT_FAILURE);
113
}
114
115
116
static
int
gisinit(
void
)
117
{
118
/* Mark window as not set */
119
G__
.
window_set
= 0;
120
121
/* no histograms */
122
G__
.
want_histogram
= 0;
123
124
/* Set compressed data buffer size to zero */
125
G__
.
compressed_buf_size
= 0;
126
G__
.
work_buf_size
= 0;
127
G__
.
null_buf_size
= 0;
128
G__
.
mask_buf_size
= 0;
129
G__
.
temp_buf_size
= 0;
130
/* mask buf we always want to keep allocated */
131
G__reallocate_mask_buf
();
132
133
/* set the write type for floating maps */
134
G__
.
fp_type
= FCELL_TYPE;
135
G__
.
fp_nbytes
=
XDR_FLOAT_NBYTES
;
136
137
/* Set masking flag unknown */
138
G__
.
auto_mask
= -1;
139
140
/* set architecture dependent bit patterns for embeded null vals */
141
G__init_null_patterns
();
142
143
initialized = 1;
144
145
setlocale(LC_NUMERIC,
"C"
);
146
147
return
0;
148
}
lib
gis
gisinit.c
Generated on Sun Sep 9 2012 18:55:31 for GRASS Programmer's Manual by
1.8.1.2