2001-09-05 21:40:40 +02:00
|
|
|
/* vi: set ts=2:
|
|
|
|
*
|
|
|
|
*
|
2003-07-29 11:48:03 +02:00
|
|
|
* Eressea PB(E)M host Copyright (C) 1998-2003
|
2001-09-05 21:40:40 +02:00
|
|
|
* 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 <config.h>
|
|
|
|
#include <eressea.h>
|
|
|
|
#include "raceprefix.h"
|
|
|
|
|
2004-07-09 21:14:10 +02:00
|
|
|
#include <util/attrib.h>
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2001-09-05 21:40:40 +02:00
|
|
|
attrib_type at_raceprefix = {
|
2001-12-10 01:13:39 +01:00
|
|
|
"raceprefix", NULL, a_finalizestring, NULL, a_writestring, a_readstring, ATF_UNIQUE
|
2001-09-05 21:40:40 +02:00
|
|
|
};
|
|
|
|
|
2004-07-09 21:14:10 +02:00
|
|
|
void
|
|
|
|
set_prefix(attrib ** ap, const char * str)
|
|
|
|
{
|
|
|
|
attrib * a = a_find(*ap, &at_raceprefix);
|
|
|
|
if (a==NULL) {
|
|
|
|
a = a_add(ap, a_new(&at_raceprefix));
|
|
|
|
} else {
|
|
|
|
free(a->data.v);
|
|
|
|
}
|
|
|
|
assert(a->type==&at_raceprefix);
|
|
|
|
a->data.v = strdup(str);
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
get_prefix(const attrib * a)
|
|
|
|
{
|
2004-08-07 09:42:22 +02:00
|
|
|
char * str;
|
2004-07-09 21:14:10 +02:00
|
|
|
a = a_findc(a, &at_raceprefix);
|
|
|
|
if (a==NULL) return NULL;
|
2004-08-07 09:42:22 +02:00
|
|
|
str = (char *)a->data.v;
|
|
|
|
/* conversion of old prefixes */
|
|
|
|
if (strncmp(str, "prefix_", 7)==0) {
|
|
|
|
((attrib*)a)->data.v = strdup(str+7);
|
|
|
|
free(str);
|
|
|
|
str = (char *)a->data.v;
|
|
|
|
}
|
|
|
|
return str;
|
2004-07-09 21:14:10 +02:00
|
|
|
}
|