/// \brief Parse detailed information about a Block /// /// Since this requires seek(s), listing information about all Blocks can /// be slow. /// /// \param pair Input file /// \param iter Location of the Block whose Check value should /// be printed. /// \param bhi Pointer to structure where to store the information /// about the Block Header field. /// /// \return False on success, true on error. If an error occurs, /// the error message is printed too so the caller doesn't /// need to worry about that. static bool parse_details(file_pair *pair, const lzma_index_iter *iter, block_header_info *bhi, xz_file_info *xfi) { if (parse_block_header(pair, iter, bhi, xfi)) return true; if (parse_check_value(pair, iter)) return true; return false; }
static int fixup_check_avp(void** param, int param_no) { struct fis_param *ap; regex_t* re; char *s; s = (char*)*param; ap = 0; if (param_no==1) { ap = avpops_parse_pvar(s); if (ap==0) { LM_ERR(" unable to get pseudo-variable in P1\n"); return E_OUT_OF_MEM; } /* attr name is mandatory */ if (ap->u.sval.type==PVT_NULL) { LM_ERR("null pseudo-variable in P1\n"); return E_UNSPEC; } } else if (param_no==2) { if ( (ap=parse_check_value(s))==0 ) { LM_ERR(" failed to parse checked value \n"); return E_UNSPEC; } /* if REGEXP op -> compile the expresion */ if (ap->ops&AVPOPS_OP_RE) { if ( (ap->opd&AVPOPS_VAL_STR)==0 ) { LM_ERR(" regexp operation requires string value\n"); return E_UNSPEC; } re = pkg_malloc(sizeof(regex_t)); if (re==0) { LM_ERR(" no more pkg mem\n"); return E_OUT_OF_MEM; } LM_DBG("compiling regexp <%.*s>\n", ap->u.s.len, ap->u.s.s); if (regcomp(re, ap->u.s.s, REG_EXTENDED|REG_ICASE|REG_NEWLINE)) { pkg_free(re); LM_ERR("bad re <%.*s>\n", ap->u.s.len, ap->u.s.s); return E_BAD_RE; } /* free the string and link the regexp */ // pkg_free(ap->sval.p.s); ap->u.s.s = (char*)re; } else if (ap->ops&AVPOPS_OP_FM) { if ( !( ap->opd&AVPOPS_VAL_PVAR || (!(ap->opd&AVPOPS_VAL_PVAR) && ap->opd&AVPOPS_VAL_STR) ) ) { LM_ERR(" fast_match operation requires string value or " "avp name/alias (%d/%d)\n", ap->opd, ap->ops); return E_UNSPEC; } } } *param=(void*)ap; return 0; }
static int fixup_check_avp(void** param, int param_no) { struct fis_param *ap; regex_t* re; char *s; s = (char*)*param; ap = 0; if (param_no==1) { if ( (ap=get_attr_or_alias(s))==0 ) { LOG(L_ERR,"ERROR:avpops:fixup_check_avp: bad attribute name" "/alias <%s>\n", (char*)*param); return E_UNSPEC; } /* attr name is mandatory */ if (ap->flags&AVPOPS_VAL_NONE) { LOG(L_ERR,"ERROR:avpops:fixup_check_avp: you must specify " "a name for the AVP\n"); return E_UNSPEC; } } else if (param_no==2) { if ( (ap=parse_check_value(s))==0 ) { LOG(L_ERR,"ERROR:avpops:fixup_check_avp: failed to parse " "checked value \n"); return E_UNSPEC; } /* if REGEXP op -> compile the expresion */ if (ap->flags&AVPOPS_OP_RE) { if ( (ap->flags&AVPOPS_VAL_STR)==0 ) { LOG(L_ERR,"ERROR:avpops:fixup_check_avp: regexp operation " "requires string value\n"); return E_UNSPEC; } re = pkg_malloc(sizeof(regex_t)); if (re==0) { LOG(L_ERR,"ERROR:avpops:fixup_check_avp: no more pkg mem\n"); return E_OUT_OF_MEM; } DBG("DEBUG:avpops:fixup_check_avp: compiling regexp <%s>\n", ap->val.s.s); if (regcomp(re, ap->val.s.s, REG_EXTENDED|REG_ICASE|REG_NEWLINE)) { pkg_free(re); LOG(L_ERR,"ERROR:avpops:fixip_check_avp: bad re <%s>\n", ap->val.s.s); return E_BAD_RE; } /* free the string and link the regexp */ pkg_free(ap->val.s.s); ap->val.s.s = (char*)re; } else if (ap->flags&AVPOPS_OP_FM) { if ( !( ap->flags&AVPOPS_VAL_AVP || (!(ap->flags&AVPOPS_VAL_AVP) && ap->flags&AVPOPS_VAL_STR) ) ) { LOG(L_ERR,"ERROR:avpops:fixup_check_avp: fast_match operation " "requires string value or avp name/alias (%d)\n", ap->flags); return E_UNSPEC; } } } pkg_free(*param); *param=(void*)ap; return 0; }