diff options
author | cbdev <cb@cbcdn.com> | 2020-04-13 22:41:29 +0200 |
---|---|---|
committer | cbdev <cb@cbcdn.com> | 2020-04-13 22:41:29 +0200 |
commit | fe6a11b69fdc3ea7c01f8ffca0c0aa26abe6d9ca (patch) | |
tree | 3d58a4a726e020f5b68438ef67c5831c584a1401 /backends/libmmbackend.h | |
parent | dd90f0a2283e6feb36d553b32f96efae0999a916 (diff) | |
download | midimonster-fe6a11b69fdc3ea7c01f8ffca0c0aa26abe6d9ca.tar.gz midimonster-fe6a11b69fdc3ea7c01f8ffca0c0aa26abe6d9ca.tar.bz2 midimonster-fe6a11b69fdc3ea7c01f8ffca0c0aa26abe6d9ca.zip |
Refactor local address query, document libmmbackend calls
Diffstat (limited to 'backends/libmmbackend.h')
-rw-r--r-- | backends/libmmbackend.h | 22 |
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 **/ |