util.h (1892B) - raw


      1 #include <sys/types.h>
      2 
      3 #include <stdio.h>
      4 
      5 #ifdef __OpenBSD__
      6 #include <unistd.h>
      7 #else
      8 #define pledge(p1,p2) 0
      9 #define unveil(p1,p2) 0
     10 #endif
     11 
     12 #undef strcasestr
     13 char *strcasestr(const char *, const char *);
     14 #undef strlcat
     15 size_t strlcat(char *, const char *, size_t);
     16 #undef strlcpy
     17 size_t strlcpy(char *, const char *, size_t);
     18 
     19 #ifndef SFEED_DUMBTERM
     20 #define PAD_TRUNCATE_SYMBOL    "\xe2\x80\xa6" /* symbol: "ellipsis" */
     21 #define UTF_INVALID_SYMBOL     "\xef\xbf\xbd" /* symbol: "replacement" */
     22 #else
     23 #define PAD_TRUNCATE_SYMBOL    "." /* symbol: "ellipsis" */
     24 #define UTF_INVALID_SYMBOL     "?" /* symbol: "replacement" */
     25 #endif
     26 
     27 /* feed info */
     28 struct feed {
     29 	char         *name;     /* feed name */
     30 	unsigned long totalnew; /* amount of new items per feed */
     31 	unsigned long total;    /* total items */
     32 	/* sfeed_curses */
     33 	char         *path;     /* path to feed or NULL for stdin */
     34 	FILE         *fp;       /* file pointer */
     35 };
     36 
     37 /* URI */
     38 struct uri {
     39 	char proto[48];     /* scheme including ":" or "://" */
     40 	char userinfo[256]; /* username [:password] */
     41 	char host[256];
     42 	char port[6];       /* numeric port */
     43 	char path[1024];
     44 	char query[1024];
     45 	char fragment[1024];
     46 };
     47 
     48 enum {
     49 	FieldUnixTimestamp = 0, FieldTitle, FieldLink, FieldContent,
     50 	FieldContentType, FieldId, FieldAuthor, FieldEnclosure, FieldCategory,
     51 	FieldLast
     52 };
     53 
     54 /* hint for compilers and static analyzers that a function exits */
     55 #ifndef __dead
     56 #define __dead
     57 #endif
     58 
     59 __dead void err(int, const char *, ...);
     60 __dead void errx(int, const char *, ...);
     61 
     62 int uri_format(char *, size_t, struct uri *);
     63 int uri_hasscheme(const char *);
     64 int uri_makeabs(struct uri *, struct uri *, struct uri *);
     65 int uri_parse(const char *, struct uri *);
     66 
     67 void parseline(char *, char *[FieldLast]);
     68 void printutf8pad(FILE *, const char *, size_t, int);
     69 int  strtotime(const char *, time_t *);
     70 void xmlencode(const char *, FILE *);