aboutsummaryrefslogtreecommitdiffstats
path: root/src/libmdsserver/util.h
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2015-08-19 14:04:36 +0200
committerMattias Andrée <maandree@operamail.com>2015-08-19 14:04:36 +0200
commite8f32d09348b2e7504d3c33c97f3c854f3f75dec (patch)
tree935d1dd1ae9eb550d5fe9d86989d06871672adb0 /src/libmdsserver/util.h
parentput full_send in libmdsserver, clients that only has one socket uses a macro to remove the socket parameter (diff)
downloadmds-e8f32d09348b2e7504d3c33c97f3c854f3f75dec.tar.gz
mds-e8f32d09348b2e7504d3c33c97f3c854f3f75dec.tar.bz2
mds-e8f32d09348b2e7504d3c33c97f3c854f3f75dec.tar.xz
add strict_atoj and strict_atouj
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/libmdsserver/util.h')
-rw-r--r--src/libmdsserver/util.h24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/libmdsserver/util.h b/src/libmdsserver/util.h
index accf038..c84156d 100644
--- a/src/libmdsserver/util.h
+++ b/src/libmdsserver/util.h
@@ -110,6 +110,28 @@ size_t send_message(int socket, const char* message, size_t length);
int strict_atoi(const char* str, int* value, int min, int max);
/**
+ * A version of `atoj` that is strict about the syntax and bounds
+ *
+ * @param str The text to parse
+ * @param value Slot in which to store the value
+ * @param min The minimum accepted value
+ * @param max The maximum accepted value
+ * @return Zero on success, -1 on syntax error
+ */
+int strict_atoj(const char* str, intmax_t* value, intmax_t min, intmax_t max);
+
+/**
+ * A version of `atouj` that is strict about the syntax and bounds
+ *
+ * @param str The text to parse
+ * @param value Slot in which to store the value
+ * @param min The minimum accepted value
+ * @param max The maximum accepted value
+ * @return Zero on success, -1 on syntax error
+ */
+int strict_atouj(const char* str, uintmax_t* value, uintmax_t min, uintmax_t max);
+
+/**
* Send a buffer into a file and ignore interruptions
*
* @param fd The file descriptor
@@ -128,7 +150,6 @@ int full_write(int fd, const char* buffer, size_t length);
*/
char* full_read(int fd, size_t* length);
-
/**
* Send a full message even if interrupted
*
@@ -139,7 +160,6 @@ char* full_read(int fd, size_t* length);
*/
int full_send(int socket, const char* message, size_t length);
-
/**
* Check whether a string begins with a specific string,
* where neither of the strings are necessarily NUL-terminated