ReactOS 0.4.15-dev-8102-g108db8f
err.h
Go to the documentation of this file.
1/*
2
3 Copyright (C) 2010 Alex Andreotti <alex.andreotti@gmail.com>
4
5 This file is part of chmc.
6
7 chmc is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 chmc is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with chmc. If not, see <http://www.gnu.org/licenses/>.
19
20*/
21#ifndef CHMC_ERR_H
22#define CHMC_ERR_H
23
24#include <stdio.h>
25#define chmcerr_printf(fmt, ...) fprintf (stderr, fmt , ## __VA_ARGS__)
26
27#include <stdlib.h>
28#define BUG_ON(fmt, ...) \
29 do { \
30 fprintf (stderr, "%s:%d: ", __FILE__, __LINE__); \
31 fprintf (stderr, fmt , ## __VA_ARGS__); \
32 abort (); \
33 } while (0)
34
35#define CHMC_ERRMAXLEN (1023)
36
37#include <errno.h>
38
39#define CHMC_NOERR (0)
40#define CHMC_ENOMEM (ENOMEM)
41#define CHMC_EINVAL (EINVAL)
42
43void chmcerr_set(int code, const char *fmt, ...);
44void chmcerr_clean(void);
45int chmcerr_code(void);
46const char *chmcerr_message(void);
47
48#define chmc_error(fmt, ...) fprintf (stdout, fmt , ## __VA_ARGS__)
49
50#define chmcerr_return_msg(fmt,...) \
51 do { \
52 chmcerr_printf ( "%s: %d: ", __FILE__, __LINE__ ); \
53 chmcerr_printf ( "error %d: ", chmcerr_code () ); \
54 chmcerr_printf ( fmt , ## __VA_ARGS__ ); \
55 chmcerr_printf ( ": %s\n", chmcerr_message () ); \
56 return chmcerr_code (); \
57 } while (0)
58
59#define chmcerr_msg(fmt,...) \
60 do { \
61 chmcerr_printf ("%s: %d: ", __FILE__, __LINE__); \
62 chmcerr_printf ("error %d: ", chmcerr_code ()); \
63 chmcerr_printf (fmt , ## __VA_ARGS__ ); \
64 chmcerr_printf (": %s\n", chmcerr_message ()); \
65 } while (0)
66
67#define chmcerr_set_return(code,fmt,...) \
68 do { \
69 chmcerr_set ( (code), (fmt), ## __VA_ARGS__ ); \
70 return (code); \
71 } while (0)
72
73#endif /* CHMC_ERR_H */
int chmcerr_code(void)
Definition: err.c:42
void chmcerr_set(int code, const char *fmt,...)
Definition: err.c:50
const char * chmcerr_message(void)
Definition: err.c:46
void chmcerr_clean(void)
Definition: err.c:37
Definition: inflate.c:139
Definition: dsound.c:943