lander/trie/src/trie/trie_entry.c

38 lines
594 B
C

#include "trie_entry.h"
#include <stdlib.h>
EntryType entry_type_from_char(char c) {
switch (c) {
case '0':
return Redirect;
case '1':
return Paste;
default:
return Unknown;
}
}
char entry_type_to_char(EntryType et) {
switch (et) {
case Redirect:
return '0';
case Paste:
return '1';
default:
return '\0';
}
}
Entry *entry_new(EntryType type, const char *string) {
Entry *entry = malloc(sizeof(Entry));
entry->type = type;
if (string != NULL) {
entry->string = strdup(string);
} else {
entry->string = NULL;
}
return entry;
}