common.h
changeset 11 082bfaf38cf0
parent 8 4d38ccbeb93e
child 12 43297144f196
equal deleted inserted replaced
10:9daa832ab9c4 11:082bfaf38cf0
    16 void perr_exit (const char *fmt, ...);
    16 void perr_exit (const char *fmt, ...);
    17 
    17 
    18 // fprintf + newline + exit
    18 // fprintf + newline + exit
    19 void err_exit (const char *fmt, ...);
    19 void err_exit (const char *fmt, ...);
    20 
    20 
       
    21 // fprintf (__func__ + msg, ...)
       
    22 void err_func (const char *func, const char *fmt, ...);
       
    23 
       
    24 // fprintf (__func__ + msg + strerror, ...)
       
    25 void perr_func (const char *func, const char *fmt, ...);
       
    26 
       
    27 // error(func + colon + msg, ...) + goto error
       
    28 #define ERROR(msg) do { err_func(__func__, "%s", msg); goto error; } while (0)
       
    29 #define ERROR_FMT(fmt, ...) do { err_func(__func__, fmt, __VA_ARGS__); goto error; } while (0)
       
    30 #define PERROR(msg) do { perr_func(__func__, "%s", msg); goto error; } while (0)
       
    31 #define PERROR_FMT(fmt, ...) do { perr_func(__func__, fmt, __VA_ARGS__); goto error; } while (0)
       
    32 
    21 /*
    33 /*
    22  * Parse a host:port string.
    34  * Parse a host:port string.
    23  *
    35  *
    24  * Valid formats:
    36  * Valid formats:
    25  *  host
    37  *  host