*s = '\0';
}
+/*
+ Tables
+*/
+
+struct nw_string_table {
+ const int id;
+ const char* string;
+};
+
+static inline const char* nw_string_table_lookup_string(
+ const struct nw_string_table* table, const int id) {
+ const struct nw_string_table* entry = NULL;
+
+ for (entry = table; entry->string; entry++)
+ if (entry->id == id)
+ return entry->string;
+
+ return NULL;
+}
+
+static inline int nw_string_table_lookup_id(
+ const struct nw_string_table* table, const char* string) {
+ const struct nw_string_table* entry = NULL;
+
+ for (entry = table; entry->string; entry++)
+ if (strcmp(entry->string, string) == 0)
+ return entry->id;
+
+ return -1;
+}
+
+#define NW_STRING_TABLE_LOOKUP_ID(type, table, method) \
+ __attribute__((unused)) static type method(const char* s) { \
+ return nw_string_table_lookup_id(table, s); \
+ }
+
+#define NW_STRING_TABLE_LOOKUP_STRING(type, table, method) \
+ __attribute__((unused)) static const char* method(const type id) { \
+ return nw_string_table_lookup_string(table, id); \
+ }
+
+#define NW_STRING_TABLE_LOOKUP(type, table) \
+ NW_STRING_TABLE_LOOKUP_ID(type, table, table ## _from_string) \
+ NW_STRING_TABLE_LOOKUP_STRING(type, table, table ## _to_string)
+
/*
Paths
*/