Fix FSF address (Tobias Mueller, #470445)
[platform/upstream/evolution-data-server.git] / camel / camel-arg.c
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 #ifdef HAVE_CONFIG_H
24 #include <config.h>
25 #endif
26
27 #include <stdio.h>
28
29 #include "camel-arg.h"
30
31 int camel_argv_build(CamelArgV *tv)
32 {
33         register guint32 tag;
34         register int i;
35         register CamelArg *a;
36         int more = TRUE;
37
38         for (i=0;i<CAMEL_ARGV_MAX;i++) {
39                 a = &tv->argv[i];
40
41                 if ( (tag = va_arg(tv->ap, guint32)) == 0) {
42                         more = FALSE;
43                         break;
44                 }
45
46                 a->tag = tag;
47
48                 switch((tag & CAMEL_ARG_TYPE)) {
49                 case CAMEL_ARG_OBJ:
50                         a->ca_object = va_arg(tv->ap, void *);
51                         break;
52                 case CAMEL_ARG_INT:
53                         a->ca_int = va_arg(tv->ap, int);
54                         break;
55                 case CAMEL_ARG_DBL:
56                         a->ca_double = va_arg(tv->ap, double);
57                         break;
58                 case CAMEL_ARG_STR:
59                         a->ca_str = va_arg(tv->ap, char *);
60                         break;
61                 case CAMEL_ARG_PTR:
62                         a->ca_ptr = va_arg(tv->ap, void *);
63                         break;
64                 case CAMEL_ARG_BOO:
65                         a->ca_int = va_arg(tv->ap, int) != 0;
66                         break;
67                 default:
68                         printf("Error, unknown type, truncating result\n");
69                         more = FALSE;
70                         goto fail;
71                 }
72
73         }
74 fail:
75         tv->argc = i;
76
77         return more;
78 }
79
80 int camel_arggetv_build(CamelArgGetV *tv)
81 {
82         register guint32 tag;
83         register int i;
84         register CamelArgGet *a;
85         int more = TRUE;
86
87         for (i=0;i<CAMEL_ARGV_MAX;i++) {
88                 a = &tv->argv[i];
89
90                 if ( (tag = va_arg(tv->ap, guint32)) == 0) {
91                         more = FALSE;
92                         break;
93                 }
94
95                 a->tag = tag;
96
97                 switch((tag & CAMEL_ARG_TYPE)) {
98                 case CAMEL_ARG_OBJ:
99                         a->ca_object = va_arg(tv->ap, void **);
100                         *a->ca_object = NULL;
101                         break;
102                 case CAMEL_ARG_INT:
103                 case CAMEL_ARG_BOO:
104                         a->ca_int = va_arg(tv->ap, int *);
105                         *a->ca_int = 0;
106                         break;
107                 case CAMEL_ARG_DBL:
108                         a->ca_double = va_arg(tv->ap, double *);
109                         *a->ca_double = 0.0;
110                         break;
111                 case CAMEL_ARG_STR:
112                         a->ca_str = va_arg(tv->ap, char **);
113                         *a->ca_str = NULL;
114                         break;
115                 case CAMEL_ARG_PTR:
116                         a->ca_ptr = va_arg(tv->ap, void **);
117                         *a->ca_ptr = NULL;
118                         break;
119                 default:
120                         printf("Error, unknown type, truncating result\n");
121                         more = FALSE;
122                         goto fail;
123                 }
124
125         }
126 fail:
127         tv->argc = i;
128
129         return more;
130 }
131