Cosmetics
[rawv.git] / misc.cpp
blobf09f8019674de852f81c09c139d9d1e348aa997d
1 /* misc utils for rawv
2 * Copyright (C) 2010 Kirill Smelkov <kirr@navytux.spb.ru>
3 * Copyright (C) 2011 Marine Bridge and Navigation Systems (http://mns.spb.ru/)
5 * This library is free software: you can Use, Study, Modify and Redistribute
6 * it under the terms of the GNU Lesser General Public License version 2.1, or
7 * any later version. This library is distributed WITHOUT ANY WARRANTY. See
8 * COPYING.LIB file for full License terms.
9 */
11 #include "rawv.h"
13 #include <stdarg.h>
14 #include <string.h>
15 #include <errno.h>
16 #include <stdio.h>
18 namespace rawv {
20 RawvError::RawvError(const char *msg) : std::runtime_error(msg)
23 RawvError::~RawvError() throw()
24 {} /* emits vtable here */
27 void die(const char *fmt, ...)
29 char msg[100];
30 va_list ap;
31 va_start(ap, fmt);
32 vsnprintf(msg, sizeof(msg), fmt, ap);
33 throw RawvError(msg);
36 void die_errno(const char *s)
38 die ("%s error %d, %s", s, errno, strerror (errno));
41 void warn(const char *fmt, ...)
43 va_list ap;
44 va_start(ap, fmt);
45 vfprintf(stderr, fmt, ap);
48 void warn_errno(const char *s)
50 warn ("W: %s error %d, %s\n", s, errno, strerror (errno));
54 } // rawv::