mirror of
git://git.psyc.eu/libpsyc
synced 2024-08-15 03:19:02 +00:00
refactoring - renamed types
This commit is contained in:
parent
f1028663dd
commit
f25e768482
23 changed files with 257 additions and 257 deletions
|
@ -13,18 +13,18 @@ int main (int argc, char **argv) {
|
|||
uint8_t verbose = argc > 1;
|
||||
int i, k, n, ret;
|
||||
|
||||
psycParseListState listState;
|
||||
psycList list_text, list_bin;
|
||||
psycString elems_text[NELEMS], elems_bin[NELEMS], elem;
|
||||
PsycParseListState listState;
|
||||
PsycList list_text, list_bin;
|
||||
PsycString elems_text[NELEMS], elems_bin[NELEMS], elem;
|
||||
char buf_text[NELEMS * 200], buf_bin[NELEMS * 200], *elems[NELEMS], **elems2 = NULL;
|
||||
|
||||
struct timeval start, end;
|
||||
|
||||
for (i=0; i<NELEMS; i++)
|
||||
elems_text[i] = (psycString) PSYC_C2STR("1234567890abcdefghijklmnopqrstuvwxyz-._ 1234567890abcdefghijklmnopqrstuvwxyz-._ 1234567890abcdefghijklmnopqrstuvwxyz-._ 1234567890");
|
||||
elems_text[i] = (PsycString) PSYC_C2STR("1234567890abcdefghijklmnopqrstuvwxyz-._ 1234567890abcdefghijklmnopqrstuvwxyz-._ 1234567890abcdefghijklmnopqrstuvwxyz-._ 1234567890");
|
||||
|
||||
for (i=0; i<NELEMS; i++)
|
||||
elems_bin[i] = (psycString) PSYC_C2STR("1234567890|abcdefghijklmnopqrstuvwxyz|_\n1234567890|abcdefghijklmnopqrstuvwxyz|_\n1234567890|abcdefghijklmnopqrstuvwxyz|_\n1234567890");
|
||||
elems_bin[i] = (PsycString) PSYC_C2STR("1234567890|abcdefghijklmnopqrstuvwxyz|_\n1234567890|abcdefghijklmnopqrstuvwxyz|_\n1234567890|abcdefghijklmnopqrstuvwxyz|_\n1234567890");
|
||||
|
||||
list_text = psyc_list_new(elems_text, PSYC_NUM_ELEM(elems_text), PSYC_LIST_NO_LENGTH);
|
||||
list_bin = psyc_list_new(elems_bin, PSYC_NUM_ELEM(elems_bin), PSYC_LIST_CHECK_LENGTH);
|
||||
|
|
|
@ -11,9 +11,9 @@ int main (int argc, char **argv)
|
|||
uint8_t verbose = argc > 2 && memchr(argv[2], (int)'v', strlen(argv[2]));
|
||||
int idx, ret;
|
||||
char buffer[2048], oper;
|
||||
psycString name, value, elem;
|
||||
psycParseState state;
|
||||
psycParseListState listState;
|
||||
PsycString name, value, elem;
|
||||
PsycParseState state;
|
||||
PsycParseListState listState;
|
||||
|
||||
if (argc < 2)
|
||||
return -1;
|
||||
|
|
|
@ -24,15 +24,15 @@ uint8_t verbose, stats;
|
|||
uint8_t multiple, single, routing_only, no_render, quiet, progress;
|
||||
size_t count = 1, recv_buf_size;
|
||||
|
||||
psycParseState parsers[NUM_PARSERS];
|
||||
psycPacket packets[NUM_PARSERS];
|
||||
psycModifier routing[NUM_PARSERS][ROUTING_LINES];
|
||||
psycModifier entity[NUM_PARSERS][ENTITY_LINES];
|
||||
PsycParseState parsers[NUM_PARSERS];
|
||||
PsycPacket packets[NUM_PARSERS];
|
||||
PsycModifier routing[NUM_PARSERS][ROUTING_LINES];
|
||||
PsycModifier entity[NUM_PARSERS][ENTITY_LINES];
|
||||
|
||||
int contbytes, exit_code;
|
||||
|
||||
static inline
|
||||
void resetString (psycString *s, uint8_t freeptr);
|
||||
void resetString (PsycString *s, uint8_t freeptr);
|
||||
|
||||
// initialize parser & packet variables
|
||||
void test_init (int i) {
|
||||
|
@ -40,9 +40,9 @@ void test_init (int i) {
|
|||
psyc_parse_state_init(&parsers[i], routing_only ?
|
||||
PSYC_PARSE_ROUTING_ONLY : PSYC_PARSE_ALL);
|
||||
|
||||
memset(&packets[i], 0, sizeof(psycPacket));
|
||||
memset(&routing[i], 0, sizeof(psycModifier) * ROUTING_LINES);
|
||||
memset(&entity[i], 0, sizeof(psycModifier) * ENTITY_LINES);
|
||||
memset(&packets[i], 0, sizeof(PsycPacket));
|
||||
memset(&routing[i], 0, sizeof(PsycModifier) * ROUTING_LINES);
|
||||
memset(&entity[i], 0, sizeof(PsycModifier) * ENTITY_LINES);
|
||||
packets[i].routing.modifiers = routing[i];
|
||||
packets[i].entity.modifiers = entity[i];
|
||||
}
|
||||
|
@ -63,14 +63,14 @@ int test_input (int i, char *recvbuf, size_t nbytes) {
|
|||
* to this function together with the new data.
|
||||
*/
|
||||
|
||||
psycParseState *parser = &parsers[i];
|
||||
psycPacket *packet = &packets[i];
|
||||
PsycParseState *parser = &parsers[i];
|
||||
PsycPacket *packet = &packets[i];
|
||||
|
||||
char oper;
|
||||
psycString name, value, elem;
|
||||
psycString *pname = NULL, *pvalue = NULL;
|
||||
psycModifier *mod = NULL;
|
||||
psycParseListState listState;
|
||||
PsycString name, value, elem;
|
||||
PsycString *pname = NULL, *pvalue = NULL;
|
||||
PsycModifier *mod = NULL;
|
||||
PsycParseListState listState;
|
||||
size_t len;
|
||||
|
||||
// Set buffer with data for the parser.
|
||||
|
@ -308,7 +308,7 @@ int test_input (int i, char *recvbuf, size_t nbytes) {
|
|||
}
|
||||
|
||||
static inline
|
||||
void resetString (psycString *s, uint8_t freeptr)
|
||||
void resetString (PsycString *s, uint8_t freeptr)
|
||||
{
|
||||
if (freeptr && s->length)
|
||||
free((void*)s->ptr);
|
||||
|
|
|
@ -23,7 +23,7 @@ uint8_t verbose, stats;
|
|||
uint8_t routing_only;
|
||||
size_t count = 1, recv_buf_size;
|
||||
|
||||
psycParseState parser;
|
||||
PsycParseState parser;
|
||||
|
||||
void test_init (int i) {
|
||||
psyc_parse_state_init(&parser, routing_only ?
|
||||
|
@ -32,7 +32,7 @@ void test_init (int i) {
|
|||
|
||||
int test_input (int i, char *recvbuf, size_t nbytes) {
|
||||
char oper;
|
||||
psycString name, value;
|
||||
PsycString name, value;
|
||||
int ret;
|
||||
|
||||
psyc_parse_buffer_set(&parser, recvbuf, nbytes);
|
||||
|
|
|
@ -11,12 +11,12 @@ int testPresence (const char *avail, int availlen,
|
|||
const char *desc, int desclen,
|
||||
const char *rendered, uint8_t verbose)
|
||||
{
|
||||
psycModifier routing[] = {
|
||||
PsycModifier routing[] = {
|
||||
psyc_modifier_new(C_GLYPH_OPERATOR_SET, PSYC_C2ARG("_context"), PSYC_C2ARG(myUNI),
|
||||
PSYC_MODIFIER_ROUTING),
|
||||
};
|
||||
|
||||
psycModifier entity[] = {
|
||||
PsycModifier entity[] = {
|
||||
// presence is to be assigned permanently in distributed state
|
||||
psyc_modifier_new(C_GLYPH_OPERATOR_ASSIGN, PSYC_C2ARG("_degree_availability"),
|
||||
avail, availlen, PSYC_MODIFIER_CHECK_LENGTH),
|
||||
|
@ -24,7 +24,7 @@ int testPresence (const char *avail, int availlen,
|
|||
desc, desclen, PSYC_MODIFIER_CHECK_LENGTH),
|
||||
};
|
||||
|
||||
psycPacket packet = psyc_packet_new(routing, PSYC_NUM_ELEM(routing),
|
||||
PsycPacket packet = psyc_packet_new(routing, PSYC_NUM_ELEM(routing),
|
||||
entity, PSYC_NUM_ELEM(entity),
|
||||
PSYC_C2ARG("_notice_presence"),
|
||||
NULL, 0,
|
||||
|
@ -39,26 +39,26 @@ int testPresence (const char *avail, int availlen,
|
|||
|
||||
int testList (const char *rendered, uint8_t verbose)
|
||||
{
|
||||
psycModifier routing[] = {
|
||||
PsycModifier routing[] = {
|
||||
psyc_modifier_new(C_GLYPH_OPERATOR_SET, PSYC_C2ARG("_source"), PSYC_C2ARG(myUNI),
|
||||
PSYC_MODIFIER_ROUTING),
|
||||
psyc_modifier_new(C_GLYPH_OPERATOR_SET, PSYC_C2ARG("_context"), PSYC_C2ARG(myUNI),
|
||||
PSYC_MODIFIER_ROUTING),
|
||||
};
|
||||
|
||||
psycString elems_text[] = {
|
||||
PsycString elems_text[] = {
|
||||
PSYC_C2STR("foo"),
|
||||
PSYC_C2STR("bar"),
|
||||
PSYC_C2STR("baz"),
|
||||
};
|
||||
|
||||
psycString elems_bin[] = {
|
||||
PsycString elems_bin[] = {
|
||||
PSYC_C2STR("foo"),
|
||||
PSYC_C2STR("b|r"),
|
||||
PSYC_C2STR("baz\nqux"),
|
||||
};
|
||||
|
||||
psycList list_text, list_bin;
|
||||
PsycList list_text, list_bin;
|
||||
list_text = psyc_list_new(elems_text, PSYC_NUM_ELEM(elems_text), PSYC_LIST_CHECK_LENGTH);
|
||||
list_bin = psyc_list_new(elems_bin, PSYC_NUM_ELEM(elems_bin), PSYC_LIST_CHECK_LENGTH);
|
||||
|
||||
|
@ -66,14 +66,14 @@ int testList (const char *rendered, uint8_t verbose)
|
|||
psyc_render_list(&list_text, buf_text, sizeof(buf_text));
|
||||
psyc_render_list(&list_bin, buf_bin, sizeof(buf_bin));
|
||||
|
||||
psycModifier entity[] = {
|
||||
PsycModifier entity[] = {
|
||||
psyc_modifier_new(C_GLYPH_OPERATOR_SET, PSYC_C2ARG("_list_text"),
|
||||
buf_text, list_text.length, list_text.flag),
|
||||
psyc_modifier_new(C_GLYPH_OPERATOR_SET, PSYC_C2ARG("_list_binary"),
|
||||
buf_bin, list_bin.length, list_bin.flag),
|
||||
};
|
||||
|
||||
psycPacket packet = psyc_packet_new(routing, PSYC_NUM_ELEM(routing),
|
||||
PsycPacket packet = psyc_packet_new(routing, PSYC_NUM_ELEM(routing),
|
||||
entity, PSYC_NUM_ELEM(entity),
|
||||
PSYC_C2ARG("_test_list"),
|
||||
PSYC_C2ARG("list test"),
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
uint8_t verbose;
|
||||
|
||||
psycTextValueRC getValueFooBar (const char *name, size_t len, psycString *value, void *extra)
|
||||
PsycTextValueRC getValueFooBar (const char *name, size_t len, PsycString *value, void *extra)
|
||||
{
|
||||
if (verbose)
|
||||
printf("> getValue: %.*s\n", (int)len, name);
|
||||
|
@ -16,7 +16,7 @@ psycTextValueRC getValueFooBar (const char *name, size_t len, psycString *value,
|
|||
return PSYC_TEXT_VALUE_FOUND;
|
||||
}
|
||||
|
||||
psycTextValueRC getValueEmpty (const char *name, size_t len, psycString *value, void *extra)
|
||||
PsycTextValueRC getValueEmpty (const char *name, size_t len, PsycString *value, void *extra)
|
||||
{
|
||||
if (verbose)
|
||||
printf("> getValue: %.*s\n", (int)len, name);
|
||||
|
@ -25,18 +25,18 @@ psycTextValueRC getValueEmpty (const char *name, size_t len, psycString *value,
|
|||
return PSYC_TEXT_VALUE_FOUND;
|
||||
}
|
||||
|
||||
psycTextValueRC getValueNotFound (const char *name, size_t len, psycString *value, void *extra)
|
||||
PsycTextValueRC getValueNotFound (const char *name, size_t len, PsycString *value, void *extra)
|
||||
{
|
||||
if (verbose)
|
||||
printf("> getValue: %.*s\n", (int)len, name);
|
||||
return PSYC_TEXT_VALUE_NOT_FOUND;
|
||||
}
|
||||
|
||||
int testText (char *template, size_t tmplen, char *buffer, size_t buflen, psycString *result, psycTextCB getValue)
|
||||
int testText (char *template, size_t tmplen, char *buffer, size_t buflen, PsycString *result, PsycTextCB getValue)
|
||||
{
|
||||
psycTextState state;
|
||||
PsycTextState state;
|
||||
size_t length = 0;
|
||||
psycTextRC ret;
|
||||
PsycTextRC ret;
|
||||
|
||||
psyc_text_state_init(&state, template, tmplen, buffer, buflen);
|
||||
do
|
||||
|
@ -71,7 +71,7 @@ int main(int argc, char **argv)
|
|||
{
|
||||
verbose = argc > 1;
|
||||
char buffer[BUFSIZE];
|
||||
psycString result;
|
||||
PsycString result;
|
||||
|
||||
char *str = "Hello [_foo] & [_bar]!";
|
||||
size_t len = strlen(str);
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
|
||||
void
|
||||
testUniform (char *str, int ret) {
|
||||
psycUniform *uni = malloc(sizeof(psycUniform));
|
||||
memset(uni, 0, sizeof(psycUniform));
|
||||
PsycUniform *uni = malloc(sizeof(PsycUniform));
|
||||
memset(uni, 0, sizeof(PsycUniform));
|
||||
printf("%s\n", str);
|
||||
int r = psyc_uniform_parse(uni, str, strlen(str));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue