2010-08-08 10:06:34 +02:00
|
|
|
#include <platform.h>
|
|
|
|
#include <kernel/config.h>
|
|
|
|
#include "racename.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
|
|
|
|
|
|
|
/* libc includes */
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
attrib_type at_racename = {
|
2015-01-30 20:37:14 +01:00
|
|
|
"racename", NULL, a_finalizestring, NULL, a_writestring, a_readstring
|
2010-08-08 10:06:34 +02:00
|
|
|
};
|
|
|
|
|
2011-03-07 08:02:35 +01:00
|
|
|
const char *get_racename(attrib * alist)
|
2010-08-08 10:06:34 +02:00
|
|
|
{
|
2015-01-30 20:37:14 +01:00
|
|
|
attrib *a = a_find(alist, &at_racename);
|
|
|
|
if (a)
|
|
|
|
return (const char *)a->data.v;
|
|
|
|
return NULL;
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|
|
|
|
|
2011-03-07 08:02:35 +01:00
|
|
|
void set_racename(attrib ** palist, const char *name)
|
2010-08-08 10:06:34 +02:00
|
|
|
{
|
2015-01-30 20:37:14 +01:00
|
|
|
attrib *a = a_find(*palist, &at_racename);
|
2020-08-03 10:33:24 +02:00
|
|
|
|
|
|
|
if (a) {
|
|
|
|
if (name) {
|
|
|
|
if (strcmp(a->data.v, name) != 0) {
|
|
|
|
free(a->data.v);
|
|
|
|
a->data.v = str_strdup(name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
a_remove(palist, a);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (name) {
|
2015-01-30 20:37:14 +01:00
|
|
|
a = a_add(palist, a_new(&at_racename));
|
2017-12-28 18:29:40 +01:00
|
|
|
a->data.v = str_strdup(name);
|
2015-01-30 20:37:14 +01:00
|
|
|
}
|
2010-08-08 10:06:34 +02:00
|
|
|
}
|