![]() | ![]() | ![]() | [Insert name here] Reference Manual | ![]() |
---|
void* prelude_realloc (void *ptr, size_t size); int prelude_resolve_addr (const char *hostname, struct in_addr *addr); int prelude_open_persistant_tmpfile (const char *filename, int flags, mode_t mode); int prelude_read_multiline (FILE *fd, int *line, char *buf, size_t size); uint64_t prelude_hton64 (uint64_t val);
void* prelude_realloc (void *ptr, size_t size);
prelude_realloc() changes the size of the memory block pointed to by ptr to size bytes. The contents will be unchanged to the minimum of the old and new sizes; newly allocated memory will be uninitialized. If ptr is NULL, the call is equivalent to malloc(size); if size is equal to zero, the call is equivalent to free(ptr). Unless ptr is NULL, it must have been returned by an earlier call to malloc(), calloc() or realloc().
This function exist because some version of realloc() doesn't handle the case where ptr is NULL. Even thought ANSI allow it.
ptr : | Pointer on a memory block. |
size : | New size. |
int prelude_resolve_addr (const char *hostname, struct in_addr *addr);
Lookup hostname, and store the resolved IP address in addr.
hostname : | Hostname to lookup. |
addr : | Pointer on an in_addr structure to store the result in. |
Returns : | 0 on success, -1 if an error occured. |
int prelude_open_persistant_tmpfile (const char *filename, int flags, mode_t mode);
Open a *possibly persistant* file for writing, trying to avoid symlink attack as much as possible.
The file is created if it does not exist. Refer to open(2) for flags and mode meaning.
filename : | Path to the file to open. |
flags : | Flags that should be used to open the file. |
mode : | Mode that should be used to open the file. |
Returns : | A valid file descriptor on success, -1 if an error occured. |
int prelude_read_multiline (FILE *fd, int *line, char *buf, size_t size);
This function handle reading line separated by the '\' character.
fd : | File descriptor to read input from. |
line : | Pointer to a line counter. |
buf : | Pointer to a buffer where the line should be stored. |
size : | Size of the buf buffer. |
Returns : | 0 on success, -1 if an error ocurred. |
uint64_t prelude_hton64 (uint64_t val);
The prelude_hton64() function converts the 64 bits unsigned integer val from host byte order to network byte order.
val : | Value to convert to network byte order. |
Returns : | val in the network bytes order. |
<<< timer | prelude-client-mgr >>> |