feat(c-miner): port miner pipeline to modular C implementation

This commit is contained in:
2026-03-30 01:07:19 +02:00
parent 9a0a170799
commit d2c118833b
18 changed files with 3299 additions and 0 deletions

46
json.h Normal file
View File

@@ -0,0 +1,46 @@
#ifndef JSON_H
#define JSON_H
#include <stddef.h>
typedef enum {
JSMN_UNDEFINED = 0,
JSMN_OBJECT = 1,
JSMN_ARRAY = 2,
JSMN_STRING = 3,
JSMN_PRIMITIVE = 4
} jsmntype_t;
typedef struct {
jsmntype_t type;
int start;
int end;
int size;
int parent;
} jsmntok_t;
typedef struct {
unsigned int pos;
unsigned int toknext;
int toksuper;
} jsmn_parser;
void jsmn_init(jsmn_parser *parser);
int jsmn_parse(jsmn_parser *parser, const char *js, size_t len, jsmntok_t *tokens, unsigned int num_tokens);
typedef struct {
const char *json;
jsmntok_t *tokens;
int token_count;
} JsonDoc;
int json_doc_parse(JsonDoc *doc, const char *json);
void json_doc_free(JsonDoc *doc);
int json_token_streq(const JsonDoc *doc, int tok_idx, const char *s);
int json_skip_token(const JsonDoc *doc, int tok_idx);
int json_object_get(const JsonDoc *doc, int obj_idx, const char *key);
int json_array_get(const JsonDoc *doc, int arr_idx, int elem_index);
char *json_token_strdup(const JsonDoc *doc, int tok_idx);
#endif