2010-08-08 10:06:34 +02:00
|
|
|
#include <platform.h>
|
|
|
|
#include <kernel/config.h>
|
|
|
|
#include "raceprefix.h"
|
|
|
|
|
2018-09-29 11:37:17 +02:00
|
|
|
#include <kernel/attrib.h>
|
2017-12-28 18:29:40 +01:00
|
|
|
#include <util/strings.h>
|
2010-08-08 10:06:34 +02:00
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <string.h>
|
2014-03-15 19:29:11 +01:00
|
|
|
#include <stdlib.h>
|
2010-08-08 10:06:34 +02:00
|
|
|
|
2011-03-07 08:02:35 +01:00
|
|
|
attrib_type at_raceprefix = {
|
2016-02-09 06:43:19 +01:00
|
|
|
"raceprefix", NULL, a_finalizestring, NULL, a_writestring, a_readstring, NULL,
|
2011-03-07 08:02:35 +01:00
|
|
|
ATF_UNIQUE
|
2010-08-08 10:06:34 +02:00
|
|
|
};
|
|
|
|
|
2011-03-07 08:02:35 +01:00
|
|
|
void set_prefix(attrib ** ap, const char *str)
|
2010-08-08 10:06:34 +02:00
|
|
|
{
|
2015-01-30 20:37:14 +01:00
|
|
|
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);
|
2017-12-28 18:29:40 +01:00
|
|
|
a->data.v = str_strdup(str);
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
|
2016-02-01 17:31:03 +01:00
|
|
|
const char *get_prefix(attrib * a)
|
2010-08-08 10:06:34 +02:00
|
|
|
{
|
2015-01-30 20:37:14 +01:00
|
|
|
char *str;
|
2016-02-01 17:31:03 +01:00
|
|
|
a = a_find(a, &at_raceprefix);
|
2015-01-30 20:37:14 +01:00
|
|
|
if (a == NULL)
|
|
|
|
return NULL;
|
2010-08-08 10:06:34 +02:00
|
|
|
str = (char *)a->data.v;
|
2015-01-30 20:37:14 +01:00
|
|
|
/* conversion of old prefixes */
|
|
|
|
if (strncmp(str, "prefix_", 7) == 0) {
|
2017-12-28 18:29:40 +01:00
|
|
|
((attrib *)a)->data.v = str_strdup(str + 7);
|
2015-01-30 20:37:14 +01:00
|
|
|
free(str);
|
|
|
|
str = (char *)a->data.v;
|
|
|
|
}
|
|
|
|
return str;
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|