make parser more robuust, add string literals and escapes
[ccc.git] / util.h
diff --git a/util.h b/util.h
index d8b40ba..79d12d8 100644 (file)
--- a/util.h
+++ b/util.h
@@ -4,10 +4,7 @@
 #include <stdarg.h>
 #include <stdbool.h>
 
-struct list {
-       void *el;
-       struct list *tail;
-};
+struct list { void *el; struct list *tail; };
 struct list *list_cons(void *el, struct list *tail);
 void list_free(struct list *head, void (*freefun)(void *));
 void **list_to_array(struct list *list, int *num, bool reverse);
@@ -16,7 +13,14 @@ int list_length(struct list *head);
 void die(const char *msg, ...);
 void pdie(const char *msg);
 
+/* if buf == NULL, a fresh buffer is allocated */
+char *escape_char(char c, char *buf, bool str);
+/* unescaped character will be in position 0 and the rest from position 1 on */
+char *unescape_char(char *c);
+/* Remove the last and first character from the string */
+char *trimquotes(char *c);
 void pindent(int indent, FILE *out);
+
 void safe_fprintf(FILE *out, const char *msg, ...);
 void *safe_malloc(size_t size);
 void *safe_strdup(const char *c);