sbot

Simple web archiver — self-contained GWTAR archives
git clone git clone https://git.krisyotam.com/krisyotam/sbot.git
Log | Files | Refs | README | LICENSE

util.h (1011B)


      1 /* See LICENSE file for copyright and license details. */
      2 
      3 #ifndef UTIL_H
      4 #define UTIL_H
      5 
      6 #include <stddef.h>
      7 
      8 /* Memory allocation with error handling */
      9 void *xmalloc(size_t size);
     10 void *xrealloc(void *ptr, size_t size);
     11 char *xstrdup(const char *s);
     12 
     13 /* Base64 encoding */
     14 char *base64_encode(const unsigned char *data, size_t input_len,
     15                     size_t *output_len);
     16 
     17 /* String utilities */
     18 int str_starts_with(const char *str, const char *prefix);
     19 int str_ends_with(const char *str, const char *suffix);
     20 char *str_tolower(char *str);
     21 char *str_trim(char *str);
     22 
     23 /* URL utilities */
     24 char *url_resolve(const char *base, const char *relative);
     25 char *url_get_domain(const char *url);
     26 int url_same_domain(const char *url1, const char *url2);
     27 
     28 /* File utilities */
     29 char *get_mime_type(const char *url);
     30 char *sanitize_filename(const char *url);
     31 
     32 /* Time utilities */
     33 char *get_iso_date(void);
     34 
     35 /* Error handling */
     36 void die(const char *fmt, ...);
     37 void warn(const char *fmt, ...);
     38 
     39 #endif /* UTIL_H */