82 buf = (
char *)malloc(
sizeof(
int));
83 temp_buf = (
char *)malloc(
sizeof(
int));
84 memcpy(temp_buf,&input,
sizeof(
int));
85 for(i=0;i<
sizeof(int);i++)
86 buf[i] = temp_buf[len-i-1];
88 free(buf);free(temp_buf);
98 char temp[4],des_temp[4];
101 int_len =
sizeof(int);
102 memcpy(temp,buffer,int_len);
103 for(i=0;i<int_len;i++)
104 des_temp[i] = temp[int_len-i-1];
105 memcpy(buffer,des_temp,int_len);
115 char temp[4],des_temp[4];
118 int_len =
sizeof(int);
121 memcpy(temp,&source[i],
sizeof(
int));
122 for(j=0;j<int_len;j++)
123 des_temp[j] = temp[int_len - j - 1];
124 memcpy(&(des[i]),des_temp,
sizeof(
int));
135 char temp[2],des_temp[2];
138 short_len =
sizeof(short);
141 memcpy(temp,&source[i],short_len);
142 for(j=0; j<short_len;j++)
143 des_temp[j] = temp[short_len -j -1];
144 memcpy(&(des[i]),des_temp,short_len);
155 char temp[8],des_temp[8];
161 memcpy(temp,&source[i],long_len);
162 for(j=0; j< long_len;j++)
163 des_temp[j] = temp[long_len -j -1];
164 memcpy(&(des[i]),des_temp,long_len);
178 temp_ptr = (
char *)malloc(size*n_items);
179 nbytes = fread(temp_ptr,size,n_items,stream);
196 int int_len, short_len, long_len;
197 int i, j, depth, current_type;
198 int header1, header2;
199 int ev_size, ev_tag, ev_num, ev_type;
200 int bk_size, bk_tag, bk_num, bk_type;
201 int sg_size, sg_tag, sg_num, sg_type;
202 short pk_size, pk_tag, pack;
203 char temp[4],temp2[2];
205 int_len =
sizeof(int);
206 short_len =
sizeof(short);
211 ev_size = *(
int *)(temp);
212 memcpy(&(buffer[i*2]),temp,int_len);
215 header2 = *(
int *)(temp);
216 ev_tag =(header2 >> 16) & (0x0000ffff);
217 ev_type=(header2 >> 8) & (0x000000ff);
218 ev_num = (header2) & (0x000000ff);
219 memcpy(&(buffer[i*2]),temp,int_len);
227 ev_size = ev_size + 1;
230 lk.head_pos = i + 2*(ev_size - 1);
232 current_type = ev_type;
236 while (i < ev_size*2){
238 while(((p =
evStack_top(head)) !=
NULL) && i == (p->length + p->posi)){
243 if (i == lk.head_pos){
249 header1 = *(
int *)(temp);
251 memcpy(&(buffer[i*2]),temp,int_len);
254 header2 = *(
int *)(temp);
255 memcpy(&(buffer[i*2]),temp,int_len);
256 bk_tag = (header2 >> 16) & (0x0000ffff);
257 bk_type = (header2 >> 8) & (0x000000ff);
258 bk_num = (header2) & (0x000000ff);
259 depth = head->length;
260 if (bk_type >= 0x10){
267 current_type = bk_type;
268 lk.head_pos = i + bk_size*2;
274 header2 = *(
int *)(temp);
275 memcpy(&(buffer[i*2]),temp,int_len);
276 sg_size = (header2) & (0x0000ffff);
277 sg_size = sg_size + 1;
278 sg_tag = (header2 >> 24) & (0x000000ff);
279 sg_type = (header2 >> 16) & (0x000000ff);
287 current_type = sg_type;
288 lk.head_pos = i + sg_size*2;
294 pack = *(
short *)(temp2);
295 memcpy(&(buffer[i*2]),temp2,short_len);
301 pk_tag = (pack >> 8) & (0x00ff);
302 pk_size = (pack) & (0x00ff);
303 current_type = lk.type;
304 lk.head_pos = i + pk_size + 1;
311 switch(current_type){
316 for(j = i; j < lk.head_pos; j=j+2){
318 memcpy(&(buffer[j*2]),temp,int_len);
327 for(j = i; j < lk.head_pos; j=j+1){
329 memcpy(&(buffer[j*2]),temp2,short_len);
338 memcpy(&(buffer[i*2]),&(source[i*2]),(lk.head_pos - i)*2);
343 for(j = i; j < lk.head_pos; j=j+4){
345 memcpy(&(buffer[j*2]),temp,long_len);
350 for(j = i; j < lk.head_pos; j=j+2){
352 memcpy(&(buffer[j*2]),temp,int_len);
357 fprintf(stderr,
"Wrong datatype 0x%x\n",current_type);
376 fprintf(stderr,
"Cannot allocate memory for evStack\n");
413 fprintf(stderr,
"Empty stack\n");
436 fprintf(stderr,
"Not enough memory for stack item\n");
static void evStack_free()
static void evStack_pushon()
void swapped_shortcpy(char *des, char *source, int size)
int int_swap_byte(int input)
void swapped_intcpy(char *des, char *source, int size)
void onmemory_swap(char *buffer)
static evStack * evStack_top()
void swapped_longcpy(char *des, char *source, int size)
void swapped_memcpy(char *buffer, char *source, int size)
static evStack * init_evStack()
static void evStack_popoff()
int swapped_fread(void *ptr, int size, int n_items, FILE *stream)