#include <stdarg.h>
#include <epp.h>

int __epp_make_av_args(av_alist *alist, const char *params_spec, va_list vl) {
    int retval = 0;
    va_list arg;

    va_copy(arg, vl);

    av_ptr(*alist, const char *, params_spec);

    while (params_spec && *params_spec) {
	switch(*params_spec) {
	    case 'l':
		av_long(*alist, va_arg(vl, long));
		break;

	    case 'L':
		av_ptr(*alist, long*, va_arg(vl, long*));
		break;

	    case 's':
		av_ptr(*alist, const char*, va_arg(vl, const char*));
		break;

	    case 'S':
		av_ptr(*alist, const char**, va_arg(vl, const char**));
		break;

	    case 'f':
		av_double(*alist, va_arg(vl, double));
		break;

	    case 'F':
		av_ptr(*alist, double*, va_arg(vl, double*));
		break;

	    case 'p':
		av_ptr(*alist, void*, va_arg(vl, void*));
		break;

	    case 'P':
		av_ptr(*alist, void**, va_arg(vl, void**));
		break;

	    case '_':
		break;

	    default:
		retval = 1;
		goto error;
	}

	params_spec++;
    }

error:
    va_end(arg);
    return(retval);
}
