diff options
author | Christian Grothoff <christian@grothoff.org> | 2020-07-27 14:14:07 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2020-07-27 14:14:40 +0200 |
commit | 022fba51d569826a376f517e5ee3302222e7470c (patch) | |
tree | 68f207fa39a6d9c9681768be3d460a1cc2202762 /src/util/payto.c | |
parent | ccdbc2a4526c5f8750cdce2180b4d5f481d264b4 (diff) | |
parent | 6fd44ff2ea8f86655ac6450efd88da85b48211cf (diff) | |
download | exchange-022fba51d569826a376f517e5ee3302222e7470c.tar.xz |
better fix
Diffstat (limited to 'src/util/payto.c')
-rw-r--r-- | src/util/payto.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/util/payto.c b/src/util/payto.c index 3540052c1..4b2bbf4e3 100644 --- a/src/util/payto.c +++ b/src/util/payto.c @@ -29,6 +29,45 @@ /** + * Extract the subject value from the URI parameters. + * + * @param payto_uri the URL to parse + * @return NULL if the subject parameter is not found. + * The caller should free the returned value. + */ +char * +TALER_payto_get_subject (const char *payto_uri) +{ + const char *key; + const char *value_start; + const char *value_end; + + key = strchr (payto_uri, + (unsigned char) '?'); + if (NULL == key) + return NULL; + + do { + if (0 == strncasecmp (++key, + "subject", + strlen ("subject"))) + { + value_start = strchr (key, + (unsigned char) '='); + if (NULL == value_start) + return NULL; + value_end = strchrnul (value_start, + (unsigned char) '&'); + + return GNUNET_strndup (value_start + 1, + value_end - value_start - 1); + } + } while ( (key = strchr (key, + (unsigned char) '&')) ); + return NULL; +} + +/** * Obtain the payment method from a @a payto_uri. The * format of a payto URI is 'payto://$METHOD/$SOMETHING'. * We return $METHOD. |