diff --git a/include/psyc/text.h b/include/psyc/text.h index a94dd3b..a09d3fb 100644 --- a/include/psyc/text.h +++ b/include/psyc/text.h @@ -64,7 +64,7 @@ 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); +typedef psycTextValueRC (*psycTextCB)(const char *name, size_t len, psycString *value, void *extra); /** * Initializes the PSYC text state struct. @@ -158,7 +158,7 @@ size_t psyc_getTextBytesWritten (psycTextState *state) * * @see http://about.psyc.eu/psyctext **/ -psycTextRC psyc_text (psycTextState *state, psycTextCB getValue); +psycTextRC psyc_text (psycTextState *state, psycTextCB getValue, void *extra); /** @} */ // end of text group diff --git a/lib/Makefile b/lib/Makefile index fa8114a..62f7a85 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -2,7 +2,7 @@ prefix = /usr libdir = ${prefix}/lib INSTALL = install -LIBS = libpsyc.a +LIBS = libpsyc.a libpsyc.so install: ${LIBS} @@ -10,7 +10,7 @@ libdir: ${INSTALL} -d ${libdir} ${LIBS}: libdir - ${INSTALL} $@ ${libdir} + -${INSTALL} $@ ${libdir} clean: rm -f ${LIBS} diff --git a/src/text.c b/src/text.c index c4a5fea..944dd41 100644 --- a/src/text.c +++ b/src/text.c @@ -1,7 +1,7 @@ #include "lib.h" #include -psycTextRC psyc_text (psycTextState *state, psycTextCB getValue) +psycTextRC psyc_text (psycTextState *state, psycTextCB getValue, void* extra) { const char *start = state->tmpl.ptr, *end; // start & end of variable name const char *prev = state->tmpl.ptr + state->cursor; @@ -35,7 +35,7 @@ psycTextRC psyc_text (psycTextState *state, psycTextCB getValue) continue; // [] is invalid, name can't be empty } - ret = getValue(start + state->open.length, end - start - state->open.length, &value); + ret = getValue(start + state->open.length, end - start - state->open.length, &value, extra); if (ret < 0) continue; // value not found, no substitution diff --git a/test/testText.c b/test/testText.c index 21f732d..5f667f5 100644 --- a/test/testText.c +++ b/test/testText.c @@ -7,7 +7,7 @@ uint8_t verbose; -psycTextValueRC getValueFooBar (const char *name, size_t len, psycString *value) +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) +psycTextValueRC getValueEmpty (const char *name, size_t len, psycString *value, void *extra) { if (verbose) printf("> getValue: %.*s\n", (int)len, name); @@ -25,7 +25,7 @@ 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) +psycTextValueRC getValueNotFound (const char *name, size_t len, psycString *value, void *extra) { if (verbose) printf("> getValue: %.*s\n", (int)len, name); @@ -41,7 +41,7 @@ int testText (char *template, size_t tmplen, char *buffer, size_t buflen, psycSt psyc_initTextState(&state, template, tmplen, buffer, buflen); do { - ret = psyc_text(&state, getValue); + ret = psyc_text(&state, getValue, NULL); length += psyc_getTextBytesWritten(&state); switch (ret) {