r4200 - in trunk/src/target/opkg: libopkg src

thomas at sita.openmoko.org thomas at sita.openmoko.org
Thu Mar 13 12:41:28 CET 2008


Author: thomas
Date: 2008-03-13 12:41:24 +0100 (Thu, 13 Mar 2008)
New Revision: 4200

Modified:
   trunk/src/target/opkg/libopkg/Makefile.am
   trunk/src/target/opkg/libopkg/args.c
   trunk/src/target/opkg/libopkg/libopkg.c
   trunk/src/target/opkg/libopkg/libopkg.h
   trunk/src/target/opkg/libopkg/opkg_cmd.c
   trunk/src/target/opkg/libopkg/opkg_cmd.h
   trunk/src/target/opkg/libopkg/opkg_download.c
   trunk/src/target/opkg/libopkg/opkg_message.c
   trunk/src/target/opkg/libopkg/user.c
   trunk/src/target/opkg/src/Makefile.am
Log:
opkg: remove redundant OPKG_LIB conditional code


Modified: trunk/src/target/opkg/libopkg/Makefile.am
===================================================================
--- trunk/src/target/opkg/libopkg/Makefile.am	2008-03-13 03:42:12 UTC (rev 4199)
+++ trunk/src/target/opkg/libopkg/Makefile.am	2008-03-13 11:41:24 UTC (rev 4200)
@@ -59,7 +59,7 @@
 	$(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
 
 

Modified: trunk/src/target/opkg/libopkg/args.c
===================================================================
--- trunk/src/target/opkg/libopkg/args.c	2008-03-13 03:42:12 UTC (rev 4199)
+++ trunk/src/target/opkg/libopkg/args.c	2008-03-13 11:41:24 UTC (rev 4200)
@@ -253,13 +253,8 @@
      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");

Modified: trunk/src/target/opkg/libopkg/libopkg.c
===================================================================
--- trunk/src/target/opkg/libopkg/libopkg.c	2008-03-13 03:42:12 UTC (rev 4199)
+++ trunk/src/target/opkg/libopkg/libopkg.c	2008-03-13 11:41:24 UTC (rev 4200)
@@ -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 @@
      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 @@
 
 	return err;
 }
-
-#endif /* OPKG_LIB */

Modified: trunk/src/target/opkg/libopkg/libopkg.h
===================================================================
--- trunk/src/target/opkg/libopkg/libopkg.h	2008-03-13 03:42:12 UTC (rev 4199)
+++ trunk/src/target/opkg/libopkg/libopkg.h	2008-03-13 11:41:24 UTC (rev 4200)
@@ -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 free_error_list();
 
 #endif
-
-
-#endif

Modified: trunk/src/target/opkg/libopkg/opkg_cmd.c
===================================================================
--- trunk/src/target/opkg/libopkg/opkg_cmd.c	2008-03-13 03:42:12 UTC (rev 4199)
+++ trunk/src/target/opkg/libopkg/opkg_cmd.c	2008-03-13 11:41:24 UTC (rev 4200)
@@ -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 @@
      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 @@
 	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 @@
 	  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 @@
 	                                 p_userdata);
 		free(version_str);
 	  }
-#endif
      }
      pkg_vec_free(available);
 
@@ -722,9 +709,6 @@
 	  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 @@
 	                                 p_userdata);
 		free(version_str);
 	  }
-#endif
      }
 
      return 0;
@@ -767,14 +750,6 @@
 	  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 @@
 */
                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 @@
 	       }
 	  }
      }
-#ifndef OPKG_LIB
-     if (buff)
-	  free(buff);
-#endif
      pkg_vec_free(available);
 
      return 0;
@@ -1077,13 +1047,6 @@
      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 @@
 					 p_userdata);
 	  free(buff);
      }
-#endif
 
      free(pkg_version);
      pkg_free_installed_files(pkg);
@@ -1403,14 +1365,10 @@
 	  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			   
 	       }		
 	  }
 

Modified: trunk/src/target/opkg/libopkg/opkg_cmd.h
===================================================================
--- trunk/src/target/opkg/libopkg/opkg_cmd.h	2008-03-13 03:42:12 UTC (rev 4199)
+++ trunk/src/target/opkg/libopkg/opkg_cmd.h	2008-03-13 11:41:24 UTC (rev 4200)
@@ -29,12 +29,8 @@
 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);

Modified: trunk/src/target/opkg/libopkg/opkg_download.c
===================================================================
--- trunk/src/target/opkg/libopkg/opkg_download.c	2008-03-13 03:42:12 UTC (rev 4199)
+++ trunk/src/target/opkg/libopkg/opkg_download.c	2008-03-13 11:41:24 UTC (rev 4200)
@@ -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 @@
     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 @@
 	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

Modified: trunk/src/target/opkg/libopkg/opkg_message.c
===================================================================
--- trunk/src/target/opkg/libopkg/opkg_message.c	2008-03-13 03:42:12 UTC (rev 4199)
+++ trunk/src/target/opkg/libopkg/opkg_message.c	2008-03-13 11:41:24 UTC (rev 4200)
@@ -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_cb_message(conf,level,ts);
 	}
 }
-#endif

Modified: trunk/src/target/opkg/libopkg/user.c
===================================================================
--- trunk/src/target/opkg/libopkg/user.c	2008-03-13 03:42:12 UTC (rev 4199)
+++ trunk/src/target/opkg/libopkg/user.c	2008-03-13 11:41:24 UTC (rev 4200)
@@ -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,13 +33,7 @@
      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);
 	       question_len = len;
@@ -50,7 +41,6 @@
 	  len = vsnprintf(question,question_len,format,ap);
      } while (len > question_len);
      response = strdup(opkg_cb_response(question));
-#endif
      str_chomp(response);
      str_tolower(response);
 

Modified: trunk/src/target/opkg/src/Makefile.am
===================================================================
--- trunk/src/target/opkg/src/Makefile.am	2008-03-13 03:42:12 UTC (rev 4199)
+++ trunk/src/target/opkg/src/Makefile.am	2008-03-13 11:41:24 UTC (rev 4200)
@@ -3,7 +3,7 @@
 
 #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 
 





More information about the commitlog mailing list