r3885 - trunk/src/target/opkg
thomas at sita.openmoko.org
thomas at sita.openmoko.org
Fri Jan 18 15:25:30 CET 2008
Author: thomas
Date: 2008-01-18 15:25:29 +0100 (Fri, 18 Jan 2008)
New Revision: 3885
Modified:
trunk/src/target/opkg/libopkg.h
trunk/src/target/opkg/opkg_download.c
Log:
opkg: add a download progress callback hook to libopkg
Modified: trunk/src/target/opkg/libopkg.h
===================================================================
--- trunk/src/target/opkg/libopkg.h 2008-01-18 13:36:37 UTC (rev 3884)
+++ trunk/src/target/opkg/libopkg.h 2008-01-18 14:25:29 UTC (rev 3885)
@@ -36,6 +36,7 @@
typedef int (*opkg_status_callback)(char *name, int istatus, char *desc,
void *userdata);
typedef char* (*opkg_response_callback)(char *question);
+typedef void (*opkg_download_progress_callback)(int percent);
extern int opkg_op(int argc, char *argv[]); /* opkglib.c */
extern int opkg_init (opkg_message_callback mcall,
@@ -78,6 +79,8 @@
extern opkg_response_callback opkg_cb_response;
extern opkg_status_callback opkg_cb_status;
extern opkg_list_callback opkg_cb_list;
+extern opkg_download_progress_callback opkg_cb_download_progress; /* ipkg_download.c */
+
extern void push_error_list(struct errlist **errors,char * msg);
extern void reverse_error_list(struct errlist **errors);
extern void free_error_list();
Modified: trunk/src/target/opkg/opkg_download.c
===================================================================
--- trunk/src/target/opkg/opkg_download.c 2008-01-18 13:36:37 UTC (rev 3884)
+++ trunk/src/target/opkg/opkg_download.c 2008-01-18 14:25:29 UTC (rev 3885)
@@ -28,6 +28,10 @@
#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 (void* data,
@@ -38,6 +42,15 @@
{
int i;
int p = d*100/t;
+
+#ifdef LIBOPKG
+ if (opkg_cb_download_progress)
+ {
+ opkg_cb_download_progress (p);
+ return 0;
+ }
+#endif
+
printf ("\r%3d%% |", p);
for (i = 1; i < 73; i++)
{
More information about the commitlog
mailing list