rpmdir.c   rpmdir.c 
skipping to change at line 20 skipping to change at line 20
#define _RPMDIR_INTERNAL #define _RPMDIR_INTERNAL
#include <rpmdir.h> #include <rpmdir.h>
#include <rpmdav.h> /* ftpOpendir/davOpendir */ #include <rpmdav.h> /* ftpOpendir/davOpendir */
#include <rpmhash.h> /* hashFunctionString */ #include <rpmhash.h> /* hashFunctionString */
#include "debug.h" #include "debug.h"
/*@access DIR @*/ /*@access DIR @*/
#ifdef __cplusplus
GENfree(time_t *)
GENfree(size_t *)
GENfree(rpmuint16_t *)
GENfree(AVDIR)
#endif /* __cplusplus */
/* =============================================================== */ /* =============================================================== */
static void avxFini(void * _avx) static void avxFini(void * _avx)
{ {
rpmavx avx = _avx; rpmavx avx = (rpmavx) _avx;
avx->mtimes = _free(avx->mtimes); avx->mtimes = _free(avx->mtimes);
avx->sizes = _free(avx->sizes); avx->sizes = _free(avx->sizes);
avx->modes = _free(avx->modes); avx->modes = _free(avx->modes);
avx->st = NULL; avx->st = NULL;
avx->av = argvFree(avx->av); avx->av = argvFree(avx->av);
avx->nalloced = 0; avx->nalloced = 0;
avx->ac = 0; avx->ac = 0;
(void) urlFree(avx->u, __FUNCTION__); (void) urlFree(avx->u, __FUNCTION__);
avx->u = NULL; avx->u = NULL;
skipping to change at line 71 skipping to change at line 78
/*@-globs@*/ /* FIX: h_errno annoyance. */ /*@-globs@*/ /* FIX: h_errno annoyance. */
if (urlSplit(uri, &u)) if (urlSplit(uri, &u))
return NULL; return NULL;
/*@=globs@*/ /*@=globs@*/
avx = avxGetPool(_avxPool); avx = avxGetPool(_avxPool);
avxFini(avx); /* XXX trash-and-burn */ avxFini(avx); /* XXX trash-and-burn */
/* XXX +1 byte for pesky trailing '/' */ /* XXX +1 byte for pesky trailing '/' */
avx->uri = strcpy(xmalloc(strlen(uri) + 1 + 1), uri); avx->uri = strcpy((char *)xmalloc(strlen(uri) + 1 + 1), uri);
avx->u = urlLink(u, __FUNCTION__); avx->u = urlLink(u, __FUNCTION__);
/*@-temptrans@*/ /* XXX note the assignment */ /*@-temptrans@*/ /* XXX note the assignment */
if ((avx->st = st) != NULL) if ((avx->st = st) != NULL)
memset(avx->st, 0, sizeof(*avx->st)); memset(avx->st, 0, sizeof(*avx->st));
/*@=temptrans@*/ /*@=temptrans@*/
return rpmavxLink(avx); return rpmavxLink(avx);
} }
skipping to change at line 96 skipping to change at line 103
if (_av_debug < 0) if (_av_debug < 0)
fprintf(stderr, "--> %s(%p,\"%s\", %06o, 0x%x, 0x%x)\n", __FUNCTION__, avx, path, (unsigned)mode, (unsigned)size, (unsigned)mtime); fprintf(stderr, "--> %s(%p,\"%s\", %06o, 0x%x, 0x%x)\n", __FUNCTION__, avx, path, (unsigned)mode, (unsigned)size, (unsigned)mtime);
xx = argvAdd(&avx->av, path); xx = argvAdd(&avx->av, path);
while (avx->ac >= avx->nalloced) { while (avx->ac >= avx->nalloced) {
if (avx->nalloced <= 0) if (avx->nalloced <= 0)
avx->nalloced = 1; avx->nalloced = 1;
avx->nalloced *= 2; avx->nalloced *= 2;
avx->modes = xrealloc(avx->modes, avx->modes = (rpmuint16_t *) xrealloc(avx->modes,
(sizeof(*avx->modes) * avx->nalloced)); (sizeof(*avx->modes) * avx->nalloced));
avx->sizes = xrealloc(avx->sizes, avx->sizes = (size_t *) xrealloc(avx->sizes,
(sizeof(*avx->sizes) * avx->nalloced)); (sizeof(*avx->sizes) * avx->nalloced));
avx->mtimes = xrealloc(avx->mtimes, avx->mtimes = (time_t *) xrealloc(avx->mtimes,
(sizeof(*avx->mtimes) * avx->nalloced)); (sizeof(*avx->mtimes) * avx->nalloced));
} }
avx->modes[avx->ac] = (rpmuint16_t)mode; avx->modes[avx->ac] = (rpmuint16_t)mode;
avx->sizes[avx->ac] = size; avx->sizes[avx->ac] = size;
avx->mtimes[avx->ac] = mtime; avx->mtimes[avx->ac] = mtime;
avx->ac++; avx->ac++;
return 0; return 0;
} }
skipping to change at line 150 skipping to change at line 157
nb = 0; nb = 0;
ac = 0; ac = 0;
if (av != NULL) if (av != NULL)
while (av[ac] != NULL) while (av[ac] != NULL)
nb += strlen(av[ac++]) + 1; nb += strlen(av[ac++]) + 1;
ac += 2; /* for "." and ".." */ ac += 2; /* for "." and ".." */
nb += sizeof(".") + sizeof(".."); nb += sizeof(".") + sizeof("..");
nb += sizeof(*avdir) + sizeof(*dp) + ((ac + 1) * sizeof(*av)) + (ac + 1 ); nb += sizeof(*avdir) + sizeof(*dp) + ((ac + 1) * sizeof(*av)) + (ac + 1 );
avdir = xcalloc(1, nb); avdir = (AVDIR) xcalloc(1, nb);
/*@-abstract@*/ /*@-abstract@*/
dp = (struct dirent *) (avdir + 1); dp = (struct dirent *) (avdir + 1);
nav = (const char **) (dp + 1); nav = (const char **) (dp + 1);
dt = (unsigned char *) (nav + (ac + 1)); dt = (unsigned char *) (nav + (ac + 1));
t = (char *) (dt + ac + 1); t = (char *) (dt + ac + 1);
/*@=abstract@*/ /*@=abstract@*/
avdir->fd = avmagicdir; avdir->fd = avmagicdir;
/*@-usereleased@*/ /*@-usereleased@*/
avdir->data = (char *) dp; avdir->data = (char *) dp;
skipping to change at line 315 skipping to change at line 322
if ((dir = Opendir(path)) == NULL) if ((dir = Opendir(path)) == NULL)
goto exit; goto exit;
rc = 0; rc = 0;
while ((dp = Readdir(dir)) != NULL) { while ((dp = Readdir(dir)) != NULL) {
if (filter != NULL && !(*filter)(dp)) if (filter != NULL && !(*filter)(dp))
continue; continue;
rc++; rc++;
if (nl == NULL) if (nl == NULL)
continue; continue;
*nl = (rc == 1 *nl = (struct dirent **) (rc == 1
? xmalloc(rc * sizeof(**nl)) ? xmalloc(rc * sizeof(**nl))
: xrealloc(*nl, rc * sizeof(**nl))); : xrealloc(*nl, rc * sizeof(**nl)));
(*nl)[rc - 1] = memcpy(xmalloc(sizeof(*dp)), dp, sizeof(*dp)); (*nl)[rc - 1] = (struct dirent *)
memcpy(xmalloc(sizeof(*dp)), dp, sizeof(*dp));
} }
(void) Closedir(dir); (void) Closedir(dir);
if (compar != NULL && rc > 1) if (compar != NULL && rc > 1)
qsort(*nl, rc, sizeof(**nl), compar); qsort(*nl, rc, sizeof(**nl), compar);
exit: exit:
return rc; return rc;
} }
skipping to change at line 470 skipping to change at line 478
rc = avScandir(path, nl, filter, compar); rc = avScandir(path, nl, filter, compar);
break; break;
case URL_IS_UNKNOWN: case URL_IS_UNKNOWN:
lpath = path; lpath = path;
/*@fallthrough@*/ /*@fallthrough@*/
case URL_IS_PATH: case URL_IS_PATH:
break; break;
} }
if (!rc) if (!rc)
rc = scandir(lpath, nl, filter, compar); rc = scandir(lpath, nl, filter,
(int (*)(const struct dirent **, const struct dirent **))compar)
;
if (_rpmio_debug) if (_rpmio_debug)
fprintf(stderr, "*** Scandir(\"%s\", %p, %p, %p) rc %d\n", path, nl, filter , compar, rc); fprintf(stderr, "*** Scandir(\"%s\", %p, %p, %p) rc %d\n", path, nl, filter , compar, rc);
return rc; return rc;
} }
int Alphasort(const void * a, const void * b) int Alphasort(const void * a, const void * b)
{ {
struct dirent *const * adp = a; struct dirent *const * adp = (struct dirent *const *) a;
struct dirent *const * bdp = b; struct dirent *const * bdp = (struct dirent *const *) b;
#if defined(HAVE_STRCOLL) #if defined(HAVE_STRCOLL)
return strcoll((*adp)->d_name, (*bdp)->d_name); return strcoll((*adp)->d_name, (*bdp)->d_name);
#else #else
return strcmp((*adp)->d_name, (*bdp)->d_name); return strcmp((*adp)->d_name, (*bdp)->d_name);
#endif #endif
} }
int Versionsort(const void * a, const void * b) int Versionsort(const void * a, const void * b)
{ {
struct dirent *const * adp = a; struct dirent *const * adp = (struct dirent *const *) a;
struct dirent *const * bdp = b; struct dirent *const * bdp = (struct dirent *const *) b;
#if defined(HAVE_STRVERSCMP) #if defined(HAVE_STRVERSCMP)
return strverscmp((*adp)->d_name, (*bdp)->d_name); return strverscmp((*adp)->d_name, (*bdp)->d_name);
#else #else
return strcmp((*adp)->d_name, (*bdp)->d_name); return strcmp((*adp)->d_name, (*bdp)->d_name);
#endif #endif
} }
void Seekdir(DIR * dir, off_t offset) void Seekdir(DIR * dir, off_t offset)
{ {
if (_rpmio_debug) if (_rpmio_debug)
 End of changes. 12 change blocks. 
13 lines changed or deleted 23 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/