Next: , Previous: , Up: Embedding API   [Contents][Index]

5.2.5 Utility functions

Within this section you will find some miscellaneous functionality and left overs of the C API.

Function: void svz_log (int level, const char *format, …)

Print a message to the log system. level specifies the prefix.

Function: void svz_log_setfile (FILE *file)

Set the file stream file to the log file all messages are printed to. Can also be stdout or stderr.

Function: int svz_hexdump (FILE *out, char *action, int from, char *buffer, int len, int max)

Dump buffer with the length len to the file stream out. Display description action along with origin and size info first, followed by the hexadecimal text representation. Stop output at either max or len (if max is zero) bytes. from is a numerical identifier of the buffers creator.

Function: char * svz_itoa (unsigned int i)

Convert an unsigned integer to its decimal string representation, returning a pointer to an internal buffer. (You should copy the result.)

Function: unsigned int svz_atoi (char *str)

Convert string str in decimal format to an unsigned integer. Stop conversion on any invalid characters.

Function: char * svz_getcwd (void)

Return the current working directory in a newly allocated string. (You should svz_free it when done.)

Function: int svz_openfiles (int max_sockets)

Check for the current and maximum limit of open files of the current process and try to set the limit to max_sockets.

Function: char * svz_time (long t)

Transform the given binary data t (UTC time) to an ASCII time text representation without any trailing characters.

Function: char * svz_tolower (char *str)

Convert the given string str to lower case text representation.

Function: char * svz_sys_version (void)

Return a statically-allocated string describing some operating system version details.

Function: int svz_socket_unavailable_error_p (void)

Return 1 if there was a "socket unavailable" error recently, 0 otherwise. This checks svz_errno against WSAEWOULDBLOCK (woe32) or EAGAIN (Unix).

Function: const char * svz_sys_strerror (void)

Return a string describing the most recent system error.

The next two functions log (with SVZ_LOG_ERROR) the current system error or network error, forming the prefix of the message using fmt and args. This formatted prefix cannot exceed 255 bytes. The rest of the message comprises: colon, space, error description, newline.

Function: void svz_log_sys_error (char const *fmt, …)

Log the current system error.

Function: void svz_log_net_error (char const *fmt, …)

Log the current network error.

Function: int svz_mingw_at_least_nt4_p (void)

Return 1 if running MinGW (Windows) NT4x or later, otherwise 0.

Next: , Previous: , Up: Embedding API   [Contents][Index]