/* Collection of code snippets by Arne Vajhøj */
/* (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) */
#ifndef DEMOLIB_H
#define DEMOLIB_H

/* workaround conflict with *nix dup function */
#if defined(NIX) || defined(VMS)
#define dup mydup
#endif

struct Data1
{
    int iv;
    char sv[50];
};

struct Data2
{
    int iv1;
    char sv1[50];
    int iv2;
    char sv2[50];
};

/* int in arg + int retval */
int add(int a, int b);
/* int array in arg + int retval */
int sum(int n, int *a);
/* string in arg + string retval */
/* caller must call free on retval */
char *dup(char *s);
/* int out arg + string out arg */
/* caller must call free on second arg */
void get_out(int *iv, char **sv);
/* caller must call free on retval */
/* struct retval */
struct Data1 *get_ret();
/* inout struct arg */
void chg(struct Data2 *d);

#endif
