#pragma once
#include <stddef.h>
enum replace_zone
{
	kZoneRequestUri = 0,
	kZoneRequestHeaders,
	kZoneRequestBody,
	kZoneResponseHeader,
	kZoneResponseBody,
	kZoneMax
};

/**
    rule type: replace
    rule type: insert(find: insert on, replace_with: insert content)
*/
struct replace_rule
{
	enum replace_zone zone;
	char * find;
	char * replace_with;
};

struct insert_rule
{
    int inject_sz;
    char * script;
    char * type;
    char * position;
};

//@parm exec_para example input:
//zone=http_req_body; substitute=/中華民國/中华人民共和国;zone=http_resp_header; substitute=/Content-Type:\btext\/html/Content-Type:\bvideo\/mp4
//@return formated rule number.
size_t execute_replace_rule(const char * in, size_t in_sz, enum replace_zone zone, const struct replace_rule * rules, size_t n_rule, char** out, int options);
size_t execute_insert_rule(char * in, size_t in_sz, const struct insert_rule * rules, char** out);
size_t insert_string(char * in, size_t in_sz, const char *insert_on, const char *stype, const char *type, char** out);
void simple_replace(const char* find, const char* replacement, const char* input, size_t in_sz, char** output, size_t *output_sz, int options);

enum replace_zone zone_name_to_id(const char * name);


