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

56 lines
1.1 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-10 12:09:32 +00:00
psycParseState *parser;
vector_t *packet;
// 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;
2011-05-09 19:33:45 +00:00
} 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-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);
ps->name = ps->value = ps->remaining = NULL;
ps->parser = NULL;
ps->packet = NULL;
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