GRASS GIS 7 Programmer's Manual  7.7.svn(2018)-r73666
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
check.c
Go to the documentation of this file.
1 
2 #include <grass/calc.h>
3 
4 int c_int0(int argc, int *argt)
5 {
6  if (argc > 0)
7  return E_ARG_HI;
8 
9  argt[0] = CELL_TYPE;
10 
11  return 0;
12 }
13 
14 int c_double0(int argc, int *argt)
15 {
16  if (argc > 0)
17  return E_ARG_HI;
18 
19  argt[0] = DCELL_TYPE;
20 
21  return 0;
22 }
23 
24 int c_double1(int argc, int *argt)
25 {
26  if (argc < 1)
27  return E_ARG_LO;
28  if (argc > 1)
29  return E_ARG_HI;
30 
31  argt[0] = DCELL_TYPE;
32  argt[1] = DCELL_TYPE;
33 
34  return 0;
35 }
36 
37 int c_double12(int argc, int *argt)
38 {
39  if (argc < 1)
40  return E_ARG_LO;
41 
42  if (argc > 2)
43  return E_ARG_HI;
44 
45  argt[0] = DCELL_TYPE;
46  argt[1] = DCELL_TYPE;
47  if (argc == 2)
48  argt[2] = DCELL_TYPE;
49 
50  return 0;
51 }
52 
53 int c_unop(int argc, int *argt)
54 {
55  if (argc < 1)
56  return E_ARG_LO;
57  if (argc > 1)
58  return E_ARG_HI;
59 
60  argt[0] = argt[1];
61 
62  return 0;
63 }
64 
65 int c_binop(int argc, int *argt)
66 {
67  if (argc < 2)
68  return E_ARG_LO;
69  if (argc > 2)
70  return E_ARG_HI;
71 
72  argt[0] = CELL_TYPE;
73  if (argt[1] == FCELL_TYPE || argt[2] == FCELL_TYPE)
74  argt[0] = FCELL_TYPE;
75  if (argt[1] == DCELL_TYPE || argt[2] == DCELL_TYPE)
76  argt[0] = DCELL_TYPE;
77 
78  argt[1] = argt[0];
79  argt[2] = argt[0];
80 
81  return 0;
82 }
83 
84 int c_varop(int argc, int *argt)
85 {
86  int i;
87 
88  if (argc < 1)
89  return E_ARG_LO;
90 
91  argt[0] = CELL_TYPE;
92 
93  for (i = 1; i <= argc; i++)
94  if (argt[i] == FCELL_TYPE)
95  argt[0] = FCELL_TYPE;
96 
97  for (i = 1; i <= argc; i++)
98  if (argt[i] == DCELL_TYPE)
99  argt[0] = DCELL_TYPE;
100 
101  for (i = 1; i <= argc; i++)
102  argt[i] = argt[0];
103 
104  return 0;
105 }
106 
107 int c_cmpop(int argc, int *argt)
108 {
109  int arg_type;
110 
111  if (argc < 2)
112  return E_ARG_LO;
113  if (argc > 2)
114  return E_ARG_HI;
115 
116  argt[0] = CELL_TYPE;
117 
118  arg_type = CELL_TYPE;
119  if (argt[1] == FCELL_TYPE || argt[2] == FCELL_TYPE)
120  arg_type = FCELL_TYPE;
121  if (argt[1] == DCELL_TYPE || argt[2] == DCELL_TYPE)
122  arg_type = DCELL_TYPE;
123 
124  argt[1] = arg_type;
125  argt[2] = arg_type;
126 
127  return 0;
128 }
129 
130 int c_logop(int argc, int *argt)
131 {
132  int i;
133 
134  if (argc < 1)
135  return E_ARG_LO;
136 
137  for (i = 1; i <= argc; i++)
138  if (argt[i] != CELL_TYPE)
139  return E_ARG_TYPE;
140 
141  argt[0] = CELL_TYPE;
142 
143  return 0;
144 }
145 
146 int c_shiftop(int argc, int *argt)
147 {
148  if (argc < 2)
149  return E_ARG_LO;
150  if (argc > 2)
151  return E_ARG_HI;
152 
153  if (argt[1] != CELL_TYPE || argt[2] != CELL_TYPE)
154  return E_ARG_TYPE;
155 
156  argt[0] = CELL_TYPE;
157 
158  return 0;
159 }
#define CELL_TYPE
Definition: raster.h:11
int c_binop(int argc, int *argt)
Definition: check.c:65
int c_shiftop(int argc, int *argt)
Definition: check.c:146
int c_double12(int argc, int *argt)
Definition: check.c:37
int c_double0(int argc, int *argt)
Definition: check.c:14
Definition: calc.h:13
int c_varop(int argc, int *argt)
Definition: check.c:84
#define DCELL_TYPE
Definition: raster.h:13
int c_double1(int argc, int *argt)
Definition: check.c:24
int c_unop(int argc, int *argt)
Definition: check.c:53
Definition: calc.h:12
int c_cmpop(int argc, int *argt)
Definition: check.c:107
int c_int0(int argc, int *argt)
Definition: check.c:4
int c_logop(int argc, int *argt)
Definition: check.c:130
#define FCELL_TYPE
Definition: raster.h:12