diff options
author | Christian Hesse <mail@eworm.de> | 2016-05-09 11:53:44 +0200 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2016-05-09 11:53:44 +0200 |
commit | daddd6cb7d021a73de45cd21f42da438c65dc1df (patch) | |
tree | e54d7536ceff83cba45c40c0bbc6850aa4248daf /lib | |
parent | b6b192b49333ff18e1a4df53f27fc4873bf1ac25 (diff) | |
download | cqrlogo-daddd6cb7d021a73de45cd21f42da438c65dc1df.tar.gz cqrlogo-daddd6cb7d021a73de45cd21f42da438c65dc1df.tar.zst |
introduce cqr_get_query_char()
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libcqrlogo.c | 22 | ||||
-rw-r--r-- | lib/libcqrlogo.h | 2 |
2 files changed, 24 insertions, 0 deletions
diff --git a/lib/libcqrlogo.c b/lib/libcqrlogo.c index d2690ab..1502887 100644 --- a/lib/libcqrlogo.c +++ b/lib/libcqrlogo.c @@ -261,6 +261,28 @@ unsigned int cqr_get_query_uint(const char *query_string, const char *pattern, return value; } +/*** get_query_char ***/ +char * cqr_get_query_char(const char *query_string, const char *pattern) { + char *value = NULL, *cut = NULL; + const char *tmp = NULL, *match = NULL; + + if ((match = strstr(query_string, pattern)) == NULL) + return NULL; + + if ((tmp = strchr(match, '=')) == NULL) + return NULL; + + if (strlen(tmp) < 1) + return NULL; + + value = strdup(tmp + 1); + + if ((cut = strchr(value, '&')) != NULL) + *cut = '\0'; + + return value; +} + /*** get_ini_value ***/ unsigned int get_ini_value(dictionary * ini, uint8_t type, const char * section, const char * parameter, unsigned int value, unsigned int min, unsigned int max) { diff --git a/lib/libcqrlogo.h b/lib/libcqrlogo.h index 4be5087..cc3153c 100644 --- a/lib/libcqrlogo.h +++ b/lib/libcqrlogo.h @@ -80,6 +80,8 @@ struct cqr_png * cqr_encode_qrcode_to_png(const char *text, const struct cqr_con /*** cqr_get_query_uint ***/ unsigned int cqr_get_query_uint(const char *query_string, const char *pattern, unsigned int value, unsigned int min, unsigned int max); +/*** get_query_char ***/ +char * cqr_get_query_char(const char *query_string, const char *pattern); /*** cqr_get_ini_value ***/ unsigned int cqr_get_ini_value(dictionary * ini, uint8_t type, const char * section, const char * parameter, unsigned int value, unsigned int min, unsigned int max); |