X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=common%2Ftr_filter.c;h=e1ab4f2e6cd0543dfec6f480086399a0a5e6444c;hb=6d1c81903470e97cd18eba15dacfea5fbd307dc3;hp=65ee1f91a2fc7ff1ea269e36cfddfbc47d98627d;hpb=1b419d2f80dd88c79565bece98dfcb591e722b3e;p=trust_router.git diff --git a/common/tr_filter.c b/common/tr_filter.c index 65ee1f9..e1ab4f2 100644 --- a/common/tr_filter.c +++ b/common/tr_filter.c @@ -85,58 +85,38 @@ void tr_fspec_free(TR_FSPEC *fspec) static int tr_fspec_destructor(void *obj) { TR_FSPEC *fspec=talloc_get_type_abort(obj, TR_FSPEC); - int ii=0; if (fspec->field!=NULL) tr_free_name(fspec->field); - for (ii=0; iimatch[ii]!=NULL) - tr_free_name(fspec->match[ii]); - } + if (fspec->match!=NULL) + tr_free_name(fspec->match); return 0; } TR_FSPEC *tr_fspec_new(TALLOC_CTX *mem_ctx) { TR_FSPEC *fspec=talloc(mem_ctx, TR_FSPEC); - int ii=0; if (fspec!=NULL) { fspec->field=NULL; - for (ii=0; iimatch[ii]=NULL; + fspec->match=NULL; talloc_set_destructor((void *)fspec, tr_fspec_destructor); } return fspec; } -/* returns 0 on success */ -int tr_fspec_add_match(TR_FSPEC *fspec, TR_NAME *match) +void tr_fspec_set_match(TR_FSPEC *fspec, TR_NAME *match) { - int ii=0; - - for (ii=0; iimatch[ii]==NULL) - break; - } - if (iimatch[ii]=match; - return 0; - } else - return -1; /* no space left */ + if (fspec->match!=NULL) + tr_free_name(fspec->match); + fspec->match=match; } /* returns 1 if the spec matches */ int tr_fspec_matches(TR_FSPEC *fspec, TR_NAME *name) { - int ii=0; - - for (ii=0; iimatch[ii]!=NULL) && - (0!=tr_prefix_wildcard_match(name->buf, fspec->match[ii]->buf))) - return 1; - } - return 0; + return ((fspec->match!=NULL) && + (0!=tr_prefix_wildcard_match(name->buf, fspec->match->buf))); } void tr_fline_free(TR_FLINE *fline)