summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2007-11-04 12:05:22 -0600
committerDan McGee <dan@archlinux.org>2007-11-04 12:05:22 -0600
commit86ca39d15e02dff47b5b0f5bcd0494cf101ce0c1 (patch)
tree4475913a7dd0fe5facbe9bed369aba34f67134aa
parent006387828cbdd11e6307879ad27e9bb9409ca193 (diff)
downloadpacman-86ca39d15e02dff47b5b0f5bcd0494cf101ce0c1.tar.xz
Clean up usage of extern variables
Instead of declaring the extern variable in every *.c file, include it in the header file that makes sense. This means handle.h for the handle, and conf.h for the pacman side config object. Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--lib/libalpm/alpm.c1
-rw-r--r--lib/libalpm/deps.c2
-rw-r--r--lib/libalpm/handle.c3
-rw-r--r--lib/libalpm/handle.h1
-rw-r--r--src/pacman/add.c2
-rw-r--r--src/pacman/callback.c2
-rw-r--r--src/pacman/conf.c3
-rw-r--r--src/pacman/conf.h3
-rw-r--r--src/pacman/deptest.c2
-rw-r--r--src/pacman/pacman.c2
-rw-r--r--src/pacman/query.c1
-rw-r--r--src/pacman/remove.c2
-rw-r--r--src/pacman/sync.c1
-rw-r--r--src/pacman/util.c2
14 files changed, 10 insertions, 17 deletions
diff --git a/lib/libalpm/alpm.c b/lib/libalpm/alpm.c
index 7bbcc869..9fe9bc17 100644
--- a/lib/libalpm/alpm.c
+++ b/lib/libalpm/alpm.c
@@ -32,7 +32,6 @@
#include "util.h"
/* Globals */
-pmhandle_t *handle = NULL;
enum _pmerrno_t pm_errno SYMEXPORT;
/** \addtogroup alpm_interface Interface Functions
diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c
index a9de1612..d8cb0d67 100644
--- a/lib/libalpm/deps.c
+++ b/lib/libalpm/deps.c
@@ -39,8 +39,6 @@
#include "provide.h"
#include "handle.h"
-extern pmhandle_t *handle;
-
static pmgraph_t *_alpm_graph_new(void)
{
pmgraph_t *graph = NULL;
diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c
index 4c18943a..9031291d 100644
--- a/lib/libalpm/handle.c
+++ b/lib/libalpm/handle.c
@@ -43,6 +43,9 @@
#include "alpm.h"
#include "server.h"
+/* global var for handle (private to libalpm) */
+pmhandle_t *handle = NULL;
+
pmhandle_t *_alpm_handle_new()
{
pmhandle_t *handle;
diff --git a/lib/libalpm/handle.h b/lib/libalpm/handle.h
index d8edf00f..0874ecd3 100644
--- a/lib/libalpm/handle.h
+++ b/lib/libalpm/handle.h
@@ -64,6 +64,7 @@ typedef struct _pmhandle_t {
unsigned short usedelta; /* Download deltas if possible */
} pmhandle_t;
+/* global handle variable */
extern pmhandle_t *handle;
pmhandle_t *_alpm_handle_new();
diff --git a/src/pacman/add.c b/src/pacman/add.c
index f883a6bd..987e62cb 100644
--- a/src/pacman/add.c
+++ b/src/pacman/add.c
@@ -34,8 +34,6 @@
#include "conf.h"
#include "util.h"
-extern config_t *config;
-
/* Free the current transaction and print an error if unsuccessful */
static int add_cleanup(void)
{
diff --git a/src/pacman/callback.c b/src/pacman/callback.c
index ccc482f8..a68b0a48 100644
--- a/src/pacman/callback.c
+++ b/src/pacman/callback.c
@@ -40,8 +40,6 @@
#define LOG_STR_LEN 256
#define FILENAME_TRIM_LEN 23
-extern config_t *config;
-
/* download progress bar */
static float rate_last;
static int xfered_last;
diff --git a/src/pacman/conf.c b/src/pacman/conf.c
index 21256d77..9b5850d7 100644
--- a/src/pacman/conf.c
+++ b/src/pacman/conf.c
@@ -28,6 +28,9 @@
/* pacman */
#include "conf.h"
+/* global config variable */
+config_t *config = NULL;
+
config_t *config_new(void)
{
config_t *newconfig = calloc(1, sizeof(config_t));
diff --git a/src/pacman/conf.h b/src/pacman/conf.h
index 4283af7d..7249f068 100644
--- a/src/pacman/conf.h
+++ b/src/pacman/conf.h
@@ -78,6 +78,9 @@ enum {
PM_OP_DEPTEST
};
+/* global config variable */
+extern config_t *config;
+
config_t *config_new(void);
int config_free(config_t *oldconfig);
diff --git a/src/pacman/deptest.c b/src/pacman/deptest.c
index 7f89f6d2..301558e9 100644
--- a/src/pacman/deptest.c
+++ b/src/pacman/deptest.c
@@ -33,8 +33,6 @@
#include "util.h"
#include "conf.h"
-extern config_t *config;
-
/* TODO: This should use _alpm_checkdeps() */
int pacman_deptest(alpm_list_t *targets)
{
diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c
index 3859c8d3..befd0219 100644
--- a/src/pacman/pacman.c
+++ b/src/pacman/pacman.c
@@ -47,8 +47,6 @@
#include "conf.h"
#include "package.h"
-config_t *config;
-
pmdb_t *db_local;
/* list of targets specified on command line */
static alpm_list_t *pm_targets;
diff --git a/src/pacman/query.c b/src/pacman/query.c
index 42e163ef..ed48799c 100644
--- a/src/pacman/query.c
+++ b/src/pacman/query.c
@@ -38,7 +38,6 @@
#include "conf.h"
#include "util.h"
-extern config_t *config;
extern pmdb_t *db_local;
static char *resolve_path(const char* file)
diff --git a/src/pacman/remove.c b/src/pacman/remove.c
index dce479ec..5bd3b5c3 100644
--- a/src/pacman/remove.c
+++ b/src/pacman/remove.c
@@ -34,8 +34,6 @@
#include "callback.h"
#include "conf.h"
-extern config_t *config;
-
extern pmdb_t *db_local;
/* Free the current transaction and print an error if unsuccessful */
diff --git a/src/pacman/sync.c b/src/pacman/sync.c
index 9e4b0ada..eedea7d4 100644
--- a/src/pacman/sync.c
+++ b/src/pacman/sync.c
@@ -41,7 +41,6 @@
#include "callback.h"
#include "conf.h"
-extern config_t *config;
extern pmdb_t *db_local;
static int sync_cleancache(int level)
diff --git a/src/pacman/util.c b/src/pacman/util.c
index ecdb2ad8..7af51daa 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -44,8 +44,6 @@
#include "util.h"
#include "conf.h"
-extern config_t *config;
-
int needs_transaction()
{
if(config->op != PM_OP_MAIN && config->op != PM_OP_QUERY && config->op != PM_OP_DEPTEST) {