~kris/hacks

sparser

ref: f042087d967b02645376087c5eaa0b4259f93cb6 sparser/extract.h -rw-r--r-- 638 bytes
f042087d — Kris Yotam Initial commit: sparser - Simple Parser 6 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/* See LICENSE file for copyright and license details. */

#ifndef EXTRACT_H
#define EXTRACT_H

#include <stddef.h>

/* Callback invoked for each extracted URL.
 * url: the extracted URL string
 * ctx: user context pointer */
typedef void (*UrlCallback)(const char *url, void *ctx);

/* Extract all http/https URLs from a buffer.
 * Calls cb for each URL found.
 * Handles: plain text, HTML, Markdown, MDX */
void extract_urls(const char *data, size_t len,
                  UrlCallback cb, void *ctx);

/* Check if a file appears to be binary (contains null bytes) */
int is_binary(const char *data, size_t len);

#endif /* EXTRACT_H */