1
0
Fork 0
mirror of git://git.psyced.org/git/psyclpc synced 2024-08-15 03:20:16 +00:00
psyclpc/src/pkg-psyc.h

54 lines
1.2 KiB
C
Raw Normal View History

#ifdef USE_PSYC
2011-05-08 19:05:54 +00:00
# ifndef PKG_PSYC_H
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.
*/
# define PSYC_ROUTING 0
# define PSYC_ENTITY 1
# define PSYC_METHOD 2
# define PSYC_BODY 3
2011-05-09 19:33:45 +00:00
# include <psyc/parse.h>
2011-05-08 19:05:54 +00:00
# include "array.h"
# include "xalloc.h"
2011-05-09 19:33:45 +00:00
typedef struct psyc_state_s {
2011-05-08 14:58:35 +00:00
psycParseState *parser;
vector_t *packet;
2011-05-09 19:33:45 +00:00
// tmp storage for incomplete modifier/body
char oper;
char *name;
size_t name_len;
char *value;
size_t value_len;
// tmp storage for remaining unparsed bytes at the end of the buffer
char *remaining;
size_t remaining_len;
} psyc_state_t;
2011-05-08 14:58:35 +00:00
static inline void
2011-05-09 19:33:45 +00:00
psyc_free_state (psyc_state_t *ps) {
2011-05-08 14:58:35 +00:00
if (!ps)
return;
2011-05-09 19:33:45 +00:00
if (ps->name)
pfree((void *) ps->name);
if (ps->value)
pfree((void *) ps->value);
if (ps->remaining)
pfree((void *) ps->remaining);
2011-05-08 18:53:12 +00:00
if (ps->parser)
2011-05-08 19:05:54 +00:00
pfree((void *) ps->parser);
2011-05-08 14:58:35 +00:00
if (ps->packet)
free_array(ps->packet);
2011-05-09 23:02:14 +00:00
ps->name = ps->value = ps->remaining = ps->parser = ps->packet = NULL;
2011-05-09 19:33:45 +00:00
ps->oper = ps->name_len = ps->value_len = ps->remaining_len = 0;
}
2011-04-26 08:02:17 +00:00
2011-05-08 19:05:54 +00:00
# define PKG_PSYC_H
# endif
#endif