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

#include "demolib.h"

// scope: gfortran and gcc only
// strategy: using fortran 77 and VAX extensions only - no modern fortran C interop features used
// add trailing underscore to function names
// always pass by reference never by value
// convert array return types to extra array argument
// assume character string contain trailing nul
int add_(int *a, int *b)
{
    return add(*a, *b);
}

int sum_(int *n, int *a)
{
    return sum(*n, a);
}

void dup_(char *s, char *s2)
{
    char *p;
    p = dup(s);
    strcpy(s2, p);
    free(p);
}

void get_out_(int *iv, char *sv)
{
    char *p;
    get_out(iv, &p);
    strcpy(sv, p);
    free(p);
}

struct Data1 get_ret_()
{
    struct Data1 d;
    memcpy(&d, get_ret(), sizeof(struct Data1));
    return d;
}

void chg_(struct Data2 *d)
{
    chg(d);
}

