[KLUG Programming] Passing on variable argument lists.
Adam Williams
programming@kalamazoolinux.org
Sun, 08 Feb 2004 19:55:14 -0500
> >It appears not; va_start/arg/end/copy seems to be for processing
> >variable parameter lists in a function, I just want to pass them into a
> >'subordinate' function.
> How is that not "processing"?
> >And it appears this can't be done directly -
> >void ogo_call(char* ogourl,
> > char* ogouser,
> > char* ogopasswd,
> > char* ogocall,
> > char* ogoargs,
> > ... ) {
> >...blah...blah...
> > results = xmlrpc_client_call_server(&env, server,
> > ogocall,
> > ogoargs);
> >
> >- results in a segmentation fault (although it obviously compiles OK).
> Right, it can't be done directly. That is what I understand the var_args stuff
> is for. AFAIK, it's used to write things like printf, which has the same
> syntax that I think you want to use... extensible, or variable paramter lists).
Yep, I was pretty sure I had it with -
#include<stdarg.h>
...blah...blah...
void ogo_call(char* ogourl,
char* ogouser,
char* ogopasswd,
char* ogocall,
char* ogoargs,
... ) {
va_list valist;
va_start(valist, ogoargs);
...blah....blah
results = xmlrpc_client_call_server(&env, server, ogocall, valist);
va_end(valist);
...blah...blah...
- and I even found examples that almost seem to claim with certainty
that this is the correct way to do it. And it compiled!
Only to be met with -
URL: http://kohocton/RPC2
User:adam
Password: ******
Call: appointment.fetch
In ogo_call
In ogo_call: server setup
In ogo_call: auth info setup
xmlrpc_data.c:488: Unknown type code when building value
- crap!
I found examples like -
#include <stdarg.h>
#include <stdio.h>
int mysprintf (char* dest, char* source,...){
va_list vlist;
va_start(vlist,source);
vsprintf(dest,"%s",vlist);
}
- which seems like exactly what I want to do.