common.h
author Tero Marttila <terom@fixme.fi>
Fri, 06 Jun 2008 03:24:55 +0300
changeset 9 fb6632e6c1bb
parent 8 4d38ccbeb93e
child 11 082bfaf38cf0
permissions -rw-r--r--
two new modules, remote_node and remote_pool

committer: Tero Marttila <terom@fixme.fi>

/*
 * error handling
 */

// perror + exit
void die (const char *msg);

// fprintf + newline
void error (const char *fmt, ...);

// fprintf + strerror + newline
void perr (const char *fmt, ...);

// fprintf + strerror + newline + exit
void perr_exit (const char *fmt, ...);

// fprintf + newline + exit
void err_exit (const char *fmt, ...);

/*
 * Parse a host:port string.
 *
 * Valid formats:
 *  host
 *  host:port
 *  [host]
 *  [host]:port
 *
 * The contents of the given hostport string *will* be modified.
 *
 * The value of *port will be set to NULL if no port was given.
 *
 * Returns 0 and sets *host if succesfull, nonzero otherwise.
 *
 */
int parse_hostport (char *hostport, char **host, char **port);