Enable GUI option for 'custom command' connection. Don't g_free strings in
[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 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 General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20  * USA
21  */
22
23 #ifndef CAMEL_ARG_H
24 #define CAMEL_ARG_H 1
25
26 #ifdef __cplusplus
27 extern "C" {
28 #pragma }
29 #endif                          /* __cplusplus } */
30
31 #include <glib.h>
32 #include <stdarg.h>
33
34 enum camel_arg_t {
35         CAMEL_ARG_END = 0,
36         CAMEL_ARG_IGNORE = 1,   /* override/ignore an arg in-place */
37
38         CAMEL_ARG_FIRST = 1024, /* 1024 args reserved for arg system */
39
40         CAMEL_ARG_TYPE = 0xf0000000, /* type field for tags */
41         CAMEL_ARG_TAG = 0x0fffffff, /* tag field for args */
42
43         CAMEL_ARG_OBJ = 0x00000000, /* object */
44         CAMEL_ARG_INT = 0x10000000, /* int */
45         CAMEL_ARG_DBL = 0x20000000, /* double */
46         CAMEL_ARG_STR = 0x30000000, /* c string */
47         CAMEL_ARG_PTR = 0x40000000, /* ptr */
48         CAMEL_ARG_BOO = 0x50000000, /* bool */
49 };
50
51 typedef struct _CamelArg CamelArg;
52 typedef struct _CamelArgV CamelArgV;
53
54 typedef struct _CamelArgGet CamelArgGet;
55 typedef struct _CamelArgGetV CamelArgGetV;
56
57 struct _CamelArg {
58         guint32 tag;
59         union {
60                 void *ca_object;
61                 int ca_int;
62                 double ca_double;
63                 char *ca_str;
64                 void *ca_ptr;
65         } u;
66 };
67 struct _CamelArgGet {
68         guint32 tag;
69         union {
70                 void **ca_object;
71                 int *ca_int;
72                 double *ca_double;
73                 char **ca_str;
74                 void **ca_ptr;
75         } u;
76 };
77 #define ca_object u.ca_object
78 #define ca_int u.ca_int
79 #define ca_double u.ca_double
80 #define ca_str u.ca_str
81 #define ca_ptr u.ca_ptr
82
83 /* maximum no of args processed at any one time, not the max of all args */
84 #define CAMEL_ARGV_MAX (20)
85
86 struct _CamelArgV {
87         va_list ap;
88         int argc;
89         CamelArg argv[CAMEL_ARGV_MAX];
90 };
91
92 struct _CamelArgGetV {
93         va_list ap;
94         int argc;
95         CamelArgGet argv[CAMEL_ARGV_MAX];
96 };
97
98 #define camel_argv_start(tv, last) va_start((tv)->ap, last)
99 #define camel_argv_end(tv) va_end((tv)->ap)
100 int camel_argv_build(CamelArgV *tv);
101 int camel_arggetv_build(CamelArgGetV *tv);
102
103 /* set an arg ignored */
104 #define camel_argv_ignore(tv, i) ((tv)->argv[i].tag = ((tv)->argv[i].tag & CAMEL_ARG_TYPE) | CAMEL_ARG_IGNORE)
105
106 /* 'self-describing' property list */
107 typedef struct _CamelProperty CamelProperty;
108
109 struct _CamelProperty {
110         guint32 tag;
111         char *name;
112         char *description;
113 };
114
115 #ifdef __cplusplus
116 }
117 #endif                          /* __cplusplus */
118
119 #endif                          /* CAMEL_ARG_H */