summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcello Stanisci <marcello.stanisci@inria.fr>2015-11-02 21:49:23 +0100
committerMarcello Stanisci <marcello.stanisci@inria.fr>2015-11-02 21:49:23 +0100
commit3a3c842e0eb3efeea45155c5ef06d5662733f332 (patch)
treed5bee12d233c31dd1ba5a16e28676aa02f25255a
parentc239900bb1c5529267015311e104d461da36d737 (diff)
downloadmerchant-3a3c842e0eb3efeea45155c5ef06d5662733f332.tar.gz
merchant-3a3c842e0eb3efeea45155c5ef06d5662733f332.tar.bz2
merchant-3a3c842e0eb3efeea45155c5ef06d5662733f332.zip
adding fetch of strings in "TMH_PARSE_navigate_json ()". Not finished
-rw-r--r--src/backend/taler-mint-httpd_parsing.c29
-rw-r--r--src/backend/taler-mint-httpd_parsing.h7
2 files changed, 34 insertions, 2 deletions
diff --git a/src/backend/taler-mint-httpd_parsing.c b/src/backend/taler-mint-httpd_parsing.c
index a4dc43ab..3a076cef 100644
--- a/src/backend/taler-mint-httpd_parsing.c
+++ b/src/backend/taler-mint-httpd_parsing.c
@@ -347,6 +347,25 @@ TMH_PARSE_post_json (struct MHD_Connection *connection,
return GNUNET_YES;
}
+/**
+ * Generate line in parser specification for string. The returned
+ * string is already nul-terminated internally by JSON, so no length
+ * information is provided. The string will live as long as the containg
+ * JSON will
+ * @param field name of the field
+ * @param[out] pointer to the string
+ * @return corresponding field spec
+ */
+struct TMH_PARSE_FieldSpecification
+TMH_PARSE_member_string (const char *field,
+ char **out)
+{
+ struct TMH_PARSE_FieldSpecification ret =
+ {field, (void **) out, 0, NULL, TMH_PARSE_JNC_RET_STRING, 0};
+ return ret;
+
+
+}
/**
* Generate line in parser specification for 64-bit integer
@@ -499,7 +518,8 @@ TMH_PARSE_member_variable (const char *field,
*
* @param connection the connection to send an error response to
* @param root the JSON node to start the navigation at.
- * @param ... navigation specification (see `enum TMH_PARSE_JsonNavigationCommand`)
+ * @param ... navigation specification (see
+ * `enum TMH_PARSE_JsonNavigationCommand`)
* @return
* #GNUNET_YES if navigation was successful
* #GNUNET_NO if json is malformed, error response was generated
@@ -611,6 +631,13 @@ TMH_PARSE_navigate_json (struct MHD_Connection *connection,
}
break;
+ case TMH_PARSE_JNC_RET_STRING:
+ {
+ void **where = va_arg (argp, void **);
+ *where = json_string_value (root);
+ ret = GNUNET_OK;
+
+ }
case TMH_PARSE_JNC_RET_DATA_VAR:
{
void **where = va_arg (argp, void **);
diff --git a/src/backend/taler-mint-httpd_parsing.h b/src/backend/taler-mint-httpd_parsing.h
index d6a2b4ea..e9fad54e 100644
--- a/src/backend/taler-mint-httpd_parsing.h
+++ b/src/backend/taler-mint-httpd_parsing.h
@@ -139,7 +139,12 @@ enum TMH_PARSE_JsonNavigationCommand
* encoded as a JSON integer.
* Param: uint64_t *
*/
- TMH_PARSE_JNC_RET_UINT64
+ TMH_PARSE_JNC_RET_UINT64,
+ /**
+ * Return a 'char *' as returned from 'json_string_value ()'.
+ * So it will live as long as the containg JSON is not freed
+ */
+ TMH_PARSE_JNC_RET_STRING
};