|
10 | 10 |
|
11 | 11 |
|
12 | 12 | /* --------------------------------------------------------------------- */
|
13 |
| -/* Is the other way around than system ntoh/hton, so we roll our own |
14 |
| -here */ |
15 |
| - |
16 |
| -#ifndefBYTE_ORDER |
| 13 | +/* These definitions for ntoh/hton are the other way around from the |
| 14 | + * default system definitions, so we roll our own here. |
| 15 | + */ |
| 16 | + |
| 17 | +#ifndefBYTE_ORDER |
17 | 18 | #error BYTE_ORDER must be defined as LITTLE_ENDIAN, BIG_ENDIAN or PDP_ENDIAN
|
18 | 19 | #endif
|
19 | 20 |
|
|
24 | 25 | # definehton_l(n) n
|
25 | 26 | #else/* BYTE_ORDER != LITTLE_ENDIAN */
|
26 | 27 | # ifBYTE_ORDER==BIG_ENDIAN
|
27 |
| -# definentoh_s(n) (u_short)(((u_char *) &n)[0] << 8 | ((u_char *) &n)[1]) |
28 |
| -# definentoh_l(n) (u_long)(((u_char *)&n)[0] << 24 | \ |
29 |
| -((u_char *)&n)[1] << 16 | \ |
30 |
| - ((u_char *)&n)[2] << 8 | ((u_char *)&n)[3]) |
31 |
| -# definehton_s(n) (u_short)(((u_char *) &n)[2] << 8 | ((u_char *) &n)[3]) |
| 28 | +# definentoh_s(n) (u_short)(((u_char *)&n)[1] << 8 \ |
| 29 | + | ((u_char *)&n)[0]) |
| 30 | +# definentoh_l(n) (u_long) (((u_char *)&n)[3] << 24 \ |
| 31 | + | ((u_char *)&n)[2] << 16 \ |
| 32 | + | ((u_char *)&n)[1] << 8 \ |
| 33 | + | ((u_char *)&n)[0]) |
| 34 | +# definehton_s(n) (ntoh_s(n)) |
32 | 35 | # definehton_l(n) (ntoh_l(n))
|
33 | 36 | # else/* BYTE_ORDER != BIG_ENDIAN */
|
34 | 37 | # ifBYTE_ORDER==PDP_ENDIAN
|
|
43 | 46 | intpqPutShort(intinteger,FILE*f)
|
44 | 47 | {
|
45 | 48 | intretval=0;
|
46 |
| -u_shortn; |
| 49 | +u_shortn,s; |
47 | 50 |
|
48 |
| -n=hton_s(integer); |
| 51 | +s=integer; |
| 52 | +n=hton_s(s); |
49 | 53 | if(fwrite(&n,sizeof(u_short),1,f)!=1)
|
50 | 54 | retval=EOF;
|
51 | 55 |
|
|