portable.c 15 KB

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