void hs_test (void) { array_t *arr; struct hs *a = hs_create (1); hs_add (a, array_from_str ("0011xx00")); hs_add (a, array_from_str ("10100x0x")); arr = array_from_str ("10100x01"); hs_diff (a, arr); hs_print (a); struct hs *b = hs_copy_a (a); hs_print (b); hs_free (b); free (arr); b = hs_create (1); hs_add (b, array_from_str ("xxxx1x00")); hs_add (b, array_from_str ("xxxxx1x0")); hs_print (b); hs_isect (b, a); hs_print (b); hs_free (b); hs_free (a); a = hs_create (1); hs_add (a, array_from_str ("10xxxxxx")); hs_add (a, array_from_str ("xxxxxx10")); arr = array_from_str ("11111111"); hs_diff (a, arr); hs_print (a); hs_cmpl (a); hs_print (a); hs_free (a); a = hs_create (1); hs_add (a, array_from_str ("10xxxxxx")); hs_add (a, array_from_str ("xxxxxx10")); b = hs_create (1); hs_add (b, array_from_str ("11111111")); hs_minus (a, b); hs_print (a); hs_free (a); hs_free (b); a = hs_create (1); hs_add (a, array_from_str ("11111111")); //hs_add (a, array_from_str ("xxxxxxx1")); hs_diff (a, arr); hs_print (a); hs_comp_diff (a); char *s = hs_to_str (a); printf ("S: %s\n", s); free (s); hs_free (a); free (arr); }
static void deps_diff_inv (struct hs *hs, uint32_t port, const struct deps *deps, const struct tf *tf) { for (int i = 0; i < deps->n; i++) { const struct dep *dep = &deps->deps[i]; if (dep->port > 0 && dep->port != port) continue; if (dep->port < 0 && !port_match (port, dep->port, tf)) continue; hs_diff (hs, DATA_ARR (dep->match)); } }
static void deps_diff (struct hs *hs, uint32_t port, const struct deps *deps, const struct tf *tf, const uint32_t *app, int napp) { for (int i = 0; i < deps->n; i++) { const struct dep *dep = &deps->deps[i]; if (app && !int_find (dep->rule, app, napp)) continue; if (dep->port > 0 && dep->port != port) continue; if (dep->port < 0 && !port_match (port, dep->port, tf)) continue; hs_diff (hs, DATA_ARR (dep->match)); } }