Fix FSF address (Tobias Mueller, #470445)
[platform/upstream/evolution-data-server.git] / camel / camel-arg.h
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
2  *
3  * Author:
4  *  Michael Zucchi <notzed@ximian.com>
5  *
6  * Copyright 2002 Ximian, Inc. (www.ximian.com)
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of version 2 of the GNU Lesser General Public
10  * License as published by the Free Software Foundation.
11  *
12  * This program 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 Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
20  * USA
21  */
22
23 #ifndef CAMEL_ARG_H
24 #define CAMEL_ARG_H 1
25
26 #include <glib.h>
27 #include <stdarg.h>
28
29 G_BEGIN_DECLS
30
31 enum camel_arg_t {
32         CAMEL_ARG_END = 0,
33         CAMEL_ARG_IGNORE = 1,   /* override/ignore an arg in-place */
34
35         CAMEL_ARG_FIRST = 1024, /* 1024 args reserved for arg system */
36
37         CAMEL_ARG_TYPE = 0xf0000000, /* type field for tags */
38         CAMEL_ARG_TAG = 0x0fffffff, /* tag field for args */
39
40         CAMEL_ARG_OBJ = 0x00000000, /* object */
41         CAMEL_ARG_INT = 0x10000000, /* int */
42         CAMEL_ARG_DBL = 0x20000000, /* double */
43         CAMEL_ARG_STR = 0x30000000, /* c string */
44         CAMEL_ARG_PTR = 0x40000000, /* ptr */
45         CAMEL_ARG_BOO = 0x50000000, /* bool */
46 };
47
48 typedef struct _CamelArg CamelArg;
49 typedef struct _CamelArgV CamelArgV;
50
51 typedef struct _CamelArgGet CamelArgGet;
52 typedef struct _CamelArgGetV CamelArgGetV;
53
54 struct _CamelArg {
55         guint32 tag;
56         union {
57                 void *ca_object;
58                 int ca_int;
59                 double ca_double;
60                 char *ca_str;
61                 void *ca_ptr;
62         } u;
63 };
64 struct _CamelArgGet {
65         guint32 tag;
66         union {
67                 void **ca_object;
68                 int *ca_int;
69                 double *ca_double;
70                 char **ca_str;
71                 void **ca_ptr;
72         } u;
73 };
74 #define ca_object u.ca_object
75 #define ca_int u.ca_int
76 #define ca_double u.ca_double
77 #define ca_str u.ca_str
78 #define ca_ptr u.ca_ptr
79
80 /* maximum no of args processed at any one time, not the max of all args */
81 #define CAMEL_ARGV_MAX (20)
82
83 struct _CamelArgV {
84         va_list ap;
85         int argc;
86         CamelArg argv[CAMEL_ARGV_MAX];
87 };
88
89 struct _CamelArgGetV {
90         va_list ap;
91         int argc;
92         CamelArgGet argv[CAMEL_ARGV_MAX];
93 };
94
95 #define camel_argv_start(tv, last) va_start((tv)->ap, last)
96 #define camel_argv_end(tv) va_end((tv)->ap)
97 int camel_argv_build(CamelArgV *tv);
98 int camel_arggetv_build(CamelArgGetV *tv);
99
100 /* set an arg ignored */
101 #define camel_argv_ignore(tv, i) ((tv)->argv[i].tag = ((tv)->argv[i].tag & CAMEL_ARG_TYPE) | CAMEL_ARG_IGNORE)
102
103 /* 'self-describing' property list */
104 typedef struct _CamelProperty CamelProperty;
105
106 struct _CamelProperty {
107         guint32 tag;
108         char *name;
109         char *description;
110 };
111
112 G_END_DECLS
113
114 #endif /* CAMEL_ARG_H */