From b695d5b6e048f6b46e70b47f20072b91168159fc Mon Sep 17 00:00:00 2001 From: ticktock35 Date: Mon, 15 Dec 2008 04:18:25 +0000 Subject: [PATCH] opkg: add a download progress callback hook to libopkg git-svn-id: http://opkg.googlecode.com/svn/trunk@10 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358 --- libopkg.h | 3 +++ opkg_download.c | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/libopkg.h b/libopkg.h index 8920e38..429e3a1 100644 --- a/libopkg.h +++ b/libopkg.h @@ -36,6 +36,7 @@ typedef int (*opkg_list_callback)(char *name, char *desc, char *version, 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_message_callback opkg_cb_message; /* opkglib.c */ 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(); diff --git a/opkg_download.c b/opkg_download.c index a73406d..6859e92 100644 --- a/opkg_download.c +++ b/opkg_download.c @@ -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 @@ curl_progress_func (void* data, { 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++) { -- 2.25.1