diff --git a/include/psyc/text.h b/include/psyc/text.h index 03d7aff..0588b65 100644 --- a/include/psyc/text.h +++ b/include/psyc/text.h @@ -62,8 +62,8 @@ typedef struct { * PSYC_TEXT_VALUE_NOT_FOUND if no match found in which case psyc_text * leaves the original template text as is. */ -typedef PsycTextValueRC (*PsycTextCB) (const char *name, size_t len, - PsycString *value, void *extra); +typedef PsycTextValueRC (*PsycTextCB) (void *cls, const char *name, size_t namelen, + PsycString *value); /** * Initializes the PSYC text state struct. @@ -156,7 +156,7 @@ psyc_text_bytes_written (PsycTextState *state) * @see http://about.psyc.eu/psyctext **/ PsycTextRC -psyc_text (PsycTextState *state, PsycTextCB getValue, void *extra); +psyc_text (PsycTextState *state, PsycTextCB get_value, void *get_value_cls); extern const PsycTemplates psyc_templates; diff --git a/src/render.c b/src/render.c index f0a93fe..d61e68e 100644 --- a/src/render.c +++ b/src/render.c @@ -60,7 +60,7 @@ psyc_render_table (PsycTable *table, char *buffer, size_t buflen) } static inline size_t -psyc_render_modifier (PsycModifier * mod, char *buffer) +psyc_render_modifier (PsycModifier *mod, char *buffer) { size_t cur = 0; @@ -87,7 +87,7 @@ psyc_render_modifier (PsycModifier * mod, char *buffer) static inline #endif PsycRenderRC -psyc_render (PsycPacket * packet, char *buffer, size_t buflen) +psyc_render (PsycPacket *packet, char *buffer, size_t buflen) { size_t i, cur = 0, len; diff --git a/src/text.c b/src/text.c index 6c91446..390460d 100644 --- a/src/text.c +++ b/src/text.c @@ -6,7 +6,7 @@ const PsycTemplates psyc_templates = { .s = { }}; PsycTextRC -psyc_text (PsycTextState *state, PsycTextCB get_value, void *extra) +psyc_text (PsycTextState *state, PsycTextCB get_value, void *get_value_cls) { const char *start = state->tmpl.data, *end; // start & end of variable name const char *prev = state->tmpl.data + state->cursor; @@ -38,8 +38,8 @@ psyc_text (PsycTextState *state, PsycTextCB get_value, void *extra) continue; // [] is invalid, name can't be empty } - ret = get_value(start + state->open.length, - end - start - state->open.length, &value, extra); + ret = get_value(get_value_cls, start + state->open.length, + end - start - state->open.length, &value); if (ret < 0) continue; // value not found, no substitution diff --git a/test/test_text.c b/test/test_text.c index 977a66e..cd6bf46 100644 --- a/test/test_text.c +++ b/test/test_text.c @@ -8,7 +8,7 @@ uint8_t verbose; PsycTextValueRC -getValueFooBar (const char *name, size_t len, PsycString *value, void *extra) +getValueFooBar (void *cls, const char *name, size_t len, PsycString *value) { if (verbose) printf("> getValue: %.*s\n", (int)len, name); @@ -18,7 +18,7 @@ getValueFooBar (const char *name, size_t len, PsycString *value, void *extra) } PsycTextValueRC -getValueEmpty (const char *name, size_t len, PsycString *value, void *extra) +getValueEmpty (void *cls, const char *name, size_t len, PsycString *value) { if (verbose) printf("> getValue: %.*s\n", (int)len, name); @@ -28,7 +28,7 @@ getValueEmpty (const char *name, size_t len, PsycString *value, void *extra) } PsycTextValueRC -getValueNotFound (const char *name, size_t len, PsycString *value, void *extra) +getValueNotFound (void *cls, const char *name, size_t len, PsycString *value) { if (verbose) printf("> getValue: %.*s\n", (int)len, name);