summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-11-24 17:15:01 +0100
committerChristian Grothoff <christian@grothoff.org>2019-11-24 17:15:01 +0100
commit287a8dec9b3d6d2ee77a55fec4afff45f2cb826d (patch)
treedd19753c7e7440c9aa0ee2986dfa0d725f464ac4 /src/include
parent481223e2eb9d1311b245fc35ad487cffbbb4de8f (diff)
downloadexchange-287a8dec9b3d6d2ee77a55fec4afff45f2cb826d.tar.gz
exchange-287a8dec9b3d6d2ee77a55fec4afff45f2cb826d.tar.bz2
exchange-287a8dec9b3d6d2ee77a55fec4afff45f2cb826d.zip
add another convenience function to libtalermhd
Diffstat (limited to 'src/include')
-rw-r--r--src/include/taler_error_codes.h1
-rw-r--r--src/include/taler_mhd_lib.h52
2 files changed, 53 insertions, 0 deletions
diff --git a/src/include/taler_error_codes.h b/src/include/taler_error_codes.h
index 871ec2bf..55cdbacb 100644
--- a/src/include/taler_error_codes.h
+++ b/src/include/taler_error_codes.h
@@ -1442,6 +1442,7 @@ enum TALER_ErrorCode
* The amount to be refunded is inconsistent: either is lower than
* the previous amount being awarded, or it is too big to be paid back.
* In this second case, the fault stays on the business dept. side.
+ * Returned with an HTTP status of #MHD_HTTP_CONFLICT.
*/
TALER_EC_REFUND_INCONSISTENT_AMOUNT = 2602,
diff --git a/src/include/taler_mhd_lib.h b/src/include/taler_mhd_lib.h
index 17783f1c..cdbc8d29 100644
--- a/src/include/taler_mhd_lib.h
+++ b/src/include/taler_mhd_lib.h
@@ -144,6 +144,40 @@ TALER_MHD_reply_with_error (struct MHD_Connection *connection,
/**
+ * Make JSON response object.
+ *
+ * @param json the json object
+ * @return MHD response object
+ */
+struct MHD_Response *
+TALER_MHD_make_json (const json_t *json);
+
+
+/**
+ * Make JSON response object.
+ *
+ * @param fmt format string for pack
+ * @param ... varargs
+ * @return MHD response object
+ */
+struct MHD_Response *
+TALER_MHD_make_json_pack (const char *fmt,
+ ...);
+
+
+/**
+ * Create a response indicating an internal error.
+ *
+ * @param ec error code to return
+ * @param hint hint about the internal error's nature
+ * @return a MHD response object
+ */
+struct MHD_Response *
+TALER_MHD_make_error (enum TALER_ErrorCode ec,
+ const char *hint);
+
+
+/**
* Send a response indicating that the request was too big.
*
* @param connection the MHD connection to use
@@ -338,4 +372,22 @@ TALER_MHD_open_unix_path (const char *unix_path,
mode_t unix_mode);
+/**
+ * Bind a listen socket to the UNIX domain path
+ * or the TCP port and IP address as specified
+ * in @a cfg in section @a section. IF only a
+ * port was specified, set @a port and return -1.
+ * Otherwise, return the bound file descriptor.
+ *
+ * @param cfg configuration to parse
+ * @param section configuration section to use
+ * @param port[out] port to set, if TCP without BINDTO
+ * @return -1 and a port of zero on error, otherwise
+ * either -1 and a port, or a bound stream socket
+ */
+int
+TALER_MHD_bind (const struct GNUNET_CONFIGURATION_Handle *cfg,
+ const char *section,
+ uint16_t *port);
+
#endif