From owner-svn-soc-all@FreeBSD.ORG Sun Aug 11 09:30:47 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 4D343C6F for ; Sun, 11 Aug 2013 09:30:47 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 39B8B2BE2 for ; Sun, 11 Aug 2013 09:30:47 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r7B9UllR091891 for ; Sun, 11 Aug 2013 09:30:47 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r7B9Ulwa091861 for svn-soc-all@FreeBSD.org; Sun, 11 Aug 2013 09:30:47 GMT (envelope-from mattbw@FreeBSD.org) Date: Sun, 11 Aug 2013 09:30:47 GMT Message-Id: <201308110930.r7B9Ulwa091861@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255801 - in soc2013/mattbw/backend: . query MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 11 Aug 2013 09:30:47 -0000 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 */ +#include /* assert */ #include #include +#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 /* 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_ */