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