2011-05-06 20:15:37 +00:00
|
|
|
#ifdef USE_PSYC
|
2011-05-08 19:05:54 +00:00
|
|
|
# ifndef PKG_PSYC_H
|
2011-05-06 20:15:37 +00:00
|
|
|
|
2011-04-26 08:02:17 +00:00
|
|
|
/* pkg-psyc takes and produces PSYC packets in form
|
|
|
|
* of an array of mapping, mapping, string and string
|
|
|
|
* or int* where necessary.
|
|
|
|
*/
|
|
|
|
|
2011-05-09 19:33:45 +00:00
|
|
|
# include <psyc/parse.h>
|
2011-05-06 20:15:37 +00:00
|
|
|
|
2011-05-08 19:05:54 +00:00
|
|
|
# include "array.h"
|
|
|
|
# include "xalloc.h"
|
|
|
|
|
2011-05-11 15:09:22 +00:00
|
|
|
enum {
|
|
|
|
PSYC_ROUTING = 0,
|
|
|
|
PSYC_ENTITY = 1,
|
|
|
|
PSYC_METHOD = 2,
|
|
|
|
PSYC_BODY = 3,
|
|
|
|
};
|
|
|
|
|
2011-05-09 19:33:45 +00:00
|
|
|
typedef struct psyc_state_s {
|
2011-05-10 12:09:32 +00:00
|
|
|
psycParseState *parser;
|
|
|
|
vector_t *packet;
|
|
|
|
// tmp storage for incomplete modifier/body
|
|
|
|
char oper;
|
2011-05-11 15:09:22 +00:00
|
|
|
string_t *name;
|
|
|
|
string_t *value;
|
2011-05-10 12:09:32 +00:00
|
|
|
size_t value_len;
|
|
|
|
// tmp storage for remaining unparsed bytes at the end of the buffer
|
|
|
|
char *remaining;
|
|
|
|
size_t remaining_len;
|
2011-05-09 19:33:45 +00:00
|
|
|
} psyc_state_t;
|
2011-05-08 14:58:35 +00:00
|
|
|
|
2011-05-06 20:15:37 +00:00
|
|
|
static inline void
|
2011-05-09 19:33:45 +00:00
|
|
|
psyc_free_state (psyc_state_t *ps) {
|
2011-05-10 12:09:32 +00:00
|
|
|
if (!ps)
|
|
|
|
return;
|
|
|
|
if (ps->name)
|
|
|
|
pfree((void *) ps->name);
|
|
|
|
if (ps->value)
|
|
|
|
pfree((void *) ps->value);
|
|
|
|
if (ps->remaining)
|
|
|
|
pfree((void *) ps->remaining);
|
|
|
|
if (ps->parser)
|
|
|
|
pfree((void *) ps->parser);
|
|
|
|
if (ps->packet)
|
|
|
|
free_array(ps->packet);
|
2011-05-10 13:36:31 +00:00
|
|
|
memset(ps, 0, sizeof(psyc_state_t));
|
2011-05-06 20:15:37 +00:00
|
|
|
}
|
2011-04-26 08:02:17 +00:00
|
|
|
|
2011-05-08 19:05:54 +00:00
|
|
|
# define PKG_PSYC_H
|
|
|
|
# endif
|
2011-05-06 20:15:37 +00:00
|
|
|
#endif
|