diff options
Diffstat (limited to 'rpmio')
-rw-r--r-- | rpmio/Makefile.am | 2 | ||||
-rw-r--r-- | rpmio/fts.c | 10 | ||||
-rw-r--r-- | rpmio/rpmfileutil.c | 10 | ||||
-rw-r--r-- | rpmio/rpmio.c | 4 | ||||
-rw-r--r-- | rpmio/rpmio.h | 97 | ||||
-rw-r--r-- | rpmio/rpmrpc.c | 413 | ||||
-rw-r--r-- | rpmio/tdir.c | 6 | ||||
-rw-r--r-- | rpmio/tglob.c | 4 | ||||
-rw-r--r-- | rpmio/tput.c | 4 | ||||
-rw-r--r-- | rpmio/url.c | 2 |
10 files changed, 21 insertions, 531 deletions
diff --git a/rpmio/Makefile.am b/rpmio/Makefile.am index 13a08a203..a492b669e 100644 --- a/rpmio/Makefile.am +++ b/rpmio/Makefile.am @@ -14,7 +14,7 @@ usrlib_LTLIBRARIES = librpmio.la librpmio_la_SOURCES = \ argv.c base64.c digest.h digest.c fts.c macro.c \ rpmhook.c rpmio.c rpmlog.c rpmlua.c rpmmalloc.c \ - rpmpgp.c rpmrpc.c rpmsq.c rpmsw.c strcasecmp.c url.c ugid.c \ + rpmpgp.c rpmsq.c rpmsw.c strcasecmp.c url.c ugid.c \ rpmio_internal.h rpmlua.h rpmhook.h ugid.h fts.h \ rpmstring.c rpmfileutil.c diff --git a/rpmio/fts.c b/rpmio/fts.c index ec5b1d672..4b747a961 100644 --- a/rpmio/fts.c +++ b/rpmio/fts.c @@ -136,11 +136,11 @@ Fts_open(char * const * argv, int options, return (NULL); memset(sp, 0, sizeof(*sp)); sp->fts_compar = (int (*) (const void *, const void *)) compar; - sp->fts_opendir = Opendir; - sp->fts_readdir = Readdir; - sp->fts_closedir = Closedir; - sp->fts_stat = Stat; - sp->fts_lstat = Lstat; + sp->fts_opendir = opendir; + sp->fts_readdir = readdir; + sp->fts_closedir = closedir; + sp->fts_stat = stat; + sp->fts_lstat = lstat; sp->fts_options = options; /* Logical walks turn on NOCHDIR; symbolic links are too hard. */ diff --git a/rpmio/rpmfileutil.c b/rpmio/rpmfileutil.c index ea201b817..b19ccc7eb 100644 --- a/rpmio/rpmfileutil.c +++ b/rpmio/rpmfileutil.c @@ -338,7 +338,7 @@ int rpmioMkpath(const char * path, mode_t mode, uid_t uid, gid_t gid) savec = de[1]; de[1] = '\0'; - rc = Stat(d, &st); + rc = stat(d, &st); if (rc) { switch(errno) { default: @@ -347,7 +347,7 @@ int rpmioMkpath(const char * path, mode_t mode, uid_t uid, gid_t gid) case ENOENT: break; } - rc = Mkdir(d, mode); + rc = mkdir(d, mode); if (rc) return errno; created = 1; @@ -741,7 +741,7 @@ int rpmGlob(const char * patterns, int * argcPtr, const char *** argvPtr) int local = (ut == URL_IS_PATH) || (ut == URL_IS_UNKNOWN); glob_t gl; - if (!local || (!Glob_pattern_p(av[j], 0) && strchr(path, '~') == NULL)) { + if (!local || (!glob_pattern_p(av[j], 0) && strchr(path, '~') == NULL)) { argv = xrealloc(argv, (argc+2) * sizeof(*argv)); argv[argc] = xstrdup(av[j]); if (_debug) @@ -752,7 +752,7 @@ fprintf(stderr, "*** rpmGlob argv[%d] \"%s\"\n", argc, argv[argc]); gl.gl_pathc = 0; gl.gl_pathv = NULL; - rc = Glob(av[j], GLOB_TILDE, Glob_error, &gl); + rc = glob(av[j], GLOB_TILDE, NULL, &gl); if (rc) goto exit; @@ -798,7 +798,7 @@ if (_debug) fprintf(stderr, "*** rpmGlob argv[%d] \"%s\"\n", argc, globURL); argv[argc++] = xstrdup(globURL); } - Globfree(&gl); + globfree(&gl); globURL = _free(globURL); } diff --git a/rpmio/rpmio.c b/rpmio/rpmio.c index 728d94b7a..d12dee61b 100644 --- a/rpmio/rpmio.c +++ b/rpmio/rpmio.c @@ -839,7 +839,7 @@ DBGIO(fd, (stderr, "==>\tufdOpen(\"%s\",%x,0%o) %s\n", url, (unsigned)flags, (un static struct FDIO_s ufdio_s = { ufdRead, ufdWrite, ufdSeek, ufdClose, XfdLink, XfdFree, XfdNew, fdFileno, - ufdOpen, NULL, fdGetFp, NULL, Mkdir, Chdir, Rmdir, Rename, Unlink + ufdOpen, NULL, fdGetFp, NULL, mkdir, chdir, rmdir, rename, unlink }; FDIO_t ufdio = &ufdio_s ; @@ -1713,6 +1713,6 @@ exit: static struct FDIO_s fpio_s = { ufdRead, ufdWrite, fdSeek, ufdClose, XfdLink, XfdFree, XfdNew, fdFileno, - ufdOpen, NULL, fdGetFp, NULL, Mkdir, Chdir, Rmdir, Rename, Unlink + ufdOpen, NULL, fdGetFp, NULL, mkdir, chdir, rmdir, rename, unlink }; FDIO_t fpio = &fpio_s ; diff --git a/rpmio/rpmio.h b/rpmio/rpmio.h index 2a715a151..65bacffb4 100644 --- a/rpmio/rpmio.h +++ b/rpmio/rpmio.h @@ -8,8 +8,6 @@ #include <sys/types.h> #include <sys/stat.h> -#include <dirent.h> -#include "misc/glob.h" #include <stdio.h> #include <stdlib.h> #include <unistd.h> @@ -105,101 +103,6 @@ int Fileno(FD_t fd); */ int Fcntl(FD_t fd, int op, void *lip); - -/** \ingroup rpmrpc - * \name RPMRPC Interface. - */ - -/** \ingroup rpmrpc - * mkdir(2) clone. - */ -int Mkdir(const char * path, mode_t mode); - -/** \ingroup rpmrpc - * chdir(2) clone. - */ -int Chdir(const char * path); - -/** \ingroup rpmrpc - * rmdir(2) clone. - */ -int Rmdir(const char * path); - -/** \ingroup rpmrpc - * rename(2) clone. - */ -int Rename(const char * oldpath, const char * newpath); - -/** \ingroup rpmrpc - * link(2) clone. - */ -int Link(const char * oldpath, const char * newpath); - -/** \ingroup rpmrpc - * unlink(2) clone. - */ -int Unlink(const char * path); - -/** \ingroup rpmrpc - * readlink(2) clone. - */ -int Readlink(const char * path, char * buf, size_t bufsiz); - -/** \ingroup rpmrpc - * stat(2) clone. - */ -int Stat(const char * path, struct stat * st); - -/** \ingroup rpmrpc - * lstat(2) clone. - */ -int Lstat(const char * path, struct stat * st); - -/** \ingroup rpmrpc - * access(2) clone. - */ -int Access(const char * path, int amode); - -/** \ingroup rpmrpc - * glob_pattern_p(3) clone. - */ -int Glob_pattern_p (const char *pattern, int quote); - -/** \ingroup rpmrpc - * glob_error(3) clone. - */ -int Glob_error(const char * epath, int eerrno); - -/** \ingroup rpmrpc - * glob(3) clone. - */ -int Glob(const char * pattern, int flags, - int errfunc(const char * epath, int eerrno), - glob_t * pglob); - -/** \ingroup rpmrpc - * globfree(3) clone. - */ -void Globfree( glob_t * pglob); - - -/** \ingroup rpmrpc - * opendir(3) clone. - */ -DIR * Opendir(const char * path); - -/** \ingroup rpmrpc - * readdir(3) clone. - */ -struct dirent * Readdir(DIR * dir); - -/** \ingroup rpmrpc - * closedir(3) clone. - */ -int Closedir(DIR * dir); - - - /** \ingroup rpmio * \name RPMIO Utilities. */ diff --git a/rpmio/rpmrpc.c b/rpmio/rpmrpc.c deleted file mode 100644 index 3b3d467a9..000000000 --- a/rpmio/rpmrpc.c +++ /dev/null @@ -1,413 +0,0 @@ -/** \ingroup rpmio - * \file rpmio/rpmrpc.c - */ - -#include "system.h" - -#if defined(HAVE_PTHREAD_H) -#include <pthread.h> -#endif - -#include <rpmurl.h> -#include <rpmstring.h> -#include "rpmio/rpmio_internal.h" - -#include "rpmio/ugid.h" -#include "debug.h" - -/* =============================================================== */ -int Mkdir (const char * path, mode_t mode) -{ - const char * lpath; - int ut = urlPath(path, &lpath); - - switch (ut) { - case URL_IS_PATH: - path = lpath; - case URL_IS_UNKNOWN: - break; - case URL_IS_DASH: - case URL_IS_HKP: - case URL_IS_FTP: - case URL_IS_HTTPS: - case URL_IS_HTTP: - default: - return -2; - break; - } - return mkdir(path, mode); -} - -int Chdir (const char * path) -{ - const char * lpath; - int ut = urlPath(path, &lpath); - - switch (ut) { - case URL_IS_PATH: - path = lpath; - case URL_IS_UNKNOWN: - break; - case URL_IS_DASH: - case URL_IS_HKP: - case URL_IS_FTP: - case URL_IS_HTTPS: - case URL_IS_HTTP: - default: - return -2; - break; - } - return chdir(path); -} - -int Rmdir (const char * path) -{ - const char * lpath; - int ut = urlPath(path, &lpath); - - switch (ut) { - case URL_IS_PATH: - path = lpath; - case URL_IS_UNKNOWN: - break; - case URL_IS_DASH: - case URL_IS_HKP: - case URL_IS_FTP: - case URL_IS_HTTPS: - case URL_IS_HTTP: - default: - return -2; - break; - } - return rmdir(path); -} - -/* XXX rpmdb.c: analogue to rename(2). */ - -int Rename (const char * oldpath, const char * newpath) -{ - const char *oe = NULL; - const char *ne = NULL; - int oldut, newut; - - /* XXX lib/install.c used to rely on this behavior. */ - if (!strcmp(oldpath, newpath)) return 0; - - oldut = urlPath(oldpath, &oe); - switch (oldut) { - case URL_IS_PATH: - case URL_IS_UNKNOWN: - break; - case URL_IS_DASH: - case URL_IS_HKP: - case URL_IS_HTTPS: - case URL_IS_HTTP: - case URL_IS_FTP: - default: - return -2; - break; - } - - newut = urlPath(newpath, &ne); - switch (newut) { - case URL_IS_PATH: - oldpath = oe; - newpath = ne; - break; - case URL_IS_UNKNOWN: - break; - case URL_IS_DASH: - case URL_IS_HKP: - case URL_IS_FTP: - case URL_IS_HTTPS: - case URL_IS_HTTP: - default: - return -2; - break; - } - return rename(oldpath, newpath); -} - -int Link (const char * oldpath, const char * newpath) -{ - const char *oe = NULL; - const char *ne = NULL; - int oldut, newut; - - oldut = urlPath(oldpath, &oe); - switch (oldut) { - case URL_IS_PATH: - case URL_IS_UNKNOWN: - break; - case URL_IS_DASH: - case URL_IS_HKP: - case URL_IS_HTTPS: - case URL_IS_HTTP: - case URL_IS_FTP: - default: - return -2; - break; - } - - newut = urlPath(newpath, &ne); - switch (newut) { - case URL_IS_PATH: -if (_rpmio_debug) -fprintf(stderr, "*** link old %*s new %*s\n", (int)(oe - oldpath), oldpath, (int)(ne - newpath), newpath); - if (!(oldut == newut && oe && ne && (oe - oldpath) == (ne - newpath) && - !xstrncasecmp(oldpath, newpath, (oe - oldpath)))) - return -2; - oldpath = oe; - newpath = ne; - break; - case URL_IS_UNKNOWN: - break; - case URL_IS_DASH: - case URL_IS_HKP: - case URL_IS_HTTPS: - case URL_IS_HTTP: - case URL_IS_FTP: - default: - return -2; - break; - } - return link(oldpath, newpath); -} - -/* XXX build/build.c: analogue to unlink(2). */ - -int Unlink(const char * path) { - const char * lpath; - int ut = urlPath(path, &lpath); - - switch (ut) { - case URL_IS_PATH: - path = lpath; - case URL_IS_UNKNOWN: - break; - case URL_IS_DASH: - case URL_IS_HKP: - case URL_IS_FTP: - case URL_IS_HTTPS: - case URL_IS_HTTP: - default: - return -2; - break; - } - return unlink(path); -} - -int Stat(const char * path, struct stat * st) -{ - const char * lpath; - int ut = urlPath(path, &lpath); - -if (_rpmio_debug) -fprintf(stderr, "*** Stat(%s,%p)\n", path, st); - switch (ut) { - case URL_IS_PATH: - path = lpath; - case URL_IS_UNKNOWN: - break; - case URL_IS_DASH: - case URL_IS_HKP: - case URL_IS_FTP: - case URL_IS_HTTPS: - case URL_IS_HTTP: - default: - return -2; - break; - } - return stat(path, st); -} - -int Lstat(const char * path, struct stat * st) -{ - const char * lpath; - int ut = urlPath(path, &lpath); - -if (_rpmio_debug) -fprintf(stderr, "*** Lstat(%s,%p)\n", path, st); - switch (ut) { - case URL_IS_PATH: - path = lpath; - case URL_IS_UNKNOWN: - break; - case URL_IS_DASH: - case URL_IS_HKP: - case URL_IS_FTP: - case URL_IS_HTTPS: - case URL_IS_HTTP: - default: - return -2; - break; - } - return lstat(path, st); -} - -int Readlink(const char * path, char * buf, size_t bufsiz) -{ - const char * lpath; - int ut = urlPath(path, &lpath); - - switch (ut) { - case URL_IS_PATH: - path = lpath; - case URL_IS_UNKNOWN: - break; - case URL_IS_DASH: - case URL_IS_HKP: - case URL_IS_FTP: - case URL_IS_HTTPS: - case URL_IS_HTTP: - default: - return -2; - break; - } -/* FIX: *buf is undefined */ - return readlink(path, buf, bufsiz); -} - -int Access(const char * path, int amode) -{ - const char * lpath; - int ut = urlPath(path, &lpath); - -if (_rpmio_debug) -fprintf(stderr, "*** Access(%s,%d)\n", path, amode); - switch (ut) { - case URL_IS_PATH: - path = lpath; - case URL_IS_UNKNOWN: - break; - case URL_IS_DASH: - case URL_IS_HKP: - case URL_IS_HTTPS: - case URL_IS_HTTP: - case URL_IS_FTP: - default: - return -2; - break; - } - return access(path, amode); -} - -/* glob_pattern_p() taken from bash - * Copyright (C) 1985, 1988, 1989 Free Software Foundation, Inc. - * - * Return nonzero if PATTERN has any special globbing chars in it. - */ -int Glob_pattern_p (const char * pattern, int quote) -{ - const char *p; - int open = 0; - char c; - - (void) urlPath(pattern, &p); - while ((c = *p++) != '\0') - switch (c) { - case '?': - case '*': - return (1); - case '\\': - if (quote && *p != '\0') - p++; - continue; - - case '[': - open = 1; - continue; - case ']': - if (open) - return (1); - continue; - - case '+': - case '@': - case '!': - if (*p == '(') - return (1); - continue; - } - - return (0); -} - -int Glob_error(const char * epath, int eerrno) -{ - return 1; -} - -int Glob(const char *pattern, int flags, - int errfunc(const char * epath, int eerrno), glob_t *pglob) -{ - const char * lpath; - int ut = urlPath(pattern, &lpath); - -if (_rpmio_debug) -fprintf(stderr, "*** Glob(%s,0x%x,%p,%p)\n", pattern, (unsigned)flags, (void *)errfunc, pglob); - switch (ut) { - case URL_IS_PATH: - pattern = lpath; - case URL_IS_UNKNOWN: - break; - case URL_IS_DASH: - case URL_IS_HKP: - case URL_IS_HTTPS: - case URL_IS_HTTP: - case URL_IS_FTP: - default: - return -2; - break; - } - return glob(pattern, flags, errfunc, pglob); -} - -void Globfree(glob_t *pglob) -{ -if (_rpmio_debug) -fprintf(stderr, "*** Globfree(%p)\n", pglob); - globfree(pglob); -} - -DIR * Opendir(const char * path) -{ - const char * lpath; - int ut = urlPath(path, &lpath); - -if (_rpmio_debug) -fprintf(stderr, "*** Opendir(%s)\n", path); - switch (ut) { - case URL_IS_PATH: - path = lpath; - case URL_IS_UNKNOWN: - break; - case URL_IS_DASH: - case URL_IS_HKP: - case URL_IS_FTP: - case URL_IS_HTTPS: - case URL_IS_HTTP: - default: - return NULL; - break; - } - return opendir(path); -} - -struct dirent * Readdir(DIR * dir) -{ -if (_rpmio_debug) -fprintf(stderr, "*** Readdir(%p)\n", (void *)dir); - if (dir == NULL) - return NULL; - return readdir(dir); -} - -int Closedir(DIR * dir) -{ -if (_rpmio_debug) -fprintf(stderr, "*** Closedir(%p)\n", (void *)dir); - if (dir == NULL) - return 0; - return closedir(dir); -} diff --git a/rpmio/tdir.c b/rpmio/tdir.c index da1ae379f..df12f9ed6 100644 --- a/rpmio/tdir.c +++ b/rpmio/tdir.c @@ -24,9 +24,9 @@ static void printDir(const char * path) int i; fprintf(stderr, "===== %s\n", path); - dir = Opendir(path); + dir = opendir(path); i = 0; - while ((dp = Readdir(dir)) != NULL) { + while ((dp = readdir(dir)) != NULL) { fprintf(stderr, "%5d (%x,%x) %x %x %s\n", i++, (unsigned) dp->d_ino, (unsigned) dp->d_off, @@ -34,7 +34,7 @@ fprintf(stderr, "%5d (%x,%x) %x %x %s\n", i++, (unsigned) dp->d_type, dp->d_name); } - xx = Closedir(dir); + xx = closedir(dir); } static struct poptOption optionsTable[] = { diff --git a/rpmio/tglob.c b/rpmio/tglob.c index fe6d9d050..3f51ea08c 100644 --- a/rpmio/tglob.c +++ b/rpmio/tglob.c @@ -40,12 +40,12 @@ fprintf(stderr, "===== %s\n", path); gl.gl_pathc = 0; gl.gl_pathv = NULL; gl.gl_offs = 0; - rc = Glob(path, 0, Glob_error, &gl); + rc = glob(path, 0, NULL, &gl); fprintf(stderr, "*** Glob rc %d\n", rc); if (rc == 0) for (i = 0; i < gl.gl_pathc; i++) fprintf(stderr, "%5d %s\n", i, gl.gl_pathv[i]); - Globfree(&gl); + globfree(&gl); } static struct poptOption optionsTable[] = { diff --git a/rpmio/tput.c b/rpmio/tput.c index 2d7eb79fe..c337e161b 100644 --- a/rpmio/tput.c +++ b/rpmio/tput.c @@ -66,7 +66,7 @@ fprintf(stderr, "===> Fclose rc %d\n", xx); static int unlinkFile(const char * path) { fprintf(stderr, "===== Unlink %s\n", path); - return Unlink(path); + return unlink(path); } static void doFile(const char * path) @@ -86,7 +86,7 @@ fprintf(stderr, "===== %s\n", path); xx = writeFile(path); #if 0 xx = readFile(path); - xx = Unlink(path); + xx = unlink(path); xx = unlink("/home/toad/tput.txt"); xx = unlink("/var/ftp/tput.txt"); diff --git a/rpmio/url.c b/rpmio/url.c index 773809f31..fd9a50d34 100644 --- a/rpmio/url.c +++ b/rpmio/url.c @@ -291,7 +291,7 @@ fprintf(stderr, "*** urlGetFile sfd %p %s tfd %p %s\n", sfd, url, (tfd ? tfd : N case URL_IS_DASH: case URL_IS_UNKNOWN: if ((rc = ufdGetFile(sfd, tfd))) { - (void) Unlink(dest); + (void) unlink(dest); /* XXX FIXME: sfd possibly closed by copyData */ (void) Fclose(sfd) ; } |