summaryrefslogtreecommitdiffstats
path: root/libopkg/opkg.c
diff options
context:
space:
mode:
authorgraham.gower <graham.gower@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>2009-12-10 22:04:35 (EST)
committer graham.gower <graham.gower@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>2009-12-10 22:04:35 (EST)
commit993e14cd113fccd973c35fd1322625804d5e5142 (patch)
tree782f9a8ddb595a238ee1e1a907fc76fe1b860421 /libopkg/opkg.c
parent307864afe92e3b941d66bb334b32979eac2b41ab (diff)
Move loading of feeds and status files out of opkg_conf_init().
git-svn-id: http://opkg.googlecode.com/svn/trunk@483 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358
Diffstat (limited to 'libopkg/opkg.c')
-rw-r--r--libopkg/opkg.c48
1 files changed, 31 insertions, 17 deletions
diff --git a/libopkg/opkg.c b/libopkg/opkg.c
index 046b5a0..383dfb5 100644
--- a/libopkg/opkg.c
+++ b/libopkg/opkg.c
@@ -33,8 +33,6 @@
#include <libbb/libbb.h>
-args_t *args;
-
#define opkg_assert(expr) if (!(expr)) { \
printf ("opkg: file %s: line %d (%s): Assertation '%s' failed",\
__FILE__, __LINE__, __PRETTY_FUNCTION__, # expr); abort (); }
@@ -117,18 +115,28 @@ curl_progress_cb(struct _curl_cb_data *cb_data, double t, /* dltotal */
int
opkg_new()
{
- int err;
+ args_t args;
- args = xcalloc(1, sizeof(args_t));
- args_init(args);
+ args_init(&args);
- err = opkg_conf_init(args);
- if (err) {
- free(args);
- return -1;
- }
+ if (opkg_conf_init(&args))
+ goto err0;
+
+ args_deinit(&args);
+
+ if (pkg_hash_load_feeds())
+ goto err1;
+
+ if (pkg_hash_load_status_files())
+ goto err1;
return 0;
+
+err1:
+ pkg_hash_deinit();
+err0:
+ opkg_conf_deinit();
+ return -1;
}
void
@@ -138,19 +146,25 @@ opkg_free(void)
opkg_curl_cleanup();
#endif
opkg_conf_deinit();
- args_deinit(args);
- free(args);
}
int
opkg_re_read_config_files(void)
{
- /* Unfortunately, the easiest way to re-read the config files right now is to
- * throw away conf and start again */
- opkg_free();
- memset(conf, '\0', sizeof(opkg_conf_t));
- return opkg_new();
+ pkg_hash_deinit();
+ pkg_hash_init();
+
+ if (pkg_hash_load_feeds())
+ goto err;
+
+ if (pkg_hash_load_status_files())
+ goto err;
+
return 0;
+
+err:
+ pkg_hash_deinit();
+ return -1;
}
void