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>
This commit is contained in:
Dan McGee 2007-11-04 12:05:22 -06:00
parent 006387828c
commit 86ca39d15e
14 changed files with 10 additions and 17 deletions

View file

@ -32,7 +32,6 @@
#include "util.h" #include "util.h"
/* Globals */ /* Globals */
pmhandle_t *handle = NULL;
enum _pmerrno_t pm_errno SYMEXPORT; enum _pmerrno_t pm_errno SYMEXPORT;
/** \addtogroup alpm_interface Interface Functions /** \addtogroup alpm_interface Interface Functions

View file

@ -39,8 +39,6 @@
#include "provide.h" #include "provide.h"
#include "handle.h" #include "handle.h"
extern pmhandle_t *handle;
static pmgraph_t *_alpm_graph_new(void) static pmgraph_t *_alpm_graph_new(void)
{ {
pmgraph_t *graph = NULL; pmgraph_t *graph = NULL;

View file

@ -43,6 +43,9 @@
#include "alpm.h" #include "alpm.h"
#include "server.h" #include "server.h"
/* global var for handle (private to libalpm) */
pmhandle_t *handle = NULL;
pmhandle_t *_alpm_handle_new() pmhandle_t *_alpm_handle_new()
{ {
pmhandle_t *handle; pmhandle_t *handle;

View file

@ -64,6 +64,7 @@ typedef struct _pmhandle_t {
unsigned short usedelta; /* Download deltas if possible */ unsigned short usedelta; /* Download deltas if possible */
} pmhandle_t; } pmhandle_t;
/* global handle variable */
extern pmhandle_t *handle; extern pmhandle_t *handle;
pmhandle_t *_alpm_handle_new(); pmhandle_t *_alpm_handle_new();

View file

@ -34,8 +34,6 @@
#include "conf.h" #include "conf.h"
#include "util.h" #include "util.h"
extern config_t *config;
/* Free the current transaction and print an error if unsuccessful */ /* Free the current transaction and print an error if unsuccessful */
static int add_cleanup(void) static int add_cleanup(void)
{ {

View file

@ -40,8 +40,6 @@
#define LOG_STR_LEN 256 #define LOG_STR_LEN 256
#define FILENAME_TRIM_LEN 23 #define FILENAME_TRIM_LEN 23
extern config_t *config;
/* download progress bar */ /* download progress bar */
static float rate_last; static float rate_last;
static int xfered_last; static int xfered_last;

View file

@ -28,6 +28,9 @@
/* pacman */ /* pacman */
#include "conf.h" #include "conf.h"
/* global config variable */
config_t *config = NULL;
config_t *config_new(void) config_t *config_new(void)
{ {
config_t *newconfig = calloc(1, sizeof(config_t)); config_t *newconfig = calloc(1, sizeof(config_t));

View file

@ -78,6 +78,9 @@ enum {
PM_OP_DEPTEST PM_OP_DEPTEST
}; };
/* global config variable */
extern config_t *config;
config_t *config_new(void); config_t *config_new(void);
int config_free(config_t *oldconfig); int config_free(config_t *oldconfig);

View file

@ -33,8 +33,6 @@
#include "util.h" #include "util.h"
#include "conf.h" #include "conf.h"
extern config_t *config;
/* TODO: This should use _alpm_checkdeps() */ /* TODO: This should use _alpm_checkdeps() */
int pacman_deptest(alpm_list_t *targets) int pacman_deptest(alpm_list_t *targets)
{ {

View file

@ -47,8 +47,6 @@
#include "conf.h" #include "conf.h"
#include "package.h" #include "package.h"
config_t *config;
pmdb_t *db_local; pmdb_t *db_local;
/* list of targets specified on command line */ /* list of targets specified on command line */
static alpm_list_t *pm_targets; static alpm_list_t *pm_targets;

View file

@ -38,7 +38,6 @@
#include "conf.h" #include "conf.h"
#include "util.h" #include "util.h"
extern config_t *config;
extern pmdb_t *db_local; extern pmdb_t *db_local;
static char *resolve_path(const char* file) static char *resolve_path(const char* file)

View file

@ -34,8 +34,6 @@
#include "callback.h" #include "callback.h"
#include "conf.h" #include "conf.h"
extern config_t *config;
extern pmdb_t *db_local; extern pmdb_t *db_local;
/* Free the current transaction and print an error if unsuccessful */ /* Free the current transaction and print an error if unsuccessful */

View file

@ -41,7 +41,6 @@
#include "callback.h" #include "callback.h"
#include "conf.h" #include "conf.h"
extern config_t *config;
extern pmdb_t *db_local; extern pmdb_t *db_local;
static int sync_cleancache(int level) static int sync_cleancache(int level)

View file

@ -44,8 +44,6 @@
#include "util.h" #include "util.h"
#include "conf.h" #include "conf.h"
extern config_t *config;
int needs_transaction() int needs_transaction()
{ {
if(config->op != PM_OP_MAIN && config->op != PM_OP_QUERY && config->op != PM_OP_DEPTEST) { if(config->op != PM_OP_MAIN && config->op != PM_OP_QUERY && config->op != PM_OP_DEPTEST) {