mirror of
git://git.psyced.org/git/psyclpc
synced 2024-08-15 03:20:16 +00:00
52 lines
1 KiB
C
52 lines
1 KiB
C
#ifdef USE_PSYC
|
|
# ifndef PKG_PSYC_H
|
|
|
|
/* 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
|
|
|
|
# include <psyc/parse.h>
|
|
|
|
# include "array.h"
|
|
# include "xalloc.h"
|
|
|
|
typedef struct psyc_state_s {
|
|
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;
|
|
} psyc_state_t;
|
|
|
|
static inline void
|
|
psyc_free_state (psyc_state_t *ps) {
|
|
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);
|
|
memset(ps, 0, sizeof(psyc_state_t));
|
|
}
|
|
|
|
# define PKG_PSYC_H
|
|
# endif
|
|
#endif
|