Add initial rules for children

This commit is contained in:
Wilson Lin 2018-07-02 22:21:13 +12:00
parent 0ed528626d
commit c874b200f4
4 changed files with 106 additions and 0 deletions

View File

@ -0,0 +1,23 @@
#ifndef _HDR_HYPERBUILD_RULE_BLACKLISTCHILDREN
#define _HDR_HYPERBUILD_RULE_BLACKLISTCHILDREN
#include "../ext/nicehash/src/main/c/set/str.h"
#include "../ext/nicehash/src/main/c/map/str.h"
NICEHASH_MAP_STR(strset, nh_set_str_t)
static nh_map_str_strset_t hb_r_blacklistchildren_map;
void hb_r_blacklistchildren_init() {
hb_r_blacklistchildren_map = nh_map_str_strset_create();
}
int hb_r_blacklistchildren_check(char *parent) {
return nh_map_str_strset_has(hb_r_blacklistchildren_map, parent);
}
int hb_r_blacklistchildren_has(char *parent, char *child) {
nh_map_str_strset_t set = nh_map_str_strset_get(hb_r_blacklistchildren_map, parent, NULL);
return nh_set_str_has(set, child);
}
#endif // _HDR_HYPERBUILD_RULE_BLACKLISTCHILDREN

View File

@ -0,0 +1,23 @@
#ifndef _HDR_HYPERBUILD_RULE_BLACKLISTPARENTS
#define _HDR_HYPERBUILD_RULE_BLACKLISTPARENTS
#include "../ext/nicehash/src/main/c/set/str.h"
#include "../ext/nicehash/src/main/c/map/str.h"
NICEHASH_MAP_STR(strset, nh_set_str_t)
static nh_map_str_strset_t hb_r_blacklistparents_map;
void hb_r_blacklistparents_init() {
hb_r_blacklistparents_map = nh_map_str_strset_create();
}
int hb_r_blacklistparents_check(char *child) {
return nh_map_str_strset_has(hb_r_blacklistparents_map, child);
}
int hb_r_blacklistparents_has(char *child, char *parent) {
nh_map_str_strset_t set = nh_map_str_strset_get(hb_r_blacklistparents_map, child, NULL);
return nh_set_str_has(set, parent);
}
#endif // _HDR_HYPERBUILD_RULE_BLACKLISTPARENTS

View File

@ -0,0 +1,32 @@
#ifndef _HDR_HYPERBUILD_RULE_WHITELISTCHILDREN
#define _HDR_HYPERBUILD_RULE_WHITELISTCHILDREN
#include "../ext/nicehash/src/main/c/set/str.h"
#include "../ext/nicehash/src/main/c/map/str.h"
NICEHASH_MAP_STR(strset, nh_set_str_t)
static nh_map_str_strset_t hb_r_whitelistchildren_map;
void hb_r_whitelistchildren_init() {
hb_r_whitelistchildren_map = nh_map_str_strset_create();
nh_set_str_t table = nh_set_str_create();
nh_set_str_add(table, "caption");
nh_set_str_add(table, "colgroup");
nh_set_str_add(table, "thead");
nh_set_str_add(table, "tbody");
nh_set_str_add(table, "tfoot");
nh_set_str_add(table, "tr");
nh_map_str_strset_set(hb_r_whitelistchildren_map, "table", table);
}
int hb_r_whitelistchildren_check(char *parent) {
return nh_map_str_strset_has(hb_r_whitelistchildren_map, parent);
}
int hb_r_whitelistchildren_has(char *parent, char *child) {
nh_map_str_strset_t set = nh_map_str_strset_get(hb_r_whitelistchildren_map, parent, NULL);
return nh_set_str_has(set, child);
}
#endif // _HDR_HYPERBUILD_RULE_WHITELISTCHILDREN

View File

@ -0,0 +1,28 @@
#ifndef _HDR_HYPERBUILD_RULE_WHITELISTPARENTS
#define _HDR_HYPERBUILD_RULE_WHITELISTPARENTS
#include "../ext/nicehash/src/main/c/set/str.h"
#include "../ext/nicehash/src/main/c/map/str.h"
NICEHASH_MAP_STR(strset, nh_set_str_t)
static nh_map_str_strset_t hb_r_whitelistparents_map;
void hb_r_whitelistparents_init() {
hb_r_whitelistparents_map = nh_map_str_strset_create();
nh_set_str_t li = nh_set_str_create();
nh_set_str_add(li, "ul");
nh_set_str_add(li, "ol");
nh_map_str_strset_set(hb_r_whitelistparents_map, "li", li);
}
int hb_r_whitelistparents_check(char *child) {
return nh_map_str_strset_has(hb_r_whitelistparents_map, child);
}
int hb_r_whitelistparents_has(char *child, char *parent) {
nh_map_str_strset_t set = nh_map_str_strset_get(hb_r_whitelistparents_map, child, NULL);
return nh_set_str_has(set, parent);
}
#endif // _HDR_HYPERBUILD_RULE_WHITELISTPARENTS