int persistent_filter_load(struct dev_filter *f, struct config_tree **cft_out) { struct pfilter *pf = (struct pfilter *) f->private; struct config_tree *cft; struct stat info; int r = 0; if (!stat(pf->file, &info)) pf->ctime = info.st_ctime; else { log_very_verbose("%s: stat failed: %s", pf->file, strerror(errno)); return_0; } if (!(cft = create_config_tree(pf->file, 1))) return_0; if (!read_config_file(cft)) goto_out; _read_array(pf, cft, "persistent_filter_cache/valid_devices", PF_GOOD_DEVICE); /* We don't gain anything by holding invalid devices */ /* _read_array(pf, cft, "persistent_filter_cache/invalid_devices", PF_BAD_DEVICE); */ /* Did we find anything? */ if (dm_hash_get_num_entries(pf->devices)) { /* We populated dev_cache ourselves */ dev_cache_scan(0); r = 1; } log_very_verbose("Loaded persistent filter cache from %s", pf->file); out: if (r && cft_out) *cft_out = cft; else destroy_config_tree(cft); return r; }
void _read_tag(pTHX_ srl_splitter_t * splitter, char tag) { /* first, self-contained tags*/ if ( tag <= SRL_HDR_POS_HIGH ) { SRL_SPLITTER_TRACE(" * POS INTEGER %d", (int)tag); } else if ( tag <= SRL_HDR_NEG_HIGH) { SRL_SPLITTER_TRACE(" * NEG INTEGER %d", (int)tag - 32); } else if ( IS_SRL_HDR_SHORT_BINARY(tag) ) { UV len = SRL_HDR_SHORT_BINARY_LEN_FROM_TAG(tag); SRL_SPLITTER_TRACE(" * SHORT BINARY of length %lu", len); char *binary_start_pos = splitter->pos - 1; _check_for_duplicates(aTHX_ splitter, binary_start_pos, len, 0); } else if ( IS_SRL_HDR_HASHREF(tag) ) { int len = tag & 0xF; SRL_SPLITTER_TRACE(" * SHORT HASHREF of length %d", len); splitter->deepness++; stack_push(splitter->status_stack, ST_DEEPNESS_UP); while (len-- > 0) { stack_push(splitter->status_stack, ST_VALUE); stack_push(splitter->status_stack, ST_VALUE); } } else if ( IS_SRL_HDR_ARRAYREF(tag) ) { int len = tag & 0xF; SRL_SPLITTER_TRACE(" * SHORT ARRAY of length %d", len); splitter->deepness++; stack_push(splitter->status_stack, ST_DEEPNESS_UP); while (len-- > 0) { stack_push(splitter->status_stack, ST_VALUE); } } else { switch (tag) { case SRL_HDR_VARINT: _read_varint(splitter); break; case SRL_HDR_ZIGZAG: _read_zigzag(splitter); break; case SRL_HDR_FLOAT: _read_float(splitter); break; case SRL_HDR_DOUBLE: _read_double(splitter); break; case SRL_HDR_LONG_DOUBLE: _read_long_double(splitter); break; case SRL_HDR_TRUE: /* no op */ break; case SRL_HDR_FALSE: /* no op */ break; case SRL_HDR_CANONICAL_UNDEF: case SRL_HDR_UNDEF: /* no op */ break; case SRL_HDR_BINARY: _read_string(aTHX_ splitter, 0); break; case SRL_HDR_STR_UTF8: _read_string(aTHX_ splitter, 1); break; case SRL_HDR_WEAKEN: _read_weaken(splitter); break; case SRL_HDR_REFN: _read_refn(splitter); break; case SRL_HDR_REFP: _read_refp(aTHX_ splitter); break; case SRL_HDR_HASH: _read_hash(splitter); break; case SRL_HDR_ARRAY: _read_array(splitter); break; case SRL_HDR_OBJECT: _read_object(splitter, 0); break; case SRL_HDR_OBJECT_FREEZE: _read_object(splitter, 1); break; case SRL_HDR_OBJECTV: _read_objectv(aTHX_ splitter, 0); break; case SRL_HDR_OBJECTV_FREEZE: _read_objectv(aTHX_ splitter, 1); break; case SRL_HDR_ALIAS: _read_alias(aTHX_ splitter); break; case SRL_HDR_COPY: _read_copy(aTHX_ splitter); break; case SRL_HDR_EXTEND: /* no op */ break; case SRL_HDR_REGEXP: _read_regexp(splitter); break; case SRL_HDR_PAD: /* no op */ break; default: croak("Unexpected tag value"); break; } } }