sparser

Simple parser — extract URLs from text files
git clone git clone https://git.krisyotam.com/krisyotam/sparser.git
Log | Files | Refs | LICENSE

extract.h (638B)


      1 /* See LICENSE file for copyright and license details. */
      2 
      3 #ifndef EXTRACT_H
      4 #define EXTRACT_H
      5 
      6 #include <stddef.h>
      7 
      8 /* Callback invoked for each extracted URL.
      9  * url: the extracted URL string
     10  * ctx: user context pointer */
     11 typedef void (*UrlCallback)(const char *url, void *ctx);
     12 
     13 /* Extract all http/https URLs from a buffer.
     14  * Calls cb for each URL found.
     15  * Handles: plain text, HTML, Markdown, MDX */
     16 void extract_urls(const char *data, size_t len,
     17                   UrlCallback cb, void *ctx);
     18 
     19 /* Check if a file appears to be binary (contains null bytes) */
     20 int is_binary(const char *data, size_t len);
     21 
     22 #endif /* EXTRACT_H */