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
gis/debug.c
Go to the documentation of this file.
1
17
#include <stdio.h>
18
#include <stdlib.h>
19
#include <string.h>
20
#include <stdarg.h>
21
#include <grass/gis.h>
22
#include <grass/glocale.h>
23
#include "
G.h
"
24
25
26
static
int
grass_debug_level = -1;
27
28
51
int
G_debug
(
int
level,
const
char
*
msg
, ...)
52
{
53
#ifdef GDEBUG
54
char
*lstr, *filen;
55
va_list ap;
56
FILE *fd;
57
58
if
(grass_debug_level < 0) {
59
lstr =
G__getenv
(
"DEBUG"
);
60
61
if
(lstr !=
NULL
)
62
grass_debug_level = atoi(lstr);
63
else
64
grass_debug_level = 0;
65
}
66
67
if
(grass_debug_level >= level) {
68
va_start(ap, msg);
69
70
filen =
getenv
(
"GRASS_DEBUG_FILE"
);
71
if
(filen !=
NULL
) {
72
fd = fopen(filen,
"a"
);
73
if
(!fd) {
74
G_warning
(_(
"Cannot open debug file '%s'"
), filen);
75
return
0;
76
}
77
}
78
else
{
79
fd = stderr;
80
}
81
82
fprintf(fd,
"D%d/%d: "
, level, grass_debug_level);
83
vfprintf(fd, msg, ap);
84
fprintf(fd,
"\n"
);
85
fflush(fd);
86
87
if
(filen !=
NULL
)
88
fclose(fd);
89
90
va_end(ap);
91
}
92
#endif
93
94
return
1;
95
}
96
97
108
int
G_dump
(
int
fd)
109
{
110
const
struct
fileinfo
*fcb = &
G__
.
fileinfo
[fd];
111
112
G_message
(
"G_dump: memory allocated to G__"
);
113
G_message
(
"Size of cell in fp maps = %d"
,
G__
.
fp_nbytes
);
114
G_message
(
"type for writing floating maps = %d"
,
G__
.
fp_type
);
115
G_message
(
"current window = %p"
, &
G__
.
window
);
116
G_message
(
"Flag: window set? %d"
,
G__
.
window_set
);
117
G_message
(
"File descriptor for automatic mask %d"
,
G__
.
mask_fd
);
118
G_message
(
"Flag denoting automatic masking %d"
,
G__
.
auto_mask
);
119
G_message
(
"CELL mask buffer %p"
,
G__
.
mask_buf
);
120
G_message
(
"buffer for reading null rows %p"
,
G__
.
null_buf
);
121
G_message
(
"Pre/post compressed data buffer %p"
,
G__
.
compressed_buf
);
122
G_message
(
"sizeof compressed_buf %d"
,
G__
.
compressed_buf_size
);
123
G_message
(
"work data buffer %p"
,
G__
.
work_buf
);
124
G_message
(
"sizeof work_buf %d"
,
G__
.
work_buf_size
);
125
G_message
(
"sizeof null_buf %d"
,
G__
.
null_buf_size
);
126
G_message
(
"sizeof mask_buf %d"
,
G__
.
mask_buf_size
);
127
G_message
(
"Histogram request %d"
,
G__
.
want_histogram
);
128
129
G_message
(
"G_dump: file #%d"
, fd);
130
G_message
(
"open mode = %d"
, fcb->
open_mode
);
131
G_message
(
"Cell header %p"
, &fcb->
cellhd
);
132
G_message
(
"Table reclass %p"
, &fcb->
reclass
);
133
G_message
(
"Cell stats %p"
, &fcb->
statf
);
134
G_message
(
"Range structure %p"
, &fcb->
range
);
135
G_message
(
"float Range structure %p"
, &fcb->
fp_range
);
136
G_message
(
"want histogram? %d"
, fcb->
want_histogram
);
137
G_message
(
"Automatic reclass flag %d"
, fcb->
reclass_flag
);
138
G_message
(
"File row addresses %p"
, fcb->
row_ptr
);
139
G_message
(
"Data to window col mapping %p"
, fcb->
col_map
);
140
G_message
(
"Data to window row constants %f,%f"
, fcb->
C1
, fcb->
C2
);
141
G_message
(
"Current data row in memory %d"
, fcb->
cur_row
);
142
G_message
(
"Current null row in memory %d"
, fcb->
null_cur_row
);
143
G_message
(
"nbytes per cell for current row %d"
, fcb->
cur_nbytes
);
144
G_message
(
"Decompressed data buffer %s"
, fcb->
data
);
145
G_message
(
"bytes per cell %d"
, fcb->
nbytes
);
146
G_message
(
"type: int, float or double map %d"
, fcb->
map_type
);
147
G_message
(
"Temporary name for NEW files %s"
, fcb->
temp_name
);
148
G_message
(
"Temporary name for NEW NULL files %s"
, fcb->
null_temp_name
);
149
G_message
(
"for existing raster maps %d"
, fcb->
null_file_exists
);
150
G_message
(
"Name of open file %s"
, fcb->
name
);
151
G_message
(
"Mapset of open file %s"
, fcb->
mapset
);
152
G_message
(
"io error warning given %d"
, fcb->
io_error
);
153
G_message
(
"xdr stream for reading fp %p"
, &fcb->
xdrstream
);
154
G_message
(
"NULL_ROWS array[%d] = %p"
,
NULL_ROWS_INMEM
, fcb->
NULL_ROWS
);
155
G_message
(
"data buffer for reading null rows %p"
, fcb->
null_work_buf
);
156
G_message
(
"Minimum row null number in memory %d"
, fcb->
min_null_row
);
157
G_message
(
"Quant ptr = %p"
, &fcb->
quant
);
158
G_message
(
"G_dump: end"
);
159
160
return
0;
161
}
lib
gis
debug.c
Generated on Wed Jun 6 2012 14:04:21 for GRASS Programmer's Manual by
1.8.1