extern void* xmalloc(size_t size);
extern char* xstrdup(const char*);
extern void packed_to_token(long, char token[]);
+extern void token_to_packed(char token[], long);
extern void speak(const char*);
extern bool wordeq(token_t, token_t);
extern bool wordempty(token_t);
}
}
+void token_to_packed(char token[6], long* packed)
+{
+ *packed = 0;
+ for (size_t i = 0; i < 5; ++i)
+ {
+ if (token[4 - i] == '\0')
+ continue;
+ char mapped = ascii_to_advent[token[4 - i]];
+ *packed |= (mapped << (6 * i));
+ }
+}
+
/* Hide the fact that wods are corrently packed longs */
bool wordeq(token_t a, token_t b)