Date: Sun, 15 Sep 2013 14:07:17 GMT From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r257375 - soc2013/mattbw/backend/query Message-ID: <201309151407.r8FE7HIK019709@socsvn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mattbw Date: Sun Sep 15 14:07:16 2013 New Revision: 257375 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257375 Log: Split query check into two functions. Modified: soc2013/mattbw/backend/query/check.c Modified: soc2013/mattbw/backend/query/check.c ============================================================================== --- soc2013/mattbw/backend/query/check.c Sun Sep 15 13:50:56 2013 (r257374) +++ soc2013/mattbw/backend/query/check.c Sun Sep 15 14:07:16 2013 (r257375) @@ -35,6 +35,7 @@ /* Attempts to match a set of QueryIDs into packages. */ static bool string_match(const char *left, const char *right); +static bool check_metadata(const char *name, const char *namever, const char *repo, const char *arch, struct query_id *query_id); /* Returns true if the given package matches the given query ID. */ bool @@ -58,33 +59,42 @@ if (namever == NULL || arch == NULL || repo == NULL) { matches = false; } else { - bool namever_matches; - bool namever_matches_name; - bool namever_matches_namever; - bool arch_matches; - bool repo_matches; - - /* - * Allow raw names to match the Query ID namever, as well as - * the full package namevers. This allows Resolve to work - * properly. - */ - namever_matches_name = string_match(query_id->namever, name); - namever_matches_namever = string_match(query_id->namever, - namever); - namever_matches = (namever_matches_name || - namever_matches_namever); + matches = check_metadata(name, namever, repo, arch, query_id); + } - arch_matches = string_match(query_id->arch, arch); - repo_matches = string_match(query_id->repo, repo); + free(namever); + return matches; +} +static bool +check_metadata(const char *name, const char *namever, const char *repo, + const char *arch, struct query_id *query_id) +{ + bool namever_matches; + bool namever_matches_name; + bool namever_matches_namever; + bool arch_matches; + bool repo_matches; + + assert(name != NULL); + assert(namever != NULL); + assert(arch != NULL); + assert(repo != NULL); + assert(query_id != NULL); + assert(query_id->namever != NULL); - matches = (namever_matches && arch_matches && repo_matches); - } + /* + * Allow raw names to match the Query ID namever, as well as the full + * package namevers. This allows Resolve to work properly. + */ + namever_matches_name = string_match(query_id->namever, name); + namever_matches_namever = string_match(query_id->namever, namever); + namever_matches = (namever_matches_name || namever_matches_namever); - free(namever); + arch_matches = string_match(query_id->arch, arch); + repo_matches = string_match(query_id->repo, repo); - return matches; + return (namever_matches && arch_matches && repo_matches); } /*
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201309151407.r8FE7HIK019709>