aboutsummaryrefslogtreecommitdiff
path: root/libmpio/debug.h
blob: c523310abd5ef04b34303e625f507f390bde74b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*
 * $Id: debug.h,v 1.5 2003/04/27 12:08:20 germeier Exp $
 *
 *  libmpio - a library for accessing Digit@lways MPIO players
 *  Copyright (C) 2002, 2003 Dirk Meyer  <dmeyer@tzi.de> and
 *                           Andreas Büsching <crunchy@tzi.de>
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2.1 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc.,g 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */

#ifndef _MPIO_DEBUG_H_
#define _MPIO_DEBUG_H_

// if DPACKAGE is not definied use PACKAGE or "unknown"

#ifndef DPACKAGE

#ifdef PACKAGE
#define DPACKAGE PACKAGE
#else
#define DPACKAGE unknown
#endif

#endif

#include <stdio.h>

#ifdef sun
#include <sys/int_types.h>
#else
#include <stdint.h>
#endif

#ifdef __cplusplus
extern "C" {
#endif

#ifndef PBOOL
#define PBOOL(x) (x)?"True":"False"
#endif

#define UNUSED(x) (x = x)

#define debugn(n,args...) \
   _debug_n(DPACKAGE, n, __FILE__, __LINE__, __FUNCTION__, args)

#define debug(args...) \
   _debug(DPACKAGE, __FILE__, __LINE__, __FUNCTION__, args)

#define debug_error(fatal,args...) \
   _error(DPACKAGE, __FILE__, __LINE__, __FUNCTION__, fatal, args)

#define hexdump(data,len) \
   _hexdump(DPACKAGE, __FILE__, __LINE__, __FUNCTION__, data, len)

#define hexdumpn(n,data,len) \
  _hexdump_n(DPACKAGE, n, __FILE__, __LINE__, __FUNCTION__, data, len)

#define hexdump_text(text,data,len) \
   _hexdump_text(text, DPACKAGE, __FILE__, __LINE__, __FUNCTION__, data, len)

#define octetstrdump(data,len) \
   _octetstr(DPACKAGE, __FILE__, __LINE__, __FUNCTION__, data, len)

#define ipadr_dump(data,len,text) \
   _octetstr(DPACKAGE, __FILE__, __LINE__, __FUNCTION__, data, len, text)

#define use_debug() \
   use_debug(DPACKAGE)


#define with_special_debug(what) \
   _use_debug(DPACKAGE, what)

void debug_init(void);
int debug_file(char *filename);
int debug_level(int level);
int debug_level_get(void);

void _debug(const char *package, const char* file, int line, 
	    const char* function, const char *format, ...);

void _debug_n(const char *package, const int n, const char* file, 
	      int line, const char* function, const char *format, ...);

void _hexdump (const char *package, const char* file, int line, 
	       const char* function, const char* data, int len);

void _hexdump_n (const char *package, const int n, const char* file, int line, 
		 const char* function, const char* data, int len);

void _hexdump_text (const char *text, 
		    const char *package, const char* file, int line, 
		    const char* function, const char* data, int len);

void _error(const char *package, const char* file, int line, 
	    const char* function, int fatal, const char *format, ...);

void _octetstr(const char *package, const char* file, int line, 
	       const char* function, const uint8_t *str, 
	       const unsigned int len, const char *what);

int _use_debug(int level);

#ifdef __cplusplus
}
#endif 

#endif /* _MPIO_DEBUG_H_ */

/* end of debug.h */