/* Collection of code snippets by Arne Vajhøj */
/* (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#include "xmlrpc_format.h"
#include "vms_http.h"
#include "xmlrpc_parse.h"

int main()
{
    char req[1000];
    xmlrpc_request(req, sizeof(req), "S.process", 1, xmlrpc_string("Hi from C!"));
    struct vms_http *ctx = http_post("localhost", 8001, "/", "text/xml", "text/xml", req);
    char resp[100000];
    short resplen;
    http_recv_all(ctx, resp, sizeof(resp), &resplen);
    resp[resplen] = 0;
    http_close(ctx);
    char *msgs[1000];
    int nelm = xmlrpc_response(resp, msgs);
    for(int i = 0; i < nelm; i++) 
    {
        printf("%s\n", msgs[i]);
        free(msgs[i]);
    }
    return 0;
}
