aboutsummaryrefslogtreecommitdiffhomepage
path: root/backends/libmmbackend.h
diff options
context:
space:
mode:
Diffstat (limited to 'backends/libmmbackend.h')
-rw-r--r--backends/libmmbackend.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/backends/libmmbackend.h b/backends/libmmbackend.h
index 557c243..08f03aa 100644
--- a/backends/libmmbackend.h
+++ b/backends/libmmbackend.h
@@ -21,8 +21,30 @@
/** Convenience functions **/
+/*
+ * Duplicate src into *dest, freeing earlier content of *dest if present
+ * On success, 0 is returned
+ * On failure, a message is printed, *dest is a NULL pointer and 1 is returned
+ */
int mmbackend_strdup(char** dest, char* src);
+
+/*
+ * Return a formatted error message pertaining to the last socket operation.
+ * On Linux/OSX, this calls through to strerror using the provided err_no.
+ * On Windows, err_no is ignored and WSAGetLastError is called to retrieve
+ * the status of the last operation. This information is then processed via
+ * FormatMessage into a fixed buffer, which is returned. Thus, this function
+ * is not thread-safe on Windows. On Linux, refer to strerror's documentation
+ * for information on thread-safety.
+ */
char* mmbackend_socket_strerror(int err_no);
+
+/*
+ * Wrap / reimplement (on Windows) inet_ntop to work with struct sockaddr* directly.
+ * Prints the address in a "human-readable" form into buffer.
+ * Will modify at most length bytes into buffer, output will be zero-terminated.
+ * This function only works with AF_INET and AF_INET6 addresses.
+ */
const char* mmbackend_sockaddr_ntop(struct sockaddr* peer, char* buffer, size_t length);
/** Networking functions **/