20 #include <grass/Vect.h>
25 #define L_TEST 123456789
34 struct Port_info port;
37 double db, td[] = { -(PORT_DOUBLE_MAX), -(
D_TEST), -(PORT_DOUBLE_MIN),
38 0, PORT_DOUBLE_MIN,
D_TEST, PORT_DOUBLE_MAX
40 float fb, tf[] = { -(PORT_FLOAT_MAX), -(
D_TEST), -(PORT_FLOAT_MIN),
41 0, PORT_FLOAT_MIN,
D_TEST, PORT_FLOAT_MAX
43 long lb, tl[] = { PORT_LONG_MIN, -(
L_TEST), 0,
L_TEST, PORT_LONG_MAX };
44 int ib, ti[] = { PORT_INT_MIN, -(
L_TEST), 0,
L_TEST, PORT_INT_MAX };
45 short sb, ts[] = { PORT_SHORT_MIN, -(
S_TEST), 0,
S_TEST, PORT_SHORT_MAX };
46 char cb, tc[] = { PORT_CHAR_MIN, -(
C_TEST), 0,
C_TEST, PORT_CHAR_MAX };
50 if (
NULL == (fp.file = fopen(
"test.tmp",
"wb+"))) {
57 byte_order = ENDIAN_LITTLE;
58 for (i = 0; i < 2; i++) {
60 for (j = 0; j < 7; j++) {
62 fprintf(fp.file,
"double ");
68 G_warning(
"Error in read/write portable double, byte_order = %d"
69 " Written: %.16e3E Read: %.16e3E",
70 byte_order, td[j], db);
74 for (j = 0; j < 7; j++) {
76 fprintf(fp.file,
"float ");
82 G_warning(
"Error in read/write portable float, byte_order = %d"
83 " Written: %.8e3E Read: %.8e3E",
84 byte_order, tf[j], fb);
89 for (j = 0; j < 5; j++) {
91 fprintf(fp.file,
"long ");
97 G_warning(
"Error in read/write portable long, byte_order = %d"
98 " Written: %lu Read: %lu",
99 byte_order, (
long unsigned) tl[j], (
long unsigned) lb);
104 for (j = 0; j < 5; j++) {
106 fprintf(fp.file,
"int ");
112 G_warning(
"Error in read/write portable int, byte_order = %d"
113 " Written: %d Read: %d",
114 byte_order, ti[j], ib);
120 for (j = 0; j < 5; j++) {
122 fprintf(fp.file,
"short ");
128 G_warning(
"Error in read/write portable short, byte_order = %d"
129 " Written: %d Read: %d",
130 byte_order, ts[j], sb);
135 for (j = 0; j < 5; j++) {
137 fprintf(fp.file,
"char ");
143 G_warning(
"Error in read/write portable char, byte_order = %d"
144 " Written: %d Read: %d",
145 byte_order, tc[j], cb);
151 byte_order = ENDIAN_BIG;
int dig_set_cur_port(struct Port_info *port)
int dig__fread_port_S(short *buf, int cnt, GVFILE *fp)
int dig__fwrite_port_D(double *buf, int cnt, GVFILE *fp)
void dig_init_portable(struct Port_info *port, int byte_order)
int dig__fread_port_L(long *buf, int cnt, GVFILE *fp)
int dig__fwrite_port_I(int *buf, int cnt, GVFILE *fp)
int dig_fseek(GVFILE *file, long offset, int whence)
Set GVFILE position.
int main(int argc, char *argv[])
int dig__fwrite_port_L(long *buf, int cnt, GVFILE *fp)
int dig__fread_port_D(double *buf, int cnt, GVFILE *fp)
int dig__fread_port_F(float *buf, int cnt, GVFILE *fp)
int dig__fread_port_C(char *buf, int cnt, GVFILE *fp)
int dig_fflush(GVFILE *file)
Flush GVFILE.
G_warning("category support for [%s] in mapset [%s] %s", name, mapset, type)
int dig__fwrite_port_F(float *buf, int cnt, GVFILE *fp)
int dig__fwrite_port_C(char *buf, int cnt, GVFILE *fp)
int dig__fwrite_port_S(short *buf, int cnt, GVFILE *fp)
int G_fatal_error(const char *msg,...)
Print a fatal error message to stderr.
int dig__fread_port_I(int *buf, int cnt, GVFILE *fp)