GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
portable.c
Go to the documentation of this file.
1 /*
2  ****************************************************************************
3  *
4  * MODULE: Vector library
5  *
6  * AUTHOR(S): Original author CERL, probably Dave Gerdes.
7  * Update to GRASS 5.7 Radim Blazek.
8  *
9  * PURPOSE: Lower level functions for reading/writing/manipulating vectors.
10  *
11  * COPYRIGHT: (C) 2001 by the GRASS Development Team
12  *
13  * This program is free software under the GNU General Public
14  * License (>=v2). Read the file COPYING that comes with GRASS
15  * for details.
16  *
17  *****************************************************************************/
18 #include <string.h>
19 #include <grass/gis.h>
20 #include <grass/Vect.h>
21 
22 extern void port_init(void);
23 
24 extern int nat_dbl;
25 extern int nat_flt;
26 extern int nat_lng;
27 extern int nat_int;
28 extern int nat_shrt;
29 
30 extern int dbl_order;
31 extern int flt_order;
32 extern int lng_order;
33 extern int int_order;
34 extern int shrt_order;
35 
36 extern unsigned char dbl_cnvrt[sizeof(double)];
37 extern unsigned char flt_cnvrt[sizeof(float)];
38 extern unsigned char lng_cnvrt[sizeof(long)];
39 extern unsigned char int_cnvrt[sizeof(int)];
40 extern unsigned char shrt_cnvrt[sizeof(short)];
41 
42 struct Port_info *Cur_Head;
43 
44 static char *buffer = NULL;
45 static int buf_alloced = 0;
46 
47 static int buf_alloc(int needed)
48 {
49  char *p;
50  int cnt;
51 
52  if (needed <= buf_alloced)
53  return (0);
54  cnt = buf_alloced;
55  p = dig__alloc_space(needed, &cnt, 100, buffer, 1);
56  if (p == NULL)
57  return (dig_out_of_memory());
58  buffer = p;
59  buf_alloced = cnt;
60  return (0);
61 }
62 
63 /***************************** READ ************************************/
64 /* These are the routines to read from the Portable Vector Format.
65  These routines must handle any type size conversions between the
66  portable format and the native machine.
67 
68  Return: 0 error
69  1 OK
70 
71  */
72 
73 
74 /* read doubles from the PVF file */
75 int dig__fread_port_D(double *buf, int cnt, GVFILE * fp)
76 {
77  int i, j, ret;
78  unsigned char *c1, *c2;
79 
80  if (Cur_Head->dbl_quick) {
81  ret = dig_fread(buf, PORT_DOUBLE, cnt, fp);
82  if (ret != cnt)
83  return 0;
84  }
85  else {
86  /* read into buffer */
87  buf_alloc(cnt * PORT_DOUBLE);
88  ret = dig_fread(buffer, PORT_DOUBLE, cnt, fp);
89  if (ret != cnt)
90  return 0;
91  /* read from buffer in changed order */
92  c1 = (unsigned char *)buffer;
93  c2 = (unsigned char *)buf;
94  for (i = 0; i < cnt; i++) {
95  for (j = 0; j < PORT_DOUBLE; j++) {
96  c2[Cur_Head->dbl_cnvrt[j]] = c1[j];
97  }
98  c1 += PORT_DOUBLE;
99  c2 += sizeof(double);
100  }
101  }
102  return 1;
103 }
104 
105 /* read floats from the PVF file */
106 int dig__fread_port_F(float *buf, int cnt, GVFILE * fp)
107 {
108  int i, j, ret;
109  unsigned char *c1, *c2;
110 
111  if (Cur_Head->flt_quick) {
112  ret = dig_fread(buf, PORT_FLOAT, cnt, fp);
113  if (ret != cnt)
114  return 0;
115  }
116  else {
117  /* read into buffer */
118  buf_alloc(cnt * PORT_FLOAT);
119  ret = dig_fread(buffer, PORT_FLOAT, cnt, fp);
120  if (ret != cnt)
121  return 0;
122  /* read from buffer in changed order */
123  c1 = (unsigned char *)buffer;
124  c2 = (unsigned char *)buf;
125  for (i = 0; i < cnt; i++) {
126  for (j = 0; j < PORT_FLOAT; j++) {
127  c2[Cur_Head->flt_cnvrt[j]] = c1[j];
128  }
129  c1 += PORT_FLOAT;
130  c2 += sizeof(float);
131  }
132  }
133  return 1;
134 }
135 
136 /* read longs from the PVF file */
137 int dig__fread_port_L(long *buf, int cnt, GVFILE * fp)
138 {
139  int i, j, ret;
140  unsigned char *c1, *c2;
141 
142  if (Cur_Head->lng_quick) {
143  if (nat_lng == PORT_LONG) {
144  ret = dig_fread(buf, PORT_LONG, cnt, fp);
145  if (ret != cnt)
146  return 0;
147  }
148  else {
149  /* read into buffer */
150  buf_alloc(cnt * PORT_LONG);
151  ret = dig_fread(buffer, PORT_LONG, cnt, fp);
152  if (ret != cnt)
153  return 0;
154  /* set buffer to zero (positive numbers) */
155  memset(buf, 0, cnt * sizeof(long));
156  /* read from buffer in changed order */
157  c1 = (unsigned char *)buffer;
158  c2 = (unsigned char *)buf;
159  for (i = 0; i < cnt; i++) {
160  /* set to FF if the value is negative */
161  if (lng_order == ENDIAN_LITTLE) {
162  if (c1[PORT_LONG - 1] & 0x80)
163  memset(c2, 0xff, sizeof(long));
164  memcpy(c2, c1, PORT_LONG);
165  }
166  else {
167  if (c1[0] & 0x80)
168  memset(c2, 0xff, sizeof(long));
169  memcpy(c2 + nat_lng - PORT_LONG, c1, PORT_LONG);
170  }
171  c1 += PORT_LONG;
172  c2 += sizeof(long);
173  }
174  }
175  }
176  else {
177  /* read into buffer */
178  buf_alloc(cnt * PORT_LONG);
179  ret = dig_fread(buffer, PORT_LONG, cnt, fp);
180  if (ret != cnt)
181  return 0;
182  /* set buffer to zero (positive numbers) */
183  memset(buf, 0, cnt * sizeof(long));
184  /* read from buffer in changed order */
185  c1 = (unsigned char *)buffer;
186  c2 = (unsigned char *)buf;
187  for (i = 0; i < cnt; i++) {
188  /* set to FF if the value is negative */
189  if (Cur_Head->byte_order == ENDIAN_LITTLE) {
190  if (c1[PORT_LONG - 1] & 0x80)
191  memset(c2, 0xff, sizeof(long));
192  }
193  else {
194  if (c1[0] & 0x80)
195  memset(c2, 0xff, sizeof(long));
196  }
197  for (j = 0; j < PORT_LONG; j++)
198  c2[Cur_Head->lng_cnvrt[j]] = c1[j];
199  c1 += PORT_LONG;
200  c2 += sizeof(long);
201  }
202  }
203  return 1;
204 }
205 
206 /* read ints from the PVF file */
207 int dig__fread_port_I(int *buf, int cnt, GVFILE * fp)
208 {
209  int i, j, ret;
210  unsigned char *c1, *c2;
211 
212  if (Cur_Head->int_quick) {
213  if (nat_int == PORT_INT) {
214  ret = dig_fread(buf, PORT_INT, cnt, fp);
215  if (ret != cnt)
216  return 0;
217  }
218  else {
219  /* read into buffer */
220  buf_alloc(cnt * PORT_INT);
221  ret = dig_fread(buffer, PORT_INT, cnt, fp);
222  if (ret != cnt)
223  return 0;
224  /* set buffer to zero (positive numbers) */
225  memset(buf, 0, cnt * sizeof(int));
226  /* read from buffer in changed order */
227  c1 = (unsigned char *)buffer;
228  c2 = (unsigned char *)buf;
229  for (i = 0; i < cnt; i++) {
230  /* set to FF if the value is negative */
231  if (int_order == ENDIAN_LITTLE) {
232  if (c1[PORT_INT - 1] & 0x80)
233  memset(c2, 0xff, sizeof(int));
234  memcpy(c2, c1, PORT_INT);
235  }
236  else {
237  if (c1[0] & 0x80)
238  memset(c2, 0xff, sizeof(int));
239  memcpy(c2 + nat_int - PORT_INT, c1, PORT_INT);
240  }
241  c1 += PORT_INT;
242  c2 += sizeof(int);
243  }
244  }
245  }
246  else {
247  /* read into buffer */
248  buf_alloc(cnt * PORT_INT);
249  ret = dig_fread(buffer, PORT_INT, cnt, fp);
250  if (ret != cnt)
251  return 0;
252  /* set buffer to zero (positive numbers) */
253  memset(buf, 0, cnt * sizeof(int));
254  /* read from buffer in changed order */
255  c1 = (unsigned char *)buffer;
256  c2 = (unsigned char *)buf;
257  for (i = 0; i < cnt; i++) {
258  /* set to FF if the value is negative */
259  if (Cur_Head->byte_order == ENDIAN_LITTLE) {
260  if (c1[PORT_INT - 1] & 0x80)
261  memset(c2, 0xff, sizeof(int));
262  }
263  else {
264  if (c1[0] & 0x80)
265  memset(c2, 0xff, sizeof(int));
266  }
267  for (j = 0; j < PORT_INT; j++)
268  c2[Cur_Head->int_cnvrt[j]] = c1[j];
269  c1 += PORT_INT;
270  c2 += sizeof(int);
271  }
272  }
273  return 1;
274 }
275 
276 /* read shorts from the PVF file */
277 int dig__fread_port_S(short *buf, int cnt, GVFILE * fp)
278 {
279  int i, j, ret;
280  unsigned char *c1, *c2;
281 
282  if (Cur_Head->shrt_quick) {
283  if (nat_shrt == PORT_SHORT) {
284  ret = dig_fread(buf, PORT_SHORT, cnt, fp);
285  if (ret != cnt)
286  return 0;
287  }
288  else {
289  /* read into buffer */
290  buf_alloc(cnt * PORT_SHORT);
291  if (0 >= (ret = dig_fread(buffer, PORT_SHORT, cnt, fp)))
292  if (ret != cnt)
293  return 0;
294  /* set buffer to zero (positive numbers) */
295  memset(buf, 0, cnt * sizeof(short));
296  /* read from buffer in changed order */
297  c1 = (unsigned char *)buffer;
298  c2 = (unsigned char *)buf;
299  for (i = 0; i < cnt; i++) {
300  /* set to FF if the value is negative */
301  if (shrt_order == ENDIAN_LITTLE) {
302  if (c1[PORT_SHORT - 1] & 0x80)
303  memset(c2, 0xff, sizeof(short));
304  memcpy(c2, c1, PORT_SHORT);
305  }
306  else {
307  if (c1[0] & 0x80)
308  memset(c2, 0xff, sizeof(short));
309  memcpy(c2 + nat_shrt - PORT_SHORT, c1, PORT_SHORT);
310  }
311  c1 += PORT_SHORT;
312  c2 += sizeof(short);
313  }
314  }
315  }
316  else {
317  /* read into buffer */
318  buf_alloc(cnt * PORT_SHORT);
319  ret = dig_fread(buffer, PORT_SHORT, cnt, fp);
320  if (ret != cnt)
321  return 0;
322  /* set buffer to zero (positive numbers) */
323  memset(buf, 0, cnt * sizeof(short));
324  /* read from buffer in changed order */
325  c1 = (unsigned char *)buffer;
326  c2 = (unsigned char *)buf;
327  for (i = 0; i < cnt; i++) {
328  /* set to FF if the value is negative */
329  if (Cur_Head->byte_order == ENDIAN_LITTLE) {
330  if (c1[PORT_SHORT - 1] & 0x80)
331  memset(c2, 0xff, sizeof(short));
332  }
333  else {
334  if (c1[0] & 0x80)
335  memset(c2, 0xff, sizeof(short));
336  }
337  for (j = 0; j < PORT_SHORT; j++)
338  c2[Cur_Head->shrt_cnvrt[j]] = c1[j];
339  c1 += PORT_SHORT;
340  c2 += sizeof(short);
341  }
342  }
343  return 1;
344 }
345 
346 /* read chars from the PVF file */
347 int dig__fread_port_C(char *buf, int cnt, GVFILE * fp)
348 {
349  int ret;
350 
351  ret = dig_fread(buf, PORT_CHAR, cnt, fp);
352  if (ret != cnt)
353  return 0;
354  return 1;
355 }
356 
357 /* read plus_t from the PVF file */
358 /* plus_t is defined as int so we only retype pointer and use int function */
359 int dig__fread_port_P(plus_t * buf, int cnt, GVFILE * fp)
360 {
361  int *ibuf;
362 
363  ibuf = (int *)buf;
364 
365  return (dig__fread_port_I(ibuf, cnt, fp));
366 }
367 
368 /***************************** WRITE ************************************/
369 
370 int dig__fwrite_port_D(double *buf, /* DOUBLE */
371  int cnt, GVFILE * fp)
372 {
373  int i, j;
374  unsigned char *c1, *c2;
375 
376  if (Cur_Head->dbl_quick) {
377  if (dig_fwrite(buf, PORT_DOUBLE, cnt, fp) == cnt)
378  return 1;
379  }
380  else {
381  buf_alloc(cnt * PORT_DOUBLE);
382  c1 = (unsigned char *)buf;
383  c2 = (unsigned char *)buffer;
384  for (i = 0; i < cnt; i++) {
385  for (j = 0; j < PORT_DOUBLE; j++)
386  c2[j] = c1[Cur_Head->dbl_cnvrt[j]];
387  c1 += sizeof(double);
388  c2 += PORT_DOUBLE;
389  }
390  if (dig_fwrite(buffer, PORT_DOUBLE, cnt, fp) == cnt)
391  return 1;
392  }
393  return 0;
394 }
395 
396 int dig__fwrite_port_F(float *buf, /* FLOAT */
397  int cnt, GVFILE * fp)
398 {
399  int i, j;
400  unsigned char *c1, *c2;
401 
402  if (Cur_Head->flt_quick) {
403  if (dig_fwrite(buf, PORT_FLOAT, cnt, fp) == cnt)
404  return 1;
405  }
406  else {
407  buf_alloc(cnt * PORT_FLOAT);
408  c1 = (unsigned char *)buf;
409  c2 = (unsigned char *)buffer;
410  for (i = 0; i < cnt; i++) {
411  for (j = 0; j < PORT_FLOAT; j++)
412  c2[j] = c1[Cur_Head->flt_cnvrt[j]];
413  c1 += sizeof(float);
414  c2 += PORT_FLOAT;
415  }
416  if (dig_fwrite(buffer, PORT_FLOAT, cnt, fp) == cnt)
417  return 1;
418  }
419  return 0;
420 }
421 
422 int dig__fwrite_port_L(long *buf, /* LONG */
423  int cnt, GVFILE * fp)
424 {
425  int i, j;
426  unsigned char *c1, *c2;
427 
428  if (Cur_Head->lng_quick) {
429  if (nat_lng == PORT_LONG) {
430  if (dig_fwrite(buf, PORT_LONG, cnt, fp) == cnt)
431  return 1;
432  }
433  else {
434  buf_alloc(cnt * PORT_LONG);
435  c1 = (unsigned char *)buf;
436  c2 = (unsigned char *)buffer;
437  for (i = 0; i < cnt; i++) {
438  if (lng_order == ENDIAN_LITTLE)
439  memcpy(c2, c1, PORT_LONG);
440  else
441  memcpy(c2, c1 + nat_lng - PORT_LONG, PORT_LONG);
442  c1 += sizeof(long);
443  c2 += PORT_LONG;
444  }
445  if (dig_fwrite(buffer, PORT_LONG, cnt, fp) == cnt)
446  return 1;
447  }
448  }
449  else {
450  buf_alloc(cnt * PORT_LONG);
451  c1 = (unsigned char *)buf;
452  c2 = (unsigned char *)buffer;
453  for (i = 0; i < cnt; i++) {
454  for (j = 0; j < PORT_LONG; j++)
455  c2[j] = c1[Cur_Head->lng_cnvrt[j]];
456  c1 += sizeof(long);
457  c2 += PORT_LONG;
458  }
459  if (dig_fwrite(buffer, PORT_LONG, cnt, fp) == cnt)
460  return 1;
461  }
462  return 0;
463 }
464 
465 int dig__fwrite_port_I(int *buf, /* INT */
466  int cnt, GVFILE * fp)
467 {
468  int i, j;
469  unsigned char *c1, *c2;
470 
471  if (Cur_Head->int_quick) {
472  if (nat_int == PORT_INT) {
473  if (dig_fwrite(buf, PORT_INT, cnt, fp) == cnt)
474  return 1;
475  }
476  else {
477  buf_alloc(cnt * PORT_INT);
478  c1 = (unsigned char *)buf;
479  c2 = (unsigned char *)buffer;
480  for (i = 0; i < cnt; i++) {
481  if (int_order == ENDIAN_LITTLE)
482  memcpy(c2, c1, PORT_INT);
483  else
484  memcpy(c2, c1 + nat_int - PORT_INT, PORT_INT);
485  c1 += sizeof(int);
486  c2 += PORT_INT;
487  }
488  if (dig_fwrite(buffer, PORT_INT, cnt, fp) == cnt)
489  return 1;
490  }
491  }
492  else {
493  buf_alloc(cnt * PORT_INT);
494  c1 = (unsigned char *)buf;
495  c2 = (unsigned char *)buffer;
496  for (i = 0; i < cnt; i++) {
497  for (j = 0; j < PORT_INT; j++)
498  c2[j] = c1[Cur_Head->int_cnvrt[j]];
499  c1 += sizeof(int);
500  c2 += PORT_INT;
501  }
502  if (dig_fwrite(buffer, PORT_INT, cnt, fp) == cnt)
503  return 1;
504  }
505  return 0;
506 }
507 
508 int dig__fwrite_port_S(short *buf, /* SHORT */
509  int cnt, GVFILE * fp)
510 {
511  int i, j;
512  unsigned char *c1, *c2;
513 
514  if (Cur_Head->shrt_quick) {
515  if (nat_shrt == PORT_SHORT) {
516  if (dig_fwrite(buf, PORT_SHORT, cnt, fp) == cnt)
517  return 1;
518  }
519  else {
520  buf_alloc(cnt * PORT_SHORT);
521  c1 = (unsigned char *)buf;
522  c2 = (unsigned char *)buffer;
523  for (i = 0; i < cnt; i++) {
524  if (shrt_order == ENDIAN_LITTLE)
525  memcpy(c2, c1, PORT_SHORT);
526  else
527  memcpy(c2, c1 + nat_shrt - PORT_SHORT, PORT_SHORT);
528  c1 += sizeof(short);
529  c2 += PORT_SHORT;
530  }
531  if (dig_fwrite(buffer, PORT_SHORT, cnt, fp) == cnt)
532  return 1;
533  }
534  }
535  else {
536  buf_alloc(cnt * PORT_SHORT);
537  c1 = (unsigned char *)buf;
538  c2 = (unsigned char *)buffer;
539  for (i = 0; i < cnt; i++) {
540  for (j = 0; j < PORT_SHORT; j++)
541  c2[j] = c1[Cur_Head->shrt_cnvrt[j]];
542  c1 += sizeof(short);
543  c2 += PORT_SHORT;
544  }
545  if (dig_fwrite(buffer, PORT_SHORT, cnt, fp) == cnt)
546  return 1;
547  }
548  return 0;
549 }
550 
551 /* plus_t is defined as int so we only retype pointer and use int function */
552 int dig__fwrite_port_P(plus_t * buf, /* PLUS_T->INT */
553  int cnt, GVFILE * fp)
554 {
555  return (dig__fwrite_port_I((int *)buf, cnt, fp));
556 }
557 
558 int dig__fwrite_port_C(char *buf, /* CHAR */
559  int cnt, GVFILE * fp)
560 {
561  if (dig_fwrite(buf, PORT_CHAR, cnt, fp) == cnt)
562  return 1;
563 
564  return 0;
565 }
566 
567 /* set portable info structure to byte order of file */
568 void dig_init_portable(struct Port_info *port, int byte_order)
569 {
570  int i;
571 
572  port_init();
573 
574  port->byte_order = byte_order;
575 
576  if (port->byte_order == dbl_order)
577  port->dbl_quick = TRUE;
578  else
579  port->dbl_quick = FALSE;
580 
581  for (i = 0; i < PORT_DOUBLE; i++) {
582  if (port->byte_order == ENDIAN_BIG)
583  port->dbl_cnvrt[i] = dbl_cnvrt[i];
584  else
585  port->dbl_cnvrt[i] = dbl_cnvrt[PORT_DOUBLE - i - 1];
586  }
587 
588  if (port->byte_order == flt_order)
589  port->flt_quick = TRUE;
590  else
591  port->flt_quick = FALSE;
592 
593  for (i = 0; i < PORT_FLOAT; i++) {
594  if (port->byte_order == ENDIAN_BIG)
595  port->flt_cnvrt[i] = flt_cnvrt[i];
596  else
597  port->flt_cnvrt[i] = flt_cnvrt[PORT_FLOAT - i - 1];
598  }
599 
600  if (port->byte_order == lng_order)
601  port->lng_quick = TRUE;
602  else
603  port->lng_quick = FALSE;
604 
605  for (i = 0; i < PORT_LONG; i++) {
606  if (port->byte_order == ENDIAN_BIG)
607  port->lng_cnvrt[i] = lng_cnvrt[i];
608  else
609  port->lng_cnvrt[i] = lng_cnvrt[PORT_LONG - i - 1];
610  }
611 
612  if (port->byte_order == int_order)
613  port->int_quick = TRUE;
614  else
615  port->int_quick = FALSE;
616 
617  for (i = 0; i < PORT_INT; i++) {
618  if (port->byte_order == ENDIAN_BIG)
619  port->int_cnvrt[i] = int_cnvrt[i];
620  else
621  port->int_cnvrt[i] = int_cnvrt[PORT_INT - i - 1];
622  }
623 
624  if (port->byte_order == shrt_order)
625  port->shrt_quick = TRUE;
626  else
627  port->shrt_quick = FALSE;
628 
629  for (i = 0; i < PORT_SHORT; i++) {
630  if (port->byte_order == ENDIAN_BIG)
631  port->shrt_cnvrt[i] = shrt_cnvrt[i];
632  else
633  port->shrt_cnvrt[i] = shrt_cnvrt[PORT_SHORT - i - 1];
634  }
635 
636  return;
637 }
638 
639 /* set current portable info */
640 int dig_set_cur_port(struct Port_info *port)
641 {
642  Cur_Head = port;
643  return 0;
644 }
645 
647 {
648  if (dbl_order == ENDIAN_LITTLE)
649  return (ENDIAN_LITTLE);
650  else
651  return (ENDIAN_BIG);
652 }
size_t dig_fwrite(void *ptr, size_t size, size_t nmemb, GVFILE *file)
Write GVFILE.
Definition: file.c:154
unsigned char lng_cnvrt[sizeof(long)]
Definition: port_init.c:93
int dig_set_cur_port(struct Port_info *port)
Definition: portable.c:640
int dig__fread_port_P(plus_t *buf, int cnt, GVFILE *fp)
Definition: portable.c:359
#define FALSE
Definition: dbfopen.c:117
int nat_lng
Definition: port_init.c:81
int nat_dbl
Definition: port_init.c:79
int dig__fread_port_S(short *buf, int cnt, GVFILE *fp)
Definition: portable.c:277
int dig__fwrite_port_D(double *buf, int cnt, GVFILE *fp)
Definition: portable.c:370
void dig_init_portable(struct Port_info *port, int byte_order)
Definition: portable.c:568
int dig__fread_port_L(long *buf, int cnt, GVFILE *fp)
Definition: portable.c:137
int nat_flt
Definition: port_init.c:80
int flt_order
Definition: port_init.c:86
int dig__fwrite_port_I(int *buf, int cnt, GVFILE *fp)
Definition: portable.c:465
int dig_out_of_memory()
Definition: struct_alloc.c:369
#define TRUE
Definition: dbfopen.c:118
int dig__fwrite_port_P(plus_t *buf, int cnt, GVFILE *fp)
Definition: portable.c:552
int dig__fwrite_port_L(long *buf, int cnt, GVFILE *fp)
Definition: portable.c:422
unsigned char dbl_cnvrt[sizeof(double)]
Definition: port_init.c:91
int
Definition: g3dcolor.c:48
int dig__fread_port_D(double *buf, int cnt, GVFILE *fp)
Definition: portable.c:75
struct Port_info * Cur_Head
Definition: portable.c:42
int dig__fread_port_F(float *buf, int cnt, GVFILE *fp)
Definition: portable.c:106
int dbl_order
Definition: port_init.c:85
int nat_shrt
Definition: port_init.c:83
int nat_int
Definition: port_init.c:82
char buf[GNAME_MAX+sizeof(G3D_DIRECTORY)+2]
Definition: g3drange.c:62
int int_order
Definition: port_init.c:88
int lng_order
Definition: port_init.c:87
int dig__fread_port_C(char *buf, int cnt, GVFILE *fp)
Definition: portable.c:347
return NULL
Definition: dbfopen.c:1394
int shrt_order
Definition: port_init.c:89
unsigned char int_cnvrt[sizeof(int)]
Definition: port_init.c:94
unsigned char shrt_cnvrt[sizeof(short)]
Definition: port_init.c:95
void * dig__alloc_space(int n_wanted, int *n_elements, int chunk_size, void *ptr, int element_size)
Definition: allocation.c:50
int dig__fwrite_port_F(float *buf, int cnt, GVFILE *fp)
Definition: portable.c:396
int dig__fwrite_port_C(char *buf, int cnt, GVFILE *fp)
Definition: portable.c:558
int dig__byte_order_out()
Definition: portable.c:646
int dig__fwrite_port_S(short *buf, int cnt, GVFILE *fp)
Definition: portable.c:508
size_t dig_fread(void *ptr, size_t size, size_t nmemb, GVFILE *file)
Read GVFILE.
Definition: file.c:122
int dig__fread_port_I(int *buf, int cnt, GVFILE *fp)
Definition: portable.c:207
unsigned char flt_cnvrt[sizeof(float)]
Definition: port_init.c:92
void port_init(void)
Definition: port_init.c:148