dtob-sys 0.1.0

Raw FFI bindings to the dtob C library (encoder + decoder).
Documentation
#ifndef CLI_H
#define CLI_H

#include "dtob_internal.h"
#include "html.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <ctype.h>

/* io.c */
uint8_t    *read_file(const char *path, size_t *out_len);
char       *read_text_file(const char *path);
int         write_file(const char *path, const uint8_t *data, size_t len);
const char *detect_filetype(const char *path);
uint8_t    *fetch_url_bytes(const char *url, size_t *out_len);
uint8_t    *fetch_url_bytes_ex(const char *url, size_t *out_len, char **effective_url_out);

/* typed_encode.c */
int typed_encode(const DtobValue *root, uint8_t **out, size_t *out_len);
int infer_typed_encode(const DtobValue *root, uint8_t **out, size_t *out_len);
int html_typed_encode(const DtobValue *root, uint8_t **out, size_t *out_len);

/* greedy.c */
void html_greedify(DtobValue *root, const char *input_path);
void html_greedify_url(DtobValue *root, const char *base_url);

/* raw greedy: resource extraction from HTML text */
typedef struct {
    uint8_t *data;
    size_t   len;
    int      is_text;
} ResourceEntry;

typedef struct {
    ResourceEntry *entries;
    size_t         count;
    size_t         cap;
} ResourceList;

void   resource_list_init(ResourceList *rl);
void   resource_list_free(ResourceList *rl);
char  *html_raw_greedify(const char *html, size_t html_len,
                          const char *input_path, ResourceList *rl);
char  *html_raw_greedify_url(const char *html, size_t html_len,
                              const char *base_url, ResourceList *rl);

/* raw HTML encoding: html string + separated resources → dtob bytes */
int html_raw_encode(const char *html, size_t html_len,
                    const ResourceList *rl,
                    uint8_t **out, size_t *out_len);

/* represent.c */
void repr_value(const DtobValue *v, int indent, const DtobTypesHeader *types);
void repr_types(const DtobTypesHeader *types);

/* memcache.c */
int cmd_memcache(int argc, char **argv);

#endif