RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  ____________________________________________________________________________

  Server: rpm5.org                         Name:   Jeff Johnson
  Root:   /v/rpm/cvs                       Email:  [EMAIL PROTECTED]
  Module: rpm                              Date:   07-Jul-2008 22:02:32
  Branch: HEAD                             Handle: 2008070720023100

  Modified files:
    rpm                     CHANGES
    rpm/rpmio               librpmio.vers rpmdav.c rpmio.c rpmurl.h rpmwget.c
                            url.c

  Log:
    - rpmio: start deconstructing the ancient URL callback.
    - rpmwget: ... display connection state in wgetNotify.
    - rpmdav: pass the neon callback thru (*u->notify) to ...
    - rpmurl: devise a passthru connection progress callback.

  Summary:
    Revision    Changes     Path
    1.2470      +4  -0      rpm/CHANGES
    2.70        +2  -0      rpm/rpmio/librpmio.vers
    2.80        +35 -49     rpm/rpmio/rpmdav.c
    1.139       +16 -16     rpm/rpmio/rpmio.c
    1.28        +22 -11     rpm/rpmio/rpmurl.h
    1.16        +81 -0      rpm/rpmio/rpmwget.c
    1.55        +13 -1      rpm/rpmio/url.c
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/CHANGES
  ============================================================================
  $ cvs diff -u -r1.2469 -r1.2470 CHANGES
  --- rpm/CHANGES       7 Jul 2008 18:02:49 -0000       1.2469
  +++ rpm/CHANGES       7 Jul 2008 20:02:31 -0000       1.2470
  @@ -1,5 +1,9 @@
   
   5.1.0 -> 5.2a0:
  +    - jbj: rpmio: start deconstructing the ancient URL callback.
  +    - jbj: rpmwget: ... display connection state in wgetNotify.
  +    - jbj: rpmdav: pass the neon callback thru (*u->notify) to ...
  +    - jbj: rpmurl: devise a passthru connection progress callback.
       - jbj: rpmwget: preliminaries for -o/-a output file logging.
       - jbj: rpmwget: wire up --quota.
       - jbj: rpmsw: change bytes accumulator to unsigned long long.
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/librpmio.vers
  ============================================================================
  $ cvs diff -u -r2.69 -r2.70 librpmio.vers
  --- rpm/rpmio/librpmio.vers   5 Jul 2008 23:35:12 -0000       2.69
  +++ rpm/rpmio/librpmio.vers   7 Jul 2008 20:02:31 -0000       2.70
  @@ -421,6 +421,8 @@
       urlGetFile;
       _url_iobuf_size;
       urlIsURL;
  +    urlNotify;
  +    urlNotifyArg;
       urlPath;
       urlSetCallback;
       urlSplit;
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmdav.c
  ============================================================================
  $ cvs diff -u -r2.79 -r2.80 rpmdav.c
  --- rpm/rpmio/rpmdav.c        6 Jul 2008 21:16:46 -0000       2.79
  +++ rpm/rpmio/rpmdav.c        7 Jul 2008 20:02:31 -0000       2.80
  @@ -321,7 +321,7 @@
       int rc;
   
   #if WITH_NEON_MIN_VERSION >= 0x002700
  -    rc = (u->connstatus == ne_status_sending || u->connstatus == 
ne_status_recving);
  +    rc = (u->info.status == ne_status_sending || u->info.status == 
ne_status_recving);
   #else
       rc = 0;  /* XXX W2DO? */
   #endif
  @@ -360,7 +360,7 @@
            if (u->lockstore != NULL)
                ne_lockstore_destroy(u->lockstore);
            u->lockstore = NULL;
  -         u->connstatus = 0;
  +         u->info.status = 0;
            ne_sock_exit();
            break;
        }
  @@ -388,7 +388,7 @@
   fprintf(stderr, "*** davDestroy()\n");
   }
   
  -static void davProgress(void * userdata, off_t current, off_t total)
  +static void davProgress(void * userdata, off_t progress, off_t total)
        /[EMAIL PROTECTED]/
   {
       urlinfo u = userdata;
  @@ -401,22 +401,23 @@
   assert(u == ne_get_session_private(sess, "urlinfo"));
   /[EMAIL PROTECTED]@*/
   
  -    u->current = current;
  -    u->total = total;
  +    u->info.progress = progress;
  +    u->info.total = total;
   
   if (_dav_debug < 0)
  -fprintf(stderr, "*** davProgress(%p,0x%x:0x%x) sess %p u %p\n", userdata, 
(unsigned int)current, (unsigned int)total, sess, u);
  +fprintf(stderr, "*** davProgress(%p,0x%x:0x%x) sess %p u %p\n", userdata, 
(unsigned int)progress, (unsigned int)total, sess, u);
   }
   
   #if WITH_NEON_MIN_VERSION >= 0x002700
   static void davNotify(void * userdata,
  -             ne_session_status connstatus, const ne_session_status_info 
*info)
  +             ne_session_status status, const ne_session_status_info *info)
   #else
   static void davNotify(void * userdata,
  -             ne_conn_status connstatus, const char * info)
  +             ne_conn_status status, const char * info)
   #endif
        /[EMAIL PROTECTED]/
   {
  +    char buf[64];
       urlinfo u = userdata;
       ne_session * sess;
   assert(u != NULL);
  @@ -426,6 +427,11 @@
   assert(u == ne_get_session_private(sess, "urlinfo"));
   /[EMAIL PROTECTED]@*/
   
  +    u->info.hostname = NULL;
  +    u->info.address = NULL;
  +    u->info.progress = 0;
  +    u->info.total = 0;
  +
   #if WITH_NEON_MIN_VERSION >= 0x002700
   #ifdef       REFERENCE
   typedef enum {
  @@ -437,60 +443,37 @@
       ne_status_disconnected /* disconnected from host */
   } ne_session_status;
   #endif
  -    if (_dav_debug) {
  -    static const char * connstates[] = {
  -     "LU", "CI", "CD", "SI", "RI", "DD", "?6", "?7"
  -    };
  -
  -    switch (connstatus) {
  +    switch (status) {
       default:
        break;
       case ne_status_lookup:   /* looking up hostname */
  -     fprintf(stderr, "Resolving %s...", info->lu.hostname);
  +     u->info.hostname = info->ci.hostname;
        break;
       case ne_status_connecting:       /* connecting to host */
  -    {        char buf[64];
  +     u->info.hostname = info->ci.hostname;
        (void) ne_iaddr_print(info->ci.address, buf, sizeof(buf));
        buf[sizeof(buf)-1] = '\0';
  -     /* Finish the lookup -> connecting state transition. */
  -     if (u->connstatus == ne_status_lookup)
  -         fprintf(stderr, " %s\n", buf);
  -     else if (u->connstatus != ne_status_disconnected)
  -fprintf(stderr, "**TODO** %s => %s\n", connstates[u->connstatus & 0x7], 
connstates[connstatus & 0x7]);
  -     fprintf(stderr, "Connecting to %s|%s|:%u...",
  -                        info->ci.hostname, buf, u->port);
  -    }        break;
  +     u->info.address = buf;
  +     break;
       case ne_status_connected:        /* connected to host */
  -     /* Finish the connecting -> connected state transition. */
  -     if (u->connstatus == ne_status_connecting)
  -         fprintf(stderr, " connected.\n");
  -     else
  -fprintf(stderr, "**TODO** %s => %s\n", connstates[u->connstatus & 0x7], 
connstates[connstatus & 0x7]);
  +     u->info.hostname = info->ci.hostname;
        break;
       case ne_status_sending:  /* sending a request body */
  -     if (u->connstatus != connstatus)
  -     if (u->connstatus != ne_status_connected)
  -fprintf(stderr, "**TODO** %s => %s\n", connstates[u->connstatus & 0x7], 
connstates[connstatus & 0x7]);
  -     if (_dav_debug < 0)     /* XXX noisy, wait for progress bar ... */
  -     fprintf(stderr, "Sending ... (%ld:%ld)\n",
  -             (long) info->sr.progress, (long) info->sr.total);
  +     u->info.progress = info->sr.progress;
  +     u->info.total = info->sr.total;
        break;
       case ne_status_recving:  /* receiving a response body */
  -     if (u->connstatus != connstatus)
  -     if (u->connstatus != ne_status_connected)
  -     if (u->connstatus != ne_status_sending)
  -fprintf(stderr, "**TODO** %s => %s\n", connstates[u->connstatus & 0x7], 
connstates[connstatus & 0x7]);
  -     if (_dav_debug < 0)     /* XXX noisy, wait for progress bar ... */
  -     fprintf(stderr, "Recving ... (%ld:%ld)\n",
  -             (long) info->sr.progress, (long) info->sr.total);
  +     u->info.progress = info->sr.progress;
  +     u->info.total = info->sr.total;
        break;
       case ne_status_disconnected:
  -     if (u->connstatus != ne_status_recving)
  -fprintf(stderr, "**TODO** %s => %s\n", connstates[u->connstatus & 0x7], 
connstates[connstatus & 0x7]);
  -     fprintf(stderr, "Disconnected from %s:%u\n", info->ci.hostname, 
u->port);
  +     u->info.hostname = info->ci.hostname;
        break;
       }
  -    }
  +
  +    if (u->notify != NULL)
  +     (void) (*u->notify) (u, status);
  +
   #else
   #ifdef       REFERENCE
   typedef enum {
  @@ -511,12 +494,15 @@
        "unknown"
       };
   
  -fprintf(stderr, "*** davNotify(%p,%d,%p) sess %p u %p %s\n", userdata, 
connstatus, info, sess, u, connstates[ (connstatus < 4 ? connstatus : 4)]);
  +fprintf(stderr, "*** davNotify(%p,%d,%p) sess %p u %p %s\n", userdata, 
status, info, sess, u, connstates[ (status < 4 ? status : 4)]);
   }
   #endif
   
  -    u->connstatus = connstatus;
  -
  +    u->info.status = status;
  +    u->info.hostname = NULL;
  +    u->info.address = NULL;
  +    u->info.progress = 0;
  +    u->info.total = 0;
   }
   
   static void davCreateRequest(ne_request * req, void * userdata,
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmio.c
  ============================================================================
  $ cvs diff -u -r1.138 -r1.139 rpmio.c
  --- rpm/rpmio/rpmio.c 5 Jul 2008 23:35:12 -0000       1.138
  +++ rpm/rpmio/rpmio.c 7 Jul 2008 20:02:31 -0000       1.139
  @@ -1489,18 +1489,18 @@
   }
   
   /[EMAIL PROTECTED]@*/ /[EMAIL PROTECTED]@*/
  -static rpmCallbackFunction   urlNotify = NULL;
  +static rpmCallbackFunction   _urlNotify = NULL;
   
   /[EMAIL PROTECTED]@*/ /[EMAIL PROTECTED]@*/
  -static void *                        urlNotifyData = NULL;
  +static void *                        _urlNotifyData = NULL;
   
   /[EMAIL PROTECTED]@*/
  -static int                   urlNotifyCount = -1;
  +static int                   _urlNotifyCount = -1;
   
   void urlSetCallback(rpmCallbackFunction notify, void *notifyData, int 
notifyCount) {
  -    urlNotify = notify;
  -    urlNotifyData = notifyData;
  -    urlNotifyCount = (notifyCount >= 0) ? notifyCount : 4096;
  +    _urlNotify = notify;
  +    _urlNotifyData = notifyData;
  +    _urlNotifyCount = (notifyCount >= 0) ? notifyCount : 4096;
   }
   
   int ufdCopy(FD_t sfd, FD_t tfd)
  @@ -1511,10 +1511,10 @@
       int rc = 0;
       int notifier = -1;
   
  -    if (urlNotify) {
  +    if (_urlNotify) {
        /[EMAIL PROTECTED] @*/ /* FIX: check rc */
  -     (void)(*urlNotify) (NULL, RPMCALLBACK_INST_OPEN_FILE,
  -             0, 0, NULL, urlNotifyData);
  +     (void)(*_urlNotify) (NULL, RPMCALLBACK_INST_OPEN_FILE,
  +             0, 0, NULL, _urlNotifyData);
        /[EMAIL PROTECTED] @*/
       }
   
  @@ -1536,12 +1536,12 @@
        }
   
        itemsCopied += itemsRead;
  -     if (urlNotify && urlNotifyCount > 0) {
  -         int n = itemsCopied/urlNotifyCount;
  +     if (_urlNotify && _urlNotifyCount > 0) {
  +         int n = itemsCopied/_urlNotifyCount;
            if (n != notifier) {
                /[EMAIL PROTECTED] @*/ /* FIX: check rc */
  -             (void)(*urlNotify) (NULL, RPMCALLBACK_INST_PROGRESS,
  -                     itemsCopied, 0, NULL, urlNotifyData);
  +             (void)(*_urlNotify) (NULL, RPMCALLBACK_INST_PROGRESS,
  +                     itemsCopied, 0, NULL, _urlNotifyData);
                /[EMAIL PROTECTED] @*/
                notifier = n;
            }
  @@ -1551,10 +1551,10 @@
       DBGIO(sfd, (stderr, "++ copied %d bytes: %s\n", itemsCopied,
        ftpStrerror(rc)));
   
  -    if (urlNotify) {
  +    if (_urlNotify) {
        /[EMAIL PROTECTED] @*/ /* FIX: check rc */
  -     (void)(*urlNotify) (NULL, RPMCALLBACK_INST_OPEN_FILE,
  -             itemsCopied, itemsCopied, NULL, urlNotifyData);
  +     (void)(*_urlNotify) (NULL, RPMCALLBACK_INST_OPEN_FILE,
  +             itemsCopied, itemsCopied, NULL, _urlNotifyData);
        /[EMAIL PROTECTED] @*/
       }
   
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmurl.h
  ============================================================================
  $ cvs diff -u -r1.27 -r1.28 rpmurl.h
  --- rpm/rpmio/rpmurl.h        3 Jul 2008 20:52:10 -0000       1.27
  +++ rpm/rpmio/rpmurl.h        7 Jul 2008 20:02:31 -0000       1.28
  @@ -28,6 +28,16 @@
   typedef /[EMAIL PROTECTED]@*/ /[EMAIL PROTECTED]@*/ struct urlinfo_s * 
urlinfo;
   
   /**
  + */
  +int (*urlNotify) (const urlinfo u, unsigned status)
  +     /[EMAIL PROTECTED]/;
  +
  +/**
  + */
  +/[EMAIL PROTECTED]@*/ /[EMAIL PROTECTED]@*/
  +extern void * urlNotifyArg;
  +
  +/**
    * URL control structure.
    */
   struct urlinfo_s {
  @@ -66,17 +76,18 @@
       void * lockstore;                /*!< neon: ne_lock_store ptr */
   /[EMAIL PROTECTED]@*/
       void * sess;             /*!< neon: ne_session ptr */
  -    off_t current;           /*!< neon: current body offset. */
  -    off_t total;             /*!< neon: total body length. */
  -    int connstatus;          /*!< neon: connection status. */
  -#ifdef  REFERENCE
  -typedef enum {
  -    ne_conn_namelookup,      /* lookup up hostname (info = hostname) */
  -    ne_conn_connecting,      /* connecting to host (info = hostname) */
  -    ne_conn_connected,       /* connected to host (info = hostname) */
  -    ne_conn_secure   /* connection now secure (info = crypto level) */
  -} ne_conn_status;
  -#endif
  +
  +    int (*notify) (const urlinfo u, unsigned status);
  +    void * arg;
  +    struct fdNotify_s {
  +     unsigned status;
  +/[EMAIL PROTECTED]@*/
  +     const char * hostname;
  +/[EMAIL PROTECTED]@*/
  +     const char * address;
  +     int64_t progress;
  +     int64_t total;
  +    } info;
   
       int bufAlloced;          /*!< sizeof I/O buffer */
   /[EMAIL PROTECTED]@*/
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmwget.c
  ============================================================================
  $ cvs diff -u -r1.15 -r1.16 rpmwget.c
  --- rpm/rpmio/rpmwget.c       7 Jul 2008 18:02:49 -0000       1.15
  +++ rpm/rpmio/rpmwget.c       7 Jul 2008 20:02:31 -0000       1.16
  @@ -280,6 +280,9 @@
   }
   
   /*==============================================================*/
  +
  +/**
  + */
   static int wgetLog(rpmwget wget, const char * fmt, ...)
   {
       int rc;
  @@ -398,6 +401,80 @@
       return tbuf;
   }
   
  +/* XXX must agree with ne_session_status enum values. */
  +typedef enum {
  +    wget_status_lookup = 0,  /* looking up hostname */
  +    wget_status_connecting = 1,      /* connecting to host */
  +    wget_status_connected = 2,       /* connected to host */
  +    wget_status_sending = 3, /* sending a request body */
  +    wget_status_recving = 4, /* receiving a response body */
  +    wget_status_disconnected = 5/* disconnected from host */
  +} wget_session_status;
  +
  +static int wgetNotify(const urlinfo u, unsigned _status)
  +{
  +    static const char * cstates[] = {
  +     "LU", "CI", "CD", "SI", "RI", "DD", "?6", "?7"
  +    };
  +    wget_session_status status = _status;
  +    rpmwget wget;
  +
  +assert(u != NULL);
  +assert(u->arg != NULL);
  +    wget = (rpmwget) u->arg;
  +
  +    switch (status) {
  +    default:
  +     break;
  +    case wget_status_lookup:         /* looking up hostname */
  +     wgetLog(wget, "Resolving %s...", u->info.hostname);
  +     break;
  +    case wget_status_connecting:     /* connecting to host */
  +     /* Finish the lookup -> connecting state transition. */
  +     if (u->info.status == wget_status_lookup)
  +         wgetLog(wget, " %s\n", u->info.address);
  +     else if (u->info.status != wget_status_disconnected)
  +fprintf(stderr, "**TODO** %s => %s\n", cstates[u->info.status & 0x7], 
cstates[status & 0x7]);
  +     wgetLog(wget, "Connecting to %s|%s|:%u...",
  +                        u->info.hostname, u->info.address, u->port);
  +     break;
  +    case wget_status_connected:              /* connected to host */
  +     /* Finish the connecting -> connected state transition. */
  +     if (u->info.status == wget_status_connecting)
  +         wgetLog(wget, " connected.\n");
  +     else
  +fprintf(stderr, "**TODO** %s => %s\n", cstates[u->info.status & 0x7], 
cstates[status & 0x7]);
  +     break;
  +    case wget_status_sending:                /* sending a request body */
  +     if (u->info.status != status)
  +     if (u->info.status != wget_status_connected)
  +fprintf(stderr, "**TODO** %s => %s\n", cstates[u->info.status & 0x7], 
cstates[status & 0x7]);
  +#ifdef       NOTYET  /* XXX noisy, wait for progress bar ... */
  +     wgetLog(wget, "Sending ... (%ld:%ld)\n",
  +             (long) info->sr.progress, (long) info->sr.total);
  +#endif
  +     break;
  +    case wget_status_recving:                /* receiving a response body */
  +     if (u->info.status != status)
  +     if (u->info.status != wget_status_connected)
  +     if (u->info.status != wget_status_sending)
  +fprintf(stderr, "**TODO** %s => %s\n", cstates[u->info.status & 0x7], 
cstates[status & 0x7]);
  +#ifdef       NOTYET  /* XXX noisy, wait for progress bar ... */
  +     wgetLog(wget, "Recving ... (%ld:%ld)\n",
  +             (long) u->info.progress, (long) u->info.total);
  +#endif
  +     break;
  +    case wget_status_disconnected:
  +     if (u->info.status != wget_status_recving)
  +fprintf(stderr, "**TODO** %s => %s\n", cstates[u->info.status & 0x7], 
cstates[status & 0x7]);
  +     wgetLog(wget, "Disconnected from %s:%u\n", u->info.hostname, u->port);
  +     break;
  +    }
  +    return 0;
  +}
  +
  +/*==============================================================*/
  +
   /**
    */
   static int isHtml(const char * contentType)
  @@ -1319,6 +1396,10 @@
        }
       }
   
  +    /* Initialize the progress callback. */
  +    urlNotify = wgetNotify;
  +    urlNotifyArg = wget;
  +
       /* Gather arguments. */
       av = poptGetArgs(optCon);
       if (av != NULL)
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/url.c
  ============================================================================
  $ cvs diff -u -r1.54 -r1.55 url.c
  --- rpm/rpmio/url.c   3 Jul 2008 20:52:10 -0000       1.54
  +++ rpm/rpmio/url.c   7 Jul 2008 20:02:31 -0000       1.55
  @@ -33,6 +33,16 @@
   
   /**
    */
  +int (*urlNotify) (const urlinfo u, unsigned status)
  +        /[EMAIL PROTECTED]/;
  +
  +/**
  + */
  +/[EMAIL PROTECTED]@*/ /[EMAIL PROTECTED]@*/
  +void * urlNotifyArg;
  +
  +/**
  + */
   /[EMAIL PROTECTED]@*/
   int _url_iobuf_size = RPMURL_IOBUF_SIZE;
   
  @@ -70,7 +80,7 @@
   urlinfo XurlNew(const char *msg, const char *file, unsigned line)
   {
       urlinfo u;
  -    if ((u = xmalloc(sizeof(*u))) == NULL)
  +    if ((u = xcalloc(1, sizeof(*u))) == NULL)
        return NULL;
       memset(u, 0, sizeof(*u));
       u->proxyp = -1;
  @@ -78,6 +88,8 @@
       u->urltype = URL_IS_UNKNOWN;
       u->ctrl = NULL;
       u->data = NULL;
  +    u->notify = urlNotify;
  +    u->arg = urlNotifyArg;
       u->bufAlloced = 0;
       u->buf = NULL;
       u->allow = RPMURL_SERVER_HASRANGE;
  @@ .
______________________________________________________________________
RPM Package Manager                                    http://rpm5.org
CVS Sources Repository                                [email protected]

Reply via email to