common.h
author Tero Marttila <terom@fixme.fi>
Fri, 06 Jun 2008 03:24:22 +0300
changeset 8 4d38ccbeb93e
parent 2 69f8c0acaac7
child 11 082bfaf38cf0
permissions -rw-r--r--
* fix Makefile to build in a (more) sensible way (still not really perfect)
* a parse_hostport in common
* fix warnings in render_file
* commandline argument parsing for render_node
* render_remote takes a struct remote_node, maintains its current_load, and actually close the socket after use now
* web_main uses a remote_pool, accepts nodes on the command line, and picks nodes from there for render_remote
* improve _http_render_execute error handling, sends back an error reply now
* ignore SIGPIPE. This hadn't shown up before (probably read-EOF instead), but it uncovered a bug in evhttp that caused an infinite bufferevent_write loop -> oom_killer -> DoS attack
* yes, this commit is missing four new files, those will be included in the next one

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);