socsvn commit: r254441 - in soc2013/mattbw/backend: . actions query
mattbw at FreeBSD.org
mattbw at FreeBSD.org
Tue Jul 9 04:51:40 UTC 2013
Author: mattbw
Date: Tue Jul 9 04:51:38 2013
New Revision: 254441
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254441
Log:
banish variadic macros
Deleted:
soc2013/mattbw/backend/hash_traverse.h
Modified:
soc2013/mattbw/backend/.indent.pro
soc2013/mattbw/backend/actions/.indent.pro
soc2013/mattbw/backend/actions/get_details.c
soc2013/mattbw/backend/actions/get_files.c
soc2013/mattbw/backend/actions/get_repo_list.c
soc2013/mattbw/backend/actions/install_files.c
soc2013/mattbw/backend/actions/install_packages.c
soc2013/mattbw/backend/actions/resolve.c
soc2013/mattbw/backend/db.c
soc2013/mattbw/backend/db.h
soc2013/mattbw/backend/licenses.c
soc2013/mattbw/backend/pk-backend-pkgng.c
soc2013/mattbw/backend/query/core.c
soc2013/mattbw/backend/query/core.h
soc2013/mattbw/backend/query/do.c
soc2013/mattbw/backend/query/do.h
soc2013/mattbw/backend/query/match.c
soc2013/mattbw/backend/query/match.h
soc2013/mattbw/backend/utils.h
Modified: soc2013/mattbw/backend/.indent.pro
==============================================================================
--- soc2013/mattbw/backend/.indent.pro Tue Jul 9 03:00:06 2013 (r254440)
+++ soc2013/mattbw/backend/.indent.pro Tue Jul 9 04:51:38 2013 (r254441)
@@ -1,6 +1,7 @@
-TPkBackend
-Tgchar
-Tgboolean
+-Tbool
-sob
-nlp
-ci4
Modified: soc2013/mattbw/backend/actions/.indent.pro
==============================================================================
--- soc2013/mattbw/backend/actions/.indent.pro Tue Jul 9 03:00:06 2013 (r254440)
+++ soc2013/mattbw/backend/actions/.indent.pro Tue Jul 9 04:51:38 2013 (r254441)
@@ -1,6 +1,7 @@
-TPkBackend
-Tgchar
-Tgboolean
+-Tbool
-sob
-nlp
-ci4
Modified: soc2013/mattbw/backend/actions/get_details.c
==============================================================================
--- soc2013/mattbw/backend/actions/get_details.c Tue Jul 9 03:00:06 2013 (r254440)
+++ soc2013/mattbw/backend/actions/get_details.c Tue Jul 9 04:51:38 2013 (r254441)
@@ -19,6 +19,7 @@
*/
#include <glib.h>
+#include <stdbool.h>
#include "../pk-backend.h"
#include "pkg.h"
@@ -29,7 +30,7 @@
static const unsigned int LOAD_FLAGS = PKG_LOAD_BASIC | PKG_LOAD_LICENSES;
-static gboolean emit(struct pkg *pkg, const gchar *id, struct query *q);
+static bool emit(struct pkg *pkg, const gchar *id, struct query *q);
/*
* The thread that performs a GetDetails operation. Should be invoked by the
@@ -38,20 +39,20 @@
gboolean
get_details_thread(PkBackend *backend)
{
- gboolean success;
+ bool success;
success = query_match_id_to_emitter(backend, LOAD_FLAGS, emit);
pk_backend_finished(backend);
- return success;
+ return success ? TRUE : FALSE;
}
/*
* Emits the given package's details. To be used as an iterating function.
*/
-static gboolean
+static bool
emit(struct pkg *pkg, const gchar *id, struct query *q)
{
- gboolean success;
+ bool success;
const char *description;
const char *origin;
const char *www;
@@ -74,7 +75,7 @@
group_from_origin(origin),
description,
www,
- flatsize);
+ flatsize) == TRUE;
query_set_percentage(q, 100);
return success;
Modified: soc2013/mattbw/backend/actions/get_files.c
==============================================================================
--- soc2013/mattbw/backend/actions/get_files.c Tue Jul 9 03:00:06 2013 (r254440)
+++ soc2013/mattbw/backend/actions/get_files.c Tue Jul 9 04:51:38 2013 (r254441)
@@ -18,6 +18,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#include <stdbool.h>
#include <glib.h>
#include <sys/sbuf.h>
@@ -25,7 +26,6 @@
#include "pkg.h"
#include "../groups.h" /* group_from_origin */
-#include "../hash_traverse.h" /* HASH_FOR */
#include "../licenses.h" /* license_from_pkg */
#include "../query.h" /* query_... */
@@ -33,7 +33,7 @@
static const unsigned int LOAD_FLAGS = PKG_LOAD_BASIC | PKG_LOAD_FILES;
-static gboolean emit(struct pkg *pkg, const gchar *id, struct query *q);
+static bool emit(struct pkg *pkg, const gchar *id, struct query *q);
/*
* The thread that performs a GetDetails operation. Should be invoked by the
@@ -48,23 +48,22 @@
success = query_match_id_to_emitter(backend, LOAD_FLAGS, emit);
(void)pk_backend_finished(backend);
- return success;
+ return success ? TRUE : FALSE;
}
/*
* Emits the given package's files. To be used as an iterating function.
*/
-static gboolean
+static bool
emit(struct pkg *pkg, const gchar *id, struct query *q)
{
- gboolean success;
- int err;
+ bool success;
struct pkg_file *file;
struct sbuf *sb;
query_set_percentage(q, 0);
- success = FALSE;
+ success = false;
file = NULL;
/*
@@ -72,7 +71,7 @@
* rid of the initial ; later.
*/
sb = sbuf_new_auto();
- for (HASH_FOR(err, pkg_files, pkg, &file))
+ while (pkg_files(pkg, &file) == EPKG_OK)
sbuf_printf(sb, ";%s", pkg_file_path(file));
if (sbuf_finish(sb) != 0)
@@ -87,7 +86,8 @@
if (filenames[0] == ';')
filenames++;
- success = pk_backend_files(query_backend(q), id, filenames);
+ success = (pk_backend_files(query_backend(q), id, filenames) ==
+ TRUE);
}
sbuf_delete(sb);
Modified: soc2013/mattbw/backend/actions/get_repo_list.c
==============================================================================
--- soc2013/mattbw/backend/actions/get_repo_list.c Tue Jul 9 03:00:06 2013 (r254440)
+++ soc2013/mattbw/backend/actions/get_repo_list.c Tue Jul 9 04:51:38 2013 (r254441)
@@ -22,7 +22,6 @@
#include "../pk-backend.h"
#include "pkg.h"
-#include "../hash_traverse.h" /* HASH_FOR */
#include "../actions.h" /* get_repo_list_thread prototype */
/*
@@ -32,15 +31,13 @@
gboolean
get_repo_list_thread(PkBackend *backend)
{
- int err;
struct pkg_repo *repo;
- repo = NULL;
-
(void)pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY);
(void)pk_backend_set_percentage(backend, 0);
- for (HASH_FOR(err, pkg_repos, &repo))
+ repo = NULL;
+ while (pkg_repos(&repo) == EPKG_OK)
pk_backend_repo_detail(backend,
pkg_repo_ident(repo),
pkg_repo_name(repo),
@@ -49,5 +46,5 @@
(void)pk_backend_set_percentage(backend, 100);
(void)pk_backend_finished(backend);
- return (err == EPKG_END ? TRUE : FALSE);
+ return TRUE;
}
Modified: soc2013/mattbw/backend/actions/install_files.c
==============================================================================
--- soc2013/mattbw/backend/actions/install_files.c Tue Jul 9 03:00:06 2013 (r254440)
+++ soc2013/mattbw/backend/actions/install_files.c Tue Jul 9 04:51:38 2013 (r254441)
@@ -23,7 +23,6 @@
#include "pkg.h"
#include "../db.h" /* db_open_remote */
-#include "../hash_traverse.h" /* HASH_FOR */
#include "../pkgutils.h" /* pkgutils_... */
#include "../utils.h" /* INTENTIONALLY_IGNORE */
Modified: soc2013/mattbw/backend/actions/install_packages.c
==============================================================================
--- soc2013/mattbw/backend/actions/install_packages.c Tue Jul 9 03:00:06 2013 (r254440)
+++ soc2013/mattbw/backend/actions/install_packages.c Tue Jul 9 04:51:38 2013 (r254441)
@@ -22,16 +22,15 @@
#include "../pk-backend.h"
#include "pkg.h"
-#include "../hash_traverse.h" /* HASH_FOR */
#include "../pkgutils.h" /* pkgutils_... */
#include "../query.h" /* query_... */
#include "../utils.h" /* INTENTIONALLY_IGNORE */
#include "../actions.h" /* install_packages_thread prototype */
-static gboolean job(struct pkg_jobs *jobs, struct query *q);
-static gboolean sim_job(struct pkg_jobs *jobs, struct query *q);
-static gboolean solve_job(struct query *q, struct pkg_jobs *jobs);
+static bool job (struct pkg_jobs *jobs, struct query *q);
+static bool sim_job(struct pkg_jobs *jobs, struct query *q);
+static bool solve_job(struct query *q, struct pkg_jobs *jobs);
static int install_event_cb(void *backend_v, struct pkg_event *event);
/*
@@ -41,13 +40,13 @@
gboolean
install_packages_thread(PkBackend *backend)
{
- gboolean success;
+ bool success;
(void)pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY);
success = query_match_id_to_job(backend, PKG_JOBS_INSTALL, job);
(void)pk_backend_finished(backend);
- return success;
+ return success ? TRUE : FALSE;
}
/*
@@ -57,29 +56,29 @@
gboolean
simulate_install_packages_thread(PkBackend *backend)
{
- gboolean success;
+ bool success;
(void)pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY);
success = query_match_id_to_job(backend, PKG_JOBS_INSTALL, sim_job);
(void)pk_backend_finished(backend);
- return success;
+ return success ? TRUE : FALSE;
}
/*
* Tries to process the given solved installation jobs.
*/
-static gboolean
+static bool
job(struct pkg_jobs *jobs, struct query *q)
{
- gboolean success;
+ bool success;
PkBackend *backend;
- success = FALSE;
+ success = false;
backend = query_backend(q);
query_set_percentage(q, 0);
- if (solve_job(q, jobs) == FALSE)
+ if (solve_job(q, jobs) == false)
goto cleanup;
pkg_event_register(install_event_cb, backend);
@@ -91,7 +90,7 @@
"job failed");
goto cleanup;
}
- success = TRUE;
+ success = true;
cleanup:
pkg_event_register(NULL, NULL);
@@ -102,18 +101,18 @@
/*
* Tries to simulate processing the given installation jobs.
*/
-static gboolean
+static bool
sim_job(struct pkg_jobs *jobs, struct query *q)
{
- gboolean success;
+ bool success;
PkBackend *backend;
struct pkg *pkg;
backend = query_backend(q);
- success = FALSE;
+ success = false;
query_set_percentage(q, 0);
- if (solve_job(q, jobs) == FALSE)
+ if (solve_job(q, jobs) == false)
goto cleanup;
pk_backend_set_status(backend, PK_STATUS_ENUM_RUNNING);
@@ -123,7 +122,7 @@
backend,
pkgutils_pkg_install_state(pkg));
- success = TRUE;
+ success = true;
cleanup:
query_set_percentage(q, 100);
@@ -133,26 +132,26 @@
/*
* Solves a job and ensures it has packages available.
*/
-static gboolean
+static bool
solve_job(struct query *q, struct pkg_jobs *jobs)
{
- gboolean success;
+ bool success;
PkBackend *backend;
- success = FALSE;
+ success = false;
backend = query_backend(q);
pk_backend_set_status(backend, PK_STATUS_ENUM_DEP_RESOLVE);
if (pkg_jobs_solve(jobs) != EPKG_OK)
- pk_backend_error_code(backend,
+ (void)pk_backend_error_code(backend,
PK_ERROR_ENUM_DEP_RESOLUTION_FAILED,
"could not solve the job");
else if (pkg_jobs_count(jobs) == 0)
- pk_backend_error_code(backend,
+ (void)pk_backend_error_code(backend,
PK_ERROR_ENUM_INTERNAL_ERROR,
"job contains no packages");
else
- success = TRUE;
+ success = true;
return success;
}
Modified: soc2013/mattbw/backend/actions/resolve.c
==============================================================================
--- soc2013/mattbw/backend/actions/resolve.c Tue Jul 9 03:00:06 2013 (r254440)
+++ soc2013/mattbw/backend/actions/resolve.c Tue Jul 9 04:51:38 2013 (r254441)
@@ -27,7 +27,7 @@
#include "../utils.h" /* INTENTIONALLY_IGNORE */
#include "../actions.h" /* resolve_thread prototype */
-static gboolean emit(struct pkg *pkg, const gchar *id, struct query *q);
+static bool emit(struct pkg *pkg, const gchar *id, struct query *q);
/*
* Resolves a package identifier, which may be a full PackageID or a package
@@ -48,10 +48,10 @@
success = query_do(backend, &s, &t);
(void)pk_backend_finished(backend);
- return success;
+ return success ? TRUE : FALSE;
}
-static gboolean
+static bool
emit(struct pkg *pkg, const gchar *id, struct query *q)
{
PkBackend *backend;
@@ -63,5 +63,5 @@
pkgutils_emit(pkg, backend, pkgutils_pkg_current_state(pkg));
query_set_percentage(q, 100);
- return TRUE;
+ return true;
}
Modified: soc2013/mattbw/backend/db.c
==============================================================================
--- soc2013/mattbw/backend/db.c Tue Jul 9 03:00:06 2013 (r254440)
+++ soc2013/mattbw/backend/db.c Tue Jul 9 04:51:38 2013 (r254441)
@@ -42,12 +42,12 @@
* This must be called during the lifetime of "backend", eg after
* "pk_backend_initialize" and before "pk_backend_destroy".
*/
-gboolean
+bool
db_open_remote(struct pkgdb **db_p, PkBackend *backend)
{
- gboolean success;
+ bool success;
- success = FALSE;
+ success = false;
(void)pk_backend_set_status(backend, PK_STATUS_ENUM_WAITING_FOR_AUTH);
if (pkgdb_access(ACCESS_MODE, ACCESS_DB) != EPKG_OK) {
@@ -70,7 +70,7 @@
goto cleanup;
}
(void)pk_backend_set_status(backend, PK_STATUS_ENUM_RUNNING);
- success = TRUE;
+ success = true;
cleanup:
return success;
Modified: soc2013/mattbw/backend/db.h
==============================================================================
--- soc2013/mattbw/backend/db.h Tue Jul 9 03:00:06 2013 (r254440)
+++ soc2013/mattbw/backend/db.h Tue Jul 9 04:51:38 2013 (r254441)
@@ -22,10 +22,10 @@
#ifndef _PKGNG_BACKEND_DB_H_
#define _PKGNG_BACKEND_DB_H_
-#include <glib.h> /* gboolean */
+#include <stdbool.h> /* bool */
#include "pk-backend.h" /* PkBackend */
#include "pkg.h" /* struct pkgdb */
-gboolean db_open_remote(struct pkgdb **db, PkBackend *backend);
+bool db_open_remote(struct pkgdb **db, PkBackend *backend);
#endif /* !_PKGNG_BACKEND_DB_H_ */
Modified: soc2013/mattbw/backend/licenses.c
==============================================================================
--- soc2013/mattbw/backend/licenses.c Tue Jul 9 03:00:06 2013 (r254440)
+++ soc2013/mattbw/backend/licenses.c Tue Jul 9 04:51:38 2013 (r254441)
@@ -24,7 +24,6 @@
#include "pkg.h" /* struct pkg, etc */
#include "pk-backend.h" /* PkLicenseEnum, PK_* */
-#include "hash_traverse.h" /* HASH_FOR */
#include "licenses.h" /* prototypes */
/*
@@ -35,7 +34,6 @@
license_name_from_pkg(struct pkg *pkg)
{
/* TODO: handle conjunctions and disjunctions */
- int err;
int sb_err;
lic_t logic;
char *license_dup;
@@ -60,7 +58,7 @@
/* Join all the licenses together with the logic word above. */
lic = NULL;
sb = sbuf_new_auto();
- for (HASH_FOR(err, pkg_licenses, pkg, &lic)) {
+ while (pkg_licenses(pkg, &lic) == EPKG_OK) {
sbuf_cat(sb, logic_str);
sbuf_cat(sb, pkg_license_name(lic));
}
Modified: soc2013/mattbw/backend/pk-backend-pkgng.c
==============================================================================
--- soc2013/mattbw/backend/pk-backend-pkgng.c Tue Jul 9 03:00:06 2013 (r254440)
+++ soc2013/mattbw/backend/pk-backend-pkgng.c Tue Jul 9 04:51:38 2013 (r254441)
@@ -96,7 +96,7 @@
{
INTENTIONALLY_IGNORE(package_ids); /* retrieved from backend */
- pk_backend_thread_create(backend, get_details_thread);
+ (void)pk_backend_thread_create(backend, get_details_thread);
}
void
@@ -104,7 +104,7 @@
{
INTENTIONALLY_IGNORE(package_ids); /* retrieved from backend */
- pk_backend_thread_create(backend, get_files_thread);
+ (void)pk_backend_thread_create(backend, get_files_thread);
}
PkBitfield
@@ -148,7 +148,7 @@
{
INTENTIONALLY_IGNORE(filters); /* not yet supported */
- pk_backend_thread_create(backend, get_repo_list_thread);
+ (void)pk_backend_thread_create(backend, get_repo_list_thread);
}
void
@@ -158,7 +158,7 @@
INTENTIONALLY_IGNORE(only_trusted); /* not yet supported */
INTENTIONALLY_IGNORE(full_paths); /* retrieved from backend */
- pk_backend_thread_create(backend, install_files_thread);
+ (void)pk_backend_thread_create(backend, install_files_thread);
}
void
@@ -168,25 +168,25 @@
INTENTIONALLY_IGNORE(only_trusted); /* not yet supported */
INTENTIONALLY_IGNORE(package_ids); /* retrieved from backend */
- pk_backend_thread_create(backend, install_packages_thread);
+ (void)pk_backend_thread_create(backend, install_packages_thread);
}
void
pk_backend_resolve(PkBackend *backend, PkBitfield filters, gchar **package_ids)
{
- INTENTIONALLY_IGNORE(filters); /* retrieved from backend */
+ INTENTIONALLY_IGNORE(filters); /* retrieved from backend */
INTENTIONALLY_IGNORE(package_ids); /* retrieved from backend */
- pk_backend_thread_create(backend, resolve_thread);
+ (void)pk_backend_thread_create(backend, resolve_thread);
}
void
pk_backend_search_names(PkBackend *backend, PkBitfield filters, gchar **values)
{
- INTENTIONALLY_IGNORE(filters); /* retrieved from backend */
- pk_backend_set_strv(backend, "values", values);
- pk_backend_thread_create(backend, search_names_thread);
+ INTENTIONALLY_IGNORE(filters); /* retrieved from backend */
+ (void)pk_backend_set_strv(backend, "values", values);
+ (void)pk_backend_thread_create(backend, search_names_thread);
}
@@ -195,7 +195,7 @@
{
INTENTIONALLY_IGNORE(full_paths); /* retrieved from backend */
- pk_backend_thread_create(backend, simulate_install_files_thread);
+ (void)pk_backend_thread_create(backend, simulate_install_files_thread);
}
void
@@ -203,5 +203,6 @@
{
INTENTIONALLY_IGNORE(package_ids); /* retrieved from backend */
- pk_backend_thread_create(backend, simulate_install_packages_thread);
+ (void)pk_backend_thread_create(backend,
+ simulate_install_packages_thread);
}
Modified: soc2013/mattbw/backend/query/core.c
==============================================================================
--- soc2013/mattbw/backend/query/core.c Tue Jul 9 03:00:06 2013 (r254440)
+++ soc2013/mattbw/backend/query/core.c Tue Jul 9 04:51:38 2013 (r254441)
@@ -18,6 +18,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#include <stdbool.h>
#include <string.h>
#include <glib.h>
#include "../pk-backend.h"
@@ -25,7 +26,6 @@
#include "../db.h" /* db_open_remote */
-#include "../hash_traverse.h" /* HASH_FOR */
#include "../utils.h" /* string_match */
#include "../pkgutils.h" /* pkgutils_... */
#include "core.h" /* Prototypes */
@@ -41,7 +41,7 @@
PkBackend *backend;
struct pkgdb *db;
- gchar **id_strv;
+ gchar **id_strv;
enum repo_type rtype;
@@ -50,7 +50,7 @@
};
static enum repo_type type_of_repo_name(const char *name);
-static gboolean can_remote_iterate(struct query *q);
+static bool can_remote_iterate(struct query *q);
static gchar *match_pkg(struct pkg *pkg, struct query *q);
static const gchar *query_repo(struct query *q);
static gchar **init_unpack_source(PkBackend *backend, struct query_source *s);
@@ -69,16 +69,16 @@
/*
* For adapting an emitter function into one that solves and applies a job.
*/
-gboolean
+bool
query_emit_to_job(struct pkg *pkg, const gchar *id, struct query *q)
{
- gboolean success;
+ bool success;
struct pkg_jobs *jobs;
PkBackend *backend;
INTENTIONALLY_IGNORE(id);
- success = FALSE;
+ success = false;
jobs = NULL;
if (q == NULL)
@@ -114,12 +114,12 @@
/*
* Runs an assembled query.
*/
-gboolean
+bool
query_run(struct query *q)
{
- gboolean success;
- gboolean try_local;
- gboolean try_remote;
+ bool success;
+ bool try_local;
+ bool try_remote;
int match;
PkBitfield filters;
const char *name;
@@ -129,7 +129,7 @@
struct pkgdb *db;
struct pkgdb_it *it;
- success = FALSE;
+ success = false;
match = MATCH_EXACT;
match_id = NULL;
pkg = NULL;
@@ -148,9 +148,9 @@
/* Apply filters, if any */
filters = pk_backend_get_uint(q->backend, "filters");
if (pk_bitfield_contain(filters, PK_FILTER_ENUM_INSTALLED))
- try_remote = FALSE;
+ try_remote = false;
if (pk_bitfield_contain(filters, PK_FILTER_ENUM_NOT_INSTALLED))
- try_local = FALSE;
+ try_local = false;
/* Try a local search first, if applicable. */
it = (try_local ? pkgdb_query(db, name, match) : NULL);
@@ -160,7 +160,7 @@
/* No point trying remote if we got a local match */
if (pkg != NULL)
- try_remote = FALSE;
+ try_remote = false;
/* Next, try a remote search, again only if applicable. */
it = (try_remote ? pkgdb_rquery(db, name, match, repo) : NULL);
@@ -196,10 +196,10 @@
struct query_source *s,
struct query_target *t)
{
- gboolean success;
+ bool success;
struct query *q;
- success = FALSE;
+ success = false;
q = calloc(1, sizeof(struct query));
if (q == NULL) {
@@ -220,10 +220,10 @@
ERR(backend, PK_ERROR_ENUM_REPO_NOT_FOUND, "no such repo");
goto cleanup;
}
- success = TRUE;
+ success = true;
cleanup:
- if (success == FALSE)
+ if (success == false)
query_free(&q);
return q;
@@ -297,13 +297,13 @@
* Checks to see if trying to do a remote package iteration with this query
* could spell disaster.
*/
-static gboolean
+static bool
can_remote_iterate(struct query *q)
{
- gboolean sane;
+ bool sane;
/* Innocent until proven guilty */
- sane = TRUE;
+ sane = true;
/*
* Stop pkg from catching fire if we try to load files from
@@ -314,7 +314,7 @@
ERR(q->backend,
PK_ERROR_ENUM_CANNOT_GET_FILELIST,
"cannot get files for remote package");
- sane = FALSE;
+ sane = false;
}
return sane;
}
@@ -326,7 +326,7 @@
static gchar *
match_pkg(struct pkg *pkg, struct query *q)
{
- gboolean matches;
+ bool matches;
int i;
gchar *match_id;
const gchar **pkg_id_bits;
@@ -337,7 +337,7 @@
/* No need to do a PackageID match if we're looking for a name. */
if (q->s->type == QUERY_SINGLE_NAME)
- matches = TRUE;
+ matches = true;
else {
/*
* Succeed if this package's PackageID fields match the
@@ -346,8 +346,8 @@
* one as a success. This means using our "weak strcmp"
* instead of normal strcmp or even g_strcmp0.
*/
- for (matches = TRUE, i = PK_PACKAGE_ID_NAME;
- matches == TRUE && i <= PK_PACKAGE_ID_DATA;
+ for (matches = true, i = PK_PACKAGE_ID_NAME;
+ matches == true && i <= PK_PACKAGE_ID_DATA;
i++)
matches = string_match((q->id_strv)[i],
pkg_id_bits[i]);
@@ -355,7 +355,7 @@
g_free(pkg_id_bits);
- if (matches == FALSE) {
+ if (matches == false) {
g_free(match_id);
match_id = NULL;
}
@@ -366,7 +366,7 @@
static const gchar *
query_repo(struct query *q)
{
- const gchar *repo;
+ const gchar *repo;
repo = q->id_strv[PK_PACKAGE_ID_DATA];
return ((repo == NULL || repo[0] == '\0') ? NULL : repo);
@@ -388,7 +388,7 @@
jobs_repo_from_query(struct pkg_jobs *jobs, struct query *q)
{
int err;
- gchar *repo;
+ gchar *repo;
repo = q->id_strv[PK_PACKAGE_ID_DATA];
if (repo == NULL || repo[0] == '\0')
@@ -435,17 +435,17 @@
}
/* Unpacks a query source into name/version/arch/data pointers. */
-static gchar **
+static gchar **
init_unpack_source(PkBackend *backend, struct query_source *s)
{
- gchar **id_strv;
+ gchar **id_strv;
id_strv = NULL;
if (s->type == QUERY_SINGLE_NAME) {
/*
- * Make a snake-oil ID vector; we won't be doing rigid checking
- * against it so it doesn't matter that the version might be in
- * the name column etc.
+ * Make a snake-oil ID vector; we won't be doing rigid
+ * checking against it so it doesn't matter that the version
+ * might be in the name column etc.
*/
id_strv = g_new0(gchar *, 5);
Modified: soc2013/mattbw/backend/query/core.h
==============================================================================
--- soc2013/mattbw/backend/query/core.h Tue Jul 9 03:00:06 2013 (r254440)
+++ soc2013/mattbw/backend/query/core.h Tue Jul 9 04:51:38 2013 (r254441)
@@ -27,9 +27,9 @@
struct query;
-typedef gboolean (*emit_ptr) (struct pkg *pkg, const gchar *id, struct query *q);
-typedef gboolean (*job_emit_ptr) (struct pkg_jobs *jobs, struct query *q);
-typedef gboolean (*query_body_ptr) (struct query *q);
+typedef bool (*emit_ptr) (struct pkg *pkg, const gchar *id, struct query *q);
+typedef bool (*job_emit_ptr) (struct pkg_jobs *jobs, struct query *q);
+typedef bool (*query_body_ptr) (struct query *q);
enum query_source_type {
QUERY_SINGLE_ID,
@@ -47,14 +47,14 @@
struct query_source {
enum query_source_type type;
union {
- gchar *single;
- } data;
+ gchar *single;
+ } data;
- query_body_ptr body;
+ query_body_ptr body;
/* Information about this query's position in a set of subqueries. */
- unsigned int position;
- unsigned int total;
+ unsigned int position;
+ unsigned int total;
};
/* Holds information about where the result of a query should go. */
@@ -62,19 +62,19 @@
enum query_target_type type;
union {
struct {
- unsigned int load_flags;
- emit_ptr f;
- } emit;
+ unsigned int load_flags;
+ emit_ptr f;
+ } emit;
struct {
- pkg_jobs_t type;
- job_emit_ptr f;
- } job;
- } data;
+ pkg_jobs_t type;
+ job_emit_ptr f;
+ } job;
+ } data;
};
PkBackend *query_backend(struct query *q);
-gboolean query_emit_to_job(struct pkg *pkg, const gchar *id, struct query *q);
-gboolean query_run(struct query *q);
+bool query_emit_to_job(struct pkg *pkg, const gchar *id, struct query *q);
+bool query_run (struct query *q);
struct query *query_init(PkBackend *backend, struct pkgdb *db, struct query_source *s, struct query_target *t);
void query_free(struct query **q_p);
void query_set_percentage(struct query *q, unsigned char percent);
Modified: soc2013/mattbw/backend/query/do.c
==============================================================================
--- soc2013/mattbw/backend/query/do.c Tue Jul 9 03:00:06 2013 (r254440)
+++ soc2013/mattbw/backend/query/do.c Tue Jul 9 04:51:38 2013 (r254441)
@@ -31,22 +31,22 @@
#include "do.h" /* query_do_... */
#include "core.h" /* query_... */
-static gboolean do_single(PkBackend *backend, struct pkgdb *db, struct query_source *s, struct query_target *t);
-static gboolean do_backend_ids(PkBackend *backend, struct pkgdb *db, struct query_source *s, struct query_target *t);
+static bool do_single(PkBackend *backend, struct pkgdb *db, struct query_source *s, struct query_target *t);
+static bool do_backend_ids(PkBackend *backend, struct pkgdb *db, struct query_source *s, struct query_target *t);
/*
* Given information about a query's source and target, creates and runs it.
*/
-gboolean
+bool
query_do(PkBackend *backend, struct query_source *s, struct query_target *t)
{
- gboolean success;
+ bool success;
struct pkgdb *db;
db = NULL;
- success = FALSE;
+ success = false;
- if (db_open_remote(&db, backend) == TRUE) {
+ if (db_open_remote(&db, backend)) {
switch (s->type) {
case QUERY_BACKEND_IDS:
case QUERY_BACKEND_MIXED:
@@ -57,7 +57,7 @@
success = do_single(backend, db, s, t);
break;
default:
- success = FALSE;
+ success = false;
break;
}
}
@@ -69,17 +69,17 @@
* Performs a query whose source is the set of PackageIDs stored in the
* backend.
*/
-static gboolean
+static bool
do_backend_ids(PkBackend *backend, struct pkgdb *db, struct query_source *s,
struct query_target *t)
{
- gboolean success;
+ bool success;
gchar **package_ids;
struct query_source new_s;
/* Cheat by running a separate single-ID query for each ID. */
- success = TRUE;
+ success = true;
package_ids = pk_backend_get_strv(backend, "package_ids");
new_s.total = g_strv_length(package_ids);
@@ -105,15 +105,15 @@
/*
* Performs a query whose source is a single PackageID or name.
*/
-static gboolean
+static bool
do_single(PkBackend *backend, struct pkgdb *db, struct query_source *s,
struct query_target *t)
{
- gboolean success;
+ bool success;
struct query *q;
q = query_init(backend, db, s, t);
- success = q == NULL ? FALSE : query_run(q);
+ success = q == NULL ? false : query_run(q);
query_free(&q);
return success;
Modified: soc2013/mattbw/backend/query/do.h
==============================================================================
--- soc2013/mattbw/backend/query/do.h Tue Jul 9 03:00:06 2013 (r254440)
+++ soc2013/mattbw/backend/query/do.h Tue Jul 9 04:51:38 2013 (r254441)
@@ -21,12 +21,12 @@
#ifndef _PKGNG_BACKEND_QUERY_DO_H_
#define _PKGNG_BACKEND_QUERY_DO_H_
-#include <glib.h>
+#include <stdbool.h>
#include "../pk-backend.h"
#include "pkg.h"
#include "core.h" /* struct query_... */
-gboolean query_do(PkBackend *backend, struct query_source *s, struct query_target *t);
+bool query_do (PkBackend *backend, struct query_source *s, struct query_target *t);
#endif /* !_PKGNG_BACKEND_QUERY_DO_H_ */
Modified: soc2013/mattbw/backend/query/match.c
==============================================================================
--- soc2013/mattbw/backend/query/match.c Tue Jul 9 03:00:06 2013 (r254440)
+++ soc2013/mattbw/backend/query/match.c Tue Jul 9 04:51:38 2013 (r254441)
@@ -18,6 +18,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#include <stdbool.h>
#include "../pk-backend.h"
#include "core.h" /* query_... */
@@ -29,7 +30,7 @@
* Runs a query over the PackageIDs selected in the backend that sends the
* first match to an emitting function.
*/
-gboolean
+bool
query_match_id_to_emitter(PkBackend *backend, unsigned int load_flags,
emit_ptr emitter)
{
@@ -50,7 +51,7 @@
* first match into a job of the given type and hands it to a function for
* solving and applying.
*/
-gboolean
+bool
query_match_id_to_job(PkBackend *backend, pkg_jobs_t type,
job_emit_ptr emitter)
{
Modified: soc2013/mattbw/backend/query/match.h
==============================================================================
--- soc2013/mattbw/backend/query/match.h Tue Jul 9 03:00:06 2013 (r254440)
+++ soc2013/mattbw/backend/query/match.h Tue Jul 9 04:51:38 2013 (r254441)
@@ -21,13 +21,13 @@
#ifndef _PKGNG_BACKEND_QUERY_MATCH_H_
#define _PKGNG_BACKEND_QUERY_MATCH_H_
-#include <glib.h>
+#include <stdbool.h>
#include "../pk-backend.h"
#include "pkg.h"
#include "core.h" /* *_ptr */
-gboolean query_match_id_to_emitter(PkBackend *backend, unsigned int load_flags, emit_ptr emitter);
-gboolean query_match_id_to_job(PkBackend *backend, pkg_jobs_t type, job_emit_ptr job_emitter);
+bool query_match_id_to_emitter(PkBackend *backend, unsigned int load_flags, emit_ptr emitter);
+bool query_match_id_to_job(PkBackend *backend, pkg_jobs_t type, job_emit_ptr job_emitter);
#endif /* !_PKGNG_BACKEND_QUERY_MATCH_H_ */
Modified: soc2013/mattbw/backend/utils.h
==============================================================================
--- soc2013/mattbw/backend/utils.h Tue Jul 9 03:00:06 2013 (r254440)
+++ soc2013/mattbw/backend/utils.h Tue Jul 9 04:51:38 2013 (r254441)
@@ -25,7 +25,8 @@
#include <glib.h> /* gboolean */
#define INTENTIONALLY_IGNORE(x) (void)(x)
-#define ERR(...) (void) pk_backend_error_code(__VA_ARGS__)
+#define ERR(backend, type, msg) \
+ (void) pk_backend_error_code((backend), (type), (msg))
const char *null_if_empty(const char *in);
gboolean
More information about the svn-soc-all
mailing list