diff options
author | ticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358> | 2008-12-14 23:53:45 (EST) |
---|---|---|
committer | ticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358> | 2008-12-14 23:53:45 (EST) |
commit | 08a92571872aaa6d4cb8d43c6170c358f8ef0d94 (patch) | |
tree | e9a41af0904d1c8d9d35003e5bc9f088622a8133 | |
parent | 77bfb4c70257f7c85ace0e5ee975e4321fdd667a (diff) |
opkg: remove redundant OPKG_LIB conditional code
git-svn-id: http://opkg.googlecode.com/svn/trunk@49 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358
-rw-r--r-- | libopkg/Makefile.am | 2 | ||||
-rw-r--r-- | libopkg/args.c | 5 | ||||
-rw-r--r-- | libopkg/libopkg.c | 7 | ||||
-rw-r--r-- | libopkg/libopkg.h | 5 | ||||
-rw-r--r-- | libopkg/opkg_cmd.c | 42 | ||||
-rw-r--r-- | libopkg/opkg_cmd.h | 4 | ||||
-rw-r--r-- | libopkg/opkg_download.c | 4 | ||||
-rw-r--r-- | libopkg/opkg_message.c | 23 | ||||
-rw-r--r-- | libopkg/user.c | 12 | ||||
-rw-r--r-- | src/Makefile.am | 2 |
10 files changed, 3 insertions, 103 deletions
diff --git a/libopkg/Makefile.am b/libopkg/Makefile.am index 3dcbea7..4ea4fc5 100644 --- a/libopkg/Makefile.am +++ b/libopkg/Makefile.am @@ -59,7 +59,7 @@ libopkg_la_SOURCES = \ $(opkg_cmd_sources) $(opkg_db_sources) \ $(opkg_util_sources) $(opkg_list_sources) -libopkg_la_CFLAGS = -DOPKG_LIB $(ALL_CFLAGS) $(CURL_CFLAGS) $(GPGME_CFLAGS) +libopkg_la_CFLAGS = $(ALL_CFLAGS) $(CURL_CFLAGS) $(GPGME_CFLAGS) lib_LTLIBRARIES = libopkg.la diff --git a/libopkg/args.c b/libopkg/args.c index d4e3b83..5431e9f 100644 --- a/libopkg/args.c +++ b/libopkg/args.c @@ -253,13 +253,8 @@ void args_usage(char *complaint) fprintf(stderr, "\tlist_installed List all and only the installed packages and description \n"); fprintf(stderr, "\tfiles <pkg> List all files belonging to <pkg>\n"); fprintf(stderr, "\tsearch <file|regexp> Search for a package providing <file>\n"); -#ifndef OPKG_LIB - fprintf(stderr, "\tinfo [pkg|regexp [<field>]] Display all/some info fields for <pkg> or all\n"); - fprintf(stderr, "\tstatus [pkg|regexp [<field>]] Display all/some status fields for <pkg> or all\n"); -#else fprintf(stderr, "\tinfo [pkg|regexp] Display all info for <pkg>\n"); fprintf(stderr, "\tstatus [pkg|regexp] Display all status for <pkg>\n"); -#endif fprintf(stderr, "\tdownload <pkg> Download <pkg> to current directory.\n"); fprintf(stderr, "\tcompare_versions <v1> <op> <v2>\n"); fprintf(stderr, "\t compare versions using <= < > >= = << >>\n"); diff --git a/libopkg/libopkg.c b/libopkg/libopkg.c index c57ad0a..afc42da 100644 --- a/libopkg/libopkg.c +++ b/libopkg/libopkg.c @@ -15,8 +15,6 @@ General Public License for more details. */ -#ifdef OPKG_LIB - #include "opkg.h" #include "includes.h" #include "libopkg.h" @@ -394,12 +392,9 @@ int default_opkg_message_callback(opkg_conf_t *conf, message_level_t level, if (conf && (conf->verbosity < level)) { return 0; } else { -#ifdef OPKG_LIB if ( level == OPKG_ERROR ){ push_error_list(&error_list, msg); -// printf(msg); } else -#endif printf(msg); } return 0; @@ -523,5 +518,3 @@ opkg_op (int argc, char *argv[]) return err; } - -#endif /* OPKG_LIB */ diff --git a/libopkg/libopkg.h b/libopkg/libopkg.h index be4c31b..c2e6bf0 100644 --- a/libopkg/libopkg.h +++ b/libopkg/libopkg.h @@ -21,8 +21,6 @@ #endif -#ifdef OPKG_LIB - #include "opkg_conf.h" #include "opkg_message.h" #include "opkg_state.h" @@ -90,6 +88,3 @@ extern void reverse_error_list(struct errlist **errors); extern void free_error_list(); #endif - - -#endif diff --git a/libopkg/opkg_cmd.c b/libopkg/opkg_cmd.c index 27765f3..2aab669 100644 --- a/libopkg/opkg_cmd.c +++ b/libopkg/opkg_cmd.c @@ -49,10 +49,8 @@ #include "opkg_configure.h" #include "opkg_message.h" -#ifdef OPKG_LIB #include "libopkg.h" static void *p_userdata = NULL; -#endif static int opkg_update_cmd(opkg_conf_t *conf, int argc, char **argv); static int opkg_upgrade_cmd(opkg_conf_t *conf, int argc, char **argv); @@ -145,7 +143,6 @@ opkg_cmd_t *opkg_cmd_find(const char *name) return NULL; } -#ifdef OPKG_LIB int opkg_cmd_exec(opkg_cmd_t *cmd, opkg_conf_t *conf, int argc, const char **argv, void *userdata) { int result; @@ -175,12 +172,6 @@ int opkg_cmd_exec(opkg_cmd_t *cmd, opkg_conf_t *conf, int argc, const char **arg p_userdata = NULL; return result; } -#else -int opkg_cmd_exec(opkg_cmd_t *cmd, opkg_conf_t *conf, int argc, const char **argv) -{ - return (cmd->fun)(conf, argc, argv); -} -#endif static int opkg_update_cmd(opkg_conf_t *conf, int argc, char **argv) { @@ -673,9 +664,6 @@ static int opkg_list_cmd(opkg_conf_t *conf, int argc, char **argv) if (newline) { *newline = '\0'; } -#ifndef OPKG_LIB - printf("%s - %s\n", pkg->name, desc_short); -#else if (opkg_cb_list) { version_str = pkg_version_str_alloc(pkg); opkg_cb_list(pkg->name,desc_short, @@ -684,7 +672,6 @@ static int opkg_list_cmd(opkg_conf_t *conf, int argc, char **argv) p_userdata); free(version_str); } -#endif } pkg_vec_free(available); @@ -722,9 +709,6 @@ static int opkg_list_installed_cmd(opkg_conf_t *conf, int argc, char **argv) if (newline) { *newline = '\0'; } -#ifndef OPKG_LIB - printf("%s - %s\n", pkg->name, desc_short); -#else if (opkg_cb_list) { version_str = pkg_version_str_alloc(pkg); opkg_cb_list(pkg->name,desc_short, @@ -733,7 +717,6 @@ static int opkg_list_installed_cmd(opkg_conf_t *conf, int argc, char **argv) p_userdata); free(version_str); } -#endif } return 0; @@ -767,14 +750,6 @@ static int opkg_info_status_cmd(opkg_conf_t *conf, int argc, char **argv, int in if (pkg_name && fnmatch(pkg_name, pkg->name, 0)) { continue; } -#ifndef OPKG_LIB - if (n_fields) { - for (j = 0; j < n_fields; j++) - pkg_print_field(pkg, stdout, pkg_fields[j]); - } else { - pkg_print_info(pkg, stdout); - } -#else buff = pkg_formatted_info(pkg); if ( buff ) { @@ -788,7 +763,6 @@ static int opkg_info_status_cmd(opkg_conf_t *conf, int argc, char **argv, int in */ free(buff); } -#endif if (conf->verbosity > 1) { conffile_list_elt_t *iter; for (iter = pkg->conffiles.head; iter; iter = iter->next) { @@ -799,10 +773,6 @@ static int opkg_info_status_cmd(opkg_conf_t *conf, int argc, char **argv, int in } } } -#ifndef OPKG_LIB - if (buff) - free(buff); -#endif pkg_vec_free(available); return 0; @@ -1077,13 +1047,6 @@ static int opkg_files_cmd(opkg_conf_t *conf, int argc, char **argv) installed_files = pkg_get_installed_files(pkg); pkg_version = pkg_version_str_alloc(pkg); -#ifndef OPKG_LIB - printf("Package %s (%s) is installed on %s and has the following files:\n", - pkg->name, pkg_version, pkg->dest->name); - for (iter = installed_files->head; iter; iter = iter->next) { - puts(iter->data); - } -#else if (buff) { try_again: used_len = snprintf(buff, buff_len, "Package %s (%s) is installed on %s and has the following files:\n", @@ -1109,7 +1072,6 @@ static int opkg_files_cmd(opkg_conf_t *conf, int argc, char **argv) p_userdata); free(buff); } -#endif free(pkg_version); pkg_free_installed_files(pkg); @@ -1403,14 +1365,10 @@ static int opkg_search_cmd(opkg_conf_t *conf, int argc, char **argv) for (iter = installed_files->head; iter; iter = iter->next) { installed_file = iter->data; if (fnmatch(argv[0], installed_file, 0)==0) { -#ifndef OPKG_LIB - printf("%s: %s\n", pkg->name, installed_file); -#else if (opkg_cb_list) opkg_cb_list(pkg->name, installed_file, pkg_version_str_alloc(pkg), pkg->state_status, p_userdata); -#endif } } diff --git a/libopkg/opkg_cmd.h b/libopkg/opkg_cmd.h index 157e929..4a691d9 100644 --- a/libopkg/opkg_cmd.h +++ b/libopkg/opkg_cmd.h @@ -29,12 +29,8 @@ struct opkg_cmd typedef struct opkg_cmd opkg_cmd_t; opkg_cmd_t *opkg_cmd_find(const char *name); -#ifdef OPKG_LIB int opkg_cmd_exec(opkg_cmd_t *cmd, opkg_conf_t *conf, int argc, const char **argv, void *userdata); -#else -int opkg_cmd_exec(opkg_cmd_t *cmd, opkg_conf_t *conf, int argc, const char **argv); -#endif int opkg_multiple_files_scan (opkg_conf_t *conf, int argc, char *argv[]); /* install any packges with state_want == SW_INSTALL */ int opkg_install_wanted_packages(opkg_conf_t *conf); diff --git a/libopkg/opkg_download.c b/libopkg/opkg_download.c index 6cce64a..25d177a 100644 --- a/libopkg/opkg_download.c +++ b/libopkg/opkg_download.c @@ -32,10 +32,8 @@ #include "file_util.h" #include "str_util.h" -#ifdef OPKG_LIB #include "libopkg.h" opkg_download_progress_callback opkg_cb_download_progress = NULL; -#endif int curl_progress_func (char* url, @@ -47,7 +45,6 @@ curl_progress_func (char* url, int i; int p = (t) ? d*100/t : 0; -#ifdef OPKG_LIB if (opkg_cb_download_progress) { static int prev = -1; @@ -61,7 +58,6 @@ curl_progress_func (char* url, opkg_cb_download_progress (p, url); return 0; } -#endif /* skip progress bar if we haven't done started yet * this prevents drawing the progress bar if we receive an error such as diff --git a/libopkg/opkg_message.c b/libopkg/opkg_message.c index 38f16df..b96e7d6 100644 --- a/libopkg/opkg_message.c +++ b/libopkg/opkg_message.c @@ -18,28 +18,6 @@ #include "opkg_conf.h" #include "opkg_message.h" -#ifndef OPKG_LIB - -void -opkg_message (opkg_conf_t * conf, message_level_t level, char *fmt, ...) -{ - va_list ap; - - if (conf && (conf->verbosity < level)) - { - return; - } - else - { - - va_start (ap, fmt); - vprintf (fmt, ap); - va_end (ap); - } -} - -#else - #include "libopkg.h" //#define opkg_message(conf, level, fmt, arg...) opkg_cb_message(conf, level, fmt, ## arg) @@ -58,4 +36,3 @@ opkg_message (opkg_conf_t * conf, message_level_t level, char *fmt, ...) opkg_cb_message(conf,level,ts); } } -#endif diff --git a/libopkg/user.c b/libopkg/user.c index 98ab7b9..557f7ce 100644 --- a/libopkg/user.c +++ b/libopkg/user.c @@ -20,15 +20,12 @@ #include <stdarg.h> #include "file_util.h" #include "str_util.h" -#ifdef OPKG_LIB #include "libopkg.h" -#endif -#ifdef OPKG_LIB static char *question = NULL; static int question_len = 255; -#endif + char *get_user_response(const char *format, ...) { int len = question_len; @@ -36,12 +33,6 @@ char *get_user_response(const char *format, ...) char *response; va_start(ap, format); -#ifndef OPKG_LIB - vprintf(format, ap); - do { - response = file_read_line_alloc(stdin); - } while (response == NULL); -#else do { if (question == NULL || len > question_len) { question = realloc(question, len + 1); @@ -50,7 +41,6 @@ char *get_user_response(const char *format, ...) len = vsnprintf(question,question_len,format,ap); } while (len > question_len); response = strdup(opkg_cb_response(question)); -#endif str_chomp(response); str_tolower(response); diff --git a/src/Makefile.am b/src/Makefile.am index dbb3869..965ca11 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -3,7 +3,7 @@ bin_PROGRAMS = opkg-cl #lib_LTLIBRARIES = libopkg.la opkg_cl_SOURCES = opkg-frontend.c -opkg_cl_CFLAGS = -DOPKG_LIB $(ALL_CFLAGS) +opkg_cl_CFLAGS = $(ALL_CFLAGS) opkg_cl_LDADD = $(top_builddir)/libopkg/libopkg.la \ $(top_builddir)/libbb/libbb.la |