Warning: That file was not part of the compilation database. It may have many parsing errors.

1#include <stdlib.h>
2#include <endian.h>
3#include <stdio.h>
4#include <errno.h>
5#include <string.h>
6
7extern long buffering_write(int outf, char *buffer, long num);
8extern int buffering_close(int fd);
9
10/* I wonder how many alignment issues this is gonna trip in the
11 future... it shouldn't trip any... I guess we'll find out :) */
12
13static inline int bigendianp(void){
14 int test=1;
15 char *hack=(char *)(&test);
16 if(hack[0])return(0);
17 return(1);
18}
19
20static inline int32_t swap32(int32_t x){
21 return((((u_int32_t)x & 0x000000ffU) << 24) |
22 (((u_int32_t)x & 0x0000ff00U) << 8) |
23 (((u_int32_t)x & 0x00ff0000U) >> 8) |
24 (((u_int32_t)x & 0xff000000U) >> 24));
25}
26
27static inline int16_t swap16(int16_t x){
28 return((((u_int16_t)x & 0x00ffU) << 8) |
29 (((u_int16_t)x & 0xff00U) >> 8));
30}
31
32#if BYTE_ORDER == LITTLE_ENDIAN
33
34static inline int32_t be32_to_cpu(int32_t x){
35 return(swap32(x));
36}
37
38static inline int16_t be16_to_cpu(int16_t x){
39 return(swap16(x));
40}
41
42static inline int32_t le32_to_cpu(int32_t x){
43 return(x);
44}
45
46static inline int16_t le16_to_cpu(int16_t x){
47 return(x);
48}
49
50#else
51
52static inline int32_t be32_to_cpu(int32_t x){
53 return(x);
54}
55
56static inline int16_t be16_to_cpu(int16_t x){
57 return(x);
58}
59
60static inline int32_t le32_to_cpu(int32_t x){
61 return(swap32(x));
62}
63
64static inline int16_t le16_to_cpu(int16_t x){
65 return(swap16(x));
66}
67
68
69#endif
70
71static inline int32_t cpu_to_be32(int32_t x){
72 return(be32_to_cpu(x));
73}
74
75static inline int32_t cpu_to_le32(int32_t x){
76 return(le32_to_cpu(x));
77}
78
79static inline int16_t cpu_to_be16(int16_t x){
80 return(be16_to_cpu(x));
81}
82
83static inline int16_t cpu_to_le16(int16_t x){
84 return(le16_to_cpu(x));
85}
86
87static inline char *copystring(const char *s){
88 if(s){
89 char *ret=malloc((strlen(s)+1)*sizeof(char));
90 strcpy(ret,s);
91 return(ret);
92 }
93 return(NULL);
94}
95
96static inline char *catstring(char *buff,const char *s){
97 if(s){
98 if(buff)
99 buff=realloc(buff,strlen(buff)+strlen(s)+1);
100 else
101 buff=calloc(strlen(s)+1,1);
102 strcat(buff,s);
103 }
104 return(buff);
105}
106
107

Warning: That file was not part of the compilation database. It may have many parsing errors.