diff --git a/src/common/attributes/viewrange.c b/src/common/attributes/viewrange.c new file mode 100644 index 000000000..2fbe4f15f --- /dev/null +++ b/src/common/attributes/viewrange.c @@ -0,0 +1,71 @@ +/* vi: set ts=2: + * + * + * Eressea PB(E)M host Copyright (C) 1998-2000 + * Christian Schlittchen (corwin@amber.kn-bremen.de) + * Katja Zedel (katze@felidae.kn-bremen.de) + * Henning Peters (faroul@beyond.kn-bremen.de) + * Enno Rehling (enno@eressea-pbem.de) + * Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de) + * + * This program may not be used, modified or distributed without + * prior permission by the authors of Eressea. + */ + +#include +#include "viewrange.h" + +/* util includes */ +#include +#include + +/* libc includes */ +#include + +static void +a_writefunction(const struct attrib * a, FILE* F) +{ + fprintf(F, "%s ", get_functionname((pf_generic)a->data.f)); +} + +static int +a_readfunction(struct attrib *a, FILE *F) +/* return 1 on success, 0 if attrib needs removal */ +{ + char buf[64]; + fscanf(F, "%s ", buf); + a->data.f = get_function(buf); + return 1; +} + +attrib_type at_viewrange = { + "viewrange", + NULL, + NULL, + NULL, + a_writefunction, + a_readfunction, +}; + +attrib * +add_viewrange(attrib ** alist, const char *function) +{ + attrib * a = a_find(*alist, &at_viewrange); + if (a==NULL) a = a_add(alist, make_viewrange(function)); + return a; +} + +attrib * +make_viewrange(const char *function) +{ + attrib * a = a_new(&at_viewrange); + a->data.f = get_function(function); + assert(a->data.f); + return a; +} + +void +init_viewrange(void) +{ + at_register(&at_viewrange); +} diff --git a/src/common/attributes/viewrange.h b/src/common/attributes/viewrange.h new file mode 100644 index 000000000..5cf771463 --- /dev/null +++ b/src/common/attributes/viewrange.h @@ -0,0 +1,19 @@ +/* vi: set ts=2: + * + * + * Eressea PB(E)M host Copyright (C) 1998-2000 + * Christian Schlittchen (corwin@amber.kn-bremen.de) + * Katja Zedel (katze@felidae.kn-bremen.de) + * Henning Peters (faroul@beyond.kn-bremen.de) + * Enno Rehling (enno@eressea-pbem.de) + * Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de) + * + * This program may not be used, modified or distributed without + * prior permission by the authors of Eressea. + */ + +extern struct attrib_type at_viewrange; + +extern struct attrib * make_viewrange(const char *function); +extern struct attrib * add_viewrange(struct attrib ** alist, const char *function); +extern void init_viewrange(void);