#include "foo.h"
#include <stdio.h>
#ifdef HAVE_STRING_H
#include <string.h>
#endif
struct lt_symlist
{
const char *name;
lt_ptr_t address;
};
extern const struct lt_symlist lt_preloaded_symbols[];
int
main (argc, argv)
int argc;
char **argv;
{
const struct lt_symlist *s;
int (*pfoo)() = 0;
int (*phello)() = 0;
int *pnothing = 0;
printf ("Welcome to *modular* GNU Hell!\n");
s = lt_preloaded_symbols;
while (s->name)
{
if (s->address) {
const char *name = s->name;
printf ("found symbol: %s\n", name);
if (!strcmp ("hello", name))
phello = (int(*)())s->address;
else if (!strcmp ("foo", name))
pfoo = (int(*)())s->address;
else if (!strcmp ("nothing", name))
#ifndef _WIN32
pnothing = (int*)s->address;
#else
pnothing = (int*)¬hing;
#endif
} else
printf ("found file: %s\n", s->name);
s ++;
}
if (pnothing)
*pnothing = 1;
else
fprintf (stderr, "did not find the `nothing' variable\n");
if (pfoo)
{
if ((*pfoo) () != FOO_RET)
return 1;
}
else
fprintf (stderr, "did not find the `foo' function\n");
if (phello)
{
if ((*phello) () != HELLO_RET)
return 3;
}
else
fprintf (stderr, "did not find the `hello' function\n");
return 0;
}