1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- *
*
* Author:
* Michael Zucchi <notzed@ximian.com>
*
* Copyright 2002 Ximian, Inc. (www.ximian.com)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include "camel-arg.h"
int camel_argv_build(CamelArgV *tv)
{
register guint32 tag;
register int i;
register CamelArg *a;
int more = TRUE;
for (i=0;i<CAMEL_ARGV_MAX;i++) {
a = &tv->argv[i];
if ( (tag = va_arg(tv->ap, guint32)) == 0) {
more = FALSE;
break;
}
a->tag = tag;
switch((tag & CAMEL_ARG_TYPE)) {
case CAMEL_ARG_OBJ:
a->ca_object = va_arg(tv->ap, void *);
break;
case CAMEL_ARG_INT:
a->ca_int = va_arg(tv->ap, int);
break;
case CAMEL_ARG_DBL:
a->ca_double = va_arg(tv->ap, double);
break;
case CAMEL_ARG_STR:
a->ca_str = va_arg(tv->ap, char *);
break;
case CAMEL_ARG_PTR:
a->ca_ptr = va_arg(tv->ap, void *);
break;
default:
printf("Error, unknown type, truncating result\n");
more = FALSE;
goto fail;
}
}
fail:
tv->argc = i;
return more;
}
int camel_arggetv_build(CamelArgGetV *tv)
{
register guint32 tag;
register int i;
register CamelArgGet *a;
int more = TRUE;
for (i=0;i<CAMEL_ARGV_MAX;i++) {
a = &tv->argv[i];
if ( (tag = va_arg(tv->ap, guint32)) == 0) {
more = FALSE;
break;
}
a->tag = tag;
switch((tag & CAMEL_ARG_TYPE)) {
case CAMEL_ARG_OBJ:
a->ca_object = va_arg(tv->ap, void **);
*a->ca_object = NULL;
break;
case CAMEL_ARG_INT:
a->ca_int = va_arg(tv->ap, int *);
*a->ca_int = 0;
break;
case CAMEL_ARG_DBL:
a->ca_double = va_arg(tv->ap, double *);
*a->ca_double = 0.0;
break;
case CAMEL_ARG_STR:
a->ca_str = va_arg(tv->ap, char **);
*a->ca_str = NULL;
break;
case CAMEL_ARG_PTR:
a->ca_ptr = va_arg(tv->ap, void **);
*a->ca_ptr = NULL;
break;
default:
printf("Error, unknown type, truncating result\n");
more = FALSE;
goto fail;
}
}
fail:
tv->argc = i;
return more;
}
|