1 |
/* |
/* |
2 |
* Copyright (C) 2002-2003 Jean-Charles Salzeber <jc@varspool.net> |
* Copyright (C) 2002-2003 Jean-Charles Salzeber <chupa@penggy.org> |
3 |
* |
* |
4 |
* This file is part of penggy. |
* This file is part of penggy. |
5 |
* |
* |
56 |
#include "fdo/stream.h" |
#include "fdo/stream.h" |
57 |
#include "fdo/atoms.h" |
#include "fdo/atoms.h" |
58 |
|
|
59 |
|
#include "log.h" |
60 |
|
|
61 |
int |
int |
62 |
fdo_lookup_atom(pid, aid, def) |
fdo_lookup_atom(pid, aid, def) |
63 |
int pid; |
int pid; |
79 |
return 0; |
return 0; |
80 |
} |
} |
81 |
|
|
82 |
/* |
|
83 |
void |
void |
84 |
display_raw_arg(arg,length) |
display_raw_arg(arg,length) |
85 |
unsigned char *arg; |
unsigned char *arg; |
87 |
{ |
{ |
88 |
int i; |
int i; |
89 |
|
|
90 |
printf("#x"); |
debug(9, "#x"); |
91 |
for(i=0;i<length;i++) |
for(i=0;i<length;i++) |
92 |
printf("%02x", arg[i]); |
debug(9, "%02x", arg[i]); |
93 |
} |
} |
94 |
|
|
95 |
void |
void |
99 |
{ |
{ |
100 |
u_int32_t dword = 0; |
u_int32_t dword = 0; |
101 |
memcpy( ((char *)&dword) + (sizeof(dword)-length), arg, length); |
memcpy( ((char *)&dword) + (sizeof(dword)-length), arg, length); |
102 |
printf("%d", ntohl(dword)); |
debug(9, "%d", ntohl(dword)); |
103 |
} |
} |
104 |
|
|
105 |
void |
void |
110 |
char str[length+1]; |
char str[length+1]; |
111 |
memcpy(str,arg,length); |
memcpy(str,arg,length); |
112 |
str[length]=0; |
str[length]=0; |
113 |
printf("\"%s\"", str); |
debug(9, "\"%s\"", str); |
114 |
} |
} |
115 |
|
|
116 |
void |
void |
121 |
|
|
122 |
if(fdo_lookup_atom(atom.protid, atom.atomid, &def)) |
if(fdo_lookup_atom(atom.protid, atom.atomid, &def)) |
123 |
{ |
{ |
124 |
printf("\t(%s", def->name); |
debug(9, "\t(%s", def->name); |
125 |
if(atom.arg_length > 0) |
if(atom.arg_length > 0) |
126 |
{ |
{ |
127 |
printf(" "); |
debug(9, " "); |
128 |
switch(def->arg) |
switch(def->arg) |
129 |
{ |
{ |
130 |
default: |
default: |
140 |
break; |
break; |
141 |
} |
} |
142 |
} |
} |
143 |
printf(")\n"); |
debug(9, ")\n"); |
144 |
} |
} |
145 |
else |
else |
146 |
{ |
{ |
147 |
printf("\tunknown_atom(p%d,a%d)", atom.protid, atom.atomid); |
debug(9, "\tunknown_atom(p%d,a%d)", atom.protid, atom.atomid); |
148 |
if(atom.arg_length > 0) |
if(atom.arg_length > 0) |
149 |
{ |
{ |
150 |
printf(" "); |
debug(9, " "); |
151 |
display_raw_arg(atom.arg, atom.arg_length); |
display_raw_arg(atom.arg, atom.arg_length); |
152 |
} |
} |
153 |
printf("\n"); |
debug(9, "\n"); |
154 |
} |
} |
155 |
} |
} |
156 |
*/ |
|
157 |
|
|
158 |
void |
void |
159 |
extract_atoms(id, length, stream) |
extract_atoms(id, length, stream) |
169 |
char data; |
char data; |
170 |
fdo_stream_t *f; |
fdo_stream_t *f; |
171 |
|
|
172 |
|
debug(9, "Atom stream (id=%d):\n", id); |
173 |
while( nread < length ) |
while( nread < length ) |
174 |
{ |
{ |
175 |
f = get_stream(id); |
f = get_stream(id); |
246 |
atom.protid += prot_add; |
atom.protid += prot_add; |
247 |
atom.atomid += atom_add; |
atom.atomid += atom_add; |
248 |
f->last_pid = atom.protid; |
f->last_pid = atom.protid; |
249 |
if(is_eos_atom(atom.protid, atom.atomid)) |
/*if(is_eos_atom(atom.protid, atom.atomid)) |
250 |
close_stream(id); |
close_stream(id);*/ |
251 |
/*display_atom(atom);*/ |
display_atom(atom); |
252 |
} |
} |
253 |
|
debug(9, "\n"); |
254 |
} |
} |
255 |
|
|
256 |
void |
void |