Date: Sun, 11 Aug 2013 09:30:47 GMT From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255801 - in soc2013/mattbw/backend: . query Message-ID: <201308110930.r7B9Ulwa091861@socsvn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mattbw Date: Sun Aug 11 09:30:46 2013 New Revision: 255801 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255801 Log: Move the repository type code to utils. This is so it can be used in jobs as well, but the new location is slightly counter-intuitive and subject to change. Modified: soc2013/mattbw/backend/query/core.c soc2013/mattbw/backend/utils.c soc2013/mattbw/backend/utils.h Modified: soc2013/mattbw/backend/query/core.c ============================================================================== --- soc2013/mattbw/backend/query/core.c Sun Aug 11 09:01:31 2013 (r255800) +++ soc2013/mattbw/backend/query/core.c Sun Aug 11 09:30:46 2013 (r255801) @@ -25,18 +25,11 @@ #include "../pk-backend.h" #include "pkg.h" - #include "../db.h" /* db_open_remote */ -#include "../utils.h" /* string_match */ +#include "../utils.h" /* string_match, type_of_repo_name */ #include "../pkgutils.h" /* pkgutils_... */ #include "core.h" /* Prototypes */ -enum repo_type { - REPO_INVALID, - REPO_ANY, - REPO_LOCAL, - REPO_REMOTE -}; struct query { PkBackend *backend; @@ -53,7 +46,7 @@ typedef struct pkgdb_it * (*query_func_ptr) (struct query *q); static bool can_remote_iterate(struct query *q); -static enum repo_type type_of_repo_name(const char *name); + static gchar *match_pkg(struct pkg *pkg, struct query *q); static gchar **init_unpack_source(PkBackend *backend, struct query_source *s); static gchar **make_fake_id_split(const char *name); @@ -308,26 +301,6 @@ return sane; } -/* - * Finds the type of the given PackageKit repository name. - */ -static enum repo_type -type_of_repo_name(const char *name) -{ - enum repo_type rtype; - - /* Null or empty implies no specific repository */ - if (name == NULL || name[0] == '\0') - rtype = REPO_ANY; - else if (strcmp(name, "installed") == 0) - rtype = REPO_LOCAL; - else if (pkg_repo_find_ident(name) != NULL) - rtype = REPO_REMOTE; - else - rtype = REPO_INVALID; - - return rtype; -} /* * Checks whether a candidate package matches any constraints provided by the Modified: soc2013/mattbw/backend/utils.c ============================================================================== --- soc2013/mattbw/backend/utils.c Sun Aug 11 09:01:31 2013 (r255800) +++ soc2013/mattbw/backend/utils.c Sun Aug 11 09:30:46 2013 (r255801) @@ -20,10 +20,11 @@ /* String/ID utilities. */ -#include <assert.h> /* assert */ +#include <assert.h> /* assert */ #include <string.h> #include <glib.h> +#include "pkg.h" #include "pk-backend.h" /* pk_backend_get_strv */ #include "utils.h" /* prototypes */ @@ -49,6 +50,28 @@ } /* + * Finds the type of the given PackageKit repository name. + */ +enum repo_type +type_of_repo_name(const char *name) +{ + enum repo_type rtype; + + /* Null or empty implies no specific repository */ + if (name == NULL || name[0] == '\0') { + rtype = REPO_ANY; + } else if (strcmp(name, "installed") == 0) { + rtype = REPO_LOCAL; + } else if (pkg_repo_find_ident(name) != NULL) { + rtype = REPO_REMOTE; + } else { + rtype = REPO_INVALID; + } + + return rtype; +} + +/* * Retrieves PackageIDs from the backend, as well as the total number of them. */ gchar ** Modified: soc2013/mattbw/backend/utils.h ============================================================================== --- soc2013/mattbw/backend/utils.h Sun Aug 11 09:01:31 2013 (r255800) +++ soc2013/mattbw/backend/utils.h Sun Aug 11 09:30:46 2013 (r255801) @@ -23,6 +23,13 @@ #include <stdbool.h> /* bool */ +enum repo_type { + REPO_INVALID, + REPO_ANY, + REPO_LOCAL, + REPO_REMOTE +}; + #define INTENTIONALLY_IGNORE(x) (void)(x) #define STATUS(backend, status) \ (void)pk_backend_set_status((backend), (status)) @@ -30,6 +37,7 @@ (void)pk_backend_error_code((backend), (type), (msg)) bool string_match(const char *left, const char *right); +enum repo_type type_of_repo_name(const char *name); gchar **get_package_ids(PkBackend *backend, guint *count_p); #endif /* !_PKGNG_BACKEND_DETAILS_H_ */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201308110930.r7B9Ulwa091861>