[Midnightbsd-cvs] src [12120] trunk/lib/libmport: add a setting to configure region
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sun Nov 25 15:18:41 EST 2018
Revision: 12120
http://svnweb.midnightbsd.org/src/?rev=12120
Author: laffer1
Date: 2018-11-25 15:18:40 -0500 (Sun, 25 Nov 2018)
Log Message:
-----------
add a setting to configure region
Modified Paths:
--------------
trunk/lib/libmport/index.c
trunk/lib/libmport/mport_private.h
Modified: trunk/lib/libmport/index.c
===================================================================
--- trunk/lib/libmport/index.c 2018-11-23 20:12:10 UTC (rev 12119)
+++ trunk/lib/libmport/index.c 2018-11-25 20:18:40 UTC (rev 12120)
@@ -36,6 +36,7 @@
#include <string.h>
#include <stdlib.h>
#include <errno.h>
+#include <stddef.h>
static int index_is_recentish(void);
static int index_last_checked_recentish(mportInstance *);
@@ -209,9 +210,15 @@
int ret, i;
int len;
sqlite3_stmt *stmt;
+ char *mirror_region;
+ mirror_region = mport_setting_get(mport, MPORT_SETTING_MIRROR_REGION);
+ if (mirror_region == NULL) {
+ mirror_region = "us";
+ }
+
/* XXX the country is hard coded until a configuration system is created */
- if (mport_db_count(mport->db, &len, "SELECT COUNT(*) FROM idx.mirrors WHERE country='us'") != MPORT_OK)
+ if (mport_db_count(mport->db, &len, "SELECT COUNT(*) FROM idx.mirrors WHERE country=%Q", mirror_region) != MPORT_OK)
RETURN_CURRENT_ERROR;
*list_size = len;
@@ -219,7 +226,7 @@
*list_p = list;
i = 0;
- if (mport_db_prepare(mport->db, &stmt, "SELECT mirror FROM idx.mirrors WHERE country='us'") != MPORT_OK) {
+ if (mport_db_prepare(mport->db, &stmt, "SELECT mirror FROM idx.mirrors WHERE country=%Q", mirror_region) != MPORT_OK) {
sqlite3_finalize(stmt);
RETURN_CURRENT_ERROR;
}
Modified: trunk/lib/libmport/mport_private.h
===================================================================
--- trunk/lib/libmport/mport_private.h 2018-11-23 20:12:10 UTC (rev 12119)
+++ trunk/lib/libmport/mport_private.h 2018-11-25 20:18:40 UTC (rev 12120)
@@ -47,6 +47,8 @@
#define MPORT_BUNDLE_VERSION 5
#define MPORT_BUNDLE_VERSION_STR "5"
+#define MPORT_SETTING_MIRROR_REGION = "mirror_region";
+
/* callback syntaxtic sugar */
void mport_call_msg_cb(mportInstance *, const char *, ...);
void mport_call_progress_init_cb(mportInstance *, const char *, ...);
More information about the Midnightbsd-cvs
mailing list