summaryrefslogtreecommitdiff
path: root/util.h
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2015-07-28 21:24:06 +0200
committerHiltjo Posthuma <hiltjo@codemadness.org>2015-07-28 21:24:06 +0200
commitce1c1697a4d3a0e592b47ae65b4096d21d4cb90b (patch)
tree94b529d85e77672f338f42d39719ea17f906e8ab /util.h
parent3a598e3357e0bda6d5a5c828065feabb49b1c029 (diff)
util: rewrite uri parser
- don't print directly but use an internal buffer (also better for testing). - encode uri when printing (security). - add some comments.
Diffstat (limited to 'util.h')
-rw-r--r--util.h42
1 files changed, 23 insertions, 19 deletions
diff --git a/util.h b/util.h
index 236365d..1cc0983 100644
--- a/util.h
+++ b/util.h
@@ -1,6 +1,3 @@
-#include <stdio.h>
-#include <time.h>
-
#ifdef COMPAT
#include "compat.h"
#endif
@@ -10,27 +7,34 @@
/* feed info */
struct feed {
- char * name; /* feed name */
- unsigned long totalnew; /* amount of new items per feed */
- unsigned long total; /* total items */
- time_t timenewest;
- char timenewestformat[64];
+ char * name; /* feed name */
+ unsigned long totalnew; /* amount of new items per feed */
+ unsigned long total; /* total items */
+ time_t timenewest;
+ char timenewestformat[64];
+};
+
+/* uri */
+struct uri {
+ char proto[48];
+ char host[255];
+ char path[2048];
};
enum { FieldUnixTimestamp = 0, FieldTimeFormatted, FieldTitle, FieldLink,
FieldContent, FieldContentType, FieldId, FieldAuthor, FieldFeedType,
FieldLast };
-ssize_t chartoxmlentity(int, char *, size_t);
-int parseline(char **, size_t *, char **, unsigned int, int, FILE *);
-void printcontent(const char *, FILE *);
-void printxmlencoded(const char *, FILE *);
-void printlink(const char *, const char *, FILE *);
-void printurlencoded(const char *, size_t, FILE *);
-void printutf8pad(FILE *, const char *, size_t, int);
-int strtotime(const char *, time_t *);
-char *trimstart(const char *);
-char *trimend(const char *);
-char *xbasename(const char *);
+int absuri(const char *, const char *, char *, size_t);
+int encodeuri(const char *, char *, size_t);
+int parseline(char **, size_t *, char **, unsigned int, int, FILE *);
+int parseuri(const char *, struct uri *, int);
+void printcontent(const char *, FILE *);
+void printxmlencoded(const char *, FILE *);
+void printutf8pad(FILE *, const char *, size_t, int);
+int strtotime(const char *, time_t *);
+char * trimstart(const char *);
+char * trimend(const char *);
+char * xbasename(const char *);