GRASS Programmer's Manual
6.4.2(2012)
|
00001 #include <grass/config.h> 00002 00003 #ifdef HAVE_SOCKET 00004 00005 #include <string.h> 00006 #include <stdlib.h> 00007 #include <stdio.h> 00008 00009 #include <grass/gis.h> 00010 #include <grass/raster.h> 00011 #include <grass/graphics.h> 00012 00013 #include "transport.h" 00014 00015 /* PAD FUNCTIONS 00016 The monitor has a very simple database management capabil 00017 ity which supports the windowing. There are scratch pads 00018 to be written on. Each scratch pad can contain items, and 00019 each item can have a list of values. These are NOT to be 00020 used by the programmer. They are used indirectly through 00021 the displaylib library calls. 00022 */ 00023 00024 static void _get_list(char ***list, int *count) 00025 { 00026 char **a; 00027 int n; 00028 char *buf; 00029 00030 *list = NULL; 00031 *count = 0; 00032 00033 buf = _get_text_2(); 00034 00035 for (n = 0; *buf; n++) { 00036 if (n == 0) 00037 a = G_malloc(sizeof(char *)); 00038 else 00039 a = G_realloc(a, (n + 1) * sizeof(char *)); 00040 00041 a[n] = G_strdup(buf); 00042 00043 buf = _get_text_2(); 00044 } 00045 00046 *list = a; 00047 *count = n; 00048 } 00049 00050 int REM_pad_create(const char *pad) 00051 { 00052 char result; 00053 00054 _hold_signals(1); 00055 00056 _send_ident(PAD_CREATE); 00057 _send_text(pad); 00058 _get_char(&result); 00059 00060 _hold_signals(0); 00061 00062 return result; 00063 } 00064 00065 int REM_pad_current(char *name) 00066 { 00067 char result; 00068 00069 _hold_signals(1); 00070 00071 _send_ident(PAD_CURRENT); 00072 _get_char(&result); 00073 _get_text(name); 00074 00075 _hold_signals(0); 00076 00077 return result; 00078 } 00079 00080 int REM_pad_delete(void) 00081 { 00082 char result; 00083 00084 _hold_signals(1); 00085 00086 _send_ident(PAD_DELETE); 00087 _get_char(&result); 00088 00089 _hold_signals(0); 00090 00091 return result; 00092 } 00093 00094 int REM_pad_invent(char *pad) 00095 { 00096 _hold_signals(1); 00097 00098 _send_ident(PAD_INVENT); 00099 _get_text(pad); 00100 00101 _hold_signals(0); 00102 00103 return 0; 00104 } 00105 00106 int REM_pad_list(char ***list, int *count) 00107 { 00108 _hold_signals(1); 00109 00110 _send_ident(PAD_LIST); 00111 _get_list(list, count); 00112 00113 _hold_signals(0); 00114 00115 return 0; 00116 } 00117 00118 int REM_pad_select(const char *pad) 00119 { 00120 char result; 00121 00122 _hold_signals(1); 00123 00124 _send_ident(PAD_SELECT); 00125 _send_text(pad); 00126 _get_char(&result); 00127 00128 _hold_signals(0); 00129 00130 return result; 00131 } 00132 00133 int REM_pad_append_item(const char *item, const char *value, int replace) 00134 { 00135 char result; 00136 00137 _hold_signals(1); 00138 00139 _send_ident(PAD_APPEND_ITEM); 00140 _send_text(item); 00141 _send_text(value); 00142 _send_int(&replace); 00143 _get_char(&result); 00144 00145 _hold_signals(0); 00146 00147 return result; 00148 } 00149 00150 int REM_pad_delete_item(const char *name) 00151 { 00152 char result; 00153 00154 _hold_signals(1); 00155 00156 _send_ident(PAD_DELETE_ITEM); 00157 _send_text(name); 00158 _get_char(&result); 00159 00160 _hold_signals(0); 00161 00162 return result; 00163 } 00164 00165 int REM_pad_get_item(const char *item, char ***list, int *count) 00166 { 00167 char result; 00168 00169 _hold_signals(1); 00170 00171 _send_ident(PAD_GET_ITEM); 00172 _send_text(item); 00173 _get_char(&result); 00174 00175 if (result == OK) 00176 _get_list(list, count); 00177 00178 _hold_signals(0); 00179 00180 return result; 00181 } 00182 00183 int REM_pad_list_items(char ***list, int *count) 00184 { 00185 char result; 00186 00187 _hold_signals(1); 00188 00189 _send_ident(PAD_LIST_ITEMS); 00190 _get_char(&result); 00191 if (result == OK) 00192 _get_list(list, count); 00193 00194 _hold_signals(0); 00195 00196 return result; 00197 } 00198 00199 int REM_pad_set_item(const char *item, const char *value) 00200 { 00201 char result; 00202 00203 _hold_signals(1); 00204 00205 _send_ident(PAD_SET_ITEM); 00206 _send_text(item); 00207 _send_text(value); 00208 _get_char(&result); 00209 00210 _hold_signals(0); 00211 00212 return result; 00213 } 00214 00215 #endif /* HAVE_SOCKET */