Imported Upstream version 2.5.1
[debian/amanda] / common-src / arglist.h
1 /*
2  * Amanda, The Advanced Maryland Automatic Network Disk Archiver
3  * Copyright (c) 1991-1998 University of Maryland at College Park
4  * All Rights Reserved.
5  *
6  * Permission to use, copy, modify, distribute, and sell this software and its
7  * documentation for any purpose is hereby granted without fee, provided that
8  * the above copyright notice appear in all copies and that both that
9  * copyright notice and this permission notice appear in supporting
10  * documentation, and that the name of U.M. not be used in advertising or
11  * publicity pertaining to distribution of the software without specific,
12  * written prior permission.  U.M. makes no representations about the
13  * suitability of this software for any purpose.  It is provided "as is"
14  * without express or implied warranty.
15  *
16  * U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M.
18  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
20  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
21  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22  *
23  * Authors: the Amanda Development Team.  Its members are listed in a
24  * file named AUTHORS, in the root directory of this distribution.
25  */
26 /*
27  * $Id: arglist.h,v 1.9 2006/06/16 11:33:43 martinea Exp $
28  *
29  * support macros for variable argument list declaration and definition
30  */
31
32 #ifndef ARGLIST_H
33 #define ARGLIST_H
34
35 #ifdef STDC_HEADERS
36
37 #include <stdarg.h>
38
39 #define printf_arglist_function(fdecl, \
40                                 hook_type, hook_name) \
41         __attribute__ ((format (printf, 1, 0))) \
42         fdecl(hook_type hook_name, ...)
43
44 #define printf_arglist_function1(fdecl, \
45                                  arg1_type, arg1_name, \
46                                  hook_type, hook_name) \
47         __attribute__ ((format (printf, 2, 0))) \
48         fdecl(arg1_type arg1_name, \
49               hook_type hook_name, ...)
50
51 #define printf_arglist_function2(fdecl, \
52                                  arg1_type, arg1_name, \
53                                  arg2_type, arg2_name, \
54                                  hook_type, hook_name) \
55         __attribute__ ((format (printf, 3, 0))) \
56         fdecl(arg1_type arg1_name, \
57               arg2_type arg2_name, \
58               hook_type hook_name, ...)
59
60 #define printf_arglist_function3(fdecl, \
61                                  arg1_type, arg1_name, \
62                                  arg2_type, arg2_name, \
63                                  arg3_type, arg3_name, \
64                                  hook_type, hook_name) \
65         __attribute__ ((format (printf, 4, 0))) \
66         fdecl(arg1_type arg1_name, \
67               arg2_type arg2_name, \
68               arg3_type arg3_name, \
69               hook_type hook_name, ...)
70
71 #define arglist_function(fdecl, \
72                          hook_type, hook_name) \
73         fdecl(hook_type hook_name, ...)
74
75 #define arglist_function1(fdecl, \
76                           arg1_type, arg1_name, \
77                           hook_type, hook_name) \
78         fdecl(arg1_type arg1_name, \
79               hook_type hook_name, ...)
80
81 #define arglist_function2(fdecl, \
82                           arg1_type, arg1_name, \
83                           arg2_type, arg2_name, \
84                           hook_type, hook_name) \
85         fdecl(arg1_type arg1_name, \
86               arg2_type arg2_name, \
87               hook_type hook_name, ...)
88
89 #define arglist_function3(fdecl, arg1_type, arg1_name, arg2_type, arg2_name, \
90                           arg3_type, arg3_name, hook_type, hook_name) \
91         fdecl(arg1_type arg1_name, arg2_type arg2_name, \
92               arg3_type arg3_name, hook_type hook_name, ...)
93
94 #define arglist_start(arg,hook_name)    va_start(arg,hook_name)
95
96 #else
97
98 #include <varargs.h>
99
100 #define printf_arglist_function(fdecl, hook_type, hook_name) \
101         fdecl(hook_name, va_alist)      \
102         hook_type hook_name;            \
103         va_dcl
104
105 #define printf_arglist_function1(fdecl, arg1_type, arg1_name, hook_type, hook_name) \
106         fdecl(arg1_name, hook_name, va_alist)   \
107         arg1_type arg1_name;                    \
108         hook_type hook_name;                    \
109         va_dcl
110
111 #define printf_arglist_function2(fdecl, arg1_type, arg1_name, arg2_type, arg2_name, hook_type, hook_name) \
112         fdecl(arg1_name, arg2_name, hook_name, va_alist)        \
113         arg1_type arg1_name;                                    \
114         arg2_type arg2_name;                                    \
115         hook_type hook_name;                                    \
116         va_dcl
117
118 #define arglist_function(fdecl, hook_type, hook_name) \
119         fdecl(hook_name, va_alist)      \
120         hook_type hook_name;            \
121         va_dcl
122
123 #define arglist_function1(fdecl, arg1_type, arg1_name, hook_type, hook_name) \
124         fdecl(arg1_name, hook_name, va_alist)   \
125         arg1_type arg1_name;                    \
126         hook_type hook_name;                    \
127         va_dcl
128
129 #define arglist_function2(fdecl, arg1_type, arg1_name, arg2_type, arg2_name, hook_type, hook_name) \
130         fdecl(arg1_name, arg2_name, hook_name, va_alist)        \
131         arg1_type arg1_name;                                    \
132         arg2_type arg2_name;                                    \
133         hook_type hook_name;                                    \
134         va_dcl
135
136 #define arglist_function3(fdecl, arg1_type, arg1_name, arg2_type, arg2_name, \
137                           arg3_type, arg3_name, hook_type, hook_name) \
138         fdecl(arg1_name, arg2_name, arg3_name, hook_name, va_alist)     \
139         arg1_type arg1_name;                                            \
140         arg2_type arg2_name;                                            \
141         arg3_type arg3_name;                                            \
142         hook_type hook_name;                                            \
143         va_dcl
144
145 #define arglist_start(arg,hook_name)    va_start(arg)
146
147 #endif
148
149 #define arglist_val(arg,type)   va_arg(arg,type)
150 #define arglist_end(arg)        va_end(arg)
151
152 #endif /* !ARGLIST_H */