GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
rem_pad.c
Go to the documentation of this file.
1 #include <grass/config.h>
2 
3 #ifdef HAVE_SOCKET
4 
5 #include <string.h>
6 #include <stdlib.h>
7 #include <stdio.h>
8 
9 #include <grass/gis.h>
10 #include <grass/raster.h>
11 #include <grass/graphics.h>
12 
13 #include "transport.h"
14 
15 /* PAD FUNCTIONS
16  The monitor has a very simple database management capabil­ ity which supports the windowing. There are scratch pads to be written on. Each scratch pad can contain items, and each item can have a list of values. These are NOT to be used by the programmer. They are used indirectly through the displaylib library calls. */ static void _get_list(char ***list, int *count) { char **a; int n; char *buf; *list = NULL; *count = 0; buf = _get_text_2(); for (n = 0; *buf; n++) { if (n == 0) a = G_malloc(sizeof(char *)); else a = G_realloc(a, (n + 1) * sizeof(char *)); a[n] = G_strdup(buf); buf = _get_text_2(); } *list = a; *count = n; } int REM_pad_create(const char *pad) { char result; _hold_signals(1); _send_ident(PAD_CREATE); _send_text(pad); _get_char(&result); _hold_signals(0); return result; } int REM_pad_current(char *name) { char result; _hold_signals(1); _send_ident(PAD_CURRENT); _get_char(&result); _get_text(name); _hold_signals(0); return result; } int REM_pad_delete(void) { char result; _hold_signals(1); _send_ident(PAD_DELETE); _get_char(&result); _hold_signals(0); return result; } int REM_pad_invent(char *pad) { _hold_signals(1); _send_ident(PAD_INVENT); _get_text(pad); _hold_signals(0); return 0; } int REM_pad_list(char ***list, int *count) { _hold_signals(1); _send_ident(PAD_LIST); _get_list(list, count); _hold_signals(0); return 0; } int REM_pad_select(const char *pad) { char result; _hold_signals(1); _send_ident(PAD_SELECT); _send_text(pad); _get_char(&result); _hold_signals(0); return result; } int REM_pad_append_item(const char *item, const char *value, int replace) { char result; _hold_signals(1); _send_ident(PAD_APPEND_ITEM); _send_text(item); _send_text(value); _send_int(&replace); _get_char(&result); _hold_signals(0); return result; } int REM_pad_delete_item(const char *name) { char result; _hold_signals(1); _send_ident(PAD_DELETE_ITEM); _send_text(name); _get_char(&result); _hold_signals(0); return result; } int REM_pad_get_item(const char *item, char ***list, int *count) { char result; _hold_signals(1); _send_ident(PAD_GET_ITEM); _send_text(item); _get_char(&result); if (result == OK) _get_list(list, count); _hold_signals(0); return result; } int REM_pad_list_items(char ***list, int *count) { char result; _hold_signals(1); _send_ident(PAD_LIST_ITEMS); _get_char(&result); if (result == OK) _get_list(list, count); _hold_signals(0); return result; } int REM_pad_set_item(const char *item, const char *value) { char result; _hold_signals(1); _send_ident(PAD_SET_ITEM); _send_text(item); _send_text(value); _get_char(&result); _hold_signals(0); return result; } #endif /* HAVE_SOCKET */
17  ity which supports the windowing. There are scratch pads
18  to be written on. Each scratch pad can contain items, and
19  each item can have a list of values. These are NOT to be
20  used by the programmer. They are used indirectly through
21  the displaylib library calls.
22  */
23 
24 static void _get_list(char ***list, int *count)
25 {
26  char **a;
27  int n;
28  char *buf;
29 
30  *list = NULL;
31  *count = 0;
32 
33  buf = _get_text_2();
34 
35  for (n = 0; *buf; n++) {
36  if (n == 0)
37  a = G_malloc(sizeof(char *));
38  else
39  a = G_realloc(a, (n + 1) * sizeof(char *));
40 
41  a[n] = G_strdup(buf);
42 
43  buf = _get_text_2();
44  }
45 
46  *list = a;
47  *count = n;
48 }
49 
50 int REM_pad_create(const char *pad)
51 {
52  char result;
53 
54  _hold_signals(1);
55 
56  _send_ident(PAD_CREATE);
57  _send_text(pad);
58  _get_char(&result);
59 
60  _hold_signals(0);
61 
62  return result;
63 }
64 
65 int REM_pad_current(char *name)
66 {
67  char result;
68 
69  _hold_signals(1);
70 
71  _send_ident(PAD_CURRENT);
72  _get_char(&result);
73  _get_text(name);
74 
75  _hold_signals(0);
76 
77  return result;
78 }
79 
80 int REM_pad_delete(void)
81 {
82  char result;
83 
84  _hold_signals(1);
85 
86  _send_ident(PAD_DELETE);
87  _get_char(&result);
88 
89  _hold_signals(0);
90 
91  return result;
92 }
93 
94 int REM_pad_invent(char *pad)
95 {
96  _hold_signals(1);
97 
98  _send_ident(PAD_INVENT);
99  _get_text(pad);
100 
101  _hold_signals(0);
102 
103  return 0;
104 }
105 
106 int REM_pad_list(char ***list, int *count)
107 {
108  _hold_signals(1);
109 
110  _send_ident(PAD_LIST);
111  _get_list(list, count);
112 
113  _hold_signals(0);
114 
115  return 0;
116 }
117 
118 int REM_pad_select(const char *pad)
119 {
120  char result;
121 
122  _hold_signals(1);
123 
124  _send_ident(PAD_SELECT);
125  _send_text(pad);
126  _get_char(&result);
127 
128  _hold_signals(0);
129 
130  return result;
131 }
132 
133 int REM_pad_append_item(const char *item, const char *value, int replace)
134 {
135  char result;
136 
137  _hold_signals(1);
138 
139  _send_ident(PAD_APPEND_ITEM);
140  _send_text(item);
141  _send_text(value);
142  _send_int(&replace);
143  _get_char(&result);
144 
145  _hold_signals(0);
146 
147  return result;
148 }
149 
150 int REM_pad_delete_item(const char *name)
151 {
152  char result;
153 
154  _hold_signals(1);
155 
156  _send_ident(PAD_DELETE_ITEM);
157  _send_text(name);
158  _get_char(&result);
159 
160  _hold_signals(0);
161 
162  return result;
163 }
164 
165 int REM_pad_get_item(const char *item, char ***list, int *count)
166 {
167  char result;
168 
169  _hold_signals(1);
170 
171  _send_ident(PAD_GET_ITEM);
172  _send_text(item);
173  _get_char(&result);
174 
175  if (result == OK)
176  _get_list(list, count);
177 
178  _hold_signals(0);
179 
180  return result;
181 }
182 
183 int REM_pad_list_items(char ***list, int *count)
184 {
185  char result;
186 
187  _hold_signals(1);
188 
189  _send_ident(PAD_LIST_ITEMS);
190  _get_char(&result);
191  if (result == OK)
192  _get_list(list, count);
193 
194  _hold_signals(0);
195 
196  return result;
197 }
198 
199 int REM_pad_set_item(const char *item, const char *value)
200 {
201  char result;
202 
203  _hold_signals(1);
204 
205  _send_ident(PAD_SET_ITEM);
206  _send_text(item);
207  _send_text(value);
208  _get_char(&result);
209 
210  _hold_signals(0);
211 
212  return result;
213 }
214 
215 #endif /* HAVE_SOCKET */
string name
Definition: render.py:1314
char * G_strdup(const char *string)
Copies the null-terminated string into a newly allocated string. The string is allocated using G_mall...
Definition: strings.c:265
int count
int REM_pad_delete_item(const char *name)
int REM_pad_set_item(const char *name, const char *value)
int REM_pad_select(const char *pad)
#define OK
Definition: plot.c:384
int REM_pad_get_item(const char *name, char ***list, int *count)
char * value
Definition: env.c:30
int REM_pad_invent(char *pad)
char buf[GNAME_MAX+sizeof(G3D_DIRECTORY)+2]
Definition: g3drange.c:62
return NULL
Definition: dbfopen.c:1394
int REM_pad_delete(void)
int REM_pad_list_items(char ***list, int *count)
int REM_pad_current(char *name)
int REM_pad_list(char ***list, int *count)
int REM_pad_create(const char *pad)
int n
Definition: dataquad.c:291
int REM_pad_append_item(const char *item, const char *value, int replace)