GRASS Programmer's Manual  6.4.2(2012)
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
com_io.c
Go to the documentation of this file.
1 
2 #include <grass/config.h>
3 
4 #include <errno.h>
5 #include <signal.h>
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <string.h>
9 #include <unistd.h>
10 
11 #include <grass/gis.h>
12 #include <grass/glocale.h>
13 #include <grass/raster.h>
14 #include <grass/graphics.h>
15 
16 #include "driver.h"
17 #include "transport.h"
18 
19 struct transport loc_trans = {
34  LOC_erase,
50  LOC_text,
52  LOC_font,
62  LOC_bitmap,
77 };
78 
79 #ifdef HAVE_SOCKET
80 
81 struct transport rem_trans = {
96  REM_erase,
100  REM_cont_rel,
107  REM_box_abs,
108  REM_box_rel,
112  REM_text,
114  REM_font,
115  REM_charset,
124  REM_bitmap,
132  REM_pad_list,
139 };
140 
141 #endif
142 
143 const struct transport *trans;
144 
145 static const struct transport *get_trans(void)
146 {
147 #ifndef HAVE_SOCKET
148  return &loc_trans;
149 #else
150  const char *p = getenv("GRASS_RENDER_IMMEDIATE");
151 
152  if (!p)
153  return &rem_trans;
154 
155  if (G_strcasecmp(p, "TRUE") == 0)
156  return &loc_trans;
157 
158  if (G_strcasecmp(p, "FALSE") == 0)
159  return &rem_trans;
160 
161  if (G_strcasecmp(p, "PNG") == 0)
162  return &loc_trans;
163 
164  if (G_strcasecmp(p, "PS") == 0)
165  return &loc_trans;
166 
167  G_warning("Unrecognised GRASS_RENDER_IMMEDIATE setting: %s", p);
168 
169  return &rem_trans;
170 #endif
171 }
172 
173 static void init_transport(void)
174 {
175  if (trans)
176  return;
177 
178  trans = get_trans();
179 }
180 
181 int R_open_driver(void)
182 {
183  init_transport();
184  return trans->open_driver();
185 }
186 
187 void R__open_quiet(void)
188 {
189  init_transport();
190  trans->open_quiet();
191 }
192 
193 void R_stabilize(void)
194 {
195  trans->stabilize();
196 }
197 
198 void R_kill_driver(void)
199 {
200  trans->kill_driver();
201 }
202 
203 void R_close_driver(void)
204 {
205  trans->close_driver();
206 }
207 
209 {
210  trans->release_driver();
211 }