Remove splint tags.
This commit is contained in:
parent
1a01bdd6c6
commit
f982bbaa79
25
rpmio/argv.c
25
rpmio/argv.c
|
@ -8,15 +8,13 @@
|
|||
|
||||
#include "debug.h"
|
||||
|
||||
/*@-bounds@*/
|
||||
/**
|
||||
* Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
|
||||
* @param p memory to free
|
||||
* @return NULL always
|
||||
*/
|
||||
/*@unused@*/ static inline /*@null@*/
|
||||
void * _free(/*@only@*/ /*@null@*/ /*@out@*/ const void * p)
|
||||
/*@modifies p @*/
|
||||
static inline
|
||||
void * _free(const void * p)
|
||||
{
|
||||
if (p != NULL) free((void *)p);
|
||||
return NULL;
|
||||
|
@ -47,15 +45,13 @@ ARGI_t argiFree(ARGI_t argi)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
ARGV_t argvFree(/*@only@*/ /*@null@*/ ARGV_t argv)
|
||||
ARGV_t argvFree(ARGV_t argv)
|
||||
{
|
||||
ARGV_t av;
|
||||
|
||||
/*@-branchstate@*/
|
||||
if (argv)
|
||||
for (av = argv; *av; av++)
|
||||
*av = _free(*av);
|
||||
/*@=branchstate@*/
|
||||
argv = _free(argv);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -87,17 +83,13 @@ int argvCount(const ARGV_t argv)
|
|||
|
||||
ARGV_t argvData(const ARGV_t argv)
|
||||
{
|
||||
/*@-retalias -temptrans @*/
|
||||
return argv;
|
||||
/*@=retalias =temptrans @*/
|
||||
}
|
||||
|
||||
int argvCmp(const void * a, const void * b)
|
||||
{
|
||||
/*@-boundsread@*/
|
||||
ARGstr_t astr = *(ARGV_t)a;
|
||||
ARGstr_t bstr = *(ARGV_t)b;
|
||||
/*@=boundsread@*/
|
||||
return strcmp(astr, bstr);
|
||||
}
|
||||
|
||||
|
@ -119,7 +111,7 @@ ARGV_t argvSearch(ARGV_t argv, ARGstr_t val,
|
|||
return bsearch(&val, argv, argvCount(argv), sizeof(*argv), compar);
|
||||
}
|
||||
|
||||
int argiAdd(/*@out@*/ ARGI_t * argip, int ix, int val)
|
||||
int argiAdd(ARGI_t * argip, int ix, int val)
|
||||
{
|
||||
ARGI_t argi;
|
||||
|
||||
|
@ -140,7 +132,7 @@ int argiAdd(/*@out@*/ ARGI_t * argip, int ix, int val)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int argvAdd(/*@out@*/ ARGV_t * argvp, ARGstr_t val)
|
||||
int argvAdd(ARGV_t * argvp, ARGstr_t val)
|
||||
{
|
||||
ARGV_t argv;
|
||||
int argc;
|
||||
|
@ -148,16 +140,14 @@ int argvAdd(/*@out@*/ ARGV_t * argvp, ARGstr_t val)
|
|||
if (argvp == NULL)
|
||||
return -1;
|
||||
argc = argvCount(*argvp);
|
||||
/*@-unqualifiedtrans@*/
|
||||
*argvp = xrealloc(*argvp, (argc + 1 + 1) * sizeof(**argvp));
|
||||
/*@=unqualifiedtrans@*/
|
||||
argv = *argvp;
|
||||
argv[argc++] = xstrdup(val);
|
||||
argv[argc ] = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int argvAppend(/*@out@*/ ARGV_t * argvp, const ARGV_t av)
|
||||
int argvAppend(ARGV_t * argvp, const ARGV_t av)
|
||||
{
|
||||
ARGV_t argv = *argvp;
|
||||
int argc = argvCount(argv);
|
||||
|
@ -200,8 +190,5 @@ int argvSplit(ARGV_t * argvp, const char * str, const char * seps)
|
|||
}
|
||||
argv[c] = NULL;
|
||||
*argvp = argv;
|
||||
/*@-nullstate@*/
|
||||
return 0;
|
||||
/*@=nullstate@*/
|
||||
}
|
||||
/*@=bounds@*/
|
||||
|
|
50
rpmio/argv.h
50
rpmio/argv.h
|
@ -25,61 +25,49 @@ extern "C" {
|
|||
* @param argv argv array
|
||||
* @param fp output file handle (NULL uses stderr)
|
||||
*/
|
||||
void argvPrint(const char * msg, ARGV_t argv, FILE * fp)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies *fp, fileSystem @*/;
|
||||
void argvPrint(const char * msg, ARGV_t argv, FILE * fp);
|
||||
|
||||
/**
|
||||
* Destroy an argi array.
|
||||
* @param argi argi array
|
||||
* @return NULL always
|
||||
*/
|
||||
/*@null@*/
|
||||
ARGI_t argiFree(/*@only@*/ /*@null@*/ ARGI_t argi)
|
||||
/*@modifies argi @*/;
|
||||
ARGI_t argiFree(ARGI_t argi);
|
||||
|
||||
/**
|
||||
* Destroy an argv array.
|
||||
* @param argv argv array
|
||||
* @return NULL always
|
||||
*/
|
||||
/*@null@*/
|
||||
ARGV_t argvFree(/*@only@*/ /*@null@*/ ARGV_t argv)
|
||||
/*@modifies argv @*/;
|
||||
ARGV_t argvFree(ARGV_t argv);
|
||||
|
||||
/**
|
||||
* Return no. of elements in argi array.
|
||||
* @param argi argi array
|
||||
* @return no. of elements
|
||||
*/
|
||||
int argiCount(/*@null@*/ const ARGI_t argi)
|
||||
/*@*/;
|
||||
int argiCount(const ARGI_t argi);
|
||||
|
||||
/**
|
||||
* Return data from argi array.
|
||||
* @param argi argi array
|
||||
* @return argi array data address
|
||||
*/
|
||||
/*@null@*/
|
||||
ARGint_t argiData(/*@null@*/ const ARGI_t argi)
|
||||
/*@*/;
|
||||
ARGint_t argiData(const ARGI_t argi);
|
||||
|
||||
/**
|
||||
* Return no. of elements in argv array.
|
||||
* @param argv argv array
|
||||
* @return no. of elements
|
||||
*/
|
||||
int argvCount(/*@null@*/ const ARGV_t argv)
|
||||
/*@*/;
|
||||
int argvCount(const ARGV_t argv);
|
||||
|
||||
/**
|
||||
* Return data from argv array.
|
||||
* @param argv argv array
|
||||
* @return argv array data address
|
||||
*/
|
||||
/*@null@*/
|
||||
ARGV_t argvData(/*@null@*/ const ARGV_t argv)
|
||||
/*@*/;
|
||||
ARGV_t argvData(const ARGV_t argv);
|
||||
|
||||
/**
|
||||
* Compare argv arrays (qsort/bsearch).
|
||||
|
@ -87,10 +75,7 @@ ARGV_t argvData(/*@null@*/ const ARGV_t argv)
|
|||
* @param b 2nd instance address
|
||||
* @return result of comparison
|
||||
*/
|
||||
/*@-exportlocal@*/
|
||||
int argvCmp(const void * a, const void * b)
|
||||
/*@*/;
|
||||
/*@=exportlocal@*/
|
||||
int argvCmp(const void * a, const void * b);
|
||||
|
||||
/**
|
||||
* Sort an argv array.
|
||||
|
@ -98,8 +83,7 @@ int argvCmp(const void * a, const void * b)
|
|||
* @param compar strcmp-like comparison function, or NULL for argvCmp()
|
||||
* @return 0 always
|
||||
*/
|
||||
int argvSort(ARGV_t argv, int (*compar)(const void *, const void *))
|
||||
/*@modifies *argv @*/;
|
||||
int argvSort(ARGV_t argv, int (*compar)(const void *, const void *));
|
||||
|
||||
/**
|
||||
* Find an element in an argv array.
|
||||
|
@ -108,10 +92,8 @@ int argvSort(ARGV_t argv, int (*compar)(const void *, const void *))
|
|||
* @param compar strcmp-like comparison function, or NULL for argvCmp()
|
||||
* @return found string (NULL on failure)
|
||||
*/
|
||||
/*@dependent@*/ /*@null@*/
|
||||
ARGV_t argvSearch(ARGV_t argv, ARGstr_t val,
|
||||
int (*compar)(const void *, const void *))
|
||||
/*@*/;
|
||||
int (*compar)(const void *, const void *));
|
||||
|
||||
/**
|
||||
* Add an int to an argi array.
|
||||
|
@ -120,8 +102,7 @@ ARGV_t argvSearch(ARGV_t argv, ARGstr_t val,
|
|||
* @param val int arg to add
|
||||
* @return 0 always
|
||||
*/
|
||||
int argiAdd(/*@out@*/ ARGI_t * argip, int ix, int val)
|
||||
/*@modifies *argip @*/;
|
||||
int argiAdd(ARGI_t * argip, int ix, int val);
|
||||
|
||||
/**
|
||||
* Add a string to an argv array.
|
||||
|
@ -129,8 +110,7 @@ int argiAdd(/*@out@*/ ARGI_t * argip, int ix, int val)
|
|||
* @param val string arg to append
|
||||
* @return 0 always
|
||||
*/
|
||||
int argvAdd(/*@out@*/ ARGV_t * argvp, ARGstr_t val)
|
||||
/*@modifies *argvp @*/;
|
||||
int argvAdd(ARGV_t * argvp, ARGstr_t val);
|
||||
|
||||
/**
|
||||
* Append one argv array to another.
|
||||
|
@ -138,8 +118,7 @@ int argvAdd(/*@out@*/ ARGV_t * argvp, ARGstr_t val)
|
|||
* @param av argv array to append
|
||||
* @return 0 always
|
||||
*/
|
||||
int argvAppend(/*@out@*/ ARGV_t * argvp, const ARGV_t av)
|
||||
/*@modifies *argvp @*/;
|
||||
int argvAppend(ARGV_t * argvp, const ARGV_t av);
|
||||
|
||||
/**
|
||||
* Split a string into an argv array.
|
||||
|
@ -148,8 +127,7 @@ int argvAppend(/*@out@*/ ARGV_t * argvp, const ARGV_t av)
|
|||
* @param seps seperator characters
|
||||
* @return 0 always
|
||||
*/
|
||||
int argvSplit(ARGV_t * argvp, const char * str, const char * seps)
|
||||
/*@modifies *argvp @*/;
|
||||
int argvSplit(ARGV_t * argvp, const char * str, const char * seps);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#define DPRINTF(_a)
|
||||
#endif
|
||||
|
||||
/*@access DIGEST_CTX@*/
|
||||
|
||||
/**
|
||||
* MD5/SHA1 digest private data.
|
||||
|
@ -27,11 +26,10 @@ struct DIGEST_CTX_s {
|
|||
/*@modifies param @*/; /*!< Digest initialize. */
|
||||
int (*Update) (void * param, const byte * data, size_t size)
|
||||
/*@modifies param @*/; /*!< Digest transform. */
|
||||
int (*Digest) (void * param, /*@out@*/ byte * digest)
|
||||
int (*Digest) (void * param, byte * digest)
|
||||
/*@modifies param, digest @*/; /*!< Digest finish. */
|
||||
};
|
||||
|
||||
/*@-boundsread@*/
|
||||
DIGEST_CTX
|
||||
rpmDigestDup(DIGEST_CTX octx)
|
||||
{
|
||||
|
@ -40,7 +38,6 @@ rpmDigestDup(DIGEST_CTX octx)
|
|||
nctx->param = memcpy(xcalloc(1, nctx->paramlen), octx->param, nctx->paramlen);
|
||||
return nctx;
|
||||
}
|
||||
/*@=boundsread@*/
|
||||
|
||||
DIGEST_CTX
|
||||
rpmDigestInit(pgpHashAlgo hashalgo, rpmDigestFlags flags)
|
||||
|
@ -54,68 +51,58 @@ rpmDigestInit(pgpHashAlgo hashalgo, rpmDigestFlags flags)
|
|||
case PGPHASHALGO_MD5:
|
||||
ctx->digestlen = 16;
|
||||
ctx->datalen = 64;
|
||||
/*@-sizeoftype@*/ /* FIX: union, not void pointer */
|
||||
/* FIX: union, not void pointer */
|
||||
ctx->paramlen = sizeof(md5Param);
|
||||
/*@=sizeoftype@*/
|
||||
ctx->param = xcalloc(1, ctx->paramlen);
|
||||
/*@-type@*/ /* FIX: cast? */
|
||||
/* FIX: cast? */
|
||||
ctx->Reset = (void *) md5Reset;
|
||||
ctx->Update = (void *) md5Update;
|
||||
ctx->Digest = (void *) md5Digest;
|
||||
/*@=type@*/
|
||||
break;
|
||||
case PGPHASHALGO_SHA1:
|
||||
ctx->digestlen = 20;
|
||||
ctx->datalen = 64;
|
||||
/*@-sizeoftype@*/ /* FIX: union, not void pointer */
|
||||
/* FIX: union, not void pointer */
|
||||
ctx->paramlen = sizeof(sha1Param);
|
||||
/*@=sizeoftype@*/
|
||||
ctx->param = xcalloc(1, ctx->paramlen);
|
||||
/*@-type@*/ /* FIX: cast? */
|
||||
/* FIX: cast? */
|
||||
ctx->Reset = (void *) sha1Reset;
|
||||
ctx->Update = (void *) sha1Update;
|
||||
ctx->Digest = (void *) sha1Digest;
|
||||
/*@=type@*/
|
||||
break;
|
||||
#if HAVE_BEECRYPT_API_H
|
||||
case PGPHASHALGO_SHA256:
|
||||
ctx->digestlen = 32;
|
||||
ctx->datalen = 64;
|
||||
/*@-sizeoftype@*/ /* FIX: union, not void pointer */
|
||||
/* FIX: union, not void pointer */
|
||||
ctx->paramlen = sizeof(sha256Param);
|
||||
/*@=sizeoftype@*/
|
||||
ctx->param = xcalloc(1, ctx->paramlen);
|
||||
/*@-type@*/ /* FIX: cast? */
|
||||
/* FIX: cast? */
|
||||
ctx->Reset = (void *) sha256Reset;
|
||||
ctx->Update = (void *) sha256Update;
|
||||
ctx->Digest = (void *) sha256Digest;
|
||||
/*@=type@*/
|
||||
break;
|
||||
case PGPHASHALGO_SHA384:
|
||||
ctx->digestlen = 48;
|
||||
ctx->datalen = 128;
|
||||
/*@-sizeoftype@*/ /* FIX: union, not void pointer */
|
||||
/* FIX: union, not void pointer */
|
||||
ctx->paramlen = sizeof(sha384Param);
|
||||
/*@=sizeoftype@*/
|
||||
ctx->param = xcalloc(1, ctx->paramlen);
|
||||
/*@-type@*/ /* FIX: cast? */
|
||||
/* FIX: cast? */
|
||||
ctx->Reset = (void *) sha384Reset;
|
||||
ctx->Update = (void *) sha384Update;
|
||||
ctx->Digest = (void *) sha384Digest;
|
||||
/*@=type@*/
|
||||
break;
|
||||
case PGPHASHALGO_SHA512:
|
||||
ctx->digestlen = 64;
|
||||
ctx->datalen = 128;
|
||||
/*@-sizeoftype@*/ /* FIX: union, not void pointer */
|
||||
/* FIX: union, not void pointer */
|
||||
ctx->paramlen = sizeof(sha512Param);
|
||||
/*@=sizeoftype@*/
|
||||
ctx->param = xcalloc(1, ctx->paramlen);
|
||||
/*@-type@*/ /* FIX: cast? */
|
||||
/* FIX: cast? */
|
||||
ctx->Reset = (void *) sha512Reset;
|
||||
ctx->Update = (void *) sha512Update;
|
||||
ctx->Digest = (void *) sha512Digest;
|
||||
/*@=type@*/
|
||||
break;
|
||||
#endif
|
||||
case PGPHASHALGO_RIPEMD160:
|
||||
|
@ -125,18 +112,16 @@ rpmDigestInit(pgpHashAlgo hashalgo, rpmDigestFlags flags)
|
|||
default:
|
||||
free(ctx);
|
||||
return NULL;
|
||||
/*@notreached@*/ break;
|
||||
break;
|
||||
}
|
||||
|
||||
/*@-boundsread@*/
|
||||
xx = (*ctx->Reset) (ctx->param);
|
||||
/*@=boundsread@*/
|
||||
|
||||
DPRINTF((stderr, "*** Init(%x) ctx %p param %p\n", flags, ctx, ctx->param));
|
||||
return ctx;
|
||||
}
|
||||
|
||||
/*@-mustmod@*/ /* LCL: ctx->param may be modified, but ctx is abstract @*/
|
||||
/* LCL: ctx->param may be modified, but ctx is abstract @*/
|
||||
int
|
||||
rpmDigestUpdate(DIGEST_CTX ctx, const void * data, size_t len)
|
||||
{
|
||||
|
@ -144,13 +129,9 @@ rpmDigestUpdate(DIGEST_CTX ctx, const void * data, size_t len)
|
|||
return -1;
|
||||
|
||||
DPRINTF((stderr, "*** Update(%p,%p,%d) param %p \"%s\"\n", ctx, data, len, ctx->param, ((char *)data)));
|
||||
/*@-boundsread@*/
|
||||
return (*ctx->Update) (ctx->param, data, len);
|
||||
/*@=boundsread@*/
|
||||
}
|
||||
/*@=mustmod@*/
|
||||
|
||||
/*@-boundswrite@*/
|
||||
int
|
||||
rpmDigestFinal(DIGEST_CTX ctx, void ** datap, size_t *lenp, int asAscii)
|
||||
{
|
||||
|
@ -163,12 +144,10 @@ rpmDigestFinal(DIGEST_CTX ctx, void ** datap, size_t *lenp, int asAscii)
|
|||
digest = xmalloc(ctx->digestlen);
|
||||
|
||||
DPRINTF((stderr, "*** Final(%p,%p,%p,%d) param %p digest %p\n", ctx, datap, lenp, asAscii, ctx->param, digest));
|
||||
/*@-noeffectuncon@*/ /* FIX: check rc */
|
||||
/* FIX: check rc */
|
||||
(void) (*ctx->Digest) (ctx->param, digest);
|
||||
/*@=noeffectuncon@*/
|
||||
|
||||
/* Return final digest. */
|
||||
/*@-branchstate@*/
|
||||
if (!asAscii) {
|
||||
if (lenp) *lenp = ctx->digestlen;
|
||||
if (datap) {
|
||||
|
@ -189,7 +168,6 @@ DPRINTF((stderr, "*** Final(%p,%p,%p,%d) param %p digest %p\n", ctx, datap, lenp
|
|||
*t = '\0';
|
||||
}
|
||||
}
|
||||
/*@=branchstate@*/
|
||||
if (digest) {
|
||||
memset(digest, 0, ctx->digestlen); /* In case it's sensitive */
|
||||
free(digest);
|
||||
|
@ -200,4 +178,3 @@ DPRINTF((stderr, "*** Final(%p,%p,%p,%d) param %p digest %p\n", ctx, datap, lenp
|
|||
free(ctx);
|
||||
return 0;
|
||||
}
|
||||
/*@=boundswrite@*/
|
||||
|
|
94
rpmio/fts.c
94
rpmio/fts.c
|
@ -1,6 +1,3 @@
|
|||
/*@-boundsread@*/
|
||||
/*@-sysunrecog -noeffectuncon -nullpass -sizeoftype -unrecog -usereleased @*/
|
||||
/*@-compdef -compmempass -dependenttrans -retalias @*/
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993, 1994
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
|
@ -87,31 +84,17 @@ static char sccsid[] = "@(#)fts.c 8.6 (Berkeley) 8/14/94";
|
|||
#endif
|
||||
|
||||
|
||||
/*@only@*/ /*@null@*/
|
||||
static FTSENT * fts_alloc(FTS * sp, const char * name, int namelen)
|
||||
/*@*/;
|
||||
/*@null@*/
|
||||
static FTSENT * fts_build(FTS * sp, int type)
|
||||
/*@globals fileSystem, internalState @*/
|
||||
/*@modifies *sp, fileSystem, internalState @*/;
|
||||
static void fts_lfree(/*@only@*/ FTSENT * head)
|
||||
/*@modifies head @*/;
|
||||
static void fts_load(FTS * sp, FTSENT * p)
|
||||
/*@modifies *sp, *p @*/;
|
||||
static size_t fts_maxarglen(char * const * argv)
|
||||
/*@*/;
|
||||
static void fts_padjust(FTS * sp, FTSENT * head)
|
||||
/*@modifies *sp, *head @*/;
|
||||
static int fts_palloc(FTS * sp, size_t more)
|
||||
/*@modifies *sp @*/;
|
||||
static FTSENT * fts_sort(FTS * sp, /*@returned@*/ FTSENT * head, int nitems)
|
||||
/*@modifies *sp @*/;
|
||||
static u_short fts_stat(FTS * sp, FTSENT * p, int follow)
|
||||
/*@modifies *p @*/;
|
||||
static FTSENT * fts_alloc(FTS * sp, const char * name, int namelen);
|
||||
static FTSENT * fts_build(FTS * sp, int type);
|
||||
static void fts_lfree(FTSENT * head);
|
||||
static void fts_load(FTS * sp, FTSENT * p);
|
||||
static size_t fts_maxarglen(char * const * argv);
|
||||
static void fts_padjust(FTS * sp, FTSENT * head);
|
||||
static int fts_palloc(FTS * sp, size_t more);
|
||||
static FTSENT * fts_sort(FTS * sp, FTSENT * head, int nitems);
|
||||
static u_short fts_stat(FTS * sp, FTSENT * p, int follow);
|
||||
static int fts_safe_changedir(FTS * sp, FTSENT * p, int fd,
|
||||
const char * path)
|
||||
/*@globals fileSystem, internalState @*/
|
||||
/*@modifies fileSystem, internalState @*/;
|
||||
const char * path);
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(a, b) ({ __typeof__ (a) _a = (a); \
|
||||
|
@ -144,9 +127,7 @@ Fts_open(char * const * argv, int options,
|
|||
|
||||
/* Options check. */
|
||||
if (options & ~FTS_OPTIONMASK) {
|
||||
/*@-boundswrite@*/
|
||||
__set_errno (EINVAL);
|
||||
/*@=boundswrite@*/
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
@ -185,9 +166,7 @@ Fts_open(char * const * argv, int options,
|
|||
for (root = NULL, nitems = 0; *argv != NULL; ++argv, ++nitems) {
|
||||
/* Don't allow zero-length paths. */
|
||||
if ((len = strlen(*argv)) == 0) {
|
||||
/*@-boundswrite@*/
|
||||
__set_errno (ENOENT);
|
||||
/*@=boundswrite@*/
|
||||
goto mem3;
|
||||
}
|
||||
|
||||
|
@ -195,19 +174,17 @@ Fts_open(char * const * argv, int options,
|
|||
switch (urlIsURL(*argv)) {
|
||||
case URL_IS_DASH:
|
||||
case URL_IS_HKP:
|
||||
/*@-boundswrite@*/
|
||||
__set_errno (ENOENT);
|
||||
/*@=boundswrite@*/
|
||||
goto mem3;
|
||||
/*@notreached@*/ /*@switchbreak@*/ break;
|
||||
break;
|
||||
case URL_IS_HTTPS:
|
||||
case URL_IS_HTTP:
|
||||
case URL_IS_FTP:
|
||||
SET(FTS_NOCHDIR);
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
case URL_IS_UNKNOWN:
|
||||
case URL_IS_PATH:
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
}
|
||||
|
||||
p = fts_alloc(sp, *argv, len);
|
||||
|
@ -240,10 +217,8 @@ Fts_open(char * const * argv, int options,
|
|||
}
|
||||
}
|
||||
}
|
||||
/*@-branchstate@*/
|
||||
if (compar && nitems > 1)
|
||||
root = fts_sort(sp, root, nitems);
|
||||
/*@=branchstate@*/
|
||||
|
||||
/*
|
||||
* Allocate a dummy pointer and make fts_read think that we've just
|
||||
|
@ -289,7 +264,6 @@ fts_load(FTS * sp, FTSENT * p)
|
|||
* known that the path will fit.
|
||||
*/
|
||||
len = p->fts_pathlen = p->fts_namelen;
|
||||
/*@-boundswrite@*/
|
||||
memmove(sp->fts_path, p->fts_name, len + 1);
|
||||
if ((cp = strrchr(p->fts_name, '/')) && (cp != p->fts_name || cp[1])) {
|
||||
len = strlen(++cp);
|
||||
|
@ -298,7 +272,6 @@ fts_load(FTS * sp, FTSENT * p)
|
|||
}
|
||||
p->fts_accpath = p->fts_path = sp->fts_path;
|
||||
sp->fts_dev = p->fts_dev;
|
||||
/*@=boundswrite@*/
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -315,7 +288,6 @@ Fts_close(FTS * sp)
|
|||
* points to the root list, so we step through to the end of the root
|
||||
* list which has a valid parent pointer.
|
||||
*/
|
||||
/*@-branchstate@*/
|
||||
if (sp->fts_cur) {
|
||||
for (p = sp->fts_cur; p->fts_level >= FTS_ROOTLEVEL;) {
|
||||
freep = p;
|
||||
|
@ -324,7 +296,6 @@ Fts_close(FTS * sp)
|
|||
}
|
||||
free(p);
|
||||
}
|
||||
/*@=branchstate@*/
|
||||
|
||||
/* Free up child linked list, sort array, path buffer. */
|
||||
if (sp->fts_child)
|
||||
|
@ -342,9 +313,7 @@ Fts_close(FTS * sp)
|
|||
if (saved_errno != 0) {
|
||||
/* Free up the stream pointer. */
|
||||
free(sp);
|
||||
/*@-boundswrite@*/
|
||||
__set_errno (saved_errno);
|
||||
/*@=boundswrite@*/
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
|
@ -461,7 +430,6 @@ Fts_read(FTS * sp)
|
|||
}
|
||||
|
||||
/* Move to the next node on this level. */
|
||||
/*@-boundswrite@*/
|
||||
next: tmp = p;
|
||||
if ((p = p->fts_link) != NULL) {
|
||||
free(tmp);
|
||||
|
@ -486,7 +454,6 @@ next: tmp = p;
|
|||
*/
|
||||
if (p->fts_instr == FTS_SKIP)
|
||||
goto next;
|
||||
/*@-branchstate@*/
|
||||
if (p->fts_instr == FTS_FOLLOW) {
|
||||
p->fts_info = fts_stat(sp, p, 1);
|
||||
if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) {
|
||||
|
@ -499,7 +466,6 @@ next: tmp = p;
|
|||
}
|
||||
p->fts_instr = FTS_NOINSTR;
|
||||
}
|
||||
/*@=branchstate@*/
|
||||
|
||||
name: t = sp->fts_path + NAPPEND(p->fts_parent);
|
||||
*t++ = '/';
|
||||
|
@ -523,7 +489,6 @@ name: t = sp->fts_path + NAPPEND(p->fts_parent);
|
|||
|
||||
/* NUL terminate the pathname. */
|
||||
sp->fts_path[p->fts_pathlen] = '\0';
|
||||
/*@=boundswrite@*/
|
||||
|
||||
/*
|
||||
* Return to the parent directory. If at a root node or came through
|
||||
|
@ -539,9 +504,7 @@ name: t = sp->fts_path + NAPPEND(p->fts_parent);
|
|||
if (FCHDIR(sp, p->fts_symfd)) {
|
||||
saved_errno = errno;
|
||||
(void)__close(p->fts_symfd);
|
||||
/*@-boundswrite@*/
|
||||
__set_errno (saved_errno);
|
||||
/*@=boundswrite@*/
|
||||
SET(FTS_STOP);
|
||||
return (NULL);
|
||||
}
|
||||
|
@ -562,13 +525,11 @@ name: t = sp->fts_path + NAPPEND(p->fts_parent);
|
|||
* reasons.
|
||||
*/
|
||||
int
|
||||
Fts_set(/*@unused@*/ FTS * sp, FTSENT * p, int instr)
|
||||
Fts_set(FTS * sp, FTSENT * p, int instr)
|
||||
{
|
||||
if (instr != 0 && instr != FTS_AGAIN && instr != FTS_FOLLOW &&
|
||||
instr != FTS_NOINSTR && instr != FTS_SKIP) {
|
||||
/*@-boundswrite@*/
|
||||
__set_errno (EINVAL);
|
||||
/*@=boundswrite@*/
|
||||
return (1);
|
||||
}
|
||||
p->fts_instr = instr;
|
||||
|
@ -582,9 +543,7 @@ Fts_children(FTS * sp, int instr)
|
|||
int fd;
|
||||
|
||||
if (instr != 0 && instr != FTS_NAMEONLY) {
|
||||
/*@-boundswrite@*/
|
||||
__set_errno (EINVAL);
|
||||
/*@=boundswrite@*/
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
@ -595,9 +554,7 @@ Fts_children(FTS * sp, int instr)
|
|||
* Errno set to 0 so user can distinguish empty directory from
|
||||
* an error.
|
||||
*/
|
||||
/*@-boundswrite@*/
|
||||
__set_errno (0);
|
||||
/*@=boundswrite@*/
|
||||
|
||||
/* Fatal errors stop here. */
|
||||
if (ISSET(FTS_STOP))
|
||||
|
@ -760,9 +717,7 @@ fts_build(FTS * sp, int type)
|
|||
len = NAPPEND(cur);
|
||||
if (ISSET(FTS_NOCHDIR)) {
|
||||
cp = sp->fts_path + len;
|
||||
/*@-boundswrite@*/
|
||||
*cp++ = '/';
|
||||
/*@=boundswrite@*/
|
||||
} else {
|
||||
/* GCC, you're too verbose. */
|
||||
cp = NULL;
|
||||
|
@ -892,10 +847,8 @@ mem1: saved_errno = errno;
|
|||
if (ISSET(FTS_NOCHDIR)) {
|
||||
if (len == sp->fts_pathlen || nitems == 0)
|
||||
--cp;
|
||||
/*@-boundswrite@*/
|
||||
if (cp != NULL) /* XXX can't happen */
|
||||
*cp = '\0';
|
||||
/*@=boundswrite@*/
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -959,9 +912,7 @@ fts_stat(FTS * sp, FTSENT * p, int follow)
|
|||
if ((*sp->fts_stat) (p->fts_accpath, sbp)) {
|
||||
saved_errno = errno;
|
||||
if (!(*sp->fts_lstat) (p->fts_accpath, sbp)) {
|
||||
/*@-boundswrite@*/
|
||||
__set_errno (0);
|
||||
/*@=boundswrite@*/
|
||||
return (FTS_SLNONE);
|
||||
}
|
||||
p->fts_errno = saved_errno;
|
||||
|
@ -969,9 +920,7 @@ fts_stat(FTS * sp, FTSENT * p, int follow)
|
|||
}
|
||||
} else if ((*sp->fts_lstat) (p->fts_accpath, sbp)) {
|
||||
p->fts_errno = errno;
|
||||
/*@-boundswrite@*/
|
||||
err: memset(sbp, 0, sizeof(*sbp));
|
||||
/*@=boundswrite@*/
|
||||
return (FTS_NS);
|
||||
}
|
||||
|
||||
|
@ -1037,7 +986,6 @@ fts_sort(FTS * sp, FTSENT * head, int nitems)
|
|||
}
|
||||
sp->fts_array = a;
|
||||
}
|
||||
/*@-boundswrite@*/
|
||||
for (ap = sp->fts_array, p = head; p != NULL; p = p->fts_link)
|
||||
*ap++ = p;
|
||||
qsort((void *)sp->fts_array, nitems, sizeof(*sp->fts_array),
|
||||
|
@ -1045,7 +993,6 @@ fts_sort(FTS * sp, FTSENT * head, int nitems)
|
|||
for (head = *(ap = sp->fts_array); --nitems; ++ap)
|
||||
ap[0]->fts_link = ap[1];
|
||||
ap[0]->fts_link = NULL;
|
||||
/*@=boundswrite@*/
|
||||
return (head);
|
||||
}
|
||||
|
||||
|
@ -1070,10 +1017,8 @@ fts_alloc(FTS * sp, const char * name, int namelen)
|
|||
return (NULL);
|
||||
|
||||
/* Copy the name and guarantee NUL termination. */
|
||||
/*@-boundswrite@*/
|
||||
memmove(p->fts_name, name, namelen);
|
||||
p->fts_name[namelen] = '\0';
|
||||
/*@=boundswrite@*/
|
||||
|
||||
if (!ISSET(FTS_NOSTAT))
|
||||
p->fts_statp = (struct stat *)ALIGN(p->fts_name + namelen + 2);
|
||||
|
@ -1093,12 +1038,10 @@ fts_lfree(FTSENT * head)
|
|||
register FTSENT *p;
|
||||
|
||||
/* Free a linked list of structures. */
|
||||
/*@-branchstate@*/
|
||||
while ((p = head)) {
|
||||
head = head->fts_link;
|
||||
free(p);
|
||||
}
|
||||
/*@=branchstate@*/
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1124,9 +1067,7 @@ fts_palloc(FTS * sp, size_t more)
|
|||
sp->fts_path = NULL;
|
||||
}
|
||||
sp->fts_path = NULL;
|
||||
/*@-boundswrite@*/
|
||||
__set_errno (ENAMETOOLONG);
|
||||
/*@=boundswrite@*/
|
||||
return (1);
|
||||
}
|
||||
p = realloc(sp->fts_path, sp->fts_pathlen);
|
||||
|
@ -1199,9 +1140,7 @@ fts_safe_changedir(FTS * sp, FTSENT * p, int fd, const char * path)
|
|||
goto bail;
|
||||
}
|
||||
if (p->fts_dev != sb.st_dev || p->fts_ino != sb.st_ino) {
|
||||
/*@-boundswrite@*/
|
||||
__set_errno (ENOENT); /* disinformation */
|
||||
/*@=boundswrite@*/
|
||||
ret = -1;
|
||||
goto bail;
|
||||
}
|
||||
|
@ -1210,11 +1149,6 @@ bail:
|
|||
oerrno = errno;
|
||||
if (fd < 0)
|
||||
(void)__close(newfd);
|
||||
/*@-boundswrite@*/
|
||||
__set_errno (oerrno);
|
||||
/*@=boundswrite@*/
|
||||
return (ret);
|
||||
}
|
||||
/*@=compdef =compmempass =dependenttrans =retalias @*/
|
||||
/*@=sysunrecog =noeffectuncon =nullpass =sizeoftype =unrecog =usereleased @*/
|
||||
/*@=boundsread@*/
|
||||
|
|
56
rpmio/fts.h
56
rpmio/fts.h
|
@ -66,37 +66,21 @@
|
|||
#include <dirent.h>
|
||||
|
||||
typedef struct {
|
||||
/*@owned@*/ /*@relnull@*/
|
||||
struct _ftsent *fts_cur; /*!< current node */
|
||||
/*@owned@*/ /*@null@*/
|
||||
struct _ftsent *fts_child; /*!< linked list of children */
|
||||
/*@owned@*/ /*@null@*/
|
||||
struct _ftsent **fts_array; /*!< sort array */
|
||||
dev_t fts_dev; /*!< starting device # */
|
||||
/*@owned@*/ /*@relnull@*/
|
||||
char *fts_path; /*!< path for this descent */
|
||||
int fts_rfd; /*!< fd for root */
|
||||
int fts_pathlen; /*!< sizeof(path) */
|
||||
int fts_nitems; /*!< elements in the sort array */
|
||||
/*@null@*/
|
||||
int (*fts_compar) (const void *, const void *)
|
||||
/*@*/; /*!< compare fn */
|
||||
int (*fts_compar) (const void *, const void *); /*!< compare fn */
|
||||
|
||||
DIR * (*fts_opendir) (const char * path)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies fileSystem @*/;
|
||||
struct dirent * (*fts_readdir) (DIR * dir)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies *dir, fileSystem @*/;
|
||||
int (*fts_closedir) (/*@only@*/ DIR * dir)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies *dir, fileSystem @*/;
|
||||
int (*fts_stat) (const char * path, /*@out@*/ struct stat * st)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies *st, fileSystem @*/;
|
||||
int (*fts_lstat) (const char * path, /*@out@*/ struct stat * st)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies *st, fileSystem @*/;
|
||||
DIR * (*fts_opendir) (const char * path);
|
||||
struct dirent * (*fts_readdir) (DIR * dir);
|
||||
int (*fts_closedir) (DIR * dir);
|
||||
int (*fts_stat) (const char * path, struct stat * st);
|
||||
int (*fts_lstat) (const char * path, struct stat * st);
|
||||
|
||||
#define FTS_COMFOLLOW 0x0001 /* follow command line symlinks */
|
||||
#define FTS_LOGICAL 0x0002 /* logical walk */
|
||||
|
@ -114,18 +98,12 @@ typedef struct {
|
|||
} FTS;
|
||||
|
||||
typedef struct _ftsent {
|
||||
/*@dependent@*/
|
||||
struct _ftsent *fts_cycle; /*!< cycle node */
|
||||
/*@dependent@*/ /*@relnull@*/
|
||||
struct _ftsent *fts_parent; /*!< parent directory */
|
||||
/*@dependent@*/ /*@null@*/
|
||||
struct _ftsent *fts_link; /*!< next file in directory */
|
||||
long fts_number; /*!< local numeric value */
|
||||
/*@null@*/
|
||||
void *fts_pointer; /*!< local address value */
|
||||
/*@dependent@*/
|
||||
char *fts_accpath; /*!< access path */
|
||||
/*@dependent@*/
|
||||
char *fts_path; /*!< root path */
|
||||
int fts_errno; /*!< errno for this node */
|
||||
int fts_symfd; /*!< fd for symlink */
|
||||
|
@ -166,7 +144,6 @@ typedef struct _ftsent {
|
|||
#define FTS_SKIP 4 /* discard node */
|
||||
u_short fts_instr; /*!< fts_set() instructions */
|
||||
|
||||
/*@dependent@*/
|
||||
struct stat *fts_statp; /*!< stat(2) information */
|
||||
char fts_name[1]; /*!< file name */
|
||||
} FTSENT;
|
||||
|
@ -179,19 +156,16 @@ __BEGIN_DECLS
|
|||
* @param instr
|
||||
* @return file set member
|
||||
*/
|
||||
/*@dependent@*/ /*@null@*/
|
||||
FTSENT *Fts_children (FTS * sp, int instr) __THROW
|
||||
/*@globals fileSystem, internalState @*/
|
||||
/*@modifies *sp, fileSystem, internalState @*/;
|
||||
;
|
||||
|
||||
/**
|
||||
* Destroy a file hierarchy traversal handle.
|
||||
* @param sp file hierarchy state
|
||||
* @return 0 on sucess, -1 on error
|
||||
*/
|
||||
int Fts_close (/*@only@*/ /*@null@*/ FTS * sp) __THROW
|
||||
/*@globals fileSystem, internalState @*/
|
||||
/*@modifies *sp, fileSystem, internalState @*/;
|
||||
int Fts_close (FTS * sp) __THROW
|
||||
;
|
||||
|
||||
/**
|
||||
* Create a handle for file hierarchy traversal.
|
||||
|
@ -200,21 +174,17 @@ int Fts_close (/*@only@*/ /*@null@*/ FTS * sp) __THROW
|
|||
* @param compar traversal ordering (or NULL)
|
||||
* @return file hierarchy state (or NULL on error)
|
||||
*/
|
||||
/*@only@*/ /*@null@*/
|
||||
FTS *Fts_open (char * const * argv, int options,
|
||||
/*@null@*/
|
||||
int (*compar) (const FTSENT **, const FTSENT **)) __THROW
|
||||
/*@*/;
|
||||
;
|
||||
|
||||
/**
|
||||
* Return next node in the file hierarchy traversal.
|
||||
* @param sp file hierarchy state
|
||||
* @return file set member
|
||||
*/
|
||||
/*@null@*/
|
||||
FTSENT *Fts_read (/*@null@*/ FTS * sp) __THROW
|
||||
/*@globals fileSystem, internalState @*/
|
||||
/*@modifies *sp, fileSystem, internalState @*/;
|
||||
FTSENT *Fts_read (FTS * sp) __THROW
|
||||
;
|
||||
|
||||
/**
|
||||
* Modify the traversal for a file set member.
|
||||
|
@ -224,7 +194,7 @@ FTSENT *Fts_read (/*@null@*/ FTS * sp) __THROW
|
|||
* @return 0 on sucess, -1 on error
|
||||
*/
|
||||
int Fts_set (FTS * sp, FTSENT * p, int instr) __THROW
|
||||
/*@modifies *p @*/;
|
||||
;
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
|
293
rpmio/macro.c
293
rpmio/macro.c
|
@ -1,4 +1,3 @@
|
|||
/*@-boundsread@*/
|
||||
/** \ingroup rpmrc rpmio
|
||||
* \file rpmio/macro.c
|
||||
*/
|
||||
|
@ -55,54 +54,38 @@ typedef FILE * FD_t;
|
|||
#include "debug.h"
|
||||
|
||||
/*@access FD_t@*/ /* XXX compared with NULL */
|
||||
/*@access MacroContext@*/
|
||||
/*@access MacroEntry@*/
|
||||
/*@access rpmlua @*/
|
||||
|
||||
static struct MacroContext_s rpmGlobalMacroContext_s;
|
||||
/*@-compmempass@*/
|
||||
MacroContext rpmGlobalMacroContext = &rpmGlobalMacroContext_s;
|
||||
/*@=compmempass@*/
|
||||
|
||||
static struct MacroContext_s rpmCLIMacroContext_s;
|
||||
/*@-compmempass@*/
|
||||
MacroContext rpmCLIMacroContext = &rpmCLIMacroContext_s;
|
||||
/*@=compmempass@*/
|
||||
|
||||
/**
|
||||
* Macro expansion state.
|
||||
*/
|
||||
typedef /*@abstract@*/ struct MacroBuf_s {
|
||||
/*@kept@*/ /*@exposed@*/
|
||||
typedef struct MacroBuf_s {
|
||||
const char * s; /*!< Text to expand. */
|
||||
/*@shared@*/
|
||||
char * t; /*!< Expansion buffer. */
|
||||
size_t nb; /*!< No. bytes remaining in expansion buffer. */
|
||||
int depth; /*!< Current expansion depth. */
|
||||
int macro_trace; /*!< Pre-print macro to expand? */
|
||||
int expand_trace; /*!< Post-print macro expansion? */
|
||||
/*@kept@*/ /*@exposed@*/ /*@null@*/
|
||||
void * spec; /*!< (future) %file expansion info?. */
|
||||
/*@kept@*/ /*@exposed@*/
|
||||
MacroContext mc;
|
||||
} * MacroBuf;
|
||||
|
||||
#define SAVECHAR(_mb, _c) { *(_mb)->t = (_c), (_mb)->t++, (_mb)->nb--; }
|
||||
|
||||
/*@-exportlocal -exportheadervar@*/
|
||||
|
||||
#define _MAX_MACRO_DEPTH 16
|
||||
/*@unchecked@*/
|
||||
int max_macro_depth = _MAX_MACRO_DEPTH;
|
||||
|
||||
#define _PRINT_MACRO_TRACE 0
|
||||
/*@unchecked@*/
|
||||
int print_macro_trace = _PRINT_MACRO_TRACE;
|
||||
|
||||
#define _PRINT_EXPAND_TRACE 0
|
||||
/*@unchecked@*/
|
||||
int print_expand_trace = _PRINT_EXPAND_TRACE;
|
||||
/*@=exportlocal =exportheadervar@*/
|
||||
|
||||
#define MACRO_CHUNK_SIZE 16
|
||||
|
||||
|
@ -118,9 +101,8 @@ static int expandMacro(MacroBuf mb)
|
|||
* @param p memory to free
|
||||
* @retval NULL always
|
||||
*/
|
||||
/*@unused@*/ static inline /*@null@*/ void *
|
||||
_free(/*@only@*/ /*@null@*/ const void * p)
|
||||
/*@modifies p@*/
|
||||
static inline void *
|
||||
_free(const void * p)
|
||||
{
|
||||
if (p != NULL) free((void *)p);
|
||||
return NULL;
|
||||
|
@ -136,7 +118,6 @@ _free(/*@only@*/ /*@null@*/ const void * p)
|
|||
*/
|
||||
static int
|
||||
compareMacroName(const void * ap, const void * bp)
|
||||
/*@*/
|
||||
{
|
||||
MacroEntry ame = *((MacroEntry *)ap);
|
||||
MacroEntry bme = *((MacroEntry *)bp);
|
||||
|
@ -154,10 +135,8 @@ compareMacroName(const void * ap, const void * bp)
|
|||
* Enlarge macro table.
|
||||
* @param mc macro context
|
||||
*/
|
||||
/*@-boundswrite@*/
|
||||
static void
|
||||
expandMacroTable(MacroContext mc)
|
||||
/*@modifies mc @*/
|
||||
{
|
||||
if (mc->macroTable == NULL) {
|
||||
mc->macrosAllocated = MACRO_CHUNK_SIZE;
|
||||
|
@ -172,7 +151,6 @@ expandMacroTable(MacroContext mc)
|
|||
}
|
||||
memset(&mc->macroTable[mc->firstFree], 0, MACRO_CHUNK_SIZE * sizeof(*(mc->macroTable)));
|
||||
}
|
||||
/*@=boundswrite@*/
|
||||
|
||||
/**
|
||||
* Sort entries in macro table.
|
||||
|
@ -180,7 +158,6 @@ expandMacroTable(MacroContext mc)
|
|||
*/
|
||||
static void
|
||||
sortMacroTable(MacroContext mc)
|
||||
/*@modifies mc @*/
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -239,23 +216,17 @@ rpmDumpMacroTable(MacroContext mc, FILE * fp)
|
|||
* @param namelen no. of bytes
|
||||
* @return address of slot in macro table with name (or NULL)
|
||||
*/
|
||||
/*@-boundswrite@*/
|
||||
/*@dependent@*/ /*@null@*/
|
||||
static MacroEntry *
|
||||
findEntry(MacroContext mc, const char * name, size_t namelen)
|
||||
/*@*/
|
||||
{
|
||||
MacroEntry key, *ret;
|
||||
struct MacroEntry_s keybuf;
|
||||
char *namebuf = NULL;
|
||||
|
||||
/*@-globs@*/
|
||||
if (mc == NULL) mc = rpmGlobalMacroContext;
|
||||
/*@=globs@*/
|
||||
if (mc->macroTable == NULL || mc->firstFree == 0)
|
||||
return NULL;
|
||||
|
||||
/*@-branchstate@*/
|
||||
if (namelen > 0) {
|
||||
namebuf = alloca(namelen + 1);
|
||||
memset(namebuf, 0, (namelen + 1));
|
||||
|
@ -263,19 +234,15 @@ findEntry(MacroContext mc, const char * name, size_t namelen)
|
|||
namebuf[namelen] = '\0';
|
||||
name = namebuf;
|
||||
}
|
||||
/*@=branchstate@*/
|
||||
|
||||
key = &keybuf;
|
||||
memset(key, 0, sizeof(*key));
|
||||
/*@-temptrans -assignexpose@*/
|
||||
key->name = (char *)name;
|
||||
/*@=temptrans =assignexpose@*/
|
||||
ret = (MacroEntry *) bsearch(&key, mc->macroTable, mc->firstFree,
|
||||
sizeof(*(mc->macroTable)), compareMacroName);
|
||||
/* XXX TODO: find 1st empty slot and return that */
|
||||
return ret;
|
||||
}
|
||||
/*@=boundswrite@*/
|
||||
|
||||
/* =============================================================== */
|
||||
|
||||
|
@ -286,12 +253,8 @@ findEntry(MacroContext mc, const char * name, size_t namelen)
|
|||
* @param fd file handle
|
||||
* @return buffer, or NULL on end-of-file
|
||||
*/
|
||||
/*@-boundswrite@*/
|
||||
/*@null@*/
|
||||
static char *
|
||||
rdcl(/*@returned@*/ char * buf, size_t size, FD_t fd)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies buf, fileSystem @*/
|
||||
rdcl(char * buf, size_t size, FD_t fd)
|
||||
{
|
||||
char *q = buf - 1; /* initialize just before buffer. */
|
||||
size_t nb = 0;
|
||||
|
@ -313,21 +276,21 @@ rdcl(/*@returned@*/ char * buf, size_t size, FD_t fd)
|
|||
switch (*p) {
|
||||
case '\\':
|
||||
switch (*(p+1)) {
|
||||
case '\0': /*@switchbreak@*/ break;
|
||||
default: p++; /*@switchbreak@*/ break;
|
||||
case '\0': break;
|
||||
default: p++; break;
|
||||
}
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
case '%':
|
||||
switch (*(p+1)) {
|
||||
case '{': p++, bc++; /*@switchbreak@*/ break;
|
||||
case '(': p++, pc++; /*@switchbreak@*/ break;
|
||||
case '%': p++; /*@switchbreak@*/ break;
|
||||
case '{': p++, bc++; break;
|
||||
case '(': p++, pc++; break;
|
||||
case '%': p++; break;
|
||||
}
|
||||
/*@switchbreak@*/ break;
|
||||
case '{': if (bc > 0) bc++; /*@switchbreak@*/ break;
|
||||
case '}': if (bc > 0) bc--; /*@switchbreak@*/ break;
|
||||
case '(': if (pc > 0) pc++; /*@switchbreak@*/ break;
|
||||
case ')': if (pc > 0) pc--; /*@switchbreak@*/ break;
|
||||
break;
|
||||
case '{': if (bc > 0) bc++; break;
|
||||
case '}': if (bc > 0) bc--; break;
|
||||
case '(': if (pc > 0) pc++; break;
|
||||
case ')': if (pc > 0) pc--; break;
|
||||
}
|
||||
}
|
||||
if (nb == 0 || (*q != '\\' && !bc && !pc) || *(q+1) == '\0') {
|
||||
|
@ -341,7 +304,6 @@ rdcl(/*@returned@*/ char * buf, size_t size, FD_t fd)
|
|||
} while (size > 0);
|
||||
return (nread > 0 ? buf : NULL);
|
||||
}
|
||||
/*@=boundswrite@*/
|
||||
|
||||
/**
|
||||
* Return text between pl and matching pr characters.
|
||||
|
@ -350,10 +312,8 @@ rdcl(/*@returned@*/ char * buf, size_t size, FD_t fd)
|
|||
* @param pr right char, i.e. ']', ')', '}', etc.
|
||||
* @return address of last char before pr (or NULL)
|
||||
*/
|
||||
/*@null@*/
|
||||
static const char *
|
||||
matchchar(const char * p, char pl, char pr)
|
||||
/*@*/
|
||||
{
|
||||
int lvl = 0;
|
||||
char c;
|
||||
|
@ -379,8 +339,6 @@ matchchar(const char * p, char pl, char pr)
|
|||
*/
|
||||
static void
|
||||
printMacro(MacroBuf mb, const char * s, const char * se)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies fileSystem @*/
|
||||
{
|
||||
const char *senl;
|
||||
const char *ellipsis;
|
||||
|
@ -423,8 +381,6 @@ printMacro(MacroBuf mb, const char * s, const char * se)
|
|||
*/
|
||||
static void
|
||||
printExpansion(MacroBuf mb, const char * t, const char * te)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies fileSystem @*/
|
||||
{
|
||||
const char *ellipsis;
|
||||
int choplen;
|
||||
|
@ -463,13 +419,11 @@ printExpansion(MacroBuf mb, const char * t, const char * te)
|
|||
/*@-globs@*/ /* FIX: __ctype_b */ \
|
||||
while (((_c) = *(_s)) && isblank(_c)) \
|
||||
(_s)++; \
|
||||
/*@=globs@*/
|
||||
|
||||
#define SKIPNONBLANK(_s, _c) \
|
||||
/*@-globs@*/ /* FIX: __ctype_b */ \
|
||||
while (((_c) = *(_s)) && !(isblank(_c) || iseol(_c))) \
|
||||
(_s)++; \
|
||||
/*@=globs@*/
|
||||
|
||||
#define COPYNAME(_ne, _s, _c) \
|
||||
{ SKIPBLANK(_s,_c); \
|
||||
|
@ -497,8 +451,6 @@ printExpansion(MacroBuf mb, const char * t, const char * te)
|
|||
*/
|
||||
static int
|
||||
expandT(MacroBuf mb, const char * f, size_t flen)
|
||||
/*@globals rpmGlobalMacroContext, h_errno, fileSystem@*/
|
||||
/*@modifies mb, rpmGlobalMacroContext, fileSystem @*/
|
||||
{
|
||||
char *sbuf;
|
||||
const char *s = mb->s;
|
||||
|
@ -525,8 +477,6 @@ expandT(MacroBuf mb, const char * f, size_t flen)
|
|||
*/
|
||||
static int
|
||||
expandS(MacroBuf mb, char * tbuf, size_t tbuflen)
|
||||
/*@globals rpmGlobalMacroContext, fileSystem@*/
|
||||
/*@modifies mb, *tbuf, rpmGlobalMacroContext, fileSystem @*/
|
||||
{
|
||||
const char *t = mb->t;
|
||||
size_t nb = mb->nb;
|
||||
|
@ -548,11 +498,8 @@ expandS(MacroBuf mb, char * tbuf, size_t tbuflen)
|
|||
* @param ulen no. bytes in u buffer
|
||||
* @return result of expansion
|
||||
*/
|
||||
/*@-boundswrite@*/
|
||||
static int
|
||||
expandU(MacroBuf mb, char * u, size_t ulen)
|
||||
/*@globals rpmGlobalMacroContext, h_errno, fileSystem@*/
|
||||
/*@modifies mb, *u, rpmGlobalMacroContext, fileSystem @*/
|
||||
{
|
||||
const char *s = mb->s;
|
||||
char *t = mb->t;
|
||||
|
@ -578,7 +525,6 @@ expandU(MacroBuf mb, char * u, size_t ulen)
|
|||
|
||||
return rc;
|
||||
}
|
||||
/*@=boundswrite@*/
|
||||
|
||||
/**
|
||||
* Expand output of shell command into target buffer.
|
||||
|
@ -587,11 +533,8 @@ expandU(MacroBuf mb, char * u, size_t ulen)
|
|||
* @param clen no. bytes in shell command
|
||||
* @return result of expansion
|
||||
*/
|
||||
/*@-boundswrite@*/
|
||||
static int
|
||||
doShellEscape(MacroBuf mb, const char * cmd, size_t clen)
|
||||
/*@globals rpmGlobalMacroContext, h_errno, fileSystem @*/
|
||||
/*@modifies mb, rpmGlobalMacroContext, fileSystem @*/
|
||||
{
|
||||
char pcmd[BUFSIZ];
|
||||
FILE *shf;
|
||||
|
@ -622,7 +565,6 @@ doShellEscape(MacroBuf mb, const char * cmd, size_t clen)
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
/*@=boundswrite@*/
|
||||
|
||||
/**
|
||||
* Parse (and execute) new macro definition.
|
||||
|
@ -632,10 +574,8 @@ doShellEscape(MacroBuf mb, const char * cmd, size_t clen)
|
|||
* @param expandbody should body be expanded?
|
||||
* @return address to continue parsing
|
||||
*/
|
||||
/*@dependent@*/ static const char *
|
||||
doDefine(MacroBuf mb, /*@returned@*/ const char * se, int level, int expandbody)
|
||||
/*@globals rpmGlobalMacroContext, h_errno @*/
|
||||
/*@modifies mb, rpmGlobalMacroContext @*/
|
||||
static const char *
|
||||
doDefine(MacroBuf mb, const char * se, int level, int expandbody)
|
||||
{
|
||||
const char *s = se;
|
||||
char buf[BUFSIZ], *n = buf, *ne = n;
|
||||
|
@ -667,35 +607,32 @@ doDefine(MacroBuf mb, /*@returned@*/ const char * se, int level, int expandbody)
|
|||
return se;
|
||||
}
|
||||
s++; /* XXX skip { */
|
||||
/*@-boundswrite@*/
|
||||
strncpy(b, s, (se - s));
|
||||
b[se - s] = '\0';
|
||||
/*@=boundswrite@*/
|
||||
be += strlen(b);
|
||||
se++; /* XXX skip } */
|
||||
s = se; /* move scan forward */
|
||||
} else { /* otherwise free-field */
|
||||
/*@-boundswrite@*/
|
||||
int bc = 0, pc = 0;
|
||||
while (*s && (bc || pc || !iseol(*s))) {
|
||||
switch (*s) {
|
||||
case '\\':
|
||||
switch (*(s+1)) {
|
||||
case '\0': /*@switchbreak@*/ break;
|
||||
default: s++; /*@switchbreak@*/ break;
|
||||
case '\0': break;
|
||||
default: s++; break;
|
||||
}
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
case '%':
|
||||
switch (*(s+1)) {
|
||||
case '{': *be++ = *s++; bc++; /*@switchbreak@*/ break;
|
||||
case '(': *be++ = *s++; pc++; /*@switchbreak@*/ break;
|
||||
case '%': *be++ = *s++; /*@switchbreak@*/ break;
|
||||
case '{': *be++ = *s++; bc++; break;
|
||||
case '(': *be++ = *s++; pc++; break;
|
||||
case '%': *be++ = *s++; break;
|
||||
}
|
||||
/*@switchbreak@*/ break;
|
||||
case '{': if (bc > 0) bc++; /*@switchbreak@*/ break;
|
||||
case '}': if (bc > 0) bc--; /*@switchbreak@*/ break;
|
||||
case '(': if (pc > 0) pc++; /*@switchbreak@*/ break;
|
||||
case ')': if (pc > 0) pc--; /*@switchbreak@*/ break;
|
||||
break;
|
||||
case '{': if (bc > 0) bc++; break;
|
||||
case '}': if (bc > 0) bc--; break;
|
||||
case '(': if (pc > 0) pc++; break;
|
||||
case ')': if (pc > 0) pc--; break;
|
||||
}
|
||||
*be++ = *s++;
|
||||
}
|
||||
|
@ -709,12 +646,9 @@ doDefine(MacroBuf mb, /*@returned@*/ const char * se, int level, int expandbody)
|
|||
}
|
||||
|
||||
/* Trim trailing blanks/newlines */
|
||||
/*@-globs@*/
|
||||
while (--be >= b && (c = *be) && (isblank(c) || iseol(c)))
|
||||
{};
|
||||
/*@=globs@*/
|
||||
*(++be) = '\0'; /* one too far */
|
||||
/*@=boundswrite@*/
|
||||
}
|
||||
|
||||
/* Move scan over body */
|
||||
|
@ -740,12 +674,10 @@ doDefine(MacroBuf mb, /*@returned@*/ const char * se, int level, int expandbody)
|
|||
return se;
|
||||
}
|
||||
|
||||
/*@-modfilesys@*/
|
||||
if (expandbody && expandU(mb, b, (&buf[sizeof(buf)] - b))) {
|
||||
rpmError(RPMERR_BADSPEC, _("Macro %%%s failed to expand\n"), n);
|
||||
return se;
|
||||
}
|
||||
/*@=modfilesys@*/
|
||||
|
||||
addMacro(mb->mc, n, o, b, (level - 1));
|
||||
|
||||
|
@ -758,10 +690,8 @@ doDefine(MacroBuf mb, /*@returned@*/ const char * se, int level, int expandbody)
|
|||
* @param se macro name to undefine
|
||||
* @return address to continue parsing
|
||||
*/
|
||||
/*@dependent@*/ static const char *
|
||||
doUndefine(MacroContext mc, /*@returned@*/ const char * se)
|
||||
/*@globals rpmGlobalMacroContext @*/
|
||||
/*@modifies mc, rpmGlobalMacroContext @*/
|
||||
static const char *
|
||||
doUndefine(MacroContext mc, const char * se)
|
||||
{
|
||||
const char *s = se;
|
||||
char buf[BUFSIZ], *n = buf, *ne = n;
|
||||
|
@ -789,8 +719,6 @@ doUndefine(MacroContext mc, /*@returned@*/ const char * se)
|
|||
#ifdef DYING
|
||||
static void
|
||||
dumpME(const char * msg, MacroEntry me)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies fileSystem @*/
|
||||
{
|
||||
if (msg)
|
||||
fprintf(stderr, "%s", msg);
|
||||
|
@ -811,30 +739,23 @@ dumpME(const char * msg, MacroEntry me)
|
|||
* @param level macro recursion level
|
||||
*/
|
||||
static void
|
||||
pushMacro(/*@out@*/ MacroEntry * mep,
|
||||
const char * n, /*@null@*/ const char * o,
|
||||
/*@null@*/ const char * b, int level)
|
||||
/*@modifies *mep @*/
|
||||
pushMacro(MacroEntry * mep,
|
||||
const char * n, const char * o,
|
||||
const char * b, int level)
|
||||
{
|
||||
MacroEntry prev = (mep && *mep ? *mep : NULL);
|
||||
MacroEntry me = (MacroEntry) xmalloc(sizeof(*me));
|
||||
|
||||
/*@-assignexpose@*/
|
||||
me->prev = prev;
|
||||
/*@=assignexpose@*/
|
||||
me->name = (prev ? prev->name : xstrdup(n));
|
||||
me->opts = (o ? xstrdup(o) : NULL);
|
||||
me->body = xstrdup(b ? b : "");
|
||||
me->used = 0;
|
||||
me->level = level;
|
||||
/*@-boundswrite@*/
|
||||
/*@-branchstate@*/
|
||||
if (mep)
|
||||
*mep = me;
|
||||
else
|
||||
me = _free(me);
|
||||
/*@=branchstate@*/
|
||||
/*@=boundswrite@*/
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -843,24 +764,17 @@ pushMacro(/*@out@*/ MacroEntry * mep,
|
|||
*/
|
||||
static void
|
||||
popMacro(MacroEntry * mep)
|
||||
/*@modifies *mep @*/
|
||||
{
|
||||
MacroEntry me = (*mep ? *mep : NULL);
|
||||
|
||||
/*@-branchstate@*/
|
||||
if (me) {
|
||||
/* XXX cast to workaround const */
|
||||
/*@-onlytrans@*/
|
||||
/*@-boundswrite@*/
|
||||
if ((*mep = me->prev) == NULL)
|
||||
me->name = _free(me->name);
|
||||
/*@=boundswrite@*/
|
||||
me->opts = _free(me->opts);
|
||||
me->body = _free(me->body);
|
||||
me = _free(me);
|
||||
/*@=onlytrans@*/
|
||||
}
|
||||
/*@=branchstate@*/
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -869,7 +783,6 @@ popMacro(MacroEntry * mep)
|
|||
*/
|
||||
static void
|
||||
freeArgs(MacroBuf mb)
|
||||
/*@modifies mb @*/
|
||||
{
|
||||
MacroContext mc = mb->mc;
|
||||
int ndeleted = 0;
|
||||
|
@ -918,12 +831,9 @@ freeArgs(MacroBuf mb)
|
|||
* @param lastc stop parsing at lastc
|
||||
* @return address to continue parsing
|
||||
*/
|
||||
/*@-bounds@*/
|
||||
/*@dependent@*/ static const char *
|
||||
grabArgs(MacroBuf mb, const MacroEntry me, /*@returned@*/ const char * se,
|
||||
static const char *
|
||||
grabArgs(MacroBuf mb, const MacroEntry me, const char * se,
|
||||
const char * lastc)
|
||||
/*@globals rpmGlobalMacroContext @*/
|
||||
/*@modifies mb, rpmGlobalMacroContext @*/
|
||||
{
|
||||
char buf[BUFSIZ], *b, *be;
|
||||
char aname[16];
|
||||
|
@ -943,12 +853,10 @@ grabArgs(MacroBuf mb, const MacroEntry me, /*@returned@*/ const char * se,
|
|||
/* Copy args into buf until lastc */
|
||||
*be++ = ' ';
|
||||
while ((c = *se++) != '\0' && (se-1) != lastc) {
|
||||
/*@-globs@*/
|
||||
if (!isblank(c)) {
|
||||
*be++ = c;
|
||||
continue;
|
||||
}
|
||||
/*@=globs@*/
|
||||
/* c is blank */
|
||||
if (be[-1] == ' ')
|
||||
continue;
|
||||
|
@ -1007,9 +915,7 @@ grabArgs(MacroBuf mb, const MacroEntry me, /*@returned@*/ const char * se,
|
|||
/* 1003.2 says this must be 1 before any call. */
|
||||
|
||||
#ifdef __GLIBC__
|
||||
/*@-mods@*/
|
||||
optind = 0; /* XXX but posix != glibc */
|
||||
/*@=mods@*/
|
||||
#else
|
||||
optind = 1;
|
||||
#endif
|
||||
|
@ -1017,9 +923,8 @@ grabArgs(MacroBuf mb, const MacroEntry me, /*@returned@*/ const char * se,
|
|||
opts = me->opts;
|
||||
|
||||
/* Define option macros. */
|
||||
/*@-nullstate@*/ /* FIX: argv[] can be NULL */
|
||||
/* FIX: argv[] can be NULL */
|
||||
while((c = getopt(argc, (char **)argv, opts)) != -1)
|
||||
/*@=nullstate@*/
|
||||
{
|
||||
if (c == '?' || (o = strchr(opts, c)) == NULL) {
|
||||
rpmError(RPMERR_BADSPEC, _("Unknown option %c in %s(%s)\n"),
|
||||
|
@ -1053,9 +958,8 @@ grabArgs(MacroBuf mb, const MacroEntry me, /*@returned@*/ const char * se,
|
|||
sprintf(aname, "%d", (c - optind + 1));
|
||||
addMacro(mb->mc, aname, NULL, argv[c], mb->depth);
|
||||
if (be != b) *be++ = ' '; /* Add space between args */
|
||||
/*@-nullpass@*/ /* FIX: argv[] can be NULL */
|
||||
/* FIX: argv[] can be NULL */
|
||||
be = stpcpy(be, argv[c]);
|
||||
/*@=nullpass@*/
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1064,7 +968,6 @@ grabArgs(MacroBuf mb, const MacroEntry me, /*@returned@*/ const char * se,
|
|||
|
||||
return se;
|
||||
}
|
||||
/*@=bounds@*/
|
||||
|
||||
/**
|
||||
* Perform macro message output
|
||||
|
@ -1075,8 +978,6 @@ grabArgs(MacroBuf mb, const MacroEntry me, /*@returned@*/ const char * se,
|
|||
*/
|
||||
static void
|
||||
doOutput(MacroBuf mb, int waserror, const char * msg, size_t msglen)
|
||||
/*@globals rpmGlobalMacroContext, h_errno, fileSystem @*/
|
||||
/*@modifies mb, rpmGlobalMacroContext, fileSystem @*/
|
||||
{
|
||||
char buf[BUFSIZ];
|
||||
|
||||
|
@ -1104,9 +1005,7 @@ doOutput(MacroBuf mb, int waserror, const char * msg, size_t msglen)
|
|||
*/
|
||||
static void
|
||||
doFoo(MacroBuf mb, int negate, const char * f, size_t fn,
|
||||
/*@null@*/ const char * g, size_t gn)
|
||||
/*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
|
||||
/*@modifies mb, rpmGlobalMacroContext, fileSystem, internalState @*/
|
||||
const char * g, size_t gn)
|
||||
{
|
||||
char buf[BUFSIZ], *b = NULL, *be;
|
||||
int c;
|
||||
|
@ -1145,17 +1044,13 @@ doFoo(MacroBuf mb, int negate, const char * f, size_t fn,
|
|||
b = (rpmIsVerbose() ? buf : NULL);
|
||||
} else if (STREQ("url2path", f, fn) || STREQ("u2p", f, fn)) {
|
||||
(void)urlPath(buf, (const char **)&b);
|
||||
/*@-branchstate@*/
|
||||
if (*b == '\0') b = "/";
|
||||
/*@=branchstate@*/
|
||||
} else if (STREQ("uncompress", f, fn)) {
|
||||
rpmCompressedMagic compressed = COMPRESSED_OTHER;
|
||||
/*@-globs@*/
|
||||
for (b = buf; (c = *b) && isblank(c);)
|
||||
b++;
|
||||
for (be = b; (c = *be) && !isblank(c);)
|
||||
be++;
|
||||
/*@=globs@*/
|
||||
*be++ = '\0';
|
||||
#ifndef DEBUG_MACROS
|
||||
(void) isCompressed(b, &compressed);
|
||||
|
@ -1237,7 +1132,6 @@ expandMacro(MacroBuf mb)
|
|||
return 1;
|
||||
}
|
||||
|
||||
/*@-branchstate@*/
|
||||
while (rc == 0 && mb->nb > 0 && (c = *s) != '\0') {
|
||||
s++;
|
||||
/* Copy text until next macro */
|
||||
|
@ -1245,14 +1139,13 @@ expandMacro(MacroBuf mb)
|
|||
case '%':
|
||||
if (*s) { /* Ensure not end-of-string. */
|
||||
if (*s != '%')
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
s++; /* skip first % in %% */
|
||||
}
|
||||
/*@fallthrough@*/
|
||||
default:
|
||||
SAVECHAR(mb, c);
|
||||
continue;
|
||||
/*@notreached@*/ /*@switchbreak@*/ break;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Expand next macro */
|
||||
|
@ -1269,10 +1162,10 @@ expandMacro(MacroBuf mb)
|
|||
switch(*s++) {
|
||||
case '!':
|
||||
negate = ((negate + 1) % 2);
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
case '?':
|
||||
chkexist++;
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
f = se = s;
|
||||
|
@ -1285,21 +1178,19 @@ expandMacro(MacroBuf mb)
|
|||
case '*':
|
||||
se++;
|
||||
if (*se == '*') se++;
|
||||
/*@innerbreak@*/ break;
|
||||
break;
|
||||
case '#':
|
||||
se++;
|
||||
/*@innerbreak@*/ break;
|
||||
break;
|
||||
default:
|
||||
/*@innerbreak@*/ break;
|
||||
break;
|
||||
}
|
||||
fe = se;
|
||||
/* For "%name " macros ... */
|
||||
/*@-globs@*/
|
||||
if ((c = *fe) && isblank(c))
|
||||
if ((lastc = strchr(fe,'\n')) == NULL)
|
||||
lastc = strchr(fe, '\0');
|
||||
/*@=globs@*/
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
case '(': /* %(...) shell escape */
|
||||
if ((se = matchchar(s, c, ')')) == NULL) {
|
||||
rpmError(RPMERR_BADSPEC,
|
||||
|
@ -1316,7 +1207,7 @@ expandMacro(MacroBuf mb)
|
|||
|
||||
s = se;
|
||||
continue;
|
||||
/*@notreached@*/ /*@switchbreak@*/ break;
|
||||
break;
|
||||
case '{': /* %{...}/%{...:...} substitution */
|
||||
if ((se = matchchar(s, c, '}')) == NULL) {
|
||||
rpmError(RPMERR_BADSPEC,
|
||||
|
@ -1330,10 +1221,10 @@ expandMacro(MacroBuf mb)
|
|||
switch(*f++) {
|
||||
case '!':
|
||||
negate = ((negate + 1) % 2);
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
case '?':
|
||||
chkexist++;
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (fe = f; (c = *fe) && !strchr(" :}", c);)
|
||||
|
@ -1342,14 +1233,14 @@ expandMacro(MacroBuf mb)
|
|||
case ':':
|
||||
g = fe + 1;
|
||||
ge = se - 1;
|
||||
/*@innerbreak@*/ break;
|
||||
break;
|
||||
case ' ':
|
||||
lastc = se-1;
|
||||
/*@innerbreak@*/ break;
|
||||
break;
|
||||
default:
|
||||
/*@innerbreak@*/ break;
|
||||
break;
|
||||
}
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
}
|
||||
|
||||
/* XXX Everything below expects fe > f */
|
||||
|
@ -1456,9 +1347,8 @@ expandMacro(MacroBuf mb)
|
|||
STREQ("S", f, fn) ||
|
||||
STREQ("P", f, fn) ||
|
||||
STREQ("F", f, fn)) {
|
||||
/*@-internalglobs@*/ /* FIX: verbose may be set */
|
||||
/* FIX: verbose may be set */
|
||||
doFoo(mb, negate, f, fn, g, gn);
|
||||
/*@=internalglobs@*/
|
||||
s = se;
|
||||
continue;
|
||||
}
|
||||
|
@ -1550,7 +1440,6 @@ expandMacro(MacroBuf mb)
|
|||
|
||||
s = se;
|
||||
}
|
||||
/*@=branchstate@*/
|
||||
|
||||
*mb->t = '\0';
|
||||
mb->s = s;
|
||||
|
@ -1569,10 +1458,8 @@ expandMacro(MacroBuf mb)
|
|||
|
||||
#define POPT_ARGV_ARRAY_GROW_DELTA 5
|
||||
|
||||
/*@-boundswrite@*/
|
||||
static int XpoptDupArgv(int argc, const char **argv,
|
||||
int * argcPtr, const char *** argvPtr)
|
||||
/*@modifies *argcPtr, *argvPtr @*/
|
||||
{
|
||||
size_t nb = (argc + 1) * sizeof(*argv);
|
||||
const char ** argv2;
|
||||
|
@ -1593,12 +1480,10 @@ static int XpoptDupArgv(int argc, const char **argv,
|
|||
argv2 = (void *) dst;
|
||||
dst += (argc + 1) * sizeof(*argv);
|
||||
|
||||
/*@-branchstate@*/
|
||||
for (i = 0; i < argc; i++) {
|
||||
argv2[i] = dst;
|
||||
dst += strlen(strcpy(dst, argv[i])) + 1;
|
||||
}
|
||||
/*@=branchstate@*/
|
||||
argv2[argc] = NULL;
|
||||
|
||||
if (argvPtr) {
|
||||
|
@ -1611,11 +1496,8 @@ static int XpoptDupArgv(int argc, const char **argv,
|
|||
*argcPtr = argc;
|
||||
return 0;
|
||||
}
|
||||
/*@=boundswrite@*/
|
||||
|
||||
/*@-bounds@*/
|
||||
static int XpoptParseArgvString(const char * s, int * argcPtr, const char *** argvPtr)
|
||||
/*@modifies *argcPtr, *argvPtr @*/
|
||||
{
|
||||
const char * src;
|
||||
char quote = '\0';
|
||||
|
@ -1656,17 +1538,16 @@ static int XpoptParseArgvString(const char * s, int * argcPtr, const char *** ar
|
|||
case '"':
|
||||
case '\'':
|
||||
quote = *src;
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
case '\\':
|
||||
src++;
|
||||
if (!*src) {
|
||||
rc = POPT_ERROR_BADQUOTE;
|
||||
goto exit;
|
||||
}
|
||||
/*@fallthrough@*/
|
||||
default:
|
||||
*buf++ = *src;
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1680,9 +1561,7 @@ exit:
|
|||
if (argv) free(argv);
|
||||
return rc;
|
||||
}
|
||||
/*@=bounds@*/
|
||||
/* =============================================================== */
|
||||
/*@unchecked@*/
|
||||
static int _debug = 0;
|
||||
|
||||
int rpmGlob(const char * patterns, int * argcPtr, const char *** argvPtr)
|
||||
|
@ -1705,14 +1584,12 @@ int rpmGlob(const char * patterns, int * argcPtr, const char *** argvPtr)
|
|||
if (rc)
|
||||
return rc;
|
||||
#ifdef ENABLE_NLS
|
||||
/*@-branchstate@*/
|
||||
t = setlocale(LC_COLLATE, NULL);
|
||||
if (t)
|
||||
old_collate = xstrdup(t);
|
||||
t = setlocale(LC_CTYPE, NULL);
|
||||
if (t)
|
||||
old_ctype = xstrdup(t);
|
||||
/*@=branchstate@*/
|
||||
(void) setlocale(LC_COLLATE, "C");
|
||||
(void) setlocale(LC_CTYPE, "C");
|
||||
#endif
|
||||
|
@ -1755,14 +1632,14 @@ fprintf(stderr, "*** rpmGlob argv[%d] \"%s\"\n", argc, argv[argc]);
|
|||
case URL_IS_PATH:
|
||||
case URL_IS_DASH:
|
||||
strncpy(globRoot, av[j], nb);
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
case URL_IS_HTTPS:
|
||||
case URL_IS_HTTP:
|
||||
case URL_IS_FTP:
|
||||
case URL_IS_HKP:
|
||||
case URL_IS_UNKNOWN:
|
||||
default:
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
}
|
||||
globRoot += nb;
|
||||
*globRoot = '\0';
|
||||
|
@ -1781,9 +1658,7 @@ if (_debug)
|
|||
fprintf(stderr, "*** rpmGlob argv[%d] \"%s\"\n", argc, globURL);
|
||||
argv[argc++] = xstrdup(globURL);
|
||||
}
|
||||
/*@-immediatetrans@*/
|
||||
Globfree(&gl);
|
||||
/*@=immediatetrans@*/
|
||||
globURL = _free(globURL);
|
||||
}
|
||||
|
||||
|
@ -1800,7 +1675,6 @@ fprintf(stderr, "*** rpmGlob argv[%d] \"%s\"\n", argc, globURL);
|
|||
|
||||
exit:
|
||||
#ifdef ENABLE_NLS
|
||||
/*@-branchstate@*/
|
||||
if (old_collate) {
|
||||
(void) setlocale(LC_COLLATE, old_collate);
|
||||
old_collate = _free(old_collate);
|
||||
|
@ -1809,19 +1683,14 @@ exit:
|
|||
(void) setlocale(LC_CTYPE, old_ctype);
|
||||
old_ctype = _free(old_ctype);
|
||||
}
|
||||
/*@=branchstate@*/
|
||||
#endif
|
||||
av = _free(av);
|
||||
/*@-branchstate@*/
|
||||
if (rc || argvPtr == NULL) {
|
||||
/*@-dependenttrans -unqualifiedtrans@*/
|
||||
if (argv != NULL)
|
||||
for (i = 0; i < argc; i++)
|
||||
argv[i] = _free(argv[i]);
|
||||
argv = _free(argv);
|
||||
/*@=dependenttrans =unqualifiedtrans@*/
|
||||
}
|
||||
/*@=branchstate@*/
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -1903,7 +1772,7 @@ delMacro(MacroContext mc, const char * n)
|
|||
}
|
||||
}
|
||||
|
||||
/*@-mustmod@*/ /* LCL: mc is modified through mb->mc, mb is abstract */
|
||||
/* LCL: mc is modified through mb->mc, mb is abstract */
|
||||
int
|
||||
rpmDefineMacro(MacroContext mc, const char * macro, int level)
|
||||
{
|
||||
|
@ -1915,7 +1784,6 @@ rpmDefineMacro(MacroContext mc, const char * macro, int level)
|
|||
(void) doDefine(mb, macro, level, 0);
|
||||
return 0;
|
||||
}
|
||||
/*@=mustmod@*/
|
||||
|
||||
void
|
||||
rpmLoadMacros(MacroContext mc, int level)
|
||||
|
@ -1951,9 +1819,7 @@ rpmLoadMacroFile(MacroContext mc, const char * fn)
|
|||
}
|
||||
|
||||
/* XXX Assume new fangled macro expansion */
|
||||
/*@-mods@*/
|
||||
max_macro_depth = 16;
|
||||
/*@=mods@*/
|
||||
|
||||
buf[0] = '\0';
|
||||
while(rdcl(buf, sizeof(buf), fd) != NULL) {
|
||||
|
@ -1991,7 +1857,7 @@ rpmInitMacros(MacroContext mc, const char * macrofiles)
|
|||
for (me = m; (me = strchr(me, ':')) != NULL; me++) {
|
||||
/* Skip over URI's. */
|
||||
if (!(me[1] == '/' && me[2] == '/'))
|
||||
/*@innerbreak@*/ break;
|
||||
break;
|
||||
}
|
||||
|
||||
if (me && *me == ':')
|
||||
|
@ -2021,12 +1887,9 @@ rpmInitMacros(MacroContext mc, const char * macrofiles)
|
|||
mfiles = _free(mfiles);
|
||||
|
||||
/* Reload cmdline macros */
|
||||
/*@-mods@*/
|
||||
rpmLoadMacros(rpmCLIMacroContext, RMIL_CMDLINE);
|
||||
/*@=mods@*/
|
||||
}
|
||||
|
||||
/*@-globstate@*/
|
||||
void
|
||||
rpmFreeMacros(MacroContext mc)
|
||||
{
|
||||
|
@ -2039,10 +1902,8 @@ rpmFreeMacros(MacroContext mc)
|
|||
MacroEntry me;
|
||||
while ((me = mc->macroTable[i]) != NULL) {
|
||||
/* XXX cast to workaround const */
|
||||
/*@-onlytrans@*/
|
||||
if ((mc->macroTable[i] = me->prev) == NULL)
|
||||
me->name = _free(me->name);
|
||||
/*@=onlytrans@*/
|
||||
me->opts = _free(me->opts);
|
||||
me->body = _free(me->body);
|
||||
me = _free(me);
|
||||
|
@ -2052,7 +1913,6 @@ rpmFreeMacros(MacroContext mc)
|
|||
}
|
||||
memset(mc, 0, sizeof(*mc));
|
||||
}
|
||||
/*@=globstate@*/
|
||||
|
||||
/* =============================================================== */
|
||||
int isCompressed(const char * file, rpmCompressedMagic * compressed)
|
||||
|
@ -2105,7 +1965,6 @@ int isCompressed(const char * file, rpmCompressedMagic * compressed)
|
|||
|
||||
/* =============================================================== */
|
||||
|
||||
/*@-modfilesys@*/
|
||||
char *
|
||||
rpmExpand(const char *arg, ...)
|
||||
{
|
||||
|
@ -2127,7 +1986,6 @@ rpmExpand(const char *arg, ...)
|
|||
(void) expandMacros(NULL, NULL, buf, sizeof(buf));
|
||||
return xstrdup(buf);
|
||||
}
|
||||
/*@=modfilesys@*/
|
||||
|
||||
int
|
||||
rpmExpandNumeric(const char *arg)
|
||||
|
@ -2175,10 +2033,10 @@ char *rpmCleanPath(char * path)
|
|||
if (s[1] == '/' && s[2] == '/') {
|
||||
*t++ = *s++;
|
||||
*t++ = *s++;
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
}
|
||||
begin=1;
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
case '/':
|
||||
/* Move parent dir forward */
|
||||
for (se = te + 1; se < t && *se != '/'; se++)
|
||||
|
@ -2191,7 +2049,7 @@ char *rpmCleanPath(char * path)
|
|||
s++;
|
||||
while (t > path && t[-1] == '/')
|
||||
t--;
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
case '.':
|
||||
/* Leading .. is special */
|
||||
/* Check that it is ../, so that we don't interpret */
|
||||
|
@ -2202,11 +2060,11 @@ char *rpmCleanPath(char * path)
|
|||
if (begin && s[1] == '.' && (s[2] == '/' || s[2] == '\0')) {
|
||||
/*fprintf(stderr, " leading \"..\"\n"); */
|
||||
*t++ = *s++;
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
}
|
||||
/* Single . is special */
|
||||
if (begin && s[1] == '\0') {
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
}
|
||||
/* Trim embedded ./ , trailing /. */
|
||||
if ((t[-1] == '/' && s[1] == '\0') || (t > path && t[-1] == '/' && s[1] == '/')) {
|
||||
|
@ -2225,10 +2083,10 @@ char *rpmCleanPath(char * path)
|
|||
s++;
|
||||
continue;
|
||||
}
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
default:
|
||||
begin = 0;
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
}
|
||||
*t++ = *s++;
|
||||
}
|
||||
|
@ -2266,9 +2124,7 @@ rpmGetPath(const char *path, ...)
|
|||
*te = '\0';
|
||||
}
|
||||
va_end(ap);
|
||||
/*@-modfilesys@*/
|
||||
(void) expandMacros(NULL, NULL, buf, sizeof(buf));
|
||||
/*@=modfilesys@*/
|
||||
|
||||
(void) rpmCleanPath(buf);
|
||||
return xstrdup(buf); /* XXX xstrdup has side effects. */
|
||||
|
@ -2279,12 +2135,12 @@ rpmGetPath(const char *path, ...)
|
|||
const char * rpmGenPath(const char * urlroot, const char * urlmdir,
|
||||
const char *urlfile)
|
||||
{
|
||||
/*@owned@*/ const char * xroot = rpmGetPath(urlroot, NULL);
|
||||
/*@dependent@*/ const char * root = xroot;
|
||||
/*@owned@*/ const char * xmdir = rpmGetPath(urlmdir, NULL);
|
||||
/*@dependent@*/ const char * mdir = xmdir;
|
||||
/*@owned@*/ const char * xfile = rpmGetPath(urlfile, NULL);
|
||||
/*@dependent@*/ const char * file = xfile;
|
||||
const char * xroot = rpmGetPath(urlroot, NULL);
|
||||
const char * root = xroot;
|
||||
const char * xmdir = rpmGetPath(urlmdir, NULL);
|
||||
const char * mdir = xmdir;
|
||||
const char * xfile = rpmGetPath(urlfile, NULL);
|
||||
const char * file = xfile;
|
||||
const char * result;
|
||||
const char * url = NULL;
|
||||
int nurl = 0;
|
||||
|
@ -2322,14 +2178,12 @@ if (_debug) fprintf(stderr, "*** RGP ut %d file %s nurl %d\n", ut, file, nurl);
|
|||
#endif
|
||||
}
|
||||
|
||||
/*@-branchstate@*/
|
||||
if (url && nurl > 0) {
|
||||
char *t = strncpy(alloca(nurl+1), url, nurl);
|
||||
t[nurl] = '\0';
|
||||
url = t;
|
||||
} else
|
||||
url = "";
|
||||
/*@=branchstate@*/
|
||||
|
||||
result = rpmGetPath(url, root, "/", mdir, "/", file, NULL);
|
||||
|
||||
|
@ -2423,4 +2277,3 @@ main(int argc, char *argv[])
|
|||
}
|
||||
#endif /* EVAL_MACROS */
|
||||
#endif /* DEBUG_MACROS */
|
||||
/*@=boundsread@*/
|
||||
|
|
202
rpmio/rpmdav.c
202
rpmio/rpmdav.c
|
@ -1,4 +1,3 @@
|
|||
/*@-modfilesys@*/
|
||||
/** \ingroup rpmio
|
||||
* \file rpmio/rpmdav.c
|
||||
*/
|
||||
|
@ -37,9 +36,6 @@
|
|||
#include "ugid.h"
|
||||
#include "debug.h"
|
||||
|
||||
/*@access DIR @*/
|
||||
/*@access FD_t @*/
|
||||
/*@access urlinfo @*/
|
||||
|
||||
#if 0 /* HACK: reasonable value needed. */
|
||||
#define TIMEOUT_SECS 60
|
||||
|
@ -48,7 +44,6 @@
|
|||
#endif
|
||||
|
||||
#ifdef WITH_NEON
|
||||
/*@unchecked@*/
|
||||
static int httpTimeoutSecs = TIMEOUT_SECS;
|
||||
#endif
|
||||
|
||||
|
@ -57,9 +52,8 @@ static int httpTimeoutSecs = TIMEOUT_SECS;
|
|||
* @param p memory to free
|
||||
* @retval NULL always
|
||||
*/
|
||||
/*@unused@*/ static inline /*@null@*/ void *
|
||||
_free(/*@only@*/ /*@null@*/ /*@out@*/ const void * p)
|
||||
/*@modifies p@*/
|
||||
static inline void *
|
||||
_free(const void * p)
|
||||
{
|
||||
if (p != NULL) free((void *)p);
|
||||
return NULL;
|
||||
|
@ -69,8 +63,6 @@ _free(/*@only@*/ /*@null@*/ /*@out@*/ const void * p)
|
|||
|
||||
/* =============================================================== */
|
||||
static int davFree(urlinfo u)
|
||||
/*@globals internalState @*/
|
||||
/*@modifies u, internalState @*/
|
||||
{
|
||||
if (u != NULL && u->sess != NULL) {
|
||||
u->capabilities = _free(u->capabilities);
|
||||
|
@ -84,7 +76,6 @@ static int davFree(urlinfo u)
|
|||
}
|
||||
|
||||
static void davProgress(void * userdata, off_t current, off_t total)
|
||||
/*@*/
|
||||
{
|
||||
urlinfo u = userdata;
|
||||
ne_session * sess;
|
||||
|
@ -103,11 +94,9 @@ fprintf(stderr, "*** davProgress(%p,0x%x:0x%x) sess %p u %p\n", userdata, (unsig
|
|||
|
||||
static void davNotify(void * userdata,
|
||||
ne_conn_status connstatus, const char * info)
|
||||
/*@*/
|
||||
{
|
||||
urlinfo u = userdata;
|
||||
ne_session * sess;
|
||||
/*@observer@*/
|
||||
static const char * connstates[] = {
|
||||
"namelookup",
|
||||
"connecting",
|
||||
|
@ -132,16 +121,13 @@ typedef enum {
|
|||
|
||||
u->connstatus = connstatus;
|
||||
|
||||
/*@-boundsread@*/
|
||||
if (_dav_debug < 0)
|
||||
fprintf(stderr, "*** davNotify(%p,%d,%p) sess %p u %p %s\n", userdata, connstatus, info, sess, u, connstates[ (connstatus < 4 ? connstatus : 4)]);
|
||||
/*@=boundsread@*/
|
||||
|
||||
}
|
||||
|
||||
static void davCreateRequest(ne_request * req, void * userdata,
|
||||
const char * method, const char * uri)
|
||||
/*@*/
|
||||
{
|
||||
urlinfo u = userdata;
|
||||
ne_session * sess;
|
||||
|
@ -187,7 +173,6 @@ fprintf(stderr, "-> %s\n", buf->data);
|
|||
}
|
||||
|
||||
static int davPostSend(ne_request * req, void * userdata, const ne_status * status)
|
||||
/*@*/
|
||||
{
|
||||
urlinfo u = userdata;
|
||||
ne_session * sess;
|
||||
|
@ -203,15 +188,12 @@ assert(u == ne_get_session_private(sess, "urlinfo"));
|
|||
|
||||
fd = ne_get_request_private(req, id);
|
||||
|
||||
/*@-evalorder@*/
|
||||
if (_dav_debug < 0)
|
||||
fprintf(stderr, "*** davPostSend(%p,%p,%p) sess %p %s %p %s\n", req, userdata, status, sess, id, fd, ne_get_error(sess));
|
||||
/*@=evalorder@*/
|
||||
return NE_OK;
|
||||
}
|
||||
|
||||
static void davDestroyRequest(ne_request * req, void * userdata)
|
||||
/*@*/
|
||||
{
|
||||
urlinfo u = userdata;
|
||||
ne_session * sess;
|
||||
|
@ -232,7 +214,6 @@ fprintf(stderr, "*** davDestroyRequest(%p,%p) sess %p %s %p\n", req, userdata, s
|
|||
}
|
||||
|
||||
static void davDestroySession(void * userdata)
|
||||
/*@*/
|
||||
{
|
||||
urlinfo u = userdata;
|
||||
ne_session * sess;
|
||||
|
@ -254,7 +235,6 @@ fprintf(stderr, "*** davDestroySession(%p) sess %p %s %p\n", userdata, sess, id,
|
|||
|
||||
static int
|
||||
davVerifyCert(void *userdata, int failures, const ne_ssl_certificate *cert)
|
||||
/*@*/
|
||||
{
|
||||
const char *hostname = userdata;
|
||||
|
||||
|
@ -265,8 +245,6 @@ fprintf(stderr, "*** davVerifyCert(%p,%d,%p) %s\n", userdata, failures, cert, ho
|
|||
}
|
||||
|
||||
static int davConnect(urlinfo u)
|
||||
/*@globals internalState @*/
|
||||
/*@modifies u, internalState @*/
|
||||
{
|
||||
const char * path = NULL;
|
||||
int rc;
|
||||
|
@ -286,7 +264,6 @@ static int davConnect(urlinfo u)
|
|||
/* HACK: "301 Moved Permanently" on empty subdir. */
|
||||
if (!strncmp("301 ", ne_get_error(u->sess), sizeof("301 ")-1))
|
||||
break;
|
||||
/*@fallthrough@*/
|
||||
case NE_CONNECT:
|
||||
case NE_LOOKUP:
|
||||
default:
|
||||
|
@ -304,8 +281,6 @@ fprintf(stderr, "*** Connect to %s:%d failed(%d):\n\t%s\n",
|
|||
}
|
||||
|
||||
static int davInit(const char * url, urlinfo * uret)
|
||||
/*@globals internalState @*/
|
||||
/*@modifies *uret, internalState @*/
|
||||
{
|
||||
urlinfo u = NULL;
|
||||
int rc = 0;
|
||||
|
@ -313,23 +288,20 @@ static int davInit(const char * url, urlinfo * uret)
|
|||
/*@-globs@*/ /* FIX: h_errno annoyance. */
|
||||
if (urlSplit(url, &u))
|
||||
return -1; /* XXX error returns needed. */
|
||||
/*@=globs@*/
|
||||
|
||||
if (u->url != NULL && u->sess == NULL)
|
||||
switch (u->urltype) {
|
||||
default:
|
||||
assert(u->urltype != u->urltype);
|
||||
/*@notreached@*/ break;
|
||||
break;
|
||||
case URL_IS_HTTPS:
|
||||
case URL_IS_HTTP:
|
||||
case URL_IS_HKP:
|
||||
{ ne_server_capabilities * capabilities;
|
||||
|
||||
/* HACK: oneshots should be done Somewhere Else Instead. */
|
||||
/*@-noeffect@*/
|
||||
rc = ((_dav_debug < 0) ? NE_DBG_HTTP : 0);
|
||||
ne_debug_init(stderr, rc); /* XXX oneshot? */
|
||||
/*@=noeffect@*/
|
||||
rc = ne_sock_init(); /* XXX oneshot? */
|
||||
|
||||
u->lockstore = ne_lockstore_create(); /* XXX oneshot? */
|
||||
|
@ -377,10 +349,8 @@ static int davInit(const char * url, urlinfo * uret)
|
|||
}
|
||||
|
||||
exit:
|
||||
/*@-boundswrite@*/
|
||||
if (rc == 0 && uret != NULL)
|
||||
*uret = urlLink(u, __FUNCTION__);
|
||||
/*@=boundswrite@*/
|
||||
u = urlFree(u, "urlSplit (davInit)");
|
||||
|
||||
return rc;
|
||||
|
@ -397,7 +367,6 @@ enum fetch_rtype_e {
|
|||
struct fetch_resource_s {
|
||||
struct fetch_resource_s *next;
|
||||
char *uri;
|
||||
/*@unused@*/
|
||||
char *displayname;
|
||||
enum fetch_rtype_e type;
|
||||
size_t size;
|
||||
|
@ -408,9 +377,7 @@ struct fetch_resource_s {
|
|||
int error_status; /* error status returned for this resource */
|
||||
};
|
||||
|
||||
/*@null@*/
|
||||
static void *fetch_destroy_item(/*@only@*/ struct fetch_resource_s *res)
|
||||
/*@modifies res @*/
|
||||
static void *fetch_destroy_item(struct fetch_resource_s *res)
|
||||
{
|
||||
NE_FREE(res->uri);
|
||||
NE_FREE(res->error_reason);
|
||||
|
@ -419,23 +386,18 @@ static void *fetch_destroy_item(/*@only@*/ struct fetch_resource_s *res)
|
|||
}
|
||||
|
||||
#ifdef UNUSED
|
||||
/*@null@*/
|
||||
static void *fetch_destroy_list(/*@only@*/ struct fetch_resource_s *res)
|
||||
/*@modifies res @*/
|
||||
static void *fetch_destroy_list(struct fetch_resource_s *res)
|
||||
{
|
||||
struct fetch_resource_s *next;
|
||||
/*@-branchstate@*/
|
||||
for (; res != NULL; res = next) {
|
||||
next = res->next;
|
||||
res = fetch_destroy_item(res);
|
||||
}
|
||||
/*@=branchstate@*/
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void *fetch_create_item(/*@unused@*/ void *userdata, /*@unused@*/ const char *uri)
|
||||
/*@*/
|
||||
static void *fetch_create_item(void *userdata, const char *uri)
|
||||
{
|
||||
struct fetch_resource_s * res = ne_calloc(sizeof(*res));
|
||||
return res;
|
||||
|
@ -443,11 +405,9 @@ static void *fetch_create_item(/*@unused@*/ void *userdata, /*@unused@*/ const c
|
|||
|
||||
/* =============================================================== */
|
||||
struct fetch_context_s {
|
||||
/*@relnull@*/
|
||||
struct fetch_resource_s **resrock;
|
||||
const char *uri;
|
||||
unsigned int include_target; /* Include resource at href */
|
||||
/*@refcounted@*/
|
||||
urlinfo u;
|
||||
int ac;
|
||||
int nalloced;
|
||||
|
@ -457,10 +417,7 @@ struct fetch_context_s {
|
|||
time_t * mtimes;
|
||||
};
|
||||
|
||||
/*@null@*/
|
||||
static void *fetch_destroy_context(/*@only@*/ /*@null@*/ struct fetch_context_s *ctx)
|
||||
/*@globals internalState @*/
|
||||
/*@modifies ctx, internalState @*/
|
||||
static void *fetch_destroy_context(struct fetch_context_s *ctx)
|
||||
{
|
||||
if (ctx == NULL)
|
||||
return NULL;
|
||||
|
@ -471,17 +428,12 @@ static void *fetch_destroy_context(/*@only@*/ /*@null@*/ struct fetch_context_s
|
|||
ctx->mtimes = _free(ctx->mtimes);
|
||||
ctx->u = urlFree(ctx->u, __FUNCTION__);
|
||||
ctx->uri = _free(ctx->uri);
|
||||
/*@-boundswrite@*/
|
||||
memset(ctx, 0, sizeof(*ctx));
|
||||
/*@=boundswrite@*/
|
||||
ctx = _free(ctx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*@null@*/
|
||||
static void *fetch_create_context(const char *uri)
|
||||
/*@globals internalState @*/
|
||||
/*@modifies internalState @*/
|
||||
{
|
||||
struct fetch_context_s * ctx;
|
||||
urlinfo u;
|
||||
|
@ -489,7 +441,6 @@ static void *fetch_create_context(const char *uri)
|
|||
/*@-globs@*/ /* FIX: h_errno annoyance. */
|
||||
if (urlSplit(uri, &u))
|
||||
return NULL;
|
||||
/*@=globs@*/
|
||||
|
||||
ctx = ne_calloc(sizeof(*ctx));
|
||||
ctx->uri = xstrdup(uri);
|
||||
|
@ -497,7 +448,6 @@ static void *fetch_create_context(const char *uri)
|
|||
return ctx;
|
||||
}
|
||||
|
||||
/*@unchecked@*/ /*@observer@*/
|
||||
static const ne_propname fetch_props[] = {
|
||||
{ "DAV:", "getcontentlength" },
|
||||
{ "DAV:", "getlastmodified" },
|
||||
|
@ -511,7 +461,6 @@ static const ne_propname fetch_props[] = {
|
|||
#define ELM_resourcetype (NE_PROPS_STATE_TOP + 1)
|
||||
#define ELM_collection (NE_PROPS_STATE_TOP + 2)
|
||||
|
||||
/*@unchecked@*/ /*@observer@*/
|
||||
static const struct ne_xml_idmap fetch_idmap[] = {
|
||||
{ "DAV:", "resourcetype", ELM_resourcetype },
|
||||
{ "DAV:", "collection", ELM_collection }
|
||||
|
@ -519,8 +468,7 @@ static const struct ne_xml_idmap fetch_idmap[] = {
|
|||
|
||||
static int fetch_startelm(void *userdata, int parent,
|
||||
const char *nspace, const char *name,
|
||||
/*@unused@*/ const char **atts)
|
||||
/*@*/
|
||||
const char **atts)
|
||||
{
|
||||
ne_propfind_handler *pfh = userdata;
|
||||
struct fetch_resource_s *r = ne_propfind_current_private(pfh);
|
||||
|
@ -541,7 +489,6 @@ static int fetch_startelm(void *userdata, int parent,
|
|||
|
||||
static int fetch_compare(const struct fetch_resource_s *r1,
|
||||
const struct fetch_resource_s *r2)
|
||||
/*@*/
|
||||
{
|
||||
/* Sort errors first, then collections, then alphabetically */
|
||||
if (r1->type == resr_error) {
|
||||
|
@ -565,7 +512,6 @@ static int fetch_compare(const struct fetch_resource_s *r1,
|
|||
|
||||
static void fetch_results(void *userdata, const char *uri,
|
||||
const ne_prop_result_set *set)
|
||||
/*@*/
|
||||
{
|
||||
struct fetch_context_s *ctx = userdata;
|
||||
struct fetch_resource_s *current, *previous, *newres;
|
||||
|
@ -594,20 +540,16 @@ fprintf(stderr, "==> %s skipping target resource.\n", path);
|
|||
|
||||
newres->uri = ne_strdup(path);
|
||||
|
||||
/*@-boundsread@*/
|
||||
clength = ne_propset_value(set, &fetch_props[0]);
|
||||
modtime = ne_propset_value(set, &fetch_props[1]);
|
||||
isexec = ne_propset_value(set, &fetch_props[2]);
|
||||
checkin = ne_propset_value(set, &fetch_props[4]);
|
||||
checkout = ne_propset_value(set, &fetch_props[5]);
|
||||
/*@=boundsread@*/
|
||||
|
||||
/*@-branchstate@*/
|
||||
if (clength == NULL)
|
||||
status = ne_propset_status(set, &fetch_props[0]);
|
||||
if (modtime == NULL)
|
||||
status = ne_propset_status(set, &fetch_props[1]);
|
||||
/*@=branchstate@*/
|
||||
|
||||
if (newres->type == resr_normal && status != NULL) {
|
||||
/* It's an error! */
|
||||
|
@ -663,16 +605,12 @@ fprintf(stderr, "==> %s skipping target resource.\n", path);
|
|||
if (previous) {
|
||||
previous->next = newres;
|
||||
} else {
|
||||
/*@-boundswrite@*/
|
||||
*ctx->resrock = newres;
|
||||
/*@=boundswrite@*/
|
||||
}
|
||||
newres->next = current;
|
||||
}
|
||||
|
||||
static int davFetch(const urlinfo u, struct fetch_context_s * ctx)
|
||||
/*@globals internalState @*/
|
||||
/*@modifies ctx, internalState @*/
|
||||
{
|
||||
const char * path = NULL;
|
||||
int depth = 1; /* XXX passed arg? */
|
||||
|
@ -724,9 +662,7 @@ static int davFetch(const urlinfo u, struct fetch_context_s * ctx)
|
|||
|
||||
val = ne_strndup(s, (se - s));
|
||||
|
||||
/*@-nullpass@*/
|
||||
val = ne_path_unescape(val);
|
||||
/*@=nullpass@*/
|
||||
|
||||
xx = argvAdd(&ctx->av, val);
|
||||
if (_dav_debug < 0)
|
||||
|
@ -748,21 +684,19 @@ fprintf(stderr, "*** argvAdd(%p,\"%s\")\n", &ctx->av, val);
|
|||
switch (current->type) {
|
||||
case resr_normal:
|
||||
st_mode = S_IFREG;
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
case resr_collection:
|
||||
st_mode = S_IFDIR;
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
case resr_reference:
|
||||
case resr_error:
|
||||
default:
|
||||
st_mode = 0;
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
}
|
||||
/*@-boundswrite@*/
|
||||
ctx->modes[ctx->ac] = st_mode;
|
||||
ctx->sizes[ctx->ac] = current->size;
|
||||
ctx->mtimes[ctx->ac] = current->modtime;
|
||||
/*@=boundswrite@*/
|
||||
ctx->ac++;
|
||||
|
||||
current = fetch_destroy_item(current);
|
||||
|
@ -773,8 +707,6 @@ fprintf(stderr, "*** argvAdd(%p,\"%s\")\n", &ctx->av, val);
|
|||
}
|
||||
|
||||
static int davNLST(struct fetch_context_s * ctx)
|
||||
/*@globals internalState @*/
|
||||
/*@modifies ctx, internalState @*/
|
||||
{
|
||||
urlinfo u = NULL;
|
||||
int rc;
|
||||
|
@ -792,7 +724,6 @@ static int davNLST(struct fetch_context_s * ctx)
|
|||
/* HACK: "301 Moved Permanently" on empty subdir. */
|
||||
if (!strncmp("301 ", ne_get_error(u->sess), sizeof("301 ")-1))
|
||||
break;
|
||||
/*@fallthrough@*/
|
||||
default:
|
||||
if (_dav_debug)
|
||||
fprintf(stderr, "*** Fetch from %s:%d failed:\n\t%s\n",
|
||||
|
@ -807,8 +738,7 @@ exit:
|
|||
}
|
||||
|
||||
/* =============================================================== */
|
||||
static int my_result(const char * msg, int ret, /*@null@*/ FILE * fp)
|
||||
/*@modifies *fp @*/
|
||||
static int my_result(const char * msg, int ret, FILE * fp)
|
||||
{
|
||||
/* HACK: don't print unless debugging. */
|
||||
if (_dav_debug >= 0)
|
||||
|
@ -829,7 +759,6 @@ static int my_result(const char * msg, int ret, /*@null@*/ FILE * fp)
|
|||
|
||||
#ifdef DYING
|
||||
static void hexdump(const unsigned char * buf, ssize_t len)
|
||||
/*@*/
|
||||
{
|
||||
int i;
|
||||
if (len <= 0)
|
||||
|
@ -843,8 +772,7 @@ static void hexdump(const unsigned char * buf, ssize_t len)
|
|||
}
|
||||
#endif
|
||||
|
||||
static void davAcceptRanges(void * userdata, /*@null@*/ const char * value)
|
||||
/*@modifies userdata @*/
|
||||
static void davAcceptRanges(void * userdata, const char * value)
|
||||
{
|
||||
urlinfo u = userdata;
|
||||
|
||||
|
@ -868,21 +796,17 @@ fprintf(stderr, "<- %s\n", value);
|
|||
}
|
||||
#endif
|
||||
|
||||
static void davContentLength(void * userdata, /*@null@*/ const char * value)
|
||||
/*@modifies userdata @*/
|
||||
static void davContentLength(void * userdata, const char * value)
|
||||
{
|
||||
FD_t ctrl = userdata;
|
||||
|
||||
if (!(ctrl && value)) return;
|
||||
if (_dav_debug < 0)
|
||||
fprintf(stderr, "*** fd %p Content-Length: %s\n", ctrl, value);
|
||||
/*@-unrecog@*/
|
||||
ctrl->contentLength = strtoll(value, NULL, 10);
|
||||
/*@=unrecog@*/
|
||||
}
|
||||
|
||||
static void davConnection(void * userdata, /*@null@*/ const char * value)
|
||||
/*@modifies userdata @*/
|
||||
static void davConnection(void * userdata, const char * value)
|
||||
{
|
||||
FD_t ctrl = userdata;
|
||||
|
||||
|
@ -895,8 +819,8 @@ fprintf(stderr, "*** fd %p Connection: %s\n", ctrl, value);
|
|||
ctrl->persist = 1;
|
||||
}
|
||||
|
||||
/*@-mustmod@*/ /* HACK: stash error in *str. */
|
||||
int davResp(urlinfo u, FD_t ctrl, /*@unused@*/ char *const * str)
|
||||
/* HACK: stash error in *str. */
|
||||
int davResp(urlinfo u, FD_t ctrl, char *const * str)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
|
@ -907,14 +831,11 @@ if (_dav_debug < 0)
|
|||
fprintf(stderr, "*** davResp(%p,%p,%p) sess %p req %p rc %d\n", u, ctrl, str, u->sess, ctrl->req, rc);
|
||||
|
||||
/* HACK FTPERR_NE_FOO == -NE_FOO error impedance match */
|
||||
/*@-observertrans@*/
|
||||
if (rc)
|
||||
fdSetSyserrno(ctrl, errno, ftpStrerror(-rc));
|
||||
/*@=observertrans@*/
|
||||
|
||||
return rc;
|
||||
}
|
||||
/*@=mustmod@*/
|
||||
|
||||
int davReq(FD_t ctrl, const char * httpCmd, const char * httpArg)
|
||||
{
|
||||
|
@ -933,9 +854,7 @@ fprintf(stderr, "*** davReq(%p,%s,\"%s\") entry sess %p req %p\n", ctrl, httpCmd
|
|||
|
||||
assert(u->sess != NULL);
|
||||
assert(ctrl->req == NULL);
|
||||
/*@-nullpass@*/
|
||||
ctrl->req = ne_request_create(u->sess, httpCmd, httpArg);
|
||||
/*@=nullpass@*/
|
||||
assert(ctrl->req != NULL);
|
||||
|
||||
ne_set_request_private(ctrl->req, "fd", ctrl);
|
||||
|
@ -995,9 +914,7 @@ fprintf(stderr, "*** davReq(%p,%s,\"%s\") exit sess %p req %p rc %d\n", ctrl, ht
|
|||
return 0;
|
||||
|
||||
errxit:
|
||||
/*@-observertrans@*/
|
||||
fdSetSyserrno(ctrl, errno, ftpStrerror(rc));
|
||||
/*@=observertrans@*/
|
||||
|
||||
/* HACK balance fd refs. ne_session_destroy to tear down non-keepalive? */
|
||||
ctrl = fdLink(ctrl, "error data (davReq)");
|
||||
|
@ -1005,8 +922,8 @@ errxit:
|
|||
return rc;
|
||||
}
|
||||
|
||||
FD_t davOpen(const char * url, /*@unused@*/ int flags,
|
||||
/*@unused@*/ mode_t mode, /*@out@*/ urlinfo * uret)
|
||||
FD_t davOpen(const char * url, int flags,
|
||||
mode_t mode, urlinfo * uret)
|
||||
{
|
||||
const char * path = NULL;
|
||||
urltype urlType = urlPath(url, &path);
|
||||
|
@ -1048,16 +965,12 @@ assert(urlType == URL_IS_HTTPS || urlType == URL_IS_HTTP || urlType == URL_IS_HK
|
|||
}
|
||||
|
||||
exit:
|
||||
/*@-boundswrite@*/
|
||||
if (uret)
|
||||
*uret = u;
|
||||
/*@=boundswrite@*/
|
||||
/*@-refcounttrans@*/
|
||||
return fd;
|
||||
/*@=refcounttrans@*/
|
||||
}
|
||||
|
||||
ssize_t davRead(void * cookie, /*@out@*/ char * buf, size_t count)
|
||||
ssize_t davRead(void * cookie, char * buf, size_t count)
|
||||
{
|
||||
FD_t fd = cookie;
|
||||
ssize_t rc;
|
||||
|
@ -1114,7 +1027,7 @@ hexdump(buf, count);
|
|||
return rc;
|
||||
}
|
||||
|
||||
int davSeek(void * cookie, /*@unused@*/ _libio_pos_t pos, int whence)
|
||||
int davSeek(void * cookie, _libio_pos_t pos, int whence)
|
||||
{
|
||||
if (_dav_debug < 0)
|
||||
fprintf(stderr, "*** davSeek(%p,pos,%d)\n", cookie, whence);
|
||||
|
@ -1124,9 +1037,7 @@ fprintf(stderr, "*** davSeek(%p,pos,%d)\n", cookie, whence);
|
|||
/*@-mustmod@*/ /* HACK: fd->req is modified. */
|
||||
int davClose(void * cookie)
|
||||
{
|
||||
/*@-onlytrans@*/
|
||||
FD_t fd = cookie;
|
||||
/*@=onlytrans@*/
|
||||
int rc;
|
||||
|
||||
assert(fd->req != NULL);
|
||||
|
@ -1140,7 +1051,6 @@ if (_dav_debug < 0)
|
|||
fprintf(stderr, "*** davClose(%p) rc %d\n", fd, rc);
|
||||
return rc;
|
||||
}
|
||||
/*@=mustmod@*/
|
||||
|
||||
/* =============================================================== */
|
||||
int davMkdir(const char * path, mode_t mode)
|
||||
|
@ -1244,8 +1154,6 @@ fprintf(stderr, "*** davUnlink(%s) rc %d\n", path, rc);
|
|||
|
||||
#ifdef NOTYET
|
||||
static int davChdir(const char * path)
|
||||
/*@globals h_errno, fileSystem, internalState @*/
|
||||
/*@modifies fileSystem, internalState @*/
|
||||
{
|
||||
return davCommand("CWD", path, NULL);
|
||||
}
|
||||
|
@ -1254,8 +1162,7 @@ static int davChdir(const char * path)
|
|||
/* =============================================================== */
|
||||
|
||||
static const char * statstr(const struct stat * st,
|
||||
/*@returned@*/ /*@out@*/ char * buf)
|
||||
/*@modifies *buf @*/
|
||||
char * buf)
|
||||
{
|
||||
sprintf(buf,
|
||||
"*** dev %x ino %x mode %0o nlink %d uid %d gid %d rdev %x size %x\n",
|
||||
|
@ -1270,13 +1177,9 @@ static const char * statstr(const struct stat * st,
|
|||
return buf;
|
||||
}
|
||||
|
||||
/*@unchecked@*/
|
||||
static int dav_st_ino = 0xdead0000;
|
||||
|
||||
/*@-boundswrite@*/
|
||||
int davStat(const char * path, /*@out@*/ struct stat *st)
|
||||
/*@globals dav_st_ino, fileSystem, internalState @*/
|
||||
/*@modifies *st, dav_st_ino, fileSystem, internalState @*/
|
||||
int davStat(const char * path, struct stat *st)
|
||||
{
|
||||
struct fetch_context_s * ctx = NULL;
|
||||
char buf[1024];
|
||||
|
@ -1316,12 +1219,8 @@ exit:
|
|||
ctx = fetch_destroy_context(ctx);
|
||||
return rc;
|
||||
}
|
||||
/*@=boundswrite@*/
|
||||
|
||||
/*@-boundswrite@*/
|
||||
int davLstat(const char * path, /*@out@*/ struct stat *st)
|
||||
/*@globals dav_st_ino, fileSystem, internalState @*/
|
||||
/*@modifies *st, dav_st_ino, fileSystem, internalState @*/
|
||||
int davLstat(const char * path, struct stat *st)
|
||||
{
|
||||
struct fetch_context_s * ctx = NULL;
|
||||
char buf[1024];
|
||||
|
@ -1361,12 +1260,9 @@ exit:
|
|||
ctx = fetch_destroy_context(ctx);
|
||||
return rc;
|
||||
}
|
||||
/*@=boundswrite@*/
|
||||
|
||||
#ifdef NOTYET
|
||||
static int davReadlink(const char * path, /*@out@*/ char * buf, size_t bufsiz)
|
||||
/*@globals h_errno, fileSystem, internalState @*/
|
||||
/*@modifies *buf, fileSystem, internalState @*/
|
||||
static int davReadlink(const char * path, char * buf, size_t bufsiz)
|
||||
{
|
||||
int rc;
|
||||
rc = davNLST(path, DO_FTP_READLINK, NULL, buf, bufsiz);
|
||||
|
@ -1379,10 +1275,9 @@ fprintf(stderr, "*** davReadlink(%s) rc %d\n", path, rc);
|
|||
#endif /* WITH_NEON */
|
||||
|
||||
/* =============================================================== */
|
||||
/*@unchecked@*/
|
||||
int avmagicdir = 0x3607113;
|
||||
|
||||
int avClosedir(/*@only@*/ DIR * dir)
|
||||
int avClosedir(DIR * dir)
|
||||
{
|
||||
AVDIR avdir = (AVDIR)dir;
|
||||
|
||||
|
@ -1390,9 +1285,7 @@ if (_av_debug)
|
|||
fprintf(stderr, "*** avClosedir(%p)\n", avdir);
|
||||
|
||||
#if defined(HAVE_PTHREAD_H)
|
||||
/*@-moduncon -noeffectuncon @*/
|
||||
(void) pthread_mutex_destroy(&avdir->lock);
|
||||
/*@=moduncon =noeffectuncon @*/
|
||||
#endif
|
||||
|
||||
avdir = _free(avdir);
|
||||
|
@ -1419,15 +1312,12 @@ struct dirent * avReaddir(DIR * dir)
|
|||
dt = (unsigned char *) (av + (ac + 1));
|
||||
i = avdir->offset + 1;
|
||||
|
||||
/*@-boundsread@*/
|
||||
if (i < 0 || i >= ac || av[i] == NULL)
|
||||
return NULL;
|
||||
/*@=boundsread@*/
|
||||
|
||||
avdir->offset = i;
|
||||
|
||||
/* XXX glob(3) uses REAL_DIR_ENTRY(dp) test on d_ino */
|
||||
/*@-type@*/
|
||||
dp->d_ino = i + 1; /* W2DO? */
|
||||
dp->d_reclen = 0; /* W2DO? */
|
||||
|
||||
|
@ -1435,11 +1325,8 @@ struct dirent * avReaddir(DIR * dir)
|
|||
#if !defined(__APPLE__)
|
||||
dp->d_off = 0; /* W2DO? */
|
||||
#endif
|
||||
/*@-boundsread@*/
|
||||
dp->d_type = dt[i];
|
||||
/*@=boundsread@*/
|
||||
#endif
|
||||
/*@=type@*/
|
||||
|
||||
strncpy(dp->d_name, av[i], sizeof(dp->d_name));
|
||||
if (_av_debug)
|
||||
|
@ -1448,7 +1335,6 @@ fprintf(stderr, "*** avReaddir(%p) %p \"%s\"\n", (void *)avdir, dp, dp->d_name);
|
|||
return dp;
|
||||
}
|
||||
|
||||
/*@-boundswrite@*/
|
||||
DIR * avOpendir(const char * path)
|
||||
{
|
||||
AVDIR avdir;
|
||||
|
@ -1466,49 +1352,37 @@ fprintf(stderr, "*** avOpendir(%s)\n", path);
|
|||
|
||||
nb += sizeof(*avdir) + sizeof(*dp) + ((ac + 1) * sizeof(*av)) + (ac + 1);
|
||||
avdir = xcalloc(1, nb);
|
||||
/*@-abstract@*/
|
||||
dp = (struct dirent *) (avdir + 1);
|
||||
av = (const char **) (dp + 1);
|
||||
dt = (unsigned char *) (av + (ac + 1));
|
||||
t = (char *) (dt + ac + 1);
|
||||
/*@=abstract@*/
|
||||
|
||||
avdir->fd = avmagicdir;
|
||||
/*@-usereleased@*/
|
||||
avdir->data = (char *) dp;
|
||||
/*@=usereleased@*/
|
||||
avdir->allocation = nb;
|
||||
avdir->size = ac;
|
||||
avdir->offset = -1;
|
||||
avdir->filepos = 0;
|
||||
|
||||
#if defined(HAVE_PTHREAD_H)
|
||||
/*@-moduncon -noeffectuncon -nullpass @*/
|
||||
(void) pthread_mutex_init(&avdir->lock, NULL);
|
||||
/*@=moduncon =noeffectuncon =nullpass @*/
|
||||
#endif
|
||||
|
||||
ac = 0;
|
||||
/*@-dependenttrans -unrecog@*/
|
||||
dt[ac] = DT_DIR; av[ac++] = t; t = stpcpy(t, "."); t++;
|
||||
dt[ac] = DT_DIR; av[ac++] = t; t = stpcpy(t, ".."); t++;
|
||||
/*@=dependenttrans =unrecog@*/
|
||||
|
||||
av[ac] = NULL;
|
||||
|
||||
/*@-kepttrans@*/
|
||||
return (DIR *) avdir;
|
||||
/*@=kepttrans@*/
|
||||
}
|
||||
/*@=boundswrite@*/
|
||||
|
||||
#ifdef WITH_NEON
|
||||
|
||||
/* =============================================================== */
|
||||
/*@unchecked@*/
|
||||
int davmagicdir = 0x8440291;
|
||||
|
||||
int davClosedir(/*@only@*/ DIR * dir)
|
||||
int davClosedir(DIR * dir)
|
||||
{
|
||||
DAVDIR avdir = (DAVDIR)dir;
|
||||
|
||||
|
@ -1516,9 +1390,7 @@ if (_dav_debug < 0)
|
|||
fprintf(stderr, "*** davClosedir(%p)\n", avdir);
|
||||
|
||||
#if defined(HAVE_PTHREAD_H)
|
||||
/*@-moduncon -noeffectuncon @*/
|
||||
(void) pthread_mutex_destroy(&avdir->lock);
|
||||
/*@=moduncon =noeffectuncon @*/
|
||||
#endif
|
||||
|
||||
avdir = _free(avdir);
|
||||
|
@ -1545,15 +1417,12 @@ struct dirent * davReaddir(DIR * dir)
|
|||
dt = (unsigned char *) (av + (ac + 1));
|
||||
i = avdir->offset + 1;
|
||||
|
||||
/*@-boundsread@*/
|
||||
if (i < 0 || i >= ac || av[i] == NULL)
|
||||
return NULL;
|
||||
/*@=boundsread@*/
|
||||
|
||||
avdir->offset = i;
|
||||
|
||||
/* XXX glob(3) uses REAL_DIR_ENTRY(dp) test on d_ino */
|
||||
/*@-type@*/
|
||||
dp->d_ino = i + 1; /* W2DO? */
|
||||
dp->d_reclen = 0; /* W2DO? */
|
||||
|
||||
|
@ -1561,11 +1430,8 @@ struct dirent * davReaddir(DIR * dir)
|
|||
#if !defined(__APPLE__)
|
||||
dp->d_off = 0; /* W2DO? */
|
||||
#endif
|
||||
/*@-boundsread@*/
|
||||
dp->d_type = dt[i];
|
||||
/*@=boundsread@*/
|
||||
#endif
|
||||
/*@=type@*/
|
||||
|
||||
strncpy(dp->d_name, av[i], sizeof(dp->d_name));
|
||||
if (_dav_debug < 0)
|
||||
|
@ -1574,7 +1440,6 @@ fprintf(stderr, "*** davReaddir(%p) %p \"%s\"\n", (void *)avdir, dp, dp->d_name)
|
|||
return dp;
|
||||
}
|
||||
|
||||
/*@-boundswrite@*/
|
||||
DIR * davOpendir(const char * path)
|
||||
{
|
||||
struct fetch_context_s * ctx;
|
||||
|
@ -1589,14 +1454,12 @@ DIR * davOpendir(const char * path)
|
|||
|
||||
/* HACK: glob does not pass dirs with trailing '/' */
|
||||
nb = strlen(path)+1;
|
||||
/*@-branchstate@*/
|
||||
if (path[nb-1] != '/') {
|
||||
char * npath = alloca(nb+1);
|
||||
*npath = '\0';
|
||||
(void) stpcpy( stpcpy(npath, path), "/");
|
||||
path = npath;
|
||||
}
|
||||
/*@=branchstate@*/
|
||||
|
||||
if (_dav_debug < 0)
|
||||
fprintf(stderr, "*** davOpendir(%s)\n", path);
|
||||
|
@ -1624,33 +1487,25 @@ fprintf(stderr, "*** davOpendir(%s)\n", path);
|
|||
|
||||
nb += sizeof(*avdir) + sizeof(*dp) + ((ac + 1) * sizeof(*av)) + (ac + 1);
|
||||
avdir = xcalloc(1, nb);
|
||||
/*@-abstract@*/
|
||||
dp = (struct dirent *) (avdir + 1);
|
||||
nav = (const char **) (dp + 1);
|
||||
dt = (unsigned char *) (nav + (ac + 1));
|
||||
t = (char *) (dt + ac + 1);
|
||||
/*@=abstract@*/
|
||||
|
||||
avdir->fd = davmagicdir;
|
||||
/*@-usereleased@*/
|
||||
avdir->data = (char *) dp;
|
||||
/*@=usereleased@*/
|
||||
avdir->allocation = nb;
|
||||
avdir->size = ac;
|
||||
avdir->offset = -1;
|
||||
avdir->filepos = 0;
|
||||
|
||||
#if defined(HAVE_PTHREAD_H)
|
||||
/*@-moduncon -noeffectuncon -nullpass @*/
|
||||
(void) pthread_mutex_init(&avdir->lock, NULL);
|
||||
/*@=moduncon =noeffectuncon =nullpass @*/
|
||||
#endif
|
||||
|
||||
nac = 0;
|
||||
/*@-dependenttrans -unrecog@*/
|
||||
dt[nac] = DT_DIR; nav[nac++] = t; t = stpcpy(t, "."); t++;
|
||||
dt[nac] = DT_DIR; nav[nac++] = t; t = stpcpy(t, ".."); t++;
|
||||
/*@=dependenttrans =unrecog@*/
|
||||
|
||||
/* Copy DAV items into DIR elments. */
|
||||
ac = 0;
|
||||
|
@ -1667,10 +1522,7 @@ fprintf(stderr, "*** davOpendir(%s)\n", path);
|
|||
|
||||
ctx = fetch_destroy_context(ctx);
|
||||
|
||||
/*@-kepttrans@*/
|
||||
return (DIR *) avdir;
|
||||
/*@=kepttrans@*/
|
||||
}
|
||||
|
||||
#endif /* WITH_NEON */
|
||||
/*@=modfilesys@*/
|
||||
|
|
|
@ -37,13 +37,11 @@ typedef DIR * DAVDIR;
|
|||
|
||||
/**
|
||||
*/
|
||||
/*@unchecked@*/
|
||||
extern int avmagicdir;
|
||||
#define ISAVMAGIC(_dir) (!memcmp((_dir), &avmagicdir, sizeof(avmagicdir)))
|
||||
|
||||
/**
|
||||
*/
|
||||
/*@unchecked@*/
|
||||
extern int davmagicdir;
|
||||
#define ISDAVMAGIC(_dir) (!memcmp((_dir), &davmagicdir, sizeof(davmagicdir)))
|
||||
|
||||
|
@ -56,29 +54,21 @@ extern "C" {
|
|||
* @param dir argv DIR
|
||||
* @return 0 always
|
||||
*/
|
||||
int avClosedir(/*@only@*/ DIR * dir)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies dir, fileSystem @*/;
|
||||
int avClosedir(DIR * dir);
|
||||
|
||||
/**
|
||||
* Return next entry from an argv directory.
|
||||
* @param dir argv DIR
|
||||
* @return next entry
|
||||
*/
|
||||
/*@dependent@*/ /*@null@*/
|
||||
struct dirent * avReaddir(DIR * dir)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies fileSystem @*/;
|
||||
struct dirent * avReaddir(DIR * dir);
|
||||
|
||||
/**
|
||||
* Create an argv directory from URL collection.
|
||||
* @param path URL for collection path
|
||||
* @return argv DIR
|
||||
*/
|
||||
/*@null@*/
|
||||
DIR * avOpendir(const char * path)
|
||||
/*@globals fileSystem, internalState @*/
|
||||
/*@modifies fileSystem, internalState @*/;
|
||||
DIR * avOpendir(const char * path);
|
||||
|
||||
/**
|
||||
* Send a http request.
|
||||
|
@ -87,9 +77,7 @@ DIR * avOpendir(const char * path)
|
|||
* @param httpArg http command argument (NULL if none)
|
||||
* @returns 0 on success
|
||||
*/
|
||||
int davReq(FD_t ctrl, const char * httpCmd, /*@null@*/ const char * httpArg)
|
||||
/*@globals fileSystem, internalState @*/
|
||||
/*@modifies ctrl, fileSystem, internalState @*/;
|
||||
int davReq(FD_t ctrl, const char * httpCmd, const char * httpArg);
|
||||
|
||||
/**
|
||||
* Read a http response.
|
||||
|
@ -98,112 +86,75 @@ int davReq(FD_t ctrl, const char * httpCmd, /*@null@*/ const char * httpArg)
|
|||
* @retval *str error msg
|
||||
* @returns 0 on success
|
||||
*/
|
||||
int davResp(urlinfo u, FD_t ctrl, /*@out@*/ /*@null@*/ char *const * str)
|
||||
/*@globals fileSystem, internalState @*/
|
||||
/*@modifies ctrl, *str, fileSystem, internalState @*/;
|
||||
int davResp(urlinfo u, FD_t ctrl, char *const * str);
|
||||
|
||||
/**
|
||||
*/
|
||||
/*@null@*/
|
||||
FD_t davOpen(const char * url, /*@unused@*/ int flags,
|
||||
/*@unused@*/ mode_t mode, /*@out@*/ urlinfo * uret)
|
||||
/*@globals internalState @*/
|
||||
/*@modifies *uret, internalState @*/;
|
||||
FD_t davOpen(const char * url, int flags,
|
||||
mode_t mode, urlinfo * uret);
|
||||
|
||||
/**
|
||||
*/
|
||||
/*@-incondefs@*/
|
||||
ssize_t davRead(void * cookie, /*@out@*/ char * buf, size_t count)
|
||||
/*@globals fileSystem, internalState @*/
|
||||
/*@modifies buf, fileSystem, internalState @*/
|
||||
/*@requires maxSet(buf) >= (count - 1) @*/
|
||||
/*@ensures maxRead(buf) == result @*/;
|
||||
/*@=incondefs@*/
|
||||
ssize_t davRead(void * cookie, char * buf, size_t count);
|
||||
|
||||
/**
|
||||
*/
|
||||
ssize_t davWrite(void * cookie, const char * buf, size_t count)
|
||||
/*@globals fileSystem, internalState @*/
|
||||
/*@modifies fileSystem, internalState @*/;
|
||||
ssize_t davWrite(void * cookie, const char * buf, size_t count);
|
||||
|
||||
/**
|
||||
*/
|
||||
int davSeek(void * cookie, _libio_pos_t pos, int whence)
|
||||
/*@globals fileSystem, internalState @*/
|
||||
/*@modifies fileSystem, internalState @*/;
|
||||
int davSeek(void * cookie, _libio_pos_t pos, int whence);
|
||||
|
||||
/**
|
||||
*/
|
||||
int davClose(void * cookie)
|
||||
/*@globals fileSystem, internalState @*/
|
||||
/*@modifies cookie, fileSystem, internalState @*/;
|
||||
int davClose(void * cookie);
|
||||
|
||||
/**
|
||||
*/
|
||||
int davMkdir(const char * path, mode_t mode)
|
||||
/*@globals fileSystem, internalState @*/
|
||||
/*@modifies fileSystem, internalState @*/;
|
||||
int davMkdir(const char * path, mode_t mode);
|
||||
|
||||
/**
|
||||
*/
|
||||
int davRmdir(const char * path)
|
||||
/*@globals fileSystem, internalState @*/
|
||||
/*@modifies fileSystem, internalState @*/;
|
||||
int davRmdir(const char * path);
|
||||
|
||||
/**
|
||||
*/
|
||||
int davRename(const char * oldpath, const char * newpath)
|
||||
/*@globals fileSystem, internalState @*/
|
||||
/*@modifies fileSystem, internalState @*/;
|
||||
int davRename(const char * oldpath, const char * newpath);
|
||||
|
||||
/**
|
||||
*/
|
||||
int davUnlink(const char * path)
|
||||
/*@globals fileSystem, internalState @*/
|
||||
/*@modifies fileSystem, internalState @*/;
|
||||
int davUnlink(const char * path);
|
||||
|
||||
/**
|
||||
* Close a DAV collection.
|
||||
* @param dir argv DIR
|
||||
* @return 0 always
|
||||
*/
|
||||
int davClosedir(/*@only@*/ DIR * dir)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies dir, fileSystem @*/;
|
||||
int davClosedir(DIR * dir);
|
||||
|
||||
/**
|
||||
* Return next entry from a DAV collection.
|
||||
* @param dir argv DIR
|
||||
* @return next entry
|
||||
*/
|
||||
/*@dependent@*/ /*@null@*/
|
||||
struct dirent * davReaddir(DIR * dir)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies fileSystem @*/;
|
||||
struct dirent * davReaddir(DIR * dir);
|
||||
|
||||
/**
|
||||
* Create an argv directory from DAV collection.
|
||||
* @param path URL for DAV collection path
|
||||
* @return argv DIR
|
||||
*/
|
||||
/*@null@*/
|
||||
DIR * davOpendir(const char * path)
|
||||
/*@globals fileSystem, internalState @*/
|
||||
/*@modifies fileSystem, internalState @*/;
|
||||
DIR * davOpendir(const char * path);
|
||||
|
||||
/**
|
||||
* stat(2) clone.
|
||||
*/
|
||||
int davStat(const char * path, /*@out@*/ struct stat * st)
|
||||
/*@globals fileSystem, internalState @*/
|
||||
/*@modifies *st, fileSystem, internalState @*/;
|
||||
int davStat(const char * path, struct stat * st);
|
||||
|
||||
/**
|
||||
* lstat(2) clone.
|
||||
*/
|
||||
int davLstat(const char * path, /*@out@*/ struct stat * st)
|
||||
/*@globals fileSystem, internalState @*/
|
||||
/*@modifies *st, fileSystem, internalState @*/;
|
||||
int davLstat(const char * path, struct stat * st);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -22,20 +22,15 @@
|
|||
/**
|
||||
* Tokens used by rpmError().
|
||||
*/
|
||||
/*@-typeuse @*/
|
||||
typedef enum rpmerrCode_e {
|
||||
/*@-enummemuse@*/
|
||||
RPMERR_GDBMOPEN = _em(2), /*!< gdbm open failed */
|
||||
RPMERR_GDBMREAD = _em(3), /*!< gdbm read failed */
|
||||
RPMERR_GDBMWRITE = _em(4), /*!< gdbm write failed */
|
||||
/*@=enummemuse@*/
|
||||
RPMERR_INTERNAL = _em(5), /*!< internal RPM error */
|
||||
RPMERR_DBCORRUPT = _em(6), /*!< rpm database is corrupt */
|
||||
/*@-enummemuse@*/
|
||||
RPMERR_OLDDBCORRUPT = _em(7), /*!< old style rpm database is corrupt */
|
||||
RPMERR_OLDDBMISSING = _em(8), /*!< old style rpm database is missing */
|
||||
RPMERR_NOCREATEDB = _em(9), /*!< cannot create new database */
|
||||
/*@=enummemuse@*/
|
||||
RPMERR_DBOPEN = _em(10), /*!< database open failed */
|
||||
RPMERR_DBGETINDEX = _em(11), /*!< database get from index failed */
|
||||
RPMERR_DBPUTINDEX = _em(12), /*!< database get from index failed */
|
||||
|
@ -44,60 +39,44 @@ typedef enum rpmerrCode_e {
|
|||
RPMERR_RENAME = _em(15), /*!< rename(2) failed */
|
||||
RPMERR_UNLINK = _em(16), /*!< unlink(2) failed */
|
||||
RPMERR_RMDIR = _em(17), /*!< rmdir(2) failed */
|
||||
/*@-enummemuse@*/
|
||||
RPMERR_PKGINSTALLED = _em(18), /*!< package already installed */
|
||||
RPMERR_CHOWN = _em(19), /*!< chown() call failed */
|
||||
RPMERR_NOUSER = _em(20), /*!< user does not exist */
|
||||
RPMERR_NOGROUP = _em(21), /*!< group does not exist */
|
||||
/*@=enummemuse@*/
|
||||
RPMERR_MKDIR = _em(22), /*!< mkdir() call failed */
|
||||
/*@-enummemuse@*/
|
||||
RPMERR_FILECONFLICT = _em(23), /*!< file being installed exists */
|
||||
/*@=enummemuse@*/
|
||||
RPMERR_RPMRC = _em(24), /*!< bad line in rpmrc */
|
||||
RPMERR_NOSPEC = _em(25), /*!< .spec file is missing */
|
||||
RPMERR_NOTSRPM = _em(26), /*!< a source rpm was expected */
|
||||
/*@-enummemuse@*/
|
||||
RPMERR_FLOCK = _em(27), /*!< locking the database failed */
|
||||
RPMERR_OLDPACKAGE = _em(28), /*!< trying upgrading to old version */
|
||||
/* RPMERR_BADARCH = _em(29), bad architecture or arch mismatch */
|
||||
/*@=enummemuse@*/
|
||||
RPMERR_CREATE = _em(30), /*!< failed to create a file */
|
||||
RPMERR_NOSPACE = _em(31), /*!< out of disk space */
|
||||
/*@-enummemuse@*/
|
||||
RPMERR_NORELOCATE = _em(32), /*!< tried to do improper relocatation */
|
||||
/* RPMERR_BADOS = _em(33), bad architecture or arch mismatch */
|
||||
RPMMESS_BACKUP = _em(34), /*!< backup made during [un]install */
|
||||
/*@=enummemuse@*/
|
||||
RPMERR_MTAB = _em(35), /*!< failed to read mount table */
|
||||
RPMERR_STAT = _em(36), /*!< failed to stat something */
|
||||
RPMERR_BADDEV = _em(37), /*!< file on device not listed in mtab */
|
||||
/*@-enummemuse@*/
|
||||
RPMMESS_ALTNAME = _em(38), /*!< file written as .rpmnew */
|
||||
RPMMESS_PREREQLOOP = _em(39), /*!< loop in prerequisites */
|
||||
RPMERR_BADRELOCATE = _em(40), /*!< bad relocation was specified */
|
||||
RPMERR_OLDDB = _em(41), /*!< old format database */
|
||||
/*@=enummemuse@*/
|
||||
|
||||
RPMERR_UNMATCHEDIF = _em(107), /*!< unclosed %ifarch or %ifos */
|
||||
RPMERR_RELOAD = _em(108), /*!< */
|
||||
RPMERR_BADARG = _em(109), /*!< */
|
||||
RPMERR_SCRIPT = _em(110), /*!< errors related to script exec */
|
||||
RPMERR_READ = _em(111), /*!< */
|
||||
/*@-enummemuse@*/
|
||||
RPMERR_UNKNOWNOS = _em(112), /*!< */
|
||||
RPMERR_UNKNOWNARCH = _em(113), /*!< */
|
||||
/*@=enummemuse@*/
|
||||
RPMERR_EXEC = _em(114), /*!< */
|
||||
RPMERR_FORK = _em(115), /*!< */
|
||||
RPMERR_CPIO = _em(116), /*!< */
|
||||
/*@-enummemuse@*/
|
||||
RPMERR_GZIP = _em(117), /*!< */
|
||||
/*@=enummemuse@*/
|
||||
RPMERR_BADSPEC = _em(118), /*!< */
|
||||
/*@-enummemuse@*/
|
||||
RPMERR_LDD = _em(119), /*!< couldn't understand ldd output */
|
||||
/*@=enummemuse@*/
|
||||
RPMERR_BADFILENAME = _em(120), /*!< */
|
||||
RPMERR_OPEN = _em(121), /*!< */
|
||||
RPMERR_POPEN = _em(122), /*!< */
|
||||
|
@ -105,11 +84,9 @@ typedef enum rpmerrCode_e {
|
|||
RPMERR_QUERY = _em(124), /*!< */
|
||||
RPMERR_QFMT = _em(125), /*!< */
|
||||
RPMERR_DBCONFIG = _em(126), /*!< */
|
||||
/*@-enummemuse@*/
|
||||
RPMERR_DBERR = _em(127), /*!< */
|
||||
RPMERR_BADPACKAGE = _em(128), /*!< getNextHeader: %s */
|
||||
RPMERR_FREELIST = _em(129), /*!< free list corrupt (%u)- please ... */
|
||||
/*@=enummemuse@*/
|
||||
RPMERR_DATATYPE = _em(130), /*!< Data type %d not supported */
|
||||
RPMERR_BUILDROOT = _em(131), /*!< */
|
||||
RPMERR_MAKETEMP = _em(132), /*!< makeTempFile failed */
|
||||
|
@ -131,11 +108,8 @@ typedef enum rpmerrCode_e {
|
|||
|
||||
RPMDEBUG_UNLINK = _dm(512u+16), /*!< unlink(2) failed */
|
||||
RPMDEBUG_RMDIR = _dm(512u+17), /*!< rmdir(2) failed */
|
||||
/*@-enummemuse@*/
|
||||
RPMWARN_FLOCK = _wm(512u+27) /*!< locking the database failed */
|
||||
/*@=enummemuse@*/
|
||||
} rpmerrCode;
|
||||
/*@=typeuse @*/
|
||||
|
||||
/**
|
||||
* Retrofit rpmError() onto rpmlog sub-system.
|
||||
|
@ -144,9 +118,7 @@ typedef enum rpmerrCode_e {
|
|||
#define rpmErrorCode() rpmlogCode()
|
||||
#define rpmErrorString() rpmlogMessage()
|
||||
#define rpmErrorSetCallback(_cb) rpmlogSetCallback(_cb)
|
||||
/*@-typeuse@*/
|
||||
typedef rpmlogCallback rpmErrorCallBackType;
|
||||
/*@=typeuse@*/
|
||||
|
||||
|
||||
#endif /* H_RPMERR */
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
/*@-bounds@*/
|
||||
#include "system.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
@ -19,7 +18,6 @@ typedef struct rpmhookItem_s {
|
|||
|
||||
typedef struct rpmhookBucket_s {
|
||||
unsigned long hash;
|
||||
/*@relnull@*/
|
||||
char *name;
|
||||
rpmhookItem item;
|
||||
} * rpmhookBucket;
|
||||
|
@ -46,9 +44,7 @@ rpmhookArgs rpmhookArgsFree(rpmhookArgs args)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/*@only@*/
|
||||
static rpmhookTable rpmhookTableNew(int size)
|
||||
/*@*/
|
||||
{
|
||||
rpmhookTable table = (rpmhookTable) xcalloc(1,
|
||||
sizeof(*table) + sizeof(table->bucket) * (size-1));
|
||||
|
@ -58,7 +54,6 @@ static rpmhookTable rpmhookTableNew(int size)
|
|||
|
||||
#if 0
|
||||
static rpmhookTable rpmhookTableFree(rpmhookTable table)
|
||||
/*@*/
|
||||
{
|
||||
rpmhookItem item, nextItem;
|
||||
int i;
|
||||
|
@ -78,11 +73,9 @@ static rpmhookTable rpmhookTableFree(rpmhookTable table)
|
|||
}
|
||||
#endif
|
||||
|
||||
static void rpmhookTableRehash(rpmhookTable *table)
|
||||
/*@modifies *table @*/;
|
||||
static void rpmhookTableRehash(rpmhookTable *table);
|
||||
|
||||
static int rpmhookTableFindBucket(rpmhookTable *table, const char *name)
|
||||
/*@modifies *table @*/
|
||||
{
|
||||
/* Hash based on http://www.isthe.com/chongo/tech/comp/fnv/ */
|
||||
unsigned long perturb;
|
||||
|
@ -104,9 +97,7 @@ static int rpmhookTableFindBucket(rpmhookTable *table, const char *name)
|
|||
while (bucket->name &&
|
||||
(bucket->hash != hash || strcmp(bucket->name, name) != 0)) {
|
||||
/* Collision resolution based on Python's perturb scheme. */
|
||||
/*@-shiftimplementation@*/
|
||||
ret = ((ret << 2) + ret + perturb + 1) % (*table)->size;
|
||||
/*@=shiftimplementation@*/
|
||||
perturb >>= 5;
|
||||
bucket = &(*table)->bucket[ret];
|
||||
}
|
||||
|
@ -116,12 +107,10 @@ static int rpmhookTableFindBucket(rpmhookTable *table, const char *name)
|
|||
}
|
||||
|
||||
static void rpmhookTableRehash(rpmhookTable *table)
|
||||
/*@modifies *table @*/
|
||||
{
|
||||
rpmhookTable newtable = rpmhookTableNew((*table)->size*2);
|
||||
int n, i = 0;
|
||||
|
||||
/*@-branchstate@*/
|
||||
for (; i != (*table)->size; i++) {
|
||||
if ((*table)->bucket[i].name == NULL)
|
||||
continue;
|
||||
|
@ -129,17 +118,13 @@ static void rpmhookTableRehash(rpmhookTable *table)
|
|||
newtable->bucket[n].name = (*table)->bucket[i].name;
|
||||
newtable->bucket[n].item = (*table)->bucket[i].item;
|
||||
}
|
||||
/*@=branchstate@*/
|
||||
newtable->used = (*table)->used;
|
||||
/*@-unqualifiedtrans@*/
|
||||
free(*table);
|
||||
/*@=unqualifiedtrans@*/
|
||||
*table = newtable;
|
||||
}
|
||||
|
||||
static void rpmhookTableAddItem(rpmhookTable *table, const char *name,
|
||||
rpmhookFunc func, void *data)
|
||||
/*@modifies *table @*/
|
||||
{
|
||||
int n = rpmhookTableFindBucket(table, name);
|
||||
rpmhookBucket bucket = &(*table)->bucket[n];
|
||||
|
@ -151,15 +136,12 @@ static void rpmhookTableAddItem(rpmhookTable *table, const char *name,
|
|||
while (*item) item = &(*item)->next;
|
||||
*item = xcalloc(1, sizeof(**item));
|
||||
(*item)->func = func;
|
||||
/*@-temptrans@*/
|
||||
(*item)->data = data;
|
||||
/*@=temptrans@*/
|
||||
}
|
||||
|
||||
static void rpmhookTableDelItem(rpmhookTable *table, const char *name,
|
||||
/*@null@*/ rpmhookFunc func, /*@null@*/ void *data,
|
||||
rpmhookFunc func, void *data,
|
||||
int matchfunc, int matchdata)
|
||||
/*@modifies *table @*/
|
||||
{
|
||||
int n = rpmhookTableFindBucket(table, name);
|
||||
rpmhookBucket bucket = &(*table)->bucket[n];
|
||||
|
@ -168,7 +150,6 @@ static void rpmhookTableDelItem(rpmhookTable *table, const char *name,
|
|||
rpmhookItem nextItem;
|
||||
while (item) {
|
||||
nextItem = item->next;
|
||||
/*@-branchstate@*/
|
||||
if ((!matchfunc || item->func == func) &&
|
||||
(!matchdata || item->data == data)) {
|
||||
free(item);
|
||||
|
@ -179,8 +160,6 @@ static void rpmhookTableDelItem(rpmhookTable *table, const char *name,
|
|||
} else {
|
||||
lastItem = item;
|
||||
}
|
||||
/*@=branchstate@*/
|
||||
/*@-usereleased@*/
|
||||
item = nextItem;
|
||||
}
|
||||
if (!bucket->item) {
|
||||
|
@ -188,38 +167,32 @@ static void rpmhookTableDelItem(rpmhookTable *table, const char *name,
|
|||
bucket->name = NULL;
|
||||
(*table)->used--;
|
||||
}
|
||||
/*@=usereleased@*/
|
||||
}
|
||||
|
||||
static rpmhookArgs rpmhookArgsParse(const char *argt, va_list ap)
|
||||
/*@*/
|
||||
{
|
||||
rpmhookArgs args = rpmhookArgsNew(strlen(argt));
|
||||
int i;
|
||||
|
||||
/*@-temptrans@*/
|
||||
args->argt = argt;
|
||||
/*@=temptrans@*/
|
||||
for (i = 0; i != args->argc; i++) {
|
||||
switch (argt[i]) {
|
||||
case 's':
|
||||
args->argv[i].s = va_arg(ap, char *);
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
case 'i':
|
||||
args->argv[i].i = va_arg(ap, int);
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
case 'f':
|
||||
args->argv[i].f = (float)va_arg(ap, double);
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
case 'p':
|
||||
args->argv[i].p = va_arg(ap, void *);
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
default:
|
||||
/*@-modfilesys @*/
|
||||
fprintf(stderr, "error: unsupported type '%c' as "
|
||||
"a hook argument\n", argt[i]);
|
||||
/*@=modfilesys @*/
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return args;
|
||||
|
@ -227,7 +200,6 @@ static rpmhookArgs rpmhookArgsParse(const char *argt, va_list ap)
|
|||
|
||||
static void rpmhookTableCallArgs(rpmhookTable *table, const char *name,
|
||||
rpmhookArgs args)
|
||||
/*@modifies *table @*/
|
||||
{
|
||||
int n = rpmhookTableFindBucket(table, name);
|
||||
rpmhookItem item = (*table)->bucket[n].item;
|
||||
|
@ -238,12 +210,9 @@ static void rpmhookTableCallArgs(rpmhookTable *table, const char *name,
|
|||
}
|
||||
}
|
||||
|
||||
/*@unchecked@*/ /*@only@*/ /*@null@*/
|
||||
static rpmhookTable globalTable = NULL;
|
||||
|
||||
void rpmhookRegister(const char *name, rpmhookFunc func, void *data)
|
||||
/*@globals globalTable @*/
|
||||
/*@modifies globalTable @*/
|
||||
{
|
||||
if (globalTable == NULL)
|
||||
globalTable = rpmhookTableNew(RPMHOOK_TABLE_INITSIZE);
|
||||
|
@ -275,9 +244,7 @@ void rpmhookCall(const char *name, const char *argt, ...)
|
|||
va_list ap;
|
||||
va_start(ap, argt);
|
||||
args = rpmhookArgsParse(argt, ap);
|
||||
/*@-noeffect@*/
|
||||
rpmhookTableCallArgs(&globalTable, name, args);
|
||||
/*@=noeffect@*/
|
||||
(void) rpmhookArgsFree(args);
|
||||
va_end(ap);
|
||||
}
|
||||
|
@ -285,9 +252,6 @@ void rpmhookCall(const char *name, const char *argt, ...)
|
|||
|
||||
void rpmhookCallArgs(const char *name, rpmhookArgs args)
|
||||
{
|
||||
/*@-noeffect@*/
|
||||
if (globalTable != NULL)
|
||||
rpmhookTableCallArgs(&globalTable, name, args);
|
||||
/*@=noeffect@*/
|
||||
}
|
||||
/*@=bounds@*/
|
||||
|
|
|
@ -2,11 +2,9 @@
|
|||
#define RPMHOOK_H
|
||||
|
||||
typedef union {
|
||||
/*@observer@*/
|
||||
const char * s;
|
||||
int i;
|
||||
float f;
|
||||
/*@observer@*/
|
||||
void * p;
|
||||
} rpmhookArgv;
|
||||
|
||||
|
@ -18,26 +16,14 @@ typedef struct rpmhookArgs_s {
|
|||
|
||||
typedef int (*rpmhookFunc) (rpmhookArgs args, void *data);
|
||||
|
||||
/*@only@*/
|
||||
rpmhookArgs rpmhookArgsNew(int argc)
|
||||
/*@*/;
|
||||
/*@null@*/
|
||||
rpmhookArgs rpmhookArgsFree(/*@only@*/ /*@null@*/ rpmhookArgs args)
|
||||
/*@modifies args @*/;
|
||||
rpmhookArgs rpmhookArgsNew(int argc);
|
||||
rpmhookArgs rpmhookArgsFree(rpmhookArgs args);
|
||||
|
||||
void rpmhookRegister(const char *name, rpmhookFunc func, void *data)
|
||||
/*@globals internalState @*/
|
||||
/*@modifies internalState @*/;
|
||||
void rpmhookUnregister(const char *name, rpmhookFunc func, void *data)
|
||||
/*@*/;
|
||||
void rpmhookUnregisterAny(const char *name, rpmhookFunc func)
|
||||
/*@*/;
|
||||
void rpmhookUnregisterAll(const char *name)
|
||||
/*@*/;
|
||||
void rpmhookCall(const char *name, const char *argt, ...)
|
||||
/*@*/;
|
||||
void rpmhookCallArgs(const char *name, rpmhookArgs args)
|
||||
/*@globals internalState @*/
|
||||
/*@modifies internalState @*/;
|
||||
void rpmhookRegister(const char *name, rpmhookFunc func, void *data);
|
||||
void rpmhookUnregister(const char *name, rpmhookFunc func, void *data);
|
||||
void rpmhookUnregisterAny(const char *name, rpmhookFunc func);
|
||||
void rpmhookUnregisterAll(const char *name);
|
||||
void rpmhookCall(const char *name, const char *argt, ...);
|
||||
void rpmhookCallArgs(const char *name, rpmhookArgs args);
|
||||
|
||||
#endif
|
||||
|
|
562
rpmio/rpmio.c
562
rpmio/rpmio.c
File diff suppressed because it is too large
Load Diff
369
rpmio/rpmio.h
369
rpmio/rpmio.h
|
@ -9,20 +9,18 @@
|
|||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <dirent.h>
|
||||
/*@-noparams@*/
|
||||
#include "glob.h"
|
||||
/*@=noparams@*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/**
|
||||
*/
|
||||
typedef /*@abstract@*/ struct pgpDig_s * pgpDig;
|
||||
typedef struct pgpDig_s * pgpDig;
|
||||
|
||||
/**
|
||||
*/
|
||||
typedef /*@abstract@*/ struct pgpDigParams_s * pgpDigParams;
|
||||
typedef struct pgpDigParams_s * pgpDigParams;
|
||||
|
||||
/** \ingroup rpmio
|
||||
* Hide libio API lossage.
|
||||
|
@ -30,7 +28,6 @@ typedef /*@abstract@*/ struct pgpDigParams_s * pgpDigParams;
|
|||
* argument as a pointer rather than as an off_t. The snarl below defines
|
||||
* typedefs to isolate the lossage.
|
||||
*/
|
||||
/*@{*/
|
||||
#if defined(__GLIBC__) && \
|
||||
(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2))
|
||||
#define USE_COOKIE_SEEK_POINTER 1
|
||||
|
@ -40,15 +37,14 @@ typedef _libio_off_t * _libio_pos_t;
|
|||
typedef off_t _libio_off_t;
|
||||
typedef off_t _libio_pos_t;
|
||||
#endif
|
||||
/*@}*/
|
||||
|
||||
/** \ingroup rpmio
|
||||
*/
|
||||
typedef /*@abstract@*/ /*@refcounted@*/ struct _FD_s * FD_t;
|
||||
typedef struct _FD_s * FD_t;
|
||||
|
||||
/** \ingroup rpmio
|
||||
*/
|
||||
typedef /*@observer@*/ struct FDIO_s * FDIO_t;
|
||||
typedef struct FDIO_s * FDIO_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -57,146 +53,98 @@ extern "C" {
|
|||
/** \ingroup rpmio
|
||||
* \name RPMIO Vectors.
|
||||
*/
|
||||
/*@{*/
|
||||
|
||||
/**
|
||||
*/
|
||||
typedef ssize_t (*fdio_read_function_t) (void *cookie, char *buf, size_t nbytes)
|
||||
/*@globals errno, fileSystem @*/
|
||||
/*@modifies *cookie, errno, fileSystem @*/
|
||||
/*@requires maxSet(buf) >= (nbytes - 1) @*/
|
||||
/*@ensures maxRead(buf) == result @*/ ;
|
||||
typedef ssize_t (*fdio_read_function_t) (void *cookie, char *buf, size_t nbytes);
|
||||
|
||||
/**
|
||||
*/
|
||||
typedef ssize_t (*fdio_write_function_t) (void *cookie, const char *buf, size_t nbytes)
|
||||
/*@globals errno, fileSystem @*/
|
||||
/*@modifies *cookie, errno, fileSystem @*/;
|
||||
typedef ssize_t (*fdio_write_function_t) (void *cookie, const char *buf, size_t nbytes);
|
||||
|
||||
/**
|
||||
*/
|
||||
typedef int (*fdio_seek_function_t) (void *cookie, _libio_pos_t pos, int whence)
|
||||
/*@globals errno, fileSystem @*/
|
||||
/*@modifies *cookie, errno, fileSystem @*/;
|
||||
typedef int (*fdio_seek_function_t) (void *cookie, _libio_pos_t pos, int whence);
|
||||
|
||||
/**
|
||||
*/
|
||||
typedef int (*fdio_close_function_t) (void *cookie)
|
||||
/*@globals errno, fileSystem, systemState @*/
|
||||
/*@modifies *cookie, errno, fileSystem, systemState @*/;
|
||||
typedef int (*fdio_close_function_t) (void *cookie);
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
typedef /*@only@*/ /*@null@*/ FD_t (*fdio_ref_function_t) ( /*@only@*/ void * cookie,
|
||||
const char * msg, const char * file, unsigned line)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies fileSystem @*/;
|
||||
typedef FD_t (*fdio_ref_function_t) ( void * cookie,
|
||||
const char * msg, const char * file, unsigned line);
|
||||
|
||||
/**
|
||||
*/
|
||||
typedef /*@only@*/ /*@null@*/ FD_t (*fdio_deref_function_t) ( /*@only@*/ FD_t fd,
|
||||
const char * msg, const char * file, unsigned line)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies fd, fileSystem @*/;
|
||||
typedef FD_t (*fdio_deref_function_t) ( FD_t fd,
|
||||
const char * msg, const char * file, unsigned line);
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
typedef /*@only@*/ /*@null@*/ FD_t (*fdio_new_function_t) (const char * msg,
|
||||
const char * file, unsigned line)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies fileSystem @*/;
|
||||
typedef FD_t (*fdio_new_function_t) (const char * msg,
|
||||
const char * file, unsigned line);
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
typedef int (*fdio_fileno_function_t) (void * cookie)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies *cookie, fileSystem @*/;
|
||||
typedef int (*fdio_fileno_function_t) (void * cookie);
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
typedef FD_t (*fdio_open_function_t) (const char * path, int flags, mode_t mode)
|
||||
/*@globals errno, fileSystem @*/
|
||||
/*@modifies errno, fileSystem @*/;
|
||||
typedef FD_t (*fdio_open_function_t) (const char * path, int flags, mode_t mode);
|
||||
|
||||
/**
|
||||
*/
|
||||
typedef FD_t (*fdio_fopen_function_t) (const char * path, const char * fmode)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies fileSystem @*/;
|
||||
typedef FD_t (*fdio_fopen_function_t) (const char * path, const char * fmode);
|
||||
|
||||
/**
|
||||
*/
|
||||
typedef void * (*fdio_ffileno_function_t) (FD_t fd)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies fileSystem @*/;
|
||||
typedef void * (*fdio_ffileno_function_t) (FD_t fd);
|
||||
|
||||
/**
|
||||
*/
|
||||
typedef int (*fdio_fflush_function_t) (FD_t fd)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies fileSystem @*/;
|
||||
/*@}*/
|
||||
typedef int (*fdio_fflush_function_t) (FD_t fd);
|
||||
|
||||
|
||||
/** \ingroup rpmrpc
|
||||
* \name RPMRPC Vectors.
|
||||
*/
|
||||
/*@{*/
|
||||
|
||||
/**
|
||||
*/
|
||||
typedef int (*fdio_mkdir_function_t) (const char * path, mode_t mode)
|
||||
/*@globals errno, fileSystem @*/
|
||||
/*@modifies errno, fileSystem @*/;
|
||||
typedef int (*fdio_mkdir_function_t) (const char * path, mode_t mode);
|
||||
|
||||
/**
|
||||
*/
|
||||
typedef int (*fdio_chdir_function_t) (const char * path)
|
||||
/*@globals errno, fileSystem @*/
|
||||
/*@modifies errno, fileSystem @*/;
|
||||
typedef int (*fdio_chdir_function_t) (const char * path);
|
||||
|
||||
/**
|
||||
*/
|
||||
typedef int (*fdio_rmdir_function_t) (const char * path)
|
||||
/*@globals errno, fileSystem @*/
|
||||
/*@modifies errno, fileSystem @*/;
|
||||
typedef int (*fdio_rmdir_function_t) (const char * path);
|
||||
|
||||
/**
|
||||
*/
|
||||
typedef int (*fdio_rename_function_t) (const char * oldpath, const char * newpath)
|
||||
/*@globals errno, fileSystem @*/
|
||||
/*@modifies errno, fileSystem @*/;
|
||||
typedef int (*fdio_rename_function_t) (const char * oldpath, const char * newpath);
|
||||
|
||||
/**
|
||||
*/
|
||||
typedef int (*fdio_unlink_function_t) (const char * path)
|
||||
/*@globals errno, fileSystem @*/
|
||||
/*@modifies errno, fileSystem @*/;
|
||||
/*@-typeuse@*/
|
||||
typedef int (*fdio_unlink_function_t) (const char * path);
|
||||
|
||||
/**
|
||||
*/
|
||||
typedef int (*fdio_stat_function_t) (const char * path, /*@out@*/ struct stat * st)
|
||||
/*@globals errno, fileSystem @*/
|
||||
/*@modifies *st, errno, fileSystem @*/;
|
||||
typedef int (*fdio_stat_function_t) (const char * path, struct stat * st);
|
||||
|
||||
/**
|
||||
*/
|
||||
typedef int (*fdio_lstat_function_t) (const char * path, /*@out@*/ struct stat * st)
|
||||
/*@globals errno, fileSystem @*/
|
||||
/*@modifies *st, errno, fileSystem @*/;
|
||||
typedef int (*fdio_lstat_function_t) (const char * path, struct stat * st);
|
||||
|
||||
/**
|
||||
*/
|
||||
typedef int (*fdio_access_function_t) (const char * path, int amode)
|
||||
/*@globals errno, fileSystem @*/
|
||||
/*@modifies errno, fileSystem @*/;
|
||||
/*@=typeuse@*/
|
||||
/*@}*/
|
||||
typedef int (*fdio_access_function_t) (const char * path, int amode);
|
||||
|
||||
|
||||
/** \ingroup rpmio
|
||||
|
@ -228,331 +176,225 @@ struct FDIO_s {
|
|||
/** \ingroup rpmio
|
||||
* \name RPMIO Interface.
|
||||
*/
|
||||
/*@{*/
|
||||
|
||||
/**
|
||||
* strerror(3) clone.
|
||||
*/
|
||||
/*@observer@*/ const char * Fstrerror(/*@null@*/ FD_t fd)
|
||||
/*@*/;
|
||||
const char * Fstrerror(FD_t fd);
|
||||
|
||||
/**
|
||||
* fread(3) clone.
|
||||
*/
|
||||
/*@-incondefs@*/
|
||||
ssize_t Fread(/*@out@*/ void * buf, size_t size, size_t nmemb, FD_t fd)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies fd, *buf, fileSystem @*/
|
||||
/*@requires maxSet(buf) >= (nmemb - 1) @*/
|
||||
/*@ensures maxRead(buf) == result @*/;
|
||||
/*@=incondefs@*/
|
||||
ssize_t Fread(void * buf, size_t size, size_t nmemb, FD_t fd);
|
||||
|
||||
/**
|
||||
* fwrite(3) clone.
|
||||
*/
|
||||
/*@-incondefs@*/
|
||||
ssize_t Fwrite(const void * buf, size_t size, size_t nmemb, FD_t fd)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies fd, fileSystem @*/
|
||||
/*@requires maxRead(buf) >= nmemb @*/;
|
||||
/*@=incondefs@*/
|
||||
ssize_t Fwrite(const void * buf, size_t size, size_t nmemb, FD_t fd);
|
||||
|
||||
/**
|
||||
* fseek(3) clone.
|
||||
*/
|
||||
int Fseek(FD_t fd, _libio_off_t offset, int whence)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies fileSystem @*/;
|
||||
int Fseek(FD_t fd, _libio_off_t offset, int whence);
|
||||
|
||||
/**
|
||||
* fclose(3) clone.
|
||||
*/
|
||||
int Fclose( /*@killref@*/ FD_t fd)
|
||||
/*@globals fileSystem, internalState @*/
|
||||
/*@modifies fd, fileSystem, internalState @*/;
|
||||
int Fclose( FD_t fd);
|
||||
|
||||
/**
|
||||
*/
|
||||
/*@null@*/ FD_t Fdopen(FD_t ofd, const char * fmode)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies ofd, fileSystem @*/;
|
||||
FD_t Fdopen(FD_t ofd, const char * fmode);
|
||||
|
||||
/**
|
||||
* fopen(3) clone.
|
||||
*/
|
||||
/*@null@*/ FD_t Fopen(/*@null@*/ const char * path,
|
||||
/*@null@*/ const char * fmode)
|
||||
/*@globals h_errno, fileSystem, internalState @*/
|
||||
/*@modifies fileSystem, internalState @*/;
|
||||
FD_t Fopen(const char * path,
|
||||
const char * fmode);
|
||||
|
||||
|
||||
/**
|
||||
* fflush(3) clone.
|
||||
*/
|
||||
int Fflush(/*@null@*/ FD_t fd)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies fd, fileSystem @*/;
|
||||
int Fflush(FD_t fd);
|
||||
|
||||
/**
|
||||
* ferror(3) clone.
|
||||
*/
|
||||
int Ferror(/*@null@*/ FD_t fd)
|
||||
/*@*/;
|
||||
int Ferror(FD_t fd);
|
||||
|
||||
/**
|
||||
* fileno(3) clone.
|
||||
*/
|
||||
int Fileno(FD_t fd)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies fileSystem@*/;
|
||||
int Fileno(FD_t fd);
|
||||
|
||||
/**
|
||||
* fcntl(2) clone.
|
||||
*/
|
||||
/*@unused@*/
|
||||
int Fcntl(FD_t fd, int op, void *lip)
|
||||
/*@globals errno, fileSystem @*/
|
||||
/*@modifies fd, *lip, errno, fileSystem @*/;
|
||||
int Fcntl(FD_t fd, int op, void *lip);
|
||||
|
||||
/*@}*/
|
||||
|
||||
/** \ingroup rpmrpc
|
||||
* \name RPMRPC Interface.
|
||||
*/
|
||||
/*@{*/
|
||||
|
||||
/**
|
||||
* mkdir(2) clone.
|
||||
*/
|
||||
int Mkdir(const char * path, mode_t mode)
|
||||
/*@globals errno, h_errno, fileSystem, internalState @*/
|
||||
/*@modifies errno, fileSystem, internalState @*/;
|
||||
int Mkdir(const char * path, mode_t mode);
|
||||
|
||||
/**
|
||||
* chdir(2) clone.
|
||||
*/
|
||||
int Chdir(const char * path)
|
||||
/*@globals errno, h_errno, fileSystem, internalState @*/
|
||||
/*@modifies errno, fileSystem, internalState @*/;
|
||||
int Chdir(const char * path);
|
||||
|
||||
/**
|
||||
* rmdir(2) clone.
|
||||
*/
|
||||
int Rmdir(const char * path)
|
||||
/*@globals errno, h_errno, fileSystem, internalState @*/
|
||||
/*@modifies errno, fileSystem, internalState @*/;
|
||||
int Rmdir(const char * path);
|
||||
|
||||
/**
|
||||
* rename(2) clone.
|
||||
*/
|
||||
int Rename(const char * oldpath, const char * newpath)
|
||||
/*@globals errno, h_errno, fileSystem, internalState @*/
|
||||
/*@modifies errno, fileSystem, internalState @*/;
|
||||
int Rename(const char * oldpath, const char * newpath);
|
||||
|
||||
/**
|
||||
* link(2) clone.
|
||||
*/
|
||||
int Link(const char * oldpath, const char * newpath)
|
||||
/*@globals errno, fileSystem, internalState @*/
|
||||
/*@modifies errno, fileSystem, internalState @*/;
|
||||
int Link(const char * oldpath, const char * newpath);
|
||||
|
||||
/**
|
||||
* unlink(2) clone.
|
||||
*/
|
||||
int Unlink(const char * path)
|
||||
/*@globals errno, h_errno, fileSystem, internalState @*/
|
||||
/*@modifies errno, fileSystem, internalState @*/;
|
||||
int Unlink(const char * path);
|
||||
|
||||
/**
|
||||
* readlink(2) clone.
|
||||
*/
|
||||
/*@-incondefs@*/
|
||||
int Readlink(const char * path, /*@out@*/ char * buf, size_t bufsiz)
|
||||
/*@globals errno, h_errno, fileSystem, internalState @*/
|
||||
/*@modifies *buf, errno, fileSystem, internalState @*/
|
||||
/*@requires maxSet(buf) >= (bufsiz - 1) @*/
|
||||
/*@ensures maxRead(buf) <= bufsiz @*/;
|
||||
/*@=incondefs@*/
|
||||
int Readlink(const char * path, char * buf, size_t bufsiz);
|
||||
|
||||
/**
|
||||
* stat(2) clone.
|
||||
*/
|
||||
int Stat(const char * path, /*@out@*/ struct stat * st)
|
||||
/*@globals errno, h_errno, fileSystem, internalState @*/
|
||||
/*@modifies *st, errno, fileSystem, internalState @*/;
|
||||
int Stat(const char * path, struct stat * st);
|
||||
|
||||
/**
|
||||
* lstat(2) clone.
|
||||
*/
|
||||
int Lstat(const char * path, /*@out@*/ struct stat * st)
|
||||
/*@globals errno, h_errno, fileSystem, internalState @*/
|
||||
/*@modifies *st, errno, fileSystem, internalState @*/;
|
||||
int Lstat(const char * path, struct stat * st);
|
||||
|
||||
/**
|
||||
* access(2) clone.
|
||||
*/
|
||||
int Access(const char * path, int amode)
|
||||
/*@globals errno, fileSystem @*/
|
||||
/*@modifies errno, fileSystem @*/;
|
||||
int Access(const char * path, int amode);
|
||||
|
||||
/**
|
||||
* glob_pattern_p(3) clone.
|
||||
*/
|
||||
int Glob_pattern_p (const char *pattern, int quote)
|
||||
/*@*/;
|
||||
int Glob_pattern_p (const char *pattern, int quote);
|
||||
|
||||
/**
|
||||
* glob_error(3) clone.
|
||||
*/
|
||||
int Glob_error(const char * epath, int eerrno)
|
||||
/*@*/;
|
||||
int Glob_error(const char * epath, int eerrno);
|
||||
|
||||
/**
|
||||
* glob(3) clone.
|
||||
*/
|
||||
int Glob(const char * pattern, int flags,
|
||||
int errfunc(const char * epath, int eerrno),
|
||||
/*@out@*/ glob_t * pglob)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies *pglob, fileSystem @*/;
|
||||
glob_t * pglob);
|
||||
|
||||
/**
|
||||
* globfree(3) clone.
|
||||
*/
|
||||
void Globfree( /*@only@*/ glob_t * pglob)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies *pglob, fileSystem @*/;
|
||||
void Globfree( glob_t * pglob);
|
||||
|
||||
|
||||
/**
|
||||
* opendir(3) clone.
|
||||
*/
|
||||
/*@null@*/
|
||||
DIR * Opendir(const char * path)
|
||||
/*@globals errno, h_errno, fileSystem, internalState @*/
|
||||
/*@modifies errno, fileSystem, internalState @*/;
|
||||
DIR * Opendir(const char * path);
|
||||
|
||||
/**
|
||||
* readdir(3) clone.
|
||||
*/
|
||||
/*@dependent@*/ /*@null@*/
|
||||
struct dirent * Readdir(DIR * dir)
|
||||
/*@globals errno, fileSystem @*/
|
||||
/*@modifies *dir, errno, fileSystem @*/;
|
||||
struct dirent * Readdir(DIR * dir);
|
||||
|
||||
/**
|
||||
* closedir(3) clone.
|
||||
*/
|
||||
int Closedir(/*@only@*/ DIR * dir)
|
||||
/*@globals errno, fileSystem @*/
|
||||
/*@modifies *dir, errno, fileSystem @*/;
|
||||
int Closedir(DIR * dir);
|
||||
|
||||
/*@}*/
|
||||
|
||||
|
||||
/** \ingroup rpmio
|
||||
* \name RPMIO Utilities.
|
||||
*/
|
||||
/*@{*/
|
||||
|
||||
/**
|
||||
*/
|
||||
off_t fdSize(FD_t fd)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies fd, fileSystem@*/;
|
||||
off_t fdSize(FD_t fd);
|
||||
|
||||
/**
|
||||
*/
|
||||
/*@null@*/ FD_t fdDup(int fdno)
|
||||
/*@globals fileSystem, internalState @*/
|
||||
/*@modifies fileSystem, internalState @*/;
|
||||
FD_t fdDup(int fdno);
|
||||
|
||||
#ifdef UNUSED
|
||||
/*@null@*/ FILE *fdFdopen( /*@only@*/ void * cookie, const char * mode);
|
||||
FILE *fdFdopen( void * cookie, const char * mode);
|
||||
#endif
|
||||
|
||||
/* XXX Legacy interfaces needed by gnorpm, rpmfind et al */
|
||||
|
||||
/*@-exportlocal@*/
|
||||
/**
|
||||
*/
|
||||
#ifndef H_RPMIO_INTERNAL /* XXX avoid gcc warning */
|
||||
/*@unused@*/ int fdFileno(void * cookie)
|
||||
/*@*/;
|
||||
int fdFileno(void * cookie);
|
||||
#define fdFileno(_fd) fdio->_fileno(_fd)
|
||||
#endif
|
||||
|
||||
/**
|
||||
*/
|
||||
/*@null@*/ FD_t fdOpen(const char *path, int flags, mode_t mode)
|
||||
/*@globals errno, fileSystem, internalState @*/
|
||||
/*@modifies errno, fileSystem, internalState @*/;
|
||||
FD_t fdOpen(const char *path, int flags, mode_t mode);
|
||||
#define fdOpen(_path, _flags, _mode) fdio->_open((_path), (_flags), (_mode))
|
||||
|
||||
/**
|
||||
*/
|
||||
/*@-incondefs@*/
|
||||
ssize_t fdRead(void * cookie, /*@out@*/ char * buf, size_t count)
|
||||
/*@globals errno, fileSystem, internalState @*/
|
||||
/*@modifies *cookie, *buf, errno, fileSystem, internalState @*/
|
||||
/*@requires maxSet(buf) >= (count - 1) @*/
|
||||
/*@ensures maxRead(buf) == result @*/ ;
|
||||
ssize_t fdRead(void * cookie, char * buf, size_t count);
|
||||
#define fdRead(_fd, _buf, _count) fdio->read((_fd), (_buf), (_count))
|
||||
/*@=incondefs@*/
|
||||
|
||||
/**
|
||||
*/
|
||||
ssize_t fdWrite(void * cookie, const char * buf, size_t count)
|
||||
/*@globals errno, fileSystem, internalState @*/
|
||||
/*@modifies *cookie, errno, fileSystem, internalState @*/;
|
||||
ssize_t fdWrite(void * cookie, const char * buf, size_t count);
|
||||
#define fdWrite(_fd, _buf, _count) fdio->write((_fd), (_buf), (_count))
|
||||
|
||||
/**
|
||||
*/
|
||||
int fdClose( /*@only@*/ void * cookie)
|
||||
/*@globals errno, fileSystem, systemState, internalState @*/
|
||||
/*@modifies *cookie, errno, fileSystem, systemState, internalState @*/;
|
||||
int fdClose( void * cookie);
|
||||
#define fdClose(_fd) fdio->close(_fd)
|
||||
|
||||
/**
|
||||
*/
|
||||
/*@unused@*/
|
||||
/*@only@*/ /*@null@*/
|
||||
FD_t fdLink (/*@only@*/ void * cookie, const char * msg)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies *cookie, fileSystem @*/;
|
||||
FD_t fdLink (void * cookie, const char * msg);
|
||||
#define fdLink(_fd, _msg) fdio->_fdref(_fd, _msg, __FILE__, __LINE__)
|
||||
|
||||
/**
|
||||
*/
|
||||
/*@unused@*/
|
||||
/*@only@*/ /*@null@*/
|
||||
FD_t fdFree(/*@only@*/ FD_t fd, const char * msg)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies fd, fileSystem @*/;
|
||||
FD_t fdFree(FD_t fd, const char * msg);
|
||||
#define fdFree(_fd, _msg) fdio->_fdderef(_fd, _msg, __FILE__, __LINE__)
|
||||
|
||||
/**
|
||||
*/
|
||||
/*@unused@*/
|
||||
/*@only@*/ /*@null@*/
|
||||
FD_t fdNew (const char * msg)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies fileSystem @*/;
|
||||
FD_t fdNew (const char * msg);
|
||||
#define fdNew(_msg) fdio->_fdnew(_msg, __FILE__, __LINE__)
|
||||
|
||||
/**
|
||||
*/
|
||||
int fdWritable(FD_t fd, int secs)
|
||||
/*@globals errno, fileSystem @*/
|
||||
/*@modifies fd, errno, fileSystem @*/;
|
||||
int fdWritable(FD_t fd, int secs);
|
||||
|
||||
/**
|
||||
*/
|
||||
int fdReadable(FD_t fd, int secs)
|
||||
/*@globals errno @*/
|
||||
/*@modifies fd, errno @*/;
|
||||
/*@=exportlocal@*/
|
||||
int fdReadable(FD_t fd, int secs);
|
||||
|
||||
/**
|
||||
* Insure that directories in path exist, creating as needed.
|
||||
|
@ -562,14 +404,11 @@ int fdReadable(FD_t fd, int secs)
|
|||
* @param gid directory uid (if created), or -1 to skip
|
||||
* @return 0 on success, errno (or -1) on error
|
||||
*/
|
||||
int rpmioMkpath(const char * path, mode_t mode, uid_t uid, gid_t gid)
|
||||
/*@globals h_errno, fileSystem, internalState @*/
|
||||
/*@modifies fileSystem, internalState @*/;
|
||||
int rpmioMkpath(const char * path, mode_t mode, uid_t uid, gid_t gid);
|
||||
|
||||
/**
|
||||
* FTP and HTTP error codes.
|
||||
*/
|
||||
/*@-typeuse@*/
|
||||
typedef enum ftperrCode_e {
|
||||
FTPERR_NE_ERROR = -1, /*!< Generic error. */
|
||||
FTPERR_NE_LOOKUP = -2, /*!< Hostname lookup failed. */
|
||||
|
@ -594,116 +433,94 @@ typedef enum ftperrCode_e {
|
|||
FTPERR_NIC_ABORT_IN_PROGRESS= -91, /*!< Abort in progress */
|
||||
FTPERR_UNKNOWN = -100 /*!< Unknown or unexpected error */
|
||||
} ftperrCode;
|
||||
/*@=typeuse@*/
|
||||
|
||||
/**
|
||||
*/
|
||||
/*@-redecl@*/
|
||||
/*@observer@*/ const char * ftpStrerror(int errorNumber)
|
||||
/*@*/;
|
||||
/*@=redecl@*/
|
||||
const char * ftpStrerror(int errorNumber);
|
||||
|
||||
/**
|
||||
*/
|
||||
/*@unused@*/
|
||||
/*@dependent@*/ /*@null@*/ void * ufdGetUrlinfo(FD_t fd)
|
||||
/*@modifies fd @*/;
|
||||
void * ufdGetUrlinfo(FD_t fd);
|
||||
|
||||
/**
|
||||
*/
|
||||
/*@-redecl@*/
|
||||
/*@unused@*/
|
||||
/*@observer@*/ const char * urlStrerror(const char * url)
|
||||
/*@globals h_errno, internalState @*/
|
||||
/*@modifies internalState @*/;
|
||||
/*@=redecl@*/
|
||||
const char * urlStrerror(const char * url);
|
||||
|
||||
/**
|
||||
*/
|
||||
/*@-exportlocal@*/
|
||||
int ufdCopy(FD_t sfd, FD_t tfd)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies sfd, tfd, fileSystem @*/;
|
||||
/*@=exportlocal@*/
|
||||
int ufdCopy(FD_t sfd, FD_t tfd);
|
||||
|
||||
/**
|
||||
*/
|
||||
int ufdGetFile( /*@killref@*/ FD_t sfd, FD_t tfd)
|
||||
/*@globals fileSystem, internalState @*/
|
||||
/*@modifies sfd, tfd, fileSystem, internalState @*/;
|
||||
int ufdGetFile( FD_t sfd, FD_t tfd);
|
||||
|
||||
/**
|
||||
*/
|
||||
/*@unused@*/ int timedRead(FD_t fd, /*@out@*/ void * bufptr, int length)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies fd, *bufptr, fileSystem @*/;
|
||||
int timedRead(FD_t fd, void * bufptr, int length);
|
||||
#define timedRead (ufdio->read)
|
||||
|
||||
/*@-exportlocal@*/
|
||||
/**
|
||||
*/
|
||||
/*@observer@*/ /*@unchecked@*/ extern FDIO_t fdio;
|
||||
extern FDIO_t fdio;
|
||||
|
||||
/**
|
||||
*/
|
||||
/*@observer@*/ /*@unchecked@*/ extern FDIO_t fpio;
|
||||
extern FDIO_t fpio;
|
||||
|
||||
/**
|
||||
*/
|
||||
/*@observer@*/ /*@unchecked@*/ extern FDIO_t ufdio;
|
||||
extern FDIO_t ufdio;
|
||||
|
||||
/**
|
||||
*/
|
||||
/*@observer@*/ /*@unchecked@*/ extern FDIO_t gzdio;
|
||||
extern FDIO_t gzdio;
|
||||
|
||||
/**
|
||||
*/
|
||||
/*@observer@*/ /*@unchecked@*/ extern FDIO_t bzdio;
|
||||
extern FDIO_t bzdio;
|
||||
|
||||
/**
|
||||
*/
|
||||
/*@observer@*/ /*@unchecked@*/ extern FDIO_t fadio;
|
||||
/*@=exportlocal@*/
|
||||
/*@}*/
|
||||
extern FDIO_t fadio;
|
||||
|
||||
/*@unused@*/ static inline int xislower(int c) /*@*/ {
|
||||
static inline int xislower(int c) {
|
||||
return (c >= 'a' && c <= 'z');
|
||||
}
|
||||
/*@unused@*/ static inline int xisupper(int c) /*@*/ {
|
||||
static inline int xisupper(int c) {
|
||||
return (c >= 'A' && c <= 'Z');
|
||||
}
|
||||
/*@unused@*/ static inline int xisalpha(int c) /*@*/ {
|
||||
static inline int xisalpha(int c) {
|
||||
return (xislower(c) || xisupper(c));
|
||||
}
|
||||
/*@unused@*/ static inline int xisdigit(int c) /*@*/ {
|
||||
static inline int xisdigit(int c) {
|
||||
return (c >= '0' && c <= '9');
|
||||
}
|
||||
/*@unused@*/ static inline int xisalnum(int c) /*@*/ {
|
||||
static inline int xisalnum(int c) {
|
||||
return (xisalpha(c) || xisdigit(c));
|
||||
}
|
||||
/*@unused@*/ static inline int xisblank(int c) /*@*/ {
|
||||
static inline int xisblank(int c) {
|
||||
return (c == ' ' || c == '\t');
|
||||
}
|
||||
/*@unused@*/ static inline int xisspace(int c) /*@*/ {
|
||||
static inline int xisspace(int c) {
|
||||
return (xisblank(c) || c == '\n' || c == '\r' || c == '\f' || c == '\v');
|
||||
}
|
||||
|
||||
/*@unused@*/ static inline int xtolower(int c) /*@*/ {
|
||||
static inline int xtolower(int c) {
|
||||
return ((xisupper(c)) ? (c | ('a' - 'A')) : c);
|
||||
}
|
||||
/*@unused@*/ static inline int xtoupper(int c) /*@*/ {
|
||||
static inline int xtoupper(int c) {
|
||||
return ((xislower(c)) ? (c & ~('a' - 'A')) : c);
|
||||
}
|
||||
|
||||
/** \ingroup rpmio
|
||||
* Locale insensitive strcasecmp(3).
|
||||
*/
|
||||
int xstrcasecmp(const char * s1, const char * s2) /*@*/;
|
||||
int xstrcasecmp(const char * s1, const char * s2) ;
|
||||
|
||||
/** \ingroup rpmio
|
||||
* Locale insensitive strncasecmp(3).
|
||||
*/
|
||||
int xstrncasecmp(const char *s1, const char * s2, size_t n) /*@*/;
|
||||
int xstrncasecmp(const char *s1, const char * s2, size_t n) ;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -38,9 +38,7 @@
|
|||
* Values parsed from OpenPGP signature/pubkey packet(s).
|
||||
*/
|
||||
struct pgpDigParams_s {
|
||||
/*@only@*/ /*@null@*/
|
||||
const char * userid;
|
||||
/*@only@*/ /*@null@*/
|
||||
const byte * hash;
|
||||
const char * params[4];
|
||||
byte tag;
|
||||
|
@ -69,19 +67,13 @@ struct pgpDig_s {
|
|||
|
||||
size_t nbytes; /*!< No. bytes of plain text. */
|
||||
|
||||
/*@only@*/ /*@null@*/
|
||||
DIGEST_CTX sha1ctx; /*!< (dsa) sha1 hash context. */
|
||||
/*@only@*/ /*@null@*/
|
||||
DIGEST_CTX hdrsha1ctx; /*!< (dsa) header sha1 hash context. */
|
||||
/*@only@*/ /*@null@*/
|
||||
void * sha1; /*!< (dsa) V3 signature hash. */
|
||||
size_t sha1len; /*!< (dsa) V3 signature hash length. */
|
||||
|
||||
/*@only@*/ /*@null@*/
|
||||
DIGEST_CTX md5ctx; /*!< (rsa) md5 hash context. */
|
||||
/*@only@*/ /*@null@*/
|
||||
DIGEST_CTX hdrmd5ctx; /*!< (rsa) header md5 hash context. */
|
||||
/*@only@*/ /*@null@*/
|
||||
void * md5; /*!< (rsa) V3 signature hash. */
|
||||
size_t md5len; /*!< (rsa) V3 signature hash length. */
|
||||
|
||||
|
@ -104,9 +96,7 @@ struct pgpDig_s {
|
|||
/** \ingroup rpmio
|
||||
*/
|
||||
typedef struct _FDSTACK_s {
|
||||
/*@exposed@*/
|
||||
FDIO_t io;
|
||||
/*@dependent@*/
|
||||
void * fp;
|
||||
int fdno;
|
||||
} FDSTACK_t;
|
||||
|
@ -126,7 +116,7 @@ typedef enum fdOpX_e {
|
|||
/** \ingroup rpmio
|
||||
* Cumulative statistics for a descriptor.
|
||||
*/
|
||||
typedef /*@abstract@*/ struct {
|
||||
typedef struct {
|
||||
struct rpmop_s ops[FDSTAT_MAX]; /*!< Cumulative statistics. */
|
||||
} * FDSTAT_t;
|
||||
|
||||
|
@ -141,7 +131,6 @@ typedef struct _FDDIGEST_s {
|
|||
* The FD_t File Handle data structure.
|
||||
*/
|
||||
struct _FD_s {
|
||||
/*@refs@*/
|
||||
int nrefs;
|
||||
int flags;
|
||||
#define RPMIO_DEBUG_IO 0x40000000
|
||||
|
@ -152,9 +141,7 @@ struct _FD_s {
|
|||
FDSTACK_t fps[8];
|
||||
int urlType; /* ufdio: */
|
||||
|
||||
/*@dependent@*/
|
||||
void * url; /* ufdio: URL info */
|
||||
/*@relnull@*/
|
||||
void * req; /* ufdio: HTTP request */
|
||||
|
||||
int rd_timeoutsecs; /* ufdRead: per FD_t timer */
|
||||
|
@ -164,7 +151,6 @@ struct _FD_s {
|
|||
int wr_chunked; /* ufdio: */
|
||||
|
||||
int syserrno; /* last system errno encountered */
|
||||
/*@observer@*/
|
||||
const void *errcookie; /* gzdio/bzdio/ufdio: */
|
||||
|
||||
FDSTAT_t stats; /* I/O statistics */
|
||||
|
@ -178,34 +164,20 @@ struct _FD_s {
|
|||
long int fileSize; /* fadio: */
|
||||
long int fd_cpioPos; /* cpio: */
|
||||
};
|
||||
/*@access FD_t@*/
|
||||
|
||||
#define FDSANE(fd) assert(fd && fd->magic == FDMAGIC)
|
||||
|
||||
/*@-redecl@*/
|
||||
/*@unchecked@*/
|
||||
extern int _rpmio_debug;
|
||||
/*@=redecl@*/
|
||||
|
||||
/*@-redecl@*/
|
||||
/*@unchecked@*/
|
||||
extern int _av_debug;
|
||||
/*@=redecl@*/
|
||||
|
||||
/*@-redecl@*/
|
||||
/*@unchecked@*/
|
||||
extern int _ftp_debug;
|
||||
/*@=redecl@*/
|
||||
|
||||
/*@-redecl@*/
|
||||
/*@unchecked@*/
|
||||
extern int _dav_debug;
|
||||
/*@=redecl@*/
|
||||
|
||||
#define DBG(_f, _m, _x) \
|
||||
/*@-modfilesys@*/ \
|
||||
\
|
||||
if ((_rpmio_debug | ((_f) ? ((FD_t)(_f))->flags : 0)) & (_m)) fprintf _x \
|
||||
/*@=modfilesys@*/
|
||||
|
||||
#define DBGIO(_f, _x) DBG((_f), RPMIO_DEBUG_IO, _x)
|
||||
#define DBGREFS(_f, _x) DBG((_f), RPMIO_DEBUG_REFS, _x)
|
||||
|
@ -216,134 +188,94 @@ extern "C" {
|
|||
|
||||
/** \ingroup rpmio
|
||||
*/
|
||||
int fdFgets(FD_t fd, char * buf, size_t len)
|
||||
/*@globals errno, fileSystem @*/
|
||||
/*@modifies *buf, fd, errno, fileSystem @*/;
|
||||
int fdFgets(FD_t fd, char * buf, size_t len);
|
||||
|
||||
/** \ingroup rpmio
|
||||
*/
|
||||
/*@null@*/ FD_t ftpOpen(const char *url, /*@unused@*/ int flags,
|
||||
/*@unused@*/ mode_t mode, /*@out@*/ urlinfo *uret)
|
||||
/*@globals h_errno, fileSystem, internalState @*/
|
||||
/*@modifies *uret, fileSystem, internalState @*/;
|
||||
FD_t ftpOpen(const char *url, int flags,
|
||||
mode_t mode, urlinfo *uret);
|
||||
|
||||
/** \ingroup rpmio
|
||||
*/
|
||||
int ftpReq(FD_t data, const char * ftpCmd, const char * ftpArg)
|
||||
/*@globals fileSystem, internalState @*/
|
||||
/*@modifies data, fileSystem, internalState @*/;
|
||||
int ftpReq(FD_t data, const char * ftpCmd, const char * ftpArg);
|
||||
|
||||
/** \ingroup rpmio
|
||||
*/
|
||||
int ftpCmd(const char * cmd, const char * url, const char * arg2)
|
||||
/*@globals h_errno, fileSystem, internalState @*/
|
||||
/*@modifies fileSystem, internalState @*/;
|
||||
int ftpCmd(const char * cmd, const char * url, const char * arg2);
|
||||
|
||||
/** \ingroup rpmio
|
||||
*/
|
||||
int ufdClose( /*@only@*/ void * cookie)
|
||||
/*@globals fileSystem, internalState @*/
|
||||
/*@modifies cookie, fileSystem, internalState @*/;
|
||||
int ufdClose( void * cookie);
|
||||
|
||||
/** \ingroup rpmio
|
||||
*/
|
||||
/*@unused@*/ static inline
|
||||
/*@null@*/ FDIO_t fdGetIo(FD_t fd)
|
||||
/*@*/
|
||||
static inline
|
||||
FDIO_t fdGetIo(FD_t fd)
|
||||
{
|
||||
FDSANE(fd);
|
||||
/*@-boundsread@*/
|
||||
return fd->fps[fd->nfps].io;
|
||||
/*@=boundsread@*/
|
||||
}
|
||||
|
||||
/** \ingroup rpmio
|
||||
*/
|
||||
/*@-nullstate@*/ /* FIX: io may be NULL */
|
||||
/*@unused@*/ static inline
|
||||
void fdSetIo(FD_t fd, /*@kept@*/ /*@null@*/ FDIO_t io)
|
||||
/*@modifies fd @*/
|
||||
/* FIX: io may be NULL */
|
||||
static inline
|
||||
void fdSetIo(FD_t fd, FDIO_t io)
|
||||
{
|
||||
FDSANE(fd);
|
||||
/*@-boundswrite@*/
|
||||
/*@-assignexpose@*/
|
||||
fd->fps[fd->nfps].io = io;
|
||||
/*@=assignexpose@*/
|
||||
/*@=boundswrite@*/
|
||||
}
|
||||
/*@=nullstate@*/
|
||||
|
||||
/** \ingroup rpmio
|
||||
*/
|
||||
/*@unused@*/ static inline
|
||||
/*@exposed@*/ /*@dependent@*/ /*@null@*/ FILE * fdGetFILE(FD_t fd)
|
||||
/*@*/
|
||||
static inline
|
||||
FILE * fdGetFILE(FD_t fd)
|
||||
{
|
||||
FDSANE(fd);
|
||||
/*@-boundsread@*/
|
||||
/*@+voidabstract@*/
|
||||
return ((FILE *)fd->fps[fd->nfps].fp);
|
||||
/*@=voidabstract@*/
|
||||
/*@=boundsread@*/
|
||||
}
|
||||
|
||||
/** \ingroup rpmio
|
||||
*/
|
||||
/*@unused@*/ static inline
|
||||
/*@exposed@*/ /*@dependent@*/ /*@null@*/ void * fdGetFp(FD_t fd)
|
||||
/*@*/
|
||||
static inline
|
||||
void * fdGetFp(FD_t fd)
|
||||
{
|
||||
FDSANE(fd);
|
||||
/*@-boundsread@*/
|
||||
return fd->fps[fd->nfps].fp;
|
||||
/*@=boundsread@*/
|
||||
}
|
||||
|
||||
/** \ingroup rpmio
|
||||
*/
|
||||
/*@-nullstate@*/ /* FIX: fp may be NULL */
|
||||
/*@unused@*/ static inline
|
||||
void fdSetFp(FD_t fd, /*@kept@*/ /*@null@*/ void * fp)
|
||||
/*@modifies fd @*/
|
||||
/* FIX: fp may be NULL */
|
||||
static inline
|
||||
void fdSetFp(FD_t fd, void * fp)
|
||||
{
|
||||
FDSANE(fd);
|
||||
/*@-boundswrite@*/
|
||||
/*@-assignexpose@*/
|
||||
fd->fps[fd->nfps].fp = fp;
|
||||
/*@=assignexpose@*/
|
||||
/*@=boundswrite@*/
|
||||
}
|
||||
/*@=nullstate@*/
|
||||
|
||||
/** \ingroup rpmio
|
||||
*/
|
||||
/*@unused@*/ static inline
|
||||
static inline
|
||||
int fdGetFdno(FD_t fd)
|
||||
/*@*/
|
||||
{
|
||||
FDSANE(fd);
|
||||
/*@-boundsread@*/
|
||||
return fd->fps[fd->nfps].fdno;
|
||||
/*@=boundsread@*/
|
||||
}
|
||||
|
||||
/** \ingroup rpmio
|
||||
*/
|
||||
/*@unused@*/ static inline
|
||||
static inline
|
||||
void fdSetFdno(FD_t fd, int fdno)
|
||||
/*@modifies fd @*/
|
||||
{
|
||||
FDSANE(fd);
|
||||
/*@-boundswrite@*/
|
||||
fd->fps[fd->nfps].fdno = fdno;
|
||||
/*@=boundswrite@*/
|
||||
}
|
||||
|
||||
/** \ingroup rpmio
|
||||
*/
|
||||
/*@unused@*/ static inline
|
||||
static inline
|
||||
void fdSetContentLength(FD_t fd, ssize_t contentLength)
|
||||
/*@modifies fd @*/
|
||||
{
|
||||
FDSANE(fd);
|
||||
fd->contentLength = fd->bytesRemain = contentLength;
|
||||
|
@ -351,9 +283,8 @@ void fdSetContentLength(FD_t fd, ssize_t contentLength)
|
|||
|
||||
/** \ingroup rpmio
|
||||
*/
|
||||
/*@unused@*/ static inline
|
||||
static inline
|
||||
void fdPush(FD_t fd, FDIO_t io, void * fp, int fdno)
|
||||
/*@modifies fd @*/
|
||||
{
|
||||
FDSANE(fd);
|
||||
if (fd->nfps >= (sizeof(fd->fps)/sizeof(fd->fps[0]) - 1))
|
||||
|
@ -366,9 +297,8 @@ void fdPush(FD_t fd, FDIO_t io, void * fp, int fdno)
|
|||
|
||||
/** \ingroup rpmio
|
||||
*/
|
||||
/*@unused@*/ static inline
|
||||
static inline
|
||||
void fdPop(FD_t fd)
|
||||
/*@modifies fd @*/
|
||||
{
|
||||
FDSANE(fd);
|
||||
if (fd->nfps < 0) return;
|
||||
|
@ -380,25 +310,20 @@ void fdPop(FD_t fd)
|
|||
|
||||
/** \ingroup rpmio
|
||||
*/
|
||||
/*@unused@*/ static inline /*@null@*/
|
||||
rpmop fdstat_op(/*@null@*/ FD_t fd, fdOpX opx)
|
||||
/*@*/
|
||||
static inline
|
||||
rpmop fdstat_op(FD_t fd, fdOpX opx)
|
||||
{
|
||||
rpmop op = NULL;
|
||||
|
||||
/*@-boundsread@*/
|
||||
if (fd != NULL && fd->stats != NULL && opx >= 0 && opx < FDSTAT_MAX)
|
||||
op = fd->stats->ops + opx;
|
||||
/*@=boundsread@*/
|
||||
return op;
|
||||
}
|
||||
|
||||
/** \ingroup rpmio
|
||||
*/
|
||||
/*@unused@*/ static inline
|
||||
void fdstat_enter(/*@null@*/ FD_t fd, int opx)
|
||||
/*@globals internalState @*/
|
||||
/*@modifies internalState @*/
|
||||
static inline
|
||||
void fdstat_enter(FD_t fd, int opx)
|
||||
{
|
||||
if (fd == NULL) return;
|
||||
if (fd->stats != NULL)
|
||||
|
@ -407,10 +332,8 @@ void fdstat_enter(/*@null@*/ FD_t fd, int opx)
|
|||
|
||||
/** \ingroup rpmio
|
||||
*/
|
||||
/*@unused@*/ static inline
|
||||
void fdstat_exit(/*@null@*/ FD_t fd, int opx, ssize_t rc)
|
||||
/*@globals internalState @*/
|
||||
/*@modifies fd, internalState @*/
|
||||
static inline
|
||||
void fdstat_exit(FD_t fd, int opx, ssize_t rc)
|
||||
{
|
||||
if (fd == NULL) return;
|
||||
if (rc == -1)
|
||||
|
@ -430,11 +353,8 @@ void fdstat_exit(/*@null@*/ FD_t fd, int opx, ssize_t rc)
|
|||
|
||||
/** \ingroup rpmio
|
||||
*/
|
||||
/*@-boundsread@*/
|
||||
/*@unused@*/ static inline
|
||||
void fdstat_print(/*@null@*/ FD_t fd, const char * msg, FILE * fp)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies *fp, fileSystem @*/
|
||||
static inline
|
||||
void fdstat_print(FD_t fd, const char * msg, FILE * fp)
|
||||
{
|
||||
static int usec_scale = (1000*1000);
|
||||
int opx;
|
||||
|
@ -449,40 +369,35 @@ void fdstat_print(/*@null@*/ FD_t fd, const char * msg, FILE * fp)
|
|||
fprintf(fp, "%8d reads, %8ld total bytes in %d.%06d secs\n",
|
||||
op->count, (long)op->bytes,
|
||||
(int)(op->usecs/usec_scale), (int)(op->usecs%usec_scale));
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
case FDSTAT_WRITE:
|
||||
if (msg) fprintf(fp, "%s:", msg);
|
||||
fprintf(fp, "%8d writes, %8ld total bytes in %d.%06d secs\n",
|
||||
op->count, (long)op->bytes,
|
||||
(int)(op->usecs/usec_scale), (int)(op->usecs%usec_scale));
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
case FDSTAT_SEEK:
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
case FDSTAT_CLOSE:
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*@=boundsread@*/
|
||||
|
||||
/** \ingroup rpmio
|
||||
*/
|
||||
/*@unused@*/ static inline
|
||||
void fdSetSyserrno(FD_t fd, int syserrno, /*@kept@*/ const void * errcookie)
|
||||
/*@modifies fd @*/
|
||||
static inline
|
||||
void fdSetSyserrno(FD_t fd, int syserrno, const void * errcookie)
|
||||
{
|
||||
FDSANE(fd);
|
||||
fd->syserrno = syserrno;
|
||||
/*@-assignexpose@*/
|
||||
fd->errcookie = errcookie;
|
||||
/*@=assignexpose@*/
|
||||
}
|
||||
|
||||
/** \ingroup rpmio
|
||||
*/
|
||||
/*@unused@*/ static inline
|
||||
static inline
|
||||
int fdGetRdTimeoutSecs(FD_t fd)
|
||||
/*@*/
|
||||
{
|
||||
FDSANE(fd);
|
||||
return fd->rd_timeoutsecs;
|
||||
|
@ -490,9 +405,8 @@ int fdGetRdTimeoutSecs(FD_t fd)
|
|||
|
||||
/** \ingroup rpmio
|
||||
*/
|
||||
/*@unused@*/ static inline
|
||||
static inline
|
||||
long int fdGetCpioPos(FD_t fd)
|
||||
/*@*/
|
||||
{
|
||||
FDSANE(fd);
|
||||
return fd->fd_cpioPos;
|
||||
|
@ -500,9 +414,8 @@ long int fdGetCpioPos(FD_t fd)
|
|||
|
||||
/** \ingroup rpmio
|
||||
*/
|
||||
/*@unused@*/ static inline
|
||||
static inline
|
||||
void fdSetCpioPos(FD_t fd, long int cpioPos)
|
||||
/*@modifies fd @*/
|
||||
{
|
||||
FDSANE(fd);
|
||||
fd->fd_cpioPos = cpioPos;
|
||||
|
@ -510,24 +423,19 @@ void fdSetCpioPos(FD_t fd, long int cpioPos)
|
|||
|
||||
/** \ingroup rpmio
|
||||
*/
|
||||
/*@mayexit@*/ /*@unused@*/ static inline
|
||||
FD_t c2f(/*@null@*/ void * cookie)
|
||||
/*@*/
|
||||
static inline
|
||||
FD_t c2f(void * cookie)
|
||||
{
|
||||
/*@-castexpose@*/
|
||||
FD_t fd = (FD_t) cookie;
|
||||
/*@=castexpose@*/
|
||||
FDSANE(fd);
|
||||
/*@-refcounttrans -retalias@*/ return fd; /*@=refcounttrans =retalias@*/
|
||||
return fd;
|
||||
}
|
||||
|
||||
/** \ingroup rpmio
|
||||
* Attach digest to fd.
|
||||
*/
|
||||
/*@unused@*/ static inline
|
||||
static inline
|
||||
void fdInitDigest(FD_t fd, pgpHashAlgo hashalgo, int flags)
|
||||
/*@globals internalState @*/
|
||||
/*@modifies fd, internalState @*/
|
||||
{
|
||||
FDDIGEST_t fddig = fd->digests + fd->ndigests;
|
||||
if (fddig != (fd->digests + FDDIGEST_MAX)) {
|
||||
|
@ -542,10 +450,8 @@ void fdInitDigest(FD_t fd, pgpHashAlgo hashalgo, int flags)
|
|||
/** \ingroup rpmio
|
||||
* Update digest(s) attached to fd.
|
||||
*/
|
||||
/*@unused@*/ static inline
|
||||
static inline
|
||||
void fdUpdateDigests(FD_t fd, const unsigned char * buf, ssize_t buflen)
|
||||
/*@globals internalState @*/
|
||||
/*@modifies fd, internalState @*/
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -562,13 +468,11 @@ void fdUpdateDigests(FD_t fd, const unsigned char * buf, ssize_t buflen)
|
|||
|
||||
/** \ingroup rpmio
|
||||
*/
|
||||
/*@unused@*/ static inline
|
||||
static inline
|
||||
void fdFiniDigest(FD_t fd, pgpHashAlgo hashalgo,
|
||||
/*@null@*/ /*@out@*/ void ** datap,
|
||||
/*@null@*/ /*@out@*/ size_t * lenp,
|
||||
void ** datap,
|
||||
size_t * lenp,
|
||||
int asAscii)
|
||||
/*@globals internalState @*/
|
||||
/*@modifies fd, *datap, *lenp, internalState @*/
|
||||
{
|
||||
int imax = -1;
|
||||
int i;
|
||||
|
@ -586,33 +490,26 @@ void fdFiniDigest(FD_t fd, pgpHashAlgo hashalgo,
|
|||
fddig->hashctx = NULL;
|
||||
break;
|
||||
}
|
||||
/*@-boundswrite@*/
|
||||
if (i < 0) {
|
||||
if (datap) *datap = NULL;
|
||||
if (lenp) *lenp = 0;
|
||||
}
|
||||
/*@=boundswrite@*/
|
||||
|
||||
fd->ndigests = imax;
|
||||
if (i < imax)
|
||||
fd->ndigests++; /* convert index to count */
|
||||
}
|
||||
|
||||
/*@-shadow@*/
|
||||
/** \ingroup rpmio
|
||||
*/
|
||||
/*@unused@*/ static inline
|
||||
int fdFileno(/*@null@*/ void * cookie)
|
||||
/*@*/
|
||||
static inline
|
||||
int fdFileno(void * cookie)
|
||||
{
|
||||
FD_t fd;
|
||||
if (cookie == NULL) return -2;
|
||||
fd = c2f(cookie);
|
||||
/*@-boundsread@*/
|
||||
return fd->fps[0].fdno;
|
||||
/*@=boundsread@*/
|
||||
}
|
||||
/*@=shadow@*/
|
||||
|
||||
/**
|
||||
* Read an entire file into a buffer.
|
||||
|
@ -622,9 +519,7 @@ int fdFileno(/*@null@*/ void * cookie)
|
|||
* @return 0 on success
|
||||
*/
|
||||
int rpmioSlurp(const char * fn,
|
||||
/*@out@*/ byte ** bp, /*@out@*/ ssize_t * blenp)
|
||||
/*@globals h_errno, fileSystem, internalState @*/
|
||||
/*@modifies *bp, *blenp, fileSystem, internalState @*/;
|
||||
byte ** bp, ssize_t * blenp);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
/*@-boundsread@*/
|
||||
/** \ingroup rpmio
|
||||
* \file rpmio/rpmlog.c
|
||||
*/
|
||||
|
@ -20,20 +19,17 @@
|
|||
# endif
|
||||
#endif
|
||||
|
||||
/*@access rpmlogRec @*/
|
||||
|
||||
/*@unchecked@*/
|
||||
static int nrecs = 0;
|
||||
/*@unchecked@*/
|
||||
static /*@only@*/ /*@null@*/ rpmlogRec recs = NULL;
|
||||
static rpmlogRec recs = NULL;
|
||||
|
||||
/**
|
||||
* Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
|
||||
* @param p memory to free
|
||||
* @retval NULL always
|
||||
*/
|
||||
/*@unused@*/ static inline /*@null@*/ void *
|
||||
_free(/*@only@*/ /*@null@*/ /*@out@*/ const void * p) /*@modifies p@*/
|
||||
static inline void *
|
||||
_free(const void * p)
|
||||
{
|
||||
if (p != NULL) free((void *)p);
|
||||
return NULL;
|
||||
|
@ -59,7 +55,6 @@ const char * rpmlogMessage(void)
|
|||
return _("(no error)");
|
||||
}
|
||||
|
||||
/*@-modfilesys@*/
|
||||
void rpmlogPrint(FILE *f)
|
||||
{
|
||||
int i;
|
||||
|
@ -74,11 +69,8 @@ void rpmlogPrint(FILE *f)
|
|||
fprintf(f, " %s", rec->message);
|
||||
}
|
||||
}
|
||||
/*@=modfilesys@*/
|
||||
|
||||
void rpmlogClose (void)
|
||||
/*@globals recs, nrecs @*/
|
||||
/*@modifies recs, nrecs @*/
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -91,22 +83,18 @@ void rpmlogClose (void)
|
|||
nrecs = 0;
|
||||
}
|
||||
|
||||
void rpmlogOpen (/*@unused@*/ const char *ident, /*@unused@*/ int option,
|
||||
/*@unused@*/ int facility)
|
||||
void rpmlogOpen (const char *ident, int option,
|
||||
int facility)
|
||||
{
|
||||
}
|
||||
|
||||
/*@unchecked@*/
|
||||
static unsigned rpmlogMask = RPMLOG_UPTO( RPMLOG_NOTICE );
|
||||
|
||||
#ifdef NOTYET
|
||||
/*@unchecked@*/
|
||||
static /*@unused@*/ unsigned rpmlogFacility = RPMLOG_USER;
|
||||
static unsigned rpmlogFacility = RPMLOG_USER;
|
||||
#endif
|
||||
|
||||
int rpmlogSetMask (int mask)
|
||||
/*@globals rpmlogMask @*/
|
||||
/*@modifies rpmlogMask @*/
|
||||
{
|
||||
int omask = rpmlogMask;
|
||||
if (mask)
|
||||
|
@ -114,24 +102,18 @@ int rpmlogSetMask (int mask)
|
|||
return omask;
|
||||
}
|
||||
|
||||
/*@unchecked@*/
|
||||
static /*@null@*/ rpmlogCallback _rpmlogCallback = NULL;
|
||||
static rpmlogCallback _rpmlogCallback = NULL;
|
||||
|
||||
rpmlogCallback rpmlogSetCallback(rpmlogCallback cb)
|
||||
/*@globals _rpmlogCallback @*/
|
||||
/*@modifies _rpmlogCallback @*/
|
||||
{
|
||||
rpmlogCallback ocb = _rpmlogCallback;
|
||||
_rpmlogCallback = cb;
|
||||
return ocb;
|
||||
}
|
||||
|
||||
/*@unchecked@*/ /*@null@*/
|
||||
static FILE * _stdlog = NULL;
|
||||
|
||||
FILE * rpmlogSetFile(FILE * fp)
|
||||
/*@globals _stdlog @*/
|
||||
/*@modifies _stdlog @*/
|
||||
{
|
||||
FILE * ofp = _stdlog;
|
||||
_stdlog = fp;
|
||||
|
@ -139,7 +121,6 @@ FILE * rpmlogSetFile(FILE * fp)
|
|||
}
|
||||
|
||||
/*@-readonlytrans@*/ /* FIX: double indirection. */
|
||||
/*@observer@*/ /*@unchecked@*/
|
||||
static char *rpmlogMsgPrefix[] = {
|
||||
N_("fatal error: "),/*!< RPMLOG_EMERG */
|
||||
N_("fatal error: "),/*!< RPMLOG_ALERT */
|
||||
|
@ -150,27 +131,23 @@ static char *rpmlogMsgPrefix[] = {
|
|||
"", /*!< RPMLOG_INFO */
|
||||
"D: ", /*!< RPMLOG_DEBUG */
|
||||
};
|
||||
/*@=readonlytrans@*/
|
||||
|
||||
#if !defined(HAVE_VSNPRINTF)
|
||||
static inline int vsnprintf(char * buf, /*@unused@*/ int nb,
|
||||
static inline int vsnprintf(char * buf, int nb,
|
||||
const char * fmt, va_list ap)
|
||||
{
|
||||
return vsprintf(buf, fmt, ap);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*@-modfilesys@*/
|
||||
/*@-compmempass@*/ /* FIX: rpmlogMsgPrefix[] dependent, not unqualified */
|
||||
/*@-nullstate@*/ /* FIX: rpmlogMsgPrefix[] may be NULL */
|
||||
/* FIX: rpmlogMsgPrefix[] dependent, not unqualified */
|
||||
/* FIX: rpmlogMsgPrefix[] may be NULL */
|
||||
static void vrpmlog (unsigned code, const char *fmt, va_list ap)
|
||||
/*@globals nrecs, recs, internalState @*/
|
||||
/*@modifies nrecs, recs, internalState @*/
|
||||
{
|
||||
unsigned pri = RPMLOG_PRI(code);
|
||||
unsigned mask = RPMLOG_MASK(pri);
|
||||
#ifdef NOTYET
|
||||
/*@unused@*/ unsigned fac = RPMLOG_FAC(code);
|
||||
unsigned fac = RPMLOG_FAC(code);
|
||||
#endif
|
||||
char *msgbuf, *msg;
|
||||
int msgnb = BUFSIZ, nb;
|
||||
|
@ -179,14 +156,13 @@ static void vrpmlog (unsigned code, const char *fmt, va_list ap)
|
|||
if ((mask & rpmlogMask) == 0)
|
||||
return;
|
||||
|
||||
/*@-boundswrite@*/
|
||||
msgbuf = xmalloc(msgnb);
|
||||
*msgbuf = '\0';
|
||||
|
||||
/* Allocate a sufficently large buffer for output. */
|
||||
while (1) {
|
||||
va_list apc;
|
||||
/*@-sysunrecog -usedef@*/ va_copy(apc, ap); /*@=sysunrecog =usedef@*/
|
||||
va_copy(apc, ap);
|
||||
nb = vsnprintf(msgbuf, msgnb, fmt, apc);
|
||||
if (nb > -1 && nb < msgnb)
|
||||
break;
|
||||
|
@ -195,15 +171,12 @@ static void vrpmlog (unsigned code, const char *fmt, va_list ap)
|
|||
else /* glibc 2.0 */
|
||||
msgnb *= 2;
|
||||
msgbuf = xrealloc(msgbuf, msgnb);
|
||||
/*@-mods@*/
|
||||
va_end(apc);
|
||||
/*@=mods@*/
|
||||
}
|
||||
msgbuf[msgnb - 1] = '\0';
|
||||
msg = msgbuf;
|
||||
|
||||
/* Save copy of all messages at warning (or below == "more important"). */
|
||||
/*@-branchstate@*/
|
||||
if (pri <= RPMLOG_WARNING) {
|
||||
|
||||
if (recs == NULL)
|
||||
|
@ -218,14 +191,11 @@ static void vrpmlog (unsigned code, const char *fmt, va_list ap)
|
|||
++nrecs;
|
||||
|
||||
if (_rpmlogCallback) {
|
||||
/*@-noeffectuncon@*/ /* FIX: useless callback */
|
||||
/* FIX: useless callback */
|
||||
_rpmlogCallback();
|
||||
/*@=noeffectuncon@*/
|
||||
return; /* XXX Preserve legacy rpmError behavior. */
|
||||
}
|
||||
}
|
||||
/*@=branchstate@*/
|
||||
/*@=boundswrite@*/
|
||||
|
||||
/* rpmMessage behavior */
|
||||
|
||||
|
@ -253,17 +223,14 @@ static void vrpmlog (unsigned code, const char *fmt, va_list ap)
|
|||
if (pri <= RPMLOG_CRIT)
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
/*@=compmempass =nullstate@*/
|
||||
/*@=modfilesys@*/
|
||||
|
||||
void rpmlog (int code, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
/*@-internalglobs@*/ /* FIX: shrug */
|
||||
/* FIX: shrug */
|
||||
vrpmlog(code, fmt, ap);
|
||||
/*@=internalglobs@*/
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
|
@ -281,4 +248,3 @@ rpmlogCallback rpmErrorSetCallback(rpmlogCallback cb)
|
|||
{
|
||||
return rpmlogSetCallback(cb);
|
||||
}
|
||||
/*@=boundsread@*/
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
*
|
||||
* priorities (these are ordered)
|
||||
*/
|
||||
/*@-typeuse@*/
|
||||
typedef enum rpmlogLvl_e {
|
||||
RPMLOG_EMERG = 0, /*!< system is unusable */
|
||||
RPMLOG_ALERT = 1, /*!< action must be taken immediately */
|
||||
|
@ -30,7 +29,6 @@ typedef enum rpmlogLvl_e {
|
|||
RPMLOG_INFO = 6, /*!< informational */
|
||||
RPMLOG_DEBUG = 7 /*!< debug-level messages */
|
||||
} rpmlogLvl;
|
||||
/*@=typeuse@*/
|
||||
|
||||
#define RPMLOG_PRIMASK 0x07 /* mask to extract priority part (internal) */
|
||||
/* extract priority */
|
||||
|
@ -67,7 +65,6 @@ RPMCODE rpmprioritynames[] =
|
|||
/**
|
||||
* facility codes
|
||||
*/
|
||||
/*@-enummemuse -typeuse@*/
|
||||
typedef enum rpmlogFac_e {
|
||||
RPMLOG_KERN = (0<<3), /*!< kernel messages */
|
||||
RPMLOG_USER = (1<<3), /*!< random user-level messages */
|
||||
|
@ -95,7 +92,6 @@ typedef enum rpmlogFac_e {
|
|||
#define RPMLOG_NFACILITIES 24 /*!< current number of facilities */
|
||||
RPMLOG_ERRMSG = (((unsigned)(RPMLOG_NFACILITIES+0))<<3)
|
||||
} rpmlogFac;
|
||||
/*@=enummemuse =typeuse@*/
|
||||
|
||||
#define RPMLOG_FACMASK 0x03f8 /*!< mask to extract facility part */
|
||||
#define RPMLOG_FAC(p) (((p) & RPMLOG_FACMASK) >> 3)
|
||||
|
@ -156,9 +152,8 @@ typedef void (*rpmlogCallback) (void);
|
|||
|
||||
/**
|
||||
*/
|
||||
typedef /*@abstract@*/ struct rpmlogRec_s {
|
||||
typedef struct rpmlogRec_s {
|
||||
int code;
|
||||
/*@owned@*/ /*@null@*/
|
||||
const char * message;
|
||||
} * rpmlogRec;
|
||||
|
||||
|
@ -170,57 +165,43 @@ extern "C" {
|
|||
* Return number of rpmError() ressages.
|
||||
* @return number of messages
|
||||
*/
|
||||
int rpmlogGetNrecs(void) /*@*/;
|
||||
int rpmlogGetNrecs(void) ;
|
||||
|
||||
/**
|
||||
* Print all rpmError() messages.
|
||||
* @param f file handle (NULL uses stderr)
|
||||
*/
|
||||
void rpmlogPrint(/*@null@*/ FILE *f)
|
||||
/*@modifies *f @*/;
|
||||
void rpmlogPrint(FILE *f);
|
||||
|
||||
/**
|
||||
* Close desriptor used to write to system logger.
|
||||
* @todo Implement.
|
||||
*/
|
||||
/*@unused@*/
|
||||
void rpmlogClose (void)
|
||||
/*@globals internalState@*/
|
||||
/*@modifies internalState @*/;
|
||||
void rpmlogClose (void);
|
||||
|
||||
/**
|
||||
* Open connection to system logger.
|
||||
* @todo Implement.
|
||||
*/
|
||||
/*@unused@*/
|
||||
void rpmlogOpen (const char * ident, int option, int facility)
|
||||
/*@globals internalState@*/
|
||||
/*@modifies internalState @*/;
|
||||
void rpmlogOpen (const char * ident, int option, int facility);
|
||||
|
||||
/**
|
||||
* Set the log mask level.
|
||||
* @param mask log mask (0 is no operation)
|
||||
* @return previous log mask
|
||||
*/
|
||||
int rpmlogSetMask (int mask)
|
||||
/*@globals internalState@*/
|
||||
/*@modifies internalState @*/;
|
||||
int rpmlogSetMask (int mask);
|
||||
|
||||
/**
|
||||
* Generate a log message using FMT string and option arguments.
|
||||
*/
|
||||
/*@mayexit@*/ /*@printflike@*/ void rpmlog (int code, const char *fmt, ...)
|
||||
/*@*/;
|
||||
void rpmlog (int code, const char *fmt, ...);
|
||||
|
||||
/*@-exportlocal@*/
|
||||
/**
|
||||
* Return text of last rpmError() message.
|
||||
* @return text of last message
|
||||
*/
|
||||
/*@-redecl@*/
|
||||
/*@observer@*/ /*@null@*/ const char * rpmlogMessage(void)
|
||||
/*@*/;
|
||||
/*@=redecl@*/
|
||||
const char * rpmlogMessage(void);
|
||||
|
||||
/**
|
||||
* Return error code from last rpmError() message.
|
||||
|
@ -229,53 +210,41 @@ int rpmlogSetMask (int mask)
|
|||
* and parsed IMHO.
|
||||
* @return code from last message
|
||||
*/
|
||||
int rpmlogCode(void)
|
||||
/*@*/;
|
||||
int rpmlogCode(void);
|
||||
|
||||
/**
|
||||
* Set rpmlog callback function.
|
||||
* @param cb rpmlog callback function
|
||||
* @return previous rpmlog callback function
|
||||
*/
|
||||
rpmlogCallback rpmlogSetCallback(rpmlogCallback cb)
|
||||
/*@globals internalState@*/
|
||||
/*@modifies internalState @*/;
|
||||
rpmlogCallback rpmlogSetCallback(rpmlogCallback cb);
|
||||
|
||||
/**
|
||||
* Set rpmlog file handle.
|
||||
* @param fp rpmlog file handle (NULL uses stdout/stderr)
|
||||
* @return previous rpmlog file handle
|
||||
*/
|
||||
/*@null@*/
|
||||
FILE * rpmlogSetFile(/*@null@*/ FILE * fp)
|
||||
/*@globals internalState@*/
|
||||
/*@modifies internalState @*/;
|
||||
/*@=exportlocal@*/
|
||||
FILE * rpmlogSetFile(FILE * fp);
|
||||
|
||||
/**
|
||||
* Set rpmlog callback function.
|
||||
* @deprecated gnorpm needs, use rpmlogSetCallback() instead.
|
||||
*/
|
||||
extern rpmlogCallback rpmErrorSetCallback(rpmlogCallback cb)
|
||||
/*@globals internalState@*/
|
||||
/*@modifies internalState @*/;
|
||||
extern rpmlogCallback rpmErrorSetCallback(rpmlogCallback cb);
|
||||
|
||||
/**
|
||||
* Return error code from last rpmError() message.
|
||||
* @deprecated Perl-RPM needs, use rpmlogCode() instead.
|
||||
* @return code from last message
|
||||
*/
|
||||
extern int rpmErrorCode(void)
|
||||
/*@*/;
|
||||
extern int rpmErrorCode(void);
|
||||
|
||||
/**
|
||||
* Return text of last rpmError() message.
|
||||
* @deprecated gnorpm needs, use rpmlogMessage() instead.
|
||||
* @return text of last message
|
||||
*/
|
||||
/*@-redecl@*/
|
||||
/*@observer@*/ /*@null@*/ extern const char * rpmErrorString(void) /*@*/;
|
||||
/*@=redecl@*/
|
||||
extern const char * rpmErrorString(void) ;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
112
rpmio/rpmlua.c
112
rpmio/rpmlua.c
|
@ -1,4 +1,3 @@
|
|||
/*@-bounds -realcompare -sizeoftype -protoparammatch @*/
|
||||
#include "system.h"
|
||||
|
||||
#ifdef WITH_LUA
|
||||
|
@ -23,7 +22,7 @@
|
|||
#include "debug.h"
|
||||
|
||||
#if !defined(HAVE_VSNPRINTF)
|
||||
static inline int vsnprintf(char * buf, /*@unused@*/ int nb,
|
||||
static inline int vsnprintf(char * buf, int nb,
|
||||
const char * fmt, va_list ap)
|
||||
{
|
||||
return vsprintf(buf, fmt, ap);
|
||||
|
@ -33,27 +32,22 @@ static inline int vsnprintf(char * buf, /*@unused@*/ int nb,
|
|||
#define INITSTATE(_lua, lua) \
|
||||
rpmlua lua = _lua ? _lua : \
|
||||
(globalLuaState ? globalLuaState : \
|
||||
/*@-mods@*/ \
|
||||
\
|
||||
(globalLuaState = rpmluaNew()) \
|
||||
/*@=mods@*/ \
|
||||
\
|
||||
)
|
||||
|
||||
/*@only@*/ /*@unchecked@*/ /*@null@*/
|
||||
static rpmlua globalLuaState = NULL;
|
||||
|
||||
static int luaopen_rpm(lua_State *L)
|
||||
/*@modifies L @*/;
|
||||
static int rpm_print(lua_State *L)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies L, fileSystem @*/;
|
||||
static int luaopen_rpm(lua_State *L);
|
||||
static int rpm_print(lua_State *L);
|
||||
|
||||
rpmlua rpmluaNew()
|
||||
{
|
||||
rpmlua lua = (rpmlua) xcalloc(1, sizeof(*lua));
|
||||
lua_State *L = lua_open();
|
||||
struct stat st;
|
||||
/*@-readonlytrans@*/
|
||||
/*@observer@*/ /*@unchecked@*/
|
||||
|
||||
static const luaL_reg lualibs[] = {
|
||||
{"base", luaopen_base},
|
||||
{"table", luaopen_table},
|
||||
|
@ -66,15 +60,12 @@ rpmlua rpmluaNew()
|
|||
{"rpm", luaopen_rpm},
|
||||
{NULL, NULL},
|
||||
};
|
||||
/*@observer@*/ /*@unchecked@*/
|
||||
|
||||
const luaL_reg *lib = lualibs;
|
||||
/*@=readonlytrans@*/
|
||||
|
||||
lua->L = L;
|
||||
for (; lib->name; lib++) {
|
||||
/*@-noeffectuncon@*/
|
||||
(void) lib->func(L);
|
||||
/*@=noeffectuncon@*/
|
||||
lua_settop(L, 0);
|
||||
}
|
||||
lua_pushliteral(L, "LUA_PATH");
|
||||
|
@ -114,17 +105,14 @@ void rpmluaSetData(rpmlua _lua, const char *key, const void *data)
|
|||
}
|
||||
|
||||
static void *getdata(lua_State *L, const char *key)
|
||||
/*@modifies L @*/
|
||||
{
|
||||
void *ret = NULL;
|
||||
lua_pushliteral(L, "rpm_");
|
||||
lua_pushstring(L, key);
|
||||
lua_concat(L, 2);
|
||||
lua_rawget(L, LUA_REGISTRYINDEX);
|
||||
/*@-branchstate@*/
|
||||
if (lua_islightuserdata(L, -1))
|
||||
ret = lua_touserdata(L, -1);
|
||||
/*@=branchstate@*/
|
||||
lua_pop(L, 1);
|
||||
return ret;
|
||||
}
|
||||
|
@ -151,7 +139,6 @@ const char *rpmluaGetPrintBuffer(rpmlua _lua)
|
|||
}
|
||||
|
||||
static int pushvar(lua_State *L, rpmluavType type, void *value)
|
||||
/*@modifies L @*/
|
||||
{
|
||||
int ret = 0;
|
||||
switch (type) {
|
||||
|
@ -197,14 +184,11 @@ void rpmluaSetVar(rpmlua _lua, rpmluav var)
|
|||
}
|
||||
|
||||
static void popvar(lua_State *L, rpmluavType *type, void *value)
|
||||
/*@modifies L, *type, *value @*/
|
||||
{
|
||||
switch (lua_type(L, -1)) {
|
||||
case LUA_TSTRING:
|
||||
*type = RPMLUAV_STRING;
|
||||
/*@-observertrans -dependenttrans @*/
|
||||
*((const char **)value) = lua_tostring(L, -1);
|
||||
/*@=observertrans =dependenttrans @*/
|
||||
break;
|
||||
case LUA_TNUMBER:
|
||||
*type = RPMLUAV_NUMBER;
|
||||
|
@ -242,7 +226,6 @@ void rpmluaGetVar(rpmlua _lua, rpmluav var)
|
|||
#define FINDKEY_CREATE 1
|
||||
#define FINDKEY_REMOVE 2
|
||||
static int findkey(lua_State *L, int oper, const char *key, va_list va)
|
||||
/*@modifies L @*/
|
||||
{
|
||||
char buf[BUFSIZ];
|
||||
const char *s, *e;
|
||||
|
@ -260,13 +243,12 @@ static int findkey(lua_State *L, int oper, const char *key, va_list va)
|
|||
lua_pushnil(L);
|
||||
lua_rawset(L, -3);
|
||||
lua_pop(L, 1);
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
}
|
||||
/*@fallthrough@*/
|
||||
case FINDKEY_RETURN:
|
||||
lua_rawget(L, -2);
|
||||
lua_remove(L, -2);
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
case FINDKEY_CREATE:
|
||||
lua_rawget(L, -2);
|
||||
if (!lua_istable(L, -1)) {
|
||||
|
@ -277,7 +259,7 @@ static int findkey(lua_State *L, int oper, const char *key, va_list va)
|
|||
lua_rawset(L, -4);
|
||||
}
|
||||
lua_remove(L, -2);
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (*e == '\0')
|
||||
|
@ -359,7 +341,6 @@ void rpmluavSetListMode(rpmluav var, int flag)
|
|||
void rpmluavSetKey(rpmluav var, rpmluavType type, const void *value)
|
||||
{
|
||||
var->keyType = type;
|
||||
/*@-assignexpose -branchstate -temptrans @*/
|
||||
switch (type) {
|
||||
case RPMLUAV_NUMBER:
|
||||
var->key.num = *((double *)value);
|
||||
|
@ -370,13 +351,11 @@ void rpmluavSetKey(rpmluav var, rpmluavType type, const void *value)
|
|||
default:
|
||||
break;
|
||||
}
|
||||
/*@=assignexpose =branchstate =temptrans @*/
|
||||
}
|
||||
|
||||
void rpmluavSetValue(rpmluav var, rpmluavType type, const void *value)
|
||||
{
|
||||
var->valueType = type;
|
||||
/*@-assignexpose -branchstate -temptrans @*/
|
||||
switch (type) {
|
||||
case RPMLUAV_NUMBER:
|
||||
var->value.num = *((const double *)value);
|
||||
|
@ -387,13 +366,11 @@ void rpmluavSetValue(rpmluav var, rpmluavType type, const void *value)
|
|||
default:
|
||||
break;
|
||||
}
|
||||
/*@=assignexpose =branchstate =temptrans @*/
|
||||
}
|
||||
|
||||
void rpmluavGetKey(rpmluav var, rpmluavType *type, void **value)
|
||||
{
|
||||
*type = var->keyType;
|
||||
/*@-onlytrans@*/
|
||||
switch (var->keyType) {
|
||||
case RPMLUAV_NUMBER:
|
||||
*((double **)value) = &var->key.num;
|
||||
|
@ -404,13 +381,11 @@ void rpmluavGetKey(rpmluav var, rpmluavType *type, void **value)
|
|||
default:
|
||||
break;
|
||||
}
|
||||
/*@=onlytrans@*/
|
||||
}
|
||||
|
||||
void rpmluavGetValue(rpmluav var, rpmluavType *type, void **value)
|
||||
{
|
||||
*type = var->valueType;
|
||||
/*@-onlytrans@*/
|
||||
switch (var->valueType) {
|
||||
case RPMLUAV_NUMBER:
|
||||
*((double **)value) = &var->value.num;
|
||||
|
@ -421,7 +396,6 @@ void rpmluavGetValue(rpmluav var, rpmluavType *type, void **value)
|
|||
default:
|
||||
break;
|
||||
}
|
||||
/*@=onlytrans@*/
|
||||
}
|
||||
|
||||
void rpmluavSetKeyNum(rpmluav var, double value)
|
||||
|
@ -469,10 +443,8 @@ int rpmluaCheckScript(rpmlua _lua, const char *script, const char *name)
|
|||
INITSTATE(_lua, lua);
|
||||
lua_State *L = lua->L;
|
||||
int ret = 0;
|
||||
/*@-branchstate@*/
|
||||
if (name == NULL)
|
||||
name = "<lua>";
|
||||
/*@=branchstate@*/
|
||||
if (luaL_loadbuffer(L, script, strlen(script), name) != 0) {
|
||||
rpmError(RPMERR_SCRIPT,
|
||||
_("invalid syntax in lua scriptlet: %s\n"),
|
||||
|
@ -488,10 +460,8 @@ int rpmluaRunScript(rpmlua _lua, const char *script, const char *name)
|
|||
INITSTATE(_lua, lua);
|
||||
lua_State *L = lua->L;
|
||||
int ret = 0;
|
||||
/*@-branchstate@*/
|
||||
if (name == NULL)
|
||||
name = "<lua>";
|
||||
/*@=branchstate@*/
|
||||
if (luaL_loadbuffer(L, script, strlen(script), name) != 0) {
|
||||
rpmError(RPMERR_SCRIPT, _("invalid syntax in lua script: %s\n"),
|
||||
lua_tostring(L, -1));
|
||||
|
@ -527,8 +497,6 @@ int rpmluaRunScriptFile(rpmlua _lua, const char *filename)
|
|||
|
||||
/* From lua.c */
|
||||
static int rpmluaReadline(lua_State *L, const char *prompt)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies L, fileSystem @*/
|
||||
{
|
||||
static char buffer[1024];
|
||||
if (prompt) {
|
||||
|
@ -545,8 +513,6 @@ static int rpmluaReadline(lua_State *L, const char *prompt)
|
|||
|
||||
/* Based on lua.c */
|
||||
static void _rpmluaInteractive(lua_State *L)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies L, fileSystem @*/
|
||||
{
|
||||
(void) fputs("\n", stdout);
|
||||
printf("RPM Interactive %s Interpreter\n", LUA_VERSION);
|
||||
|
@ -556,25 +522,21 @@ static void _rpmluaInteractive(lua_State *L)
|
|||
if (rpmluaReadline(L, "> ") == 0)
|
||||
break;
|
||||
if (lua_tostring(L, -1)[0] == '=') {
|
||||
/*@-evalorder@*/
|
||||
(void) lua_pushfstring(L, "print(%s)", lua_tostring(L, -1)+1);
|
||||
/*@=evalorder@*/
|
||||
lua_remove(L, -2);
|
||||
}
|
||||
for (;;) {
|
||||
/*@-evalorder@*/
|
||||
rc = luaL_loadbuffer(L, lua_tostring(L, -1),
|
||||
lua_strlen(L, -1), "<lua>");
|
||||
/*@=evalorder@*/
|
||||
if (rc == LUA_ERRSYNTAX &&
|
||||
strstr(lua_tostring(L, -1), "near `<eof>'") != NULL) {
|
||||
if (rpmluaReadline(L, ">> ") == 0)
|
||||
/*@innerbreak@*/ break;
|
||||
break;
|
||||
lua_remove(L, -2); /* Remove error */
|
||||
lua_concat(L, 2);
|
||||
/*@innercontinue@*/ continue;
|
||||
continue;
|
||||
}
|
||||
/*@innerbreak@*/ break;
|
||||
break;
|
||||
}
|
||||
if (rc == 0)
|
||||
rc = lua_pcall(L, 0, 0, 0);
|
||||
|
@ -587,20 +549,16 @@ static void _rpmluaInteractive(lua_State *L)
|
|||
(void) fputs("\n", stdout);
|
||||
}
|
||||
|
||||
/*@-mods@*/
|
||||
void rpmluaInteractive(rpmlua _lua)
|
||||
{
|
||||
INITSTATE(_lua, lua);
|
||||
_rpmluaInteractive(lua->L);
|
||||
}
|
||||
/*@=mods@*/
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Lua API */
|
||||
|
||||
static int rpm_expand(lua_State *L)
|
||||
/*@globals rpmGlobalMacroContext, h_errno @*/
|
||||
/*@modifies L, rpmGlobalMacroContext @*/
|
||||
{
|
||||
const char *str = luaL_checkstring(L, 1);
|
||||
lua_pushstring(L, rpmExpand(str, NULL));
|
||||
|
@ -608,8 +566,6 @@ static int rpm_expand(lua_State *L)
|
|||
}
|
||||
|
||||
static int rpm_define(lua_State *L)
|
||||
/*@globals rpmGlobalMacroContext, h_errno @*/
|
||||
/*@modifies L, rpmGlobalMacroContext @*/
|
||||
{
|
||||
const char *str = luaL_checkstring(L, 1);
|
||||
(void) rpmDefineMacro(NULL, str, 0);
|
||||
|
@ -617,22 +573,18 @@ static int rpm_define(lua_State *L)
|
|||
}
|
||||
|
||||
static int rpm_interactive(lua_State *L)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies L, fileSystem @*/
|
||||
{
|
||||
_rpmluaInteractive(L);
|
||||
return 0;
|
||||
}
|
||||
|
||||
typedef struct rpmluaHookData_s {
|
||||
/*@shared@*/
|
||||
lua_State *L;
|
||||
int funcRef;
|
||||
int dataRef;
|
||||
} * rpmluaHookData;
|
||||
|
||||
static int rpmluaHookWrapper(rpmhookArgs args, void *data)
|
||||
/*@*/
|
||||
{
|
||||
rpmluaHookData hookdata = (rpmluaHookData)data;
|
||||
lua_State *L = hookdata->L;
|
||||
|
@ -645,23 +597,23 @@ static int rpmluaHookWrapper(rpmhookArgs args, void *data)
|
|||
case 's':
|
||||
lua_pushstring(L, args->argv[i].s);
|
||||
lua_rawseti(L, -2, i+1);
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
case 'i':
|
||||
lua_pushnumber(L, (lua_Number)args->argv[i].i);
|
||||
lua_rawseti(L, -2, i+1);
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
case 'f':
|
||||
lua_pushnumber(L, (lua_Number)args->argv[i].f);
|
||||
lua_rawseti(L, -2, i+1);
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
case 'p':
|
||||
lua_pushlightuserdata(L, args->argv[i].p);
|
||||
lua_rawseti(L, -2, i+1);
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
default:
|
||||
(void) luaL_error(L, "unsupported type '%c' as "
|
||||
"a hook argument\n", args->argt[i]);
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (lua_pcall(L, 1, 1, 0) != 0) {
|
||||
|
@ -677,8 +629,6 @@ static int rpmluaHookWrapper(rpmhookArgs args, void *data)
|
|||
}
|
||||
|
||||
static int rpm_register(lua_State *L)
|
||||
/*@globals internalState @*/
|
||||
/*@modifies L, internalState @*/
|
||||
{
|
||||
if (!lua_isstring(L, 1)) {
|
||||
(void) luaL_argerror(L, 1, "hook name expected");
|
||||
|
@ -691,9 +641,7 @@ static int rpm_register(lua_State *L)
|
|||
hookdata->dataRef = luaL_ref(L, LUA_REGISTRYINDEX);
|
||||
lua_pushvalue(L, 2);
|
||||
hookdata->funcRef = luaL_ref(L, LUA_REGISTRYINDEX);
|
||||
/*@-temptrans@*/
|
||||
hookdata->L = L;
|
||||
/*@=temptrans@*/
|
||||
rpmhookRegister(lua_tostring(L, 1), rpmluaHookWrapper, hookdata);
|
||||
return 1;
|
||||
}
|
||||
|
@ -701,7 +649,6 @@ static int rpm_register(lua_State *L)
|
|||
}
|
||||
|
||||
static int rpm_unregister(lua_State *L)
|
||||
/*@modifies L @*/
|
||||
{
|
||||
if (!lua_isstring(L, 1)) {
|
||||
(void) luaL_argerror(L, 1, "hook name expected");
|
||||
|
@ -717,8 +664,6 @@ static int rpm_unregister(lua_State *L)
|
|||
}
|
||||
|
||||
static int rpm_call(lua_State *L)
|
||||
/*@globals internalState @*/
|
||||
/*@modifies L, internalState @*/
|
||||
{
|
||||
if (!lua_isstring(L, 1)) {
|
||||
(void) luaL_argerror(L, 1, "hook name expected");
|
||||
|
@ -732,10 +677,9 @@ static int rpm_call(lua_State *L)
|
|||
case LUA_TNIL:
|
||||
argt[i] = 'p';
|
||||
args->argv[i].p = NULL;
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
case LUA_TNUMBER: {
|
||||
float f = (float)lua_tonumber(L, i+1);
|
||||
/*@+relaxtypes@*/
|
||||
if (f == (int)f) {
|
||||
argt[i] = 'i';
|
||||
args->argv[i].i = (int)f;
|
||||
|
@ -743,38 +687,33 @@ static int rpm_call(lua_State *L)
|
|||
argt[i] = 'f';
|
||||
args->argv[i].f = f;
|
||||
}
|
||||
/*@=relaxtypes@*/
|
||||
} /*@switchbreak@*/ break;
|
||||
} break;
|
||||
case LUA_TSTRING:
|
||||
argt[i] = 's';
|
||||
args->argv[i].s = lua_tostring(L, i+1);
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
case LUA_TUSERDATA:
|
||||
case LUA_TLIGHTUSERDATA:
|
||||
argt[i] = 'p';
|
||||
args->argv[i].p = lua_touserdata(L, i+1);
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
default:
|
||||
(void) luaL_error(L, "unsupported Lua type passed to hook");
|
||||
argt[i] = 'p';
|
||||
args->argv[i].p = NULL;
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*@-compdef -kepttrans -usereleased @*/
|
||||
args->argt = argt;
|
||||
rpmhookCallArgs(name, args);
|
||||
free(argt);
|
||||
(void) rpmhookArgsFree(args);
|
||||
/*@=compdef =kepttrans =usereleased @*/
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Based on luaB_print. */
|
||||
static int rpm_print (lua_State *L)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies L, fileSystem @*/
|
||||
{
|
||||
rpmlua lua = (rpmlua)getdata(L, "lua");
|
||||
int n = lua_gettop(L); /* number of arguments */
|
||||
|
@ -820,8 +759,6 @@ static int rpm_print (lua_State *L)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*@-readonlytrans@*/
|
||||
/*@observer@*/ /*@unchecked@*/
|
||||
static const luaL_reg rpmlib[] = {
|
||||
{"expand", rpm_expand},
|
||||
{"define", rpm_define},
|
||||
|
@ -831,10 +768,8 @@ static const luaL_reg rpmlib[] = {
|
|||
{"interactive", rpm_interactive},
|
||||
{NULL, NULL}
|
||||
};
|
||||
/*@=readonlytrans@*/
|
||||
|
||||
static int luaopen_rpm(lua_State *L)
|
||||
/*@modifies L @*/
|
||||
{
|
||||
lua_pushvalue(L, LUA_GLOBALSINDEX);
|
||||
luaL_openlib(L, "rpm", rpmlib, 0);
|
||||
|
@ -842,4 +777,3 @@ static int luaopen_rpm(lua_State *L)
|
|||
}
|
||||
#endif /* WITH_LUA */
|
||||
|
||||
/*@=bounds =realcompare =sizeoftype =protoparammatch @*/
|
||||
|
|
127
rpmio/rpmlua.h
127
rpmio/rpmlua.h
|
@ -39,107 +39,46 @@ struct rpmluav_s {
|
|||
|
||||
#endif /* _RPMLUA_INTERNAL */
|
||||
|
||||
typedef /*@abstract@*/ struct rpmlua_s * rpmlua;
|
||||
typedef /*@abstract@*/ struct rpmluav_s * rpmluav;
|
||||
typedef struct rpmlua_s * rpmlua;
|
||||
typedef struct rpmluav_s * rpmluav;
|
||||
|
||||
/*@-exportlocal@*/
|
||||
/*@only@*/
|
||||
rpmlua rpmluaNew(void)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies fileSystem @*/;
|
||||
/*@=exportlocal@*/
|
||||
void *rpmluaFree(/*@only@*/ rpmlua lua)
|
||||
/*@modifies lua @*/;
|
||||
rpmlua rpmluaNew(void);
|
||||
void *rpmluaFree(rpmlua lua);
|
||||
|
||||
int rpmluaCheckScript(/*@null@*/ rpmlua lua, const char *script,
|
||||
/*@null@*/ const char *name)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies lua, fileSystem @*/;
|
||||
int rpmluaRunScript(/*@null@*/ rpmlua lua, const char *script,
|
||||
/*@null@*/ const char *name)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies lua, fileSystem @*/;
|
||||
/*@-exportlocal@*/
|
||||
int rpmluaRunScriptFile(/*@null@*/ rpmlua lua, const char *filename)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies lua, fileSystem @*/;
|
||||
/*@=exportlocal@*/
|
||||
void rpmluaInteractive(/*@null@*/ rpmlua lua)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies lua, fileSystem @*/;
|
||||
int rpmluaCheckScript(rpmlua lua, const char *script,
|
||||
const char *name);
|
||||
int rpmluaRunScript(rpmlua lua, const char *script,
|
||||
const char *name);
|
||||
int rpmluaRunScriptFile(rpmlua lua, const char *filename);
|
||||
void rpmluaInteractive(rpmlua lua);
|
||||
|
||||
void *rpmluaGetData(/*@null@*/ rpmlua lua, const char *key)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies lua, fileSystem @*/;
|
||||
/*@-exportlocal@*/
|
||||
void rpmluaSetData(/*@null@*/ rpmlua lua, const char *key, const void *data)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies lua, fileSystem @*/;
|
||||
/*@=exportlocal@*/
|
||||
void *rpmluaGetData(rpmlua lua, const char *key);
|
||||
void rpmluaSetData(rpmlua lua, const char *key, const void *data);
|
||||
|
||||
/*@exposed@*/
|
||||
const char *rpmluaGetPrintBuffer(/*@null@*/ rpmlua lua)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies lua, fileSystem @*/;
|
||||
void rpmluaSetPrintBuffer(/*@null@*/ rpmlua lua, int flag)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies lua, fileSystem @*/;
|
||||
const char *rpmluaGetPrintBuffer(rpmlua lua);
|
||||
void rpmluaSetPrintBuffer(rpmlua lua, int flag);
|
||||
|
||||
void rpmluaGetVar(/*@null@*/ rpmlua lua, rpmluav var)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies lua, var, fileSystem @*/;
|
||||
void rpmluaSetVar(/*@null@*/ rpmlua lua, rpmluav var)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies lua, var, fileSystem @*/;
|
||||
void rpmluaDelVar(/*@null@*/ rpmlua lua, const char *key, ...)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies lua, fileSystem @*/;
|
||||
int rpmluaVarExists(/*@null@*/ rpmlua lua, const char *key, ...)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies lua, fileSystem @*/;
|
||||
void rpmluaPushTable(/*@null@*/ rpmlua lua, const char *key, ...)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies lua, fileSystem @*/;
|
||||
void rpmluaPop(/*@null@*/ rpmlua lua)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies lua, fileSystem @*/;
|
||||
void rpmluaGetVar(rpmlua lua, rpmluav var);
|
||||
void rpmluaSetVar(rpmlua lua, rpmluav var);
|
||||
void rpmluaDelVar(rpmlua lua, const char *key, ...);
|
||||
int rpmluaVarExists(rpmlua lua, const char *key, ...);
|
||||
void rpmluaPushTable(rpmlua lua, const char *key, ...);
|
||||
void rpmluaPop(rpmlua lua);
|
||||
|
||||
/*@only@*/
|
||||
rpmluav rpmluavNew(void)
|
||||
/*@*/;
|
||||
void * rpmluavFree(/*@only@*/ rpmluav var)
|
||||
/*@modifes var @*/;
|
||||
void rpmluavSetListMode(rpmluav var, int flag)
|
||||
/*@modifies var @*/;
|
||||
/*@-exportlocal@*/
|
||||
void rpmluavSetKey(rpmluav var, rpmluavType type, const void *value)
|
||||
/*@modifies var @*/;
|
||||
/*@=exportlocal@*/
|
||||
/*@-exportlocal@*/
|
||||
void rpmluavSetValue(rpmluav var, rpmluavType type, const void *value)
|
||||
/*@modifies var @*/;
|
||||
/*@=exportlocal@*/
|
||||
/*@-exportlocal@*/
|
||||
void rpmluavGetKey(rpmluav var, /*@out@*/ rpmluavType *type, /*@out@*/ void **value)
|
||||
/*@modifies *type, *value @*/;
|
||||
/*@=exportlocal@*/
|
||||
/*@-exportlocal@*/
|
||||
void rpmluavGetValue(rpmluav var, /*@out@*/ rpmluavType *type, /*@out@*/ void **value)
|
||||
/*@modifies *type, *value @*/;
|
||||
/*@=exportlocal@*/
|
||||
rpmluav rpmluavNew(void);
|
||||
void * rpmluavFree(rpmluav var);
|
||||
void rpmluavSetListMode(rpmluav var, int flag);
|
||||
void rpmluavSetKey(rpmluav var, rpmluavType type, const void *value);
|
||||
void rpmluavSetValue(rpmluav var, rpmluavType type, const void *value);
|
||||
void rpmluavGetKey(rpmluav var, rpmluavType *type, void **value);
|
||||
void rpmluavGetValue(rpmluav var, rpmluavType *type, void **value);
|
||||
|
||||
/* Optional helpers for numbers. */
|
||||
void rpmluavSetKeyNum(rpmluav var, double value)
|
||||
/*@modifies var @*/;
|
||||
void rpmluavSetValueNum(rpmluav var, double value)
|
||||
/*@modifies var @*/;
|
||||
double rpmluavGetKeyNum(rpmluav var)
|
||||
/*@*/;
|
||||
double rpmluavGetValueNum(rpmluav var)
|
||||
/*@*/;
|
||||
int rpmluavKeyIsNum(rpmluav var)
|
||||
/*@*/;
|
||||
int rpmluavValueIsNum(rpmluav var)
|
||||
/*@*/;
|
||||
void rpmluavSetKeyNum(rpmluav var, double value);
|
||||
void rpmluavSetValueNum(rpmluav var, double value);
|
||||
double rpmluavGetKeyNum(rpmluav var);
|
||||
double rpmluavGetValueNum(rpmluav var);
|
||||
int rpmluavKeyIsNum(rpmluav var);
|
||||
int rpmluavValueIsNum(rpmluav var);
|
||||
|
||||
#endif /* RPMLUA_H */
|
||||
|
|
101
rpmio/rpmmacro.h
101
rpmio/rpmmacro.h
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
/*! The structure used to store a macro. */
|
||||
typedef /*@abstract@*/ struct MacroEntry_s {
|
||||
typedef struct MacroEntry_s {
|
||||
struct MacroEntry_s *prev;/*!< Macro entry stack. */
|
||||
const char *name; /*!< Macro name. */
|
||||
const char *opts; /*!< Macro parameters (a la getopt) */
|
||||
|
@ -16,29 +16,22 @@ typedef /*@abstract@*/ struct MacroEntry_s {
|
|||
} * MacroEntry;
|
||||
|
||||
/*! The structure used to store the set of macros in a context. */
|
||||
typedef /*@abstract@*/ struct MacroContext_s {
|
||||
/*@owned@*//*@null@*/ MacroEntry *macroTable; /*!< Macro entry table for context. */
|
||||
typedef struct MacroContext_s {
|
||||
/*@owned@*/MacroEntry *macroTable; /*!< Macro entry table for context. */
|
||||
int macrosAllocated;/*!< No. of allocated macros. */
|
||||
int firstFree; /*!< No. of macros. */
|
||||
} * MacroContext;
|
||||
|
||||
/*@-redecl@*/
|
||||
/*@checked@*/
|
||||
extern MacroContext rpmGlobalMacroContext;
|
||||
|
||||
/*@checked@*/
|
||||
extern MacroContext rpmCLIMacroContext;
|
||||
/*@=redecl@*/
|
||||
|
||||
/** \ingroup rpmrc
|
||||
* List of macro files to read when configuring rpm.
|
||||
* This is a colon separated list of files. URI's are permitted as well,
|
||||
* identified by the token '://', so file paths must not begin with '//'.
|
||||
*/
|
||||
/*@-redecl@*/
|
||||
/*@observer@*/ /*@checked@*/
|
||||
extern const char * macrofiles;
|
||||
/*@=redecl@*/
|
||||
|
||||
/**
|
||||
* Markers for sources of macros added throughout rpm.
|
||||
|
@ -62,10 +55,8 @@ extern "C" {
|
|||
* @param mc macro context (NULL uses global context).
|
||||
* @param fp file stream (NULL uses stderr).
|
||||
*/
|
||||
void rpmDumpMacroTable (/*@null@*/ MacroContext mc,
|
||||
/*@null@*/ FILE * fp)
|
||||
/*@globals rpmGlobalMacroContext, fileSystem @*/
|
||||
/*@modifies *fp, fileSystem @*/;
|
||||
void rpmDumpMacroTable (MacroContext mc,
|
||||
FILE * fp);
|
||||
|
||||
/**
|
||||
* Return URL path(s) from a (URL prefixed) pattern glob.
|
||||
|
@ -74,10 +65,8 @@ void rpmDumpMacroTable (/*@null@*/ MacroContext mc,
|
|||
* @retval *argvPtr array of paths (malloc'd contiguous blob)
|
||||
* @return 0 on success
|
||||
*/
|
||||
int rpmGlob(const char * patterns, /*@out@*/ int * argcPtr,
|
||||
/*@out@*/ const char *** argvPtr)
|
||||
/*@globals fileSystem, internalState @*/
|
||||
/*@modifies *argcPtr, *argvPtr, fileSystem, internalState @*/;
|
||||
int rpmGlob(const char * patterns, int * argcPtr,
|
||||
const char *** argvPtr);
|
||||
|
||||
/**
|
||||
* Expand macro into buffer.
|
||||
|
@ -89,11 +78,9 @@ int rpmGlob(const char * patterns, /*@out@*/ int * argcPtr,
|
|||
* @param slen size of buffer
|
||||
* @return 0 on success
|
||||
*/
|
||||
int expandMacros (/*@null@*/ void * spec, /*@null@*/ MacroContext mc,
|
||||
/*@in@*/ /*@out@*/ char * sbuf,
|
||||
size_t slen)
|
||||
/*@globals rpmGlobalMacroContext, h_errno, fileSystem @*/
|
||||
/*@modifies *sbuf, rpmGlobalMacroContext, fileSystem @*/;
|
||||
int expandMacros (void * spec, MacroContext mc,
|
||||
char * sbuf,
|
||||
size_t slen);
|
||||
|
||||
/**
|
||||
* Add macro to context.
|
||||
|
@ -104,20 +91,16 @@ int expandMacros (/*@null@*/ void * spec, /*@null@*/ MacroContext mc,
|
|||
* @param b macro body
|
||||
* @param level macro recursion level (0 is entry API)
|
||||
*/
|
||||
void addMacro (/*@null@*/ MacroContext mc, const char * n,
|
||||
/*@null@*/ const char * o,
|
||||
/*@null@*/ const char * b, int level)
|
||||
/*@globals rpmGlobalMacroContext @*/
|
||||
/*@modifies mc, rpmGlobalMacroContext @*/;
|
||||
void addMacro (MacroContext mc, const char * n,
|
||||
const char * o,
|
||||
const char * b, int level);
|
||||
|
||||
/**
|
||||
* Delete macro from context.
|
||||
* @param mc macro context (NULL uses global context).
|
||||
* @param n macro name
|
||||
*/
|
||||
void delMacro (/*@null@*/ MacroContext mc, const char * n)
|
||||
/*@globals rpmGlobalMacroContext @*/
|
||||
/*@modifies mc, rpmGlobalMacroContext @*/;
|
||||
void delMacro (MacroContext mc, const char * n);
|
||||
|
||||
/**
|
||||
* Define macro in context.
|
||||
|
@ -126,47 +109,41 @@ void delMacro (/*@null@*/ MacroContext mc, const char * n)
|
|||
* @param level macro recursion level (0 is entry API)
|
||||
* @return @todo Document.
|
||||
*/
|
||||
int rpmDefineMacro (/*@null@*/ MacroContext mc, const char * macro,
|
||||
int level)
|
||||
/*@globals rpmGlobalMacroContext, h_errno @*/
|
||||
/*@modifies mc, rpmGlobalMacroContext @*/;
|
||||
int rpmDefineMacro (MacroContext mc, const char * macro,
|
||||
int level);
|
||||
|
||||
/**
|
||||
* Load macros from specific context into global context.
|
||||
* @param mc macro context (NULL does nothing).
|
||||
* @param level macro recursion level (0 is entry API)
|
||||
*/
|
||||
void rpmLoadMacros (/*@null@*/ MacroContext mc, int level)
|
||||
/*@globals rpmGlobalMacroContext @*/
|
||||
/*@modifies rpmGlobalMacroContext @*/;
|
||||
void rpmLoadMacros (MacroContext mc, int level);
|
||||
|
||||
/**
|
||||
* Load macro context from a macro file.
|
||||
* @param mc (unused)
|
||||
* @param fn macro file name
|
||||
*/
|
||||
int rpmLoadMacroFile(/*@null@*/ MacroContext mc, const char * fn)
|
||||
int rpmLoadMacroFile(MacroContext mc, const char * fn)
|
||||
/*@globals rpmGlobalMacroContext,
|
||||
h_errno, fileSystem, internalState @*/
|
||||
/*@modifies mc, rpmGlobalMacroContext, fileSystem, internalState @*/;
|
||||
;
|
||||
|
||||
/**
|
||||
* Initialize macro context from set of macrofile(s).
|
||||
* @param mc macro context
|
||||
* @param macrofiles colon separated list of macro files (NULL does nothing)
|
||||
*/
|
||||
void rpmInitMacros (/*@null@*/ MacroContext mc, const char * macrofiles)
|
||||
void rpmInitMacros (MacroContext mc, const char * macrofiles)
|
||||
/*@globals rpmGlobalMacroContext, rpmCLIMacroContext,
|
||||
h_errno, fileSystem, internalState @*/
|
||||
/*@modifies mc, rpmGlobalMacroContext, fileSystem, internalState @*/;
|
||||
;
|
||||
|
||||
/**
|
||||
* Destroy macro context.
|
||||
* @param mc macro context (NULL uses global context).
|
||||
*/
|
||||
void rpmFreeMacros (/*@null@*/ MacroContext mc)
|
||||
/*@globals rpmGlobalMacroContext @*/
|
||||
/*@modifies mc, rpmGlobalMacroContext @*/;
|
||||
void rpmFreeMacros (MacroContext mc);
|
||||
|
||||
typedef enum rpmCompressedMagic_e {
|
||||
COMPRESSED_NOT = 0, /*!< not compressed */
|
||||
|
@ -182,38 +159,29 @@ typedef enum rpmCompressedMagic_e {
|
|||
* @return 0 on success, 1 on I/O error
|
||||
*/
|
||||
int isCompressed (const char * file,
|
||||
/*@out@*/ rpmCompressedMagic * compressed)
|
||||
/*@globals h_errno, fileSystem, internalState @*/
|
||||
/*@modifies *compressed, fileSystem, internalState @*/;
|
||||
rpmCompressedMagic * compressed);
|
||||
|
||||
/**
|
||||
* Return (malloc'ed) concatenated macro expansion(s).
|
||||
* @param arg macro(s) to expand (NULL terminates list)
|
||||
* @return macro expansion (malloc'ed)
|
||||
*/
|
||||
char * rpmExpand (/*@null@*/ const char * arg, ...)
|
||||
/*@globals rpmGlobalMacroContext, h_errno @*/
|
||||
/*@modifies rpmGlobalMacroContext @*/;
|
||||
char * rpmExpand (const char * arg, ...);
|
||||
|
||||
/**
|
||||
* Canonicalize file path.
|
||||
* @param path path to canonicalize (in-place)
|
||||
* @return canonicalized path (malloc'ed)
|
||||
*/
|
||||
/*@null@*/
|
||||
char * rpmCleanPath (/*@returned@*/ /*@null@*/ char * path)
|
||||
/*@modifies *path @*/;
|
||||
char * rpmCleanPath (char * path);
|
||||
|
||||
/**
|
||||
* Return (malloc'ed) expanded, canonicalized, file path.
|
||||
* @param path macro(s) to expand (NULL terminates list)
|
||||
* @return canonicalized path (malloc'ed)
|
||||
*/
|
||||
/*@-redecl@*/ /* LCL: shrug */
|
||||
const char * rpmGetPath (/*@null@*/ const char * path, ...)
|
||||
/*@globals rpmGlobalMacroContext, h_errno @*/
|
||||
/*@modifies rpmGlobalMacroContext @*/;
|
||||
/*@=redecl@*/
|
||||
/* LCL: shrug */
|
||||
const char * rpmGetPath (const char * path, ...);
|
||||
|
||||
/**
|
||||
* Merge 3 args into path, any or all of which may be a url.
|
||||
|
@ -225,13 +193,10 @@ const char * rpmGetPath (/*@null@*/ const char * path, ...)
|
|||
* @param urlfile file URL (often a file, or NULL)
|
||||
* @return expanded, merged, canonicalized path (malloc'ed)
|
||||
*/
|
||||
/*@-redecl@*/ /* LCL: shrug */
|
||||
const char * rpmGenPath (/*@null@*/ const char * urlroot,
|
||||
/*@null@*/ const char * urlmdir,
|
||||
/*@null@*/ const char * urlfile)
|
||||
/*@globals rpmGlobalMacroContext, h_errno @*/
|
||||
/*@modifies rpmGlobalMacroContext @*/;
|
||||
/*@=redecl@*/
|
||||
/* LCL: shrug */
|
||||
const char * rpmGenPath (const char * urlroot,
|
||||
const char * urlmdir,
|
||||
const char * urlfile);
|
||||
|
||||
/**
|
||||
* Return macro expansion as a numeric value.
|
||||
|
@ -240,9 +205,7 @@ const char * rpmGenPath (/*@null@*/ const char * urlroot,
|
|||
* @param arg macro to expand
|
||||
* @return numeric value
|
||||
*/
|
||||
int rpmExpandNumeric (const char * arg)
|
||||
/*@globals rpmGlobalMacroContext, h_errno @*/
|
||||
/*@modifies rpmGlobalMacroContext @*/;
|
||||
int rpmExpandNumeric (const char * arg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -9,19 +9,16 @@
|
|||
#define EXIT_FAILURE 1
|
||||
#endif
|
||||
|
||||
/*@-modfilesys@*/
|
||||
/*@only@*/ void *vmefail(size_t size)
|
||||
void *vmefail(size_t size)
|
||||
{
|
||||
fprintf(stderr, _("memory alloc (%u bytes) returned NULL.\n"), (unsigned)size);
|
||||
exit(EXIT_FAILURE);
|
||||
/*@notreached@*/
|
||||
return NULL;
|
||||
}
|
||||
/*@=modfilesys@*/
|
||||
|
||||
#if !(HAVE_MCHECK_H && defined(__GNUC__))
|
||||
|
||||
/*@out@*/ /*@only@*/ void * xmalloc (size_t size)
|
||||
void * xmalloc (size_t size)
|
||||
{
|
||||
register void *value;
|
||||
if (size == 0) size++;
|
||||
|
@ -31,7 +28,7 @@
|
|||
return value;
|
||||
}
|
||||
|
||||
/*@only@*/ void * xcalloc (size_t nmemb, size_t size)
|
||||
void * xcalloc (size_t nmemb, size_t size)
|
||||
{
|
||||
register void *value;
|
||||
if (size == 0) size++;
|
||||
|
@ -42,7 +39,7 @@
|
|||
return value;
|
||||
}
|
||||
|
||||
/*@only@*/ void * xrealloc (/*@only@*/ void *ptr, size_t size)
|
||||
void * xrealloc (void *ptr, size_t size)
|
||||
{
|
||||
register void *value;
|
||||
if (size == 0) size++;
|
||||
|
@ -52,7 +49,7 @@
|
|||
return value;
|
||||
}
|
||||
|
||||
/*@only@*/ char * xstrdup (const char *str)
|
||||
char * xstrdup (const char *str)
|
||||
{
|
||||
size_t size = strlen(str) + 1;
|
||||
char *newstr = (char *) malloc (size);
|
||||
|
|
|
@ -31,9 +31,8 @@
|
|||
#define rpmIsDebug() \
|
||||
(rpmlogSetMask(0) >= RPMLOG_MASK( RPMMESS_DEBUG ))
|
||||
|
||||
/*@-redef@*/ /* LCL: ??? */
|
||||
typedef /*@abstract@*/ const void * fnpyKey;
|
||||
/*@=redef@*/
|
||||
/* LCL: ??? */
|
||||
typedef const void * fnpyKey;
|
||||
|
||||
/**
|
||||
* Bit(s) to identify progress callbacks.
|
||||
|
@ -68,18 +67,15 @@ extern "C" {
|
|||
/**
|
||||
*/
|
||||
typedef void * (*rpmCallbackFunction)
|
||||
(/*@null@*/ const void * h,
|
||||
(const void * h,
|
||||
const rpmCallbackType what,
|
||||
const unsigned long amount,
|
||||
const unsigned long total,
|
||||
/*@null@*/ fnpyKey key,
|
||||
/*@null@*/ rpmCallbackData data)
|
||||
/*@globals internalState@*/
|
||||
/*@modifies internalState@*/;
|
||||
fnpyKey key,
|
||||
rpmCallbackData data);
|
||||
|
||||
/**
|
||||
*/
|
||||
/*@unused@*/
|
||||
void urlSetCallback(rpmCallbackFunction notify, rpmCallbackData notifyData,
|
||||
int notifyCount);
|
||||
|
||||
|
|
175
rpmio/rpmpgp.c
175
rpmio/rpmpgp.c
|
@ -1,4 +1,3 @@
|
|||
/*@-boundsread@*/
|
||||
/** \ingroup rpmio signature
|
||||
* \file rpmio/rpmpgp.c
|
||||
* Routines to handle RFC-2440 detached signatures.
|
||||
|
@ -8,19 +7,13 @@
|
|||
#include "rpmio_internal.h"
|
||||
#include "debug.h"
|
||||
|
||||
/*@access pgpDig @*/
|
||||
/*@access pgpDigParams @*/
|
||||
|
||||
/*@unchecked@*/
|
||||
static int _debug = 0;
|
||||
|
||||
/*@unchecked@*/
|
||||
static int _print = 0;
|
||||
|
||||
/*@unchecked@*/ /*@null@*/
|
||||
static pgpDig _dig = NULL;
|
||||
|
||||
/*@unchecked@*/ /*@null@*/
|
||||
static pgpDigParams _digp = NULL;
|
||||
|
||||
struct pgpValTbl_s pgpSigTypeTbl[] = {
|
||||
|
@ -90,13 +83,10 @@ struct pgpValTbl_s pgpHashTbl[] = {
|
|||
{ -1, "Unknown hash algorithm" },
|
||||
};
|
||||
|
||||
/*@-exportlocal -exportheadervar@*/
|
||||
/*@observer@*/ /*@unchecked@*/
|
||||
struct pgpValTbl_s pgpKeyServerPrefsTbl[] = {
|
||||
{ 0x80, "No-modify" },
|
||||
{ -1, "Unknown key server preference" },
|
||||
};
|
||||
/*@=exportlocal =exportheadervar@*/
|
||||
|
||||
struct pgpValTbl_s pgpSubTypeTbl[] = {
|
||||
{ PGPSUBTYPE_SIG_CREATE_TIME,"signature creation time" },
|
||||
|
@ -188,25 +178,20 @@ struct pgpValTbl_s pgpArmorKeyTbl[] = {
|
|||
* @param p memory to free
|
||||
* @return NULL always
|
||||
*/
|
||||
/*@unused@*/ static inline /*@null@*/ void *
|
||||
_free(/*@only@*/ /*@null@*/ /*@out@*/ const void * p)
|
||||
/*@modifies p @*/
|
||||
static inline void *
|
||||
_free(const void * p)
|
||||
{
|
||||
if (p != NULL) free((void *)p);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void pgpPrtNL(void)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies fileSystem @*/
|
||||
{
|
||||
if (!_print) return;
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
static void pgpPrtInt(const char *pre, int i)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies fileSystem @*/
|
||||
{
|
||||
if (!_print) return;
|
||||
if (pre && *pre)
|
||||
|
@ -215,8 +200,6 @@ static void pgpPrtInt(const char *pre, int i)
|
|||
}
|
||||
|
||||
static void pgpPrtStr(const char *pre, const char *s)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies fileSystem @*/
|
||||
{
|
||||
if (!_print) return;
|
||||
if (pre && *pre)
|
||||
|
@ -225,8 +208,6 @@ static void pgpPrtStr(const char *pre, const char *s)
|
|||
}
|
||||
|
||||
static void pgpPrtHex(const char *pre, const byte *p, unsigned int plen)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies fileSystem @*/
|
||||
{
|
||||
if (!_print) return;
|
||||
if (pre && *pre)
|
||||
|
@ -235,8 +216,6 @@ static void pgpPrtHex(const char *pre, const byte *p, unsigned int plen)
|
|||
}
|
||||
|
||||
void pgpPrtVal(const char * pre, pgpValTbl vs, byte val)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies fileSystem @*/
|
||||
{
|
||||
if (!_print) return;
|
||||
if (pre && *pre)
|
||||
|
@ -246,9 +225,8 @@ void pgpPrtVal(const char * pre, pgpValTbl vs, byte val)
|
|||
|
||||
/**
|
||||
*/
|
||||
/*@unused@*/ static /*@observer@*/
|
||||
static
|
||||
const char * pgpMpiHex(const byte *p)
|
||||
/*@*/
|
||||
{
|
||||
static char prbuf[2048];
|
||||
char *t = prbuf;
|
||||
|
@ -256,14 +234,11 @@ const char * pgpMpiHex(const byte *p)
|
|||
return prbuf;
|
||||
}
|
||||
|
||||
/*@-boundswrite@*/
|
||||
/**
|
||||
* @return 0 on success
|
||||
*/
|
||||
static int pgpHexSet(const char * pre, int lbits,
|
||||
/*@out@*/ mpnumber * mpn, const byte * p, const byte * pend)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies mpn, fileSystem @*/
|
||||
mpnumber * mpn, const byte * p, const byte * pend)
|
||||
{
|
||||
unsigned int mbits = pgpMpiBits(p);
|
||||
unsigned int nbits;
|
||||
|
@ -291,7 +266,6 @@ if (_debug && _print)
|
|||
fprintf(stderr, "\t %s ", pre), mpfprintln(stderr, mpn->size, mpn->data);
|
||||
return 0;
|
||||
}
|
||||
/*@=boundswrite@*/
|
||||
|
||||
int pgpPrtSubType(const byte *h, unsigned int hlen, pgpSigType sigtype)
|
||||
{
|
||||
|
@ -312,29 +286,26 @@ int pgpPrtSubType(const byte *h, unsigned int hlen, pgpSigType sigtype)
|
|||
case PGPSUBTYPE_PREFER_SYMKEY: /* preferred symmetric algorithms */
|
||||
for (i = 1; i < plen; i++)
|
||||
pgpPrtVal(" ", pgpSymkeyTbl, p[i]);
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
case PGPSUBTYPE_PREFER_HASH: /* preferred hash algorithms */
|
||||
for (i = 1; i < plen; i++)
|
||||
pgpPrtVal(" ", pgpHashTbl, p[i]);
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
case PGPSUBTYPE_PREFER_COMPRESS:/* preferred compression algorithms */
|
||||
for (i = 1; i < plen; i++)
|
||||
pgpPrtVal(" ", pgpCompressionTbl, p[i]);
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
case PGPSUBTYPE_KEYSERVER_PREFERS:/* key server preferences */
|
||||
for (i = 1; i < plen; i++)
|
||||
pgpPrtVal(" ", pgpKeyServerPrefsTbl, p[i]);
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
case PGPSUBTYPE_SIG_CREATE_TIME:
|
||||
/*@-mods -mayaliasunique @*/
|
||||
if (_digp && !(_digp->saved & PGPDIG_SAVED_TIME) &&
|
||||
(sigtype == PGPSIGTYPE_POSITIVE_CERT || sigtype == PGPSIGTYPE_BINARY || sigtype == PGPSIGTYPE_TEXT || sigtype == PGPSIGTYPE_STANDALONE))
|
||||
{
|
||||
_digp->saved |= PGPDIG_SAVED_TIME;
|
||||
memcpy(_digp->time, p+1, sizeof(_digp->time));
|
||||
}
|
||||
/*@=mods =mayaliasunique @*/
|
||||
/*@fallthrough@*/
|
||||
case PGPSUBTYPE_SIG_EXPIRE_TIME:
|
||||
case PGPSUBTYPE_KEY_EXPIRE_TIME:
|
||||
if ((plen - 1) == 4) {
|
||||
|
@ -343,18 +314,15 @@ int pgpPrtSubType(const byte *h, unsigned int hlen, pgpSigType sigtype)
|
|||
fprintf(stderr, " %-24.24s(0x%08x)", ctime(&t), (unsigned)t);
|
||||
} else
|
||||
pgpPrtHex("", p+1, plen-1);
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
|
||||
case PGPSUBTYPE_ISSUER_KEYID: /* issuer key ID */
|
||||
/*@-mods -mayaliasunique @*/
|
||||
if (_digp && !(_digp->saved & PGPDIG_SAVED_ID) &&
|
||||
(sigtype == PGPSIGTYPE_POSITIVE_CERT || sigtype == PGPSIGTYPE_BINARY || sigtype == PGPSIGTYPE_TEXT || sigtype == PGPSIGTYPE_STANDALONE))
|
||||
{
|
||||
_digp->saved |= PGPDIG_SAVED_ID;
|
||||
memcpy(_digp->signid, p+1, sizeof(_digp->signid));
|
||||
}
|
||||
/*@=mods =mayaliasunique @*/
|
||||
/*@fallthrough@*/
|
||||
case PGPSUBTYPE_EXPORTABLE_CERT:
|
||||
case PGPSUBTYPE_TRUST_SIG:
|
||||
case PGPSUBTYPE_REGEX:
|
||||
|
@ -383,7 +351,7 @@ int pgpPrtSubType(const byte *h, unsigned int hlen, pgpSigType sigtype)
|
|||
case PGPSUBTYPE_INTERNAL_110:
|
||||
default:
|
||||
pgpPrtHex("", p+1, plen-1);
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
}
|
||||
pgpPrtNL();
|
||||
p += plen;
|
||||
|
@ -392,25 +360,19 @@ int pgpPrtSubType(const byte *h, unsigned int hlen, pgpSigType sigtype)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*@-varuse =readonlytrans @*/
|
||||
/*@observer@*/ /*@unchecked@*/
|
||||
static const char * pgpSigRSA[] = {
|
||||
" m**d =",
|
||||
NULL,
|
||||
};
|
||||
|
||||
/*@observer@*/ /*@unchecked@*/
|
||||
static const char * pgpSigDSA[] = {
|
||||
" r =",
|
||||
" s =",
|
||||
NULL,
|
||||
};
|
||||
/*@=varuse =readonlytrans @*/
|
||||
|
||||
static int pgpPrtSigParams(/*@unused@*/ pgpTag tag, byte pubkey_algo, byte sigtype,
|
||||
static int pgpPrtSigParams(pgpTag tag, byte pubkey_algo, byte sigtype,
|
||||
const byte *p, const byte *h, unsigned int hlen)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies fileSystem @*/
|
||||
{
|
||||
const byte * pend = h + hlen;
|
||||
int i;
|
||||
|
@ -426,9 +388,9 @@ static int pgpPrtSigParams(/*@unused@*/ pgpTag tag, byte pubkey_algo, byte sigty
|
|||
(void) mpnsethex(&_dig->c, pgpMpiHex(p));
|
||||
if (_debug && _print)
|
||||
fprintf(stderr, "\t m**d = "), mpfprintln(stderr, _dig->c.size, _dig->c.data);
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
default:
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
pgpPrtStr("", pgpSigRSA[i]);
|
||||
|
@ -442,13 +404,13 @@ fprintf(stderr, "\t m**d = "), mpfprintln(stderr, _dig->c.size, _dig->c.data);
|
|||
switch (i) {
|
||||
case 0: /* r */
|
||||
xx = pgpHexSet(pgpSigDSA[i], 160, &_dig->r, p, pend);
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
case 1: /* s */
|
||||
xx = pgpHexSet(pgpSigDSA[i], 160, &_dig->s, p, pend);
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
default:
|
||||
xx = 1;
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
}
|
||||
if (xx) return xx;
|
||||
}
|
||||
|
@ -465,8 +427,6 @@ fprintf(stderr, "\t m**d = "), mpfprintln(stderr, _dig->c.size, _dig->c.data);
|
|||
}
|
||||
|
||||
int pgpPrtSig(pgpTag tag, const byte *h, unsigned int hlen)
|
||||
/*@globals _digp @*/
|
||||
/*@modifies *_digp @*/
|
||||
{
|
||||
byte version = h[0];
|
||||
byte * p;
|
||||
|
@ -571,8 +531,6 @@ fprintf(stderr, " unhash[%u] -- %s\n", plen, pgpHexStr(p, plen));
|
|||
return rc;
|
||||
}
|
||||
|
||||
/*@-varuse =readonlytrans @*/
|
||||
/*@observer@*/ /*@unchecked@*/
|
||||
static const char * pgpPublicRSA[] = {
|
||||
" n =",
|
||||
" e =",
|
||||
|
@ -580,7 +538,6 @@ static const char * pgpPublicRSA[] = {
|
|||
};
|
||||
|
||||
#ifdef NOTYET
|
||||
/*@observer@*/ /*@unchecked@*/
|
||||
static const char * pgpSecretRSA[] = {
|
||||
" d =",
|
||||
" p =",
|
||||
|
@ -590,7 +547,6 @@ static const char * pgpSecretRSA[] = {
|
|||
};
|
||||
#endif
|
||||
|
||||
/*@observer@*/ /*@unchecked@*/
|
||||
static const char * pgpPublicDSA[] = {
|
||||
" p =",
|
||||
" q =",
|
||||
|
@ -600,14 +556,12 @@ static const char * pgpPublicDSA[] = {
|
|||
};
|
||||
|
||||
#ifdef NOTYET
|
||||
/*@observer@*/ /*@unchecked@*/
|
||||
static const char * pgpSecretDSA[] = {
|
||||
" x =",
|
||||
NULL,
|
||||
};
|
||||
#endif
|
||||
|
||||
/*@observer@*/ /*@unchecked@*/
|
||||
static const char * pgpPublicELGAMAL[] = {
|
||||
" p =",
|
||||
" g =",
|
||||
|
@ -616,18 +570,14 @@ static const char * pgpPublicELGAMAL[] = {
|
|||
};
|
||||
|
||||
#ifdef NOTYET
|
||||
/*@observer@*/ /*@unchecked@*/
|
||||
static const char * pgpSecretELGAMAL[] = {
|
||||
" x =",
|
||||
NULL,
|
||||
};
|
||||
#endif
|
||||
/*@=varuse =readonlytrans @*/
|
||||
|
||||
static const byte * pgpPrtPubkeyParams(byte pubkey_algo,
|
||||
/*@returned@*/ const byte *p, const byte *h, unsigned int hlen)
|
||||
/*@globals fileSystem, internalState @*/
|
||||
/*@modifies fileSystem, internalState @*/
|
||||
const byte *p, const byte *h, unsigned int hlen)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -640,14 +590,14 @@ static const byte * pgpPrtPubkeyParams(byte pubkey_algo,
|
|||
(void) mpbsethex(&_dig->rsa_pk.n, pgpMpiHex(p));
|
||||
if (_debug && _print)
|
||||
fprintf(stderr, "\t n = "), mpfprintln(stderr, _dig->rsa_pk.n.size, _dig->rsa_pk.n.modl);
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
case 1: /* e */
|
||||
(void) mpnsethex(&_dig->rsa_pk.e, pgpMpiHex(p));
|
||||
if (_debug && _print)
|
||||
fprintf(stderr, "\t e = "), mpfprintln(stderr, _dig->rsa_pk.e.size, _dig->rsa_pk.e.data);
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
default:
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
pgpPrtStr("", pgpPublicRSA[i]);
|
||||
|
@ -659,24 +609,24 @@ fprintf(stderr, "\t e = "), mpfprintln(stderr, _dig->rsa_pk.e.size, _dig->r
|
|||
(void) mpbsethex(&_dig->p, pgpMpiHex(p));
|
||||
if (_debug && _print)
|
||||
fprintf(stderr, "\t p = "), mpfprintln(stderr, _dig->p.size, _dig->p.modl);
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
case 1: /* q */
|
||||
(void) mpbsethex(&_dig->q, pgpMpiHex(p));
|
||||
if (_debug && _print)
|
||||
fprintf(stderr, "\t q = "), mpfprintln(stderr, _dig->q.size, _dig->q.modl);
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
case 2: /* g */
|
||||
(void) mpnsethex(&_dig->g, pgpMpiHex(p));
|
||||
if (_debug && _print)
|
||||
fprintf(stderr, "\t g = "), mpfprintln(stderr, _dig->g.size, _dig->g.data);
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
case 3: /* y */
|
||||
(void) mpnsethex(&_dig->y, pgpMpiHex(p));
|
||||
if (_debug && _print)
|
||||
fprintf(stderr, "\t y = "), mpfprintln(stderr, _dig->y.size, _dig->y.data);
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
default:
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
pgpPrtStr("", pgpPublicDSA[i]);
|
||||
|
@ -694,10 +644,8 @@ fprintf(stderr, "\t y = "), mpfprintln(stderr, _dig->y.size, _dig->y.data);
|
|||
return p;
|
||||
}
|
||||
|
||||
static const byte * pgpPrtSeckeyParams(/*@unused@*/ byte pubkey_algo,
|
||||
/*@returned@*/ const byte *p, const byte *h, unsigned int hlen)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies fileSystem @*/
|
||||
static const byte * pgpPrtSeckeyParams(byte pubkey_algo,
|
||||
const byte *p, const byte *h, unsigned int hlen)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -712,21 +660,20 @@ static const byte * pgpPrtSeckeyParams(/*@unused@*/ byte pubkey_algo,
|
|||
case 0x00:
|
||||
pgpPrtVal(" simple ", pgpHashTbl, p[2]);
|
||||
p += 2;
|
||||
/*@innerbreak@*/ break;
|
||||
break;
|
||||
case 0x01:
|
||||
pgpPrtVal(" salted ", pgpHashTbl, p[2]);
|
||||
pgpPrtHex("", p+3, 8);
|
||||
p += 10;
|
||||
/*@innerbreak@*/ break;
|
||||
break;
|
||||
case 0x03:
|
||||
pgpPrtVal(" iterated/salted ", pgpHashTbl, p[2]);
|
||||
/*@-shiftnegative -shiftimplementation @*/ /* FIX: unsigned cast */
|
||||
/* FIX: unsigned cast */
|
||||
i = (16 + (p[11] & 0xf)) << ((p[11] >> 4) + 6);
|
||||
/*@=shiftnegative =shiftimplementation @*/
|
||||
pgpPrtHex("", p+3, 8);
|
||||
pgpPrtInt(" iter", i);
|
||||
p += 11;
|
||||
/*@innerbreak@*/ break;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -769,8 +716,6 @@ static const byte * pgpPrtSeckeyParams(/*@unused@*/ byte pubkey_algo,
|
|||
}
|
||||
|
||||
int pgpPrtKey(pgpTag tag, const byte *h, unsigned int hlen)
|
||||
/*@globals _digp @*/
|
||||
/*@modifies *_digp @*/
|
||||
{
|
||||
byte version = *h;
|
||||
const byte * p;
|
||||
|
@ -829,10 +774,7 @@ int pgpPrtKey(pgpTag tag, const byte *h, unsigned int hlen)
|
|||
return rc;
|
||||
}
|
||||
|
||||
/*@-boundswrite@*/
|
||||
int pgpPrtUserID(pgpTag tag, const byte *h, unsigned int hlen)
|
||||
/*@globals _digp @*/
|
||||
/*@modifies *_digp @*/
|
||||
{
|
||||
pgpPrtVal("", pgpTagTbl, tag);
|
||||
if (_print)
|
||||
|
@ -845,7 +787,6 @@ int pgpPrtUserID(pgpTag tag, const byte *h, unsigned int hlen)
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
/*@=boundswrite@*/
|
||||
|
||||
int pgpPrtComment(pgpTag tag, const byte *h, unsigned int hlen)
|
||||
{
|
||||
|
@ -873,7 +814,7 @@ int pgpPrtComment(pgpTag tag, const byte *h, unsigned int hlen)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int pgpPubkeyFingerprint(const byte * pkt, /*@unused@*/ unsigned int pktlen,
|
||||
int pgpPubkeyFingerprint(const byte * pkt, unsigned int pktlen,
|
||||
byte * keyid)
|
||||
{
|
||||
const byte *s = pkt;
|
||||
|
@ -893,13 +834,11 @@ int pgpPubkeyFingerprint(const byte * pkt, /*@unused@*/ unsigned int pktlen,
|
|||
switch (v->pubkey_algo) {
|
||||
case PGPPUBKEYALGO_RSA:
|
||||
s += (pgpMpiLen(s) - 8);
|
||||
/*@-boundswrite@*/
|
||||
memmove(keyid, s, 8);
|
||||
/*@=boundswrite@*/
|
||||
rc = 0;
|
||||
/*@innerbreak@*/ break;
|
||||
break;
|
||||
default: /* TODO: md5 of mpi bodies (i.e. no length) */
|
||||
/*@innerbreak@*/ break;
|
||||
break;
|
||||
}
|
||||
} break;
|
||||
case 4:
|
||||
|
@ -912,11 +851,11 @@ int pgpPubkeyFingerprint(const byte * pkt, /*@unused@*/ unsigned int pktlen,
|
|||
case PGPPUBKEYALGO_RSA:
|
||||
for (i = 0; i < 2; i++)
|
||||
s += pgpMpiLen(s);
|
||||
/*@innerbreak@*/ break;
|
||||
break;
|
||||
case PGPPUBKEYALGO_DSA:
|
||||
for (i = 0; i < 4; i++)
|
||||
s += pgpMpiLen(s);
|
||||
/*@innerbreak@*/ break;
|
||||
break;
|
||||
}
|
||||
|
||||
ctx = rpmDigestInit(PGPHASHALGO_SHA1, RPMDIGEST_NONE);
|
||||
|
@ -924,9 +863,7 @@ int pgpPubkeyFingerprint(const byte * pkt, /*@unused@*/ unsigned int pktlen,
|
|||
(void) rpmDigestFinal(ctx, (void **)&SHA1, NULL, 0);
|
||||
|
||||
s = SHA1 + 12;
|
||||
/*@-boundswrite@*/
|
||||
memmove(keyid, s, 8);
|
||||
/*@=boundswrite@*/
|
||||
rc = 0;
|
||||
|
||||
if (SHA1) free(SHA1);
|
||||
|
@ -970,14 +907,11 @@ int pgpPrtPkt(const byte *pkt, unsigned int pleft)
|
|||
case PGPTAG_PUBLIC_KEY:
|
||||
/* Get the public key fingerprint. */
|
||||
if (_digp) {
|
||||
/*@-mods@*/
|
||||
if (!pgpPubkeyFingerprint(pkt, pktlen, _digp->signid))
|
||||
_digp->saved |= PGPDIG_SAVED_ID;
|
||||
else
|
||||
memset(_digp->signid, 0, sizeof(_digp->signid));
|
||||
/*@=mods@*/
|
||||
}
|
||||
/*@fallthrough@*/
|
||||
case PGPTAG_PUBLIC_SUBKEY:
|
||||
rc = pgpPrtKey(tag, h, hlen);
|
||||
break;
|
||||
|
@ -1023,7 +957,6 @@ pgpDig pgpNewDig(void)
|
|||
return dig;
|
||||
}
|
||||
|
||||
/*@-boundswrite@*/
|
||||
void pgpCleanDig(pgpDig dig)
|
||||
{
|
||||
if (dig != NULL) {
|
||||
|
@ -1032,12 +965,11 @@ void pgpCleanDig(pgpDig dig)
|
|||
dig->pubkey.userid = _free(dig->pubkey.userid);
|
||||
dig->signature.hash = _free(dig->signature.hash);
|
||||
dig->pubkey.hash = _free(dig->pubkey.hash);
|
||||
/*@-unqualifiedtrans@*/ /* FIX: double indirection */
|
||||
/* FIX: double indirection */
|
||||
for (i = 0; i < 4; i++) {
|
||||
dig->signature.params[i] = _free(dig->signature.params[i]);
|
||||
dig->pubkey.params[i] = _free(dig->pubkey.params[i]);
|
||||
}
|
||||
/*@=unqualifiedtrans@*/
|
||||
|
||||
memset(&dig->signature, 0, sizeof(dig->signature));
|
||||
memset(&dig->pubkey, 0, sizeof(dig->pubkey));
|
||||
|
@ -1053,30 +985,22 @@ void pgpCleanDig(pgpDig dig)
|
|||
mpnfree(&dig->c);
|
||||
mpnfree(&dig->rsahm);
|
||||
}
|
||||
/*@-nullstate@*/
|
||||
return;
|
||||
/*@=nullstate@*/
|
||||
}
|
||||
/*@=boundswrite@*/
|
||||
|
||||
pgpDig pgpFreeDig(/*@only@*/ /*@null@*/ pgpDig dig)
|
||||
/*@modifies dig @*/
|
||||
pgpDig pgpFreeDig(pgpDig dig)
|
||||
{
|
||||
if (dig != NULL) {
|
||||
|
||||
/* DUmp the signature/pubkey data. */
|
||||
pgpCleanDig(dig);
|
||||
|
||||
/*@-branchstate@*/
|
||||
if (dig->hdrsha1ctx != NULL)
|
||||
(void) rpmDigestFinal(dig->hdrsha1ctx, NULL, NULL, 0);
|
||||
/*@=branchstate@*/
|
||||
dig->hdrsha1ctx = NULL;
|
||||
|
||||
/*@-branchstate@*/
|
||||
if (dig->sha1ctx != NULL)
|
||||
(void) rpmDigestFinal(dig->sha1ctx, NULL, NULL, 0);
|
||||
/*@=branchstate@*/
|
||||
dig->sha1ctx = NULL;
|
||||
|
||||
mpbfree(&dig->p);
|
||||
|
@ -1088,17 +1012,13 @@ pgpDig pgpFreeDig(/*@only@*/ /*@null@*/ pgpDig dig)
|
|||
mpnfree(&dig->s);
|
||||
|
||||
#ifdef NOTYET
|
||||
/*@-branchstate@*/
|
||||
if (dig->hdrmd5ctx != NULL)
|
||||
(void) rpmDigestFinal(dig->hdrmd5ctx, NULL, NULL, 0);
|
||||
/*@=branchstate@*/
|
||||
dig->hdrmd5ctx = NULL;
|
||||
#endif
|
||||
|
||||
/*@-branchstate@*/
|
||||
if (dig->md5ctx != NULL)
|
||||
(void) rpmDigestFinal(dig->md5ctx, NULL, NULL, 0);
|
||||
/*@=branchstate@*/
|
||||
dig->md5ctx = NULL;
|
||||
|
||||
mpbfree(&dig->rsa_pk.n);
|
||||
|
@ -1113,8 +1033,6 @@ pgpDig pgpFreeDig(/*@only@*/ /*@null@*/ pgpDig dig)
|
|||
}
|
||||
|
||||
int pgpPrtPkts(const byte * pkts, unsigned int pktlen, pgpDig dig, int printing)
|
||||
/*@globals _dig, _digp, _print @*/
|
||||
/*@modifies _dig, _digp, *_digp, _print @*/
|
||||
{
|
||||
unsigned int val = *pkts;
|
||||
const byte *p;
|
||||
|
@ -1140,7 +1058,6 @@ int pgpPrtPkts(const byte * pkts, unsigned int pktlen, pgpDig dig, int printing)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*@-boundswrite@*/
|
||||
pgpArmor pgpReadPkts(const char * fn, const byte ** pkt, size_t * pktlen)
|
||||
{
|
||||
byte * b = NULL;
|
||||
|
@ -1199,7 +1116,7 @@ pgpArmor pgpReadPkts(const char * fn, const byte ** pkt, size_t * pktlen)
|
|||
continue;
|
||||
*t = '\0';
|
||||
pstate++;
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
case 1:
|
||||
enc = NULL;
|
||||
rc = pgpValTok(pgpArmorKeyTbl, t, te);
|
||||
|
@ -1211,7 +1128,7 @@ pgpArmor pgpReadPkts(const char * fn, const byte ** pkt, size_t * pktlen)
|
|||
}
|
||||
enc = te; /* Start of encoded packets */
|
||||
pstate++;
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
case 2:
|
||||
crcenc = NULL;
|
||||
if (*t != '=')
|
||||
|
@ -1219,7 +1136,7 @@ pgpArmor pgpReadPkts(const char * fn, const byte ** pkt, size_t * pktlen)
|
|||
*t++ = '\0'; /* Terminate encoded packets */
|
||||
crcenc = t; /* Start of encoded crc */
|
||||
pstate++;
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
case 3:
|
||||
pstate = 0;
|
||||
if (!TOKEQ(t, "-----END PGP ")) {
|
||||
|
@ -1272,7 +1189,7 @@ pgpArmor pgpReadPkts(const char * fn, const byte ** pkt, size_t * pktlen)
|
|||
blen = declen;
|
||||
ec = PGPARMOR_PUBKEY; /* XXX ASCII Pubkeys only, please. */
|
||||
goto exit;
|
||||
/*@notreached@*/ /*@switchbreak@*/ break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ec = PGPARMOR_NONE;
|
||||
|
@ -1286,7 +1203,6 @@ exit:
|
|||
*pktlen = blen;
|
||||
return ec;
|
||||
}
|
||||
/*@=boundswrite@*/
|
||||
|
||||
char * pgpArmorWrap(int atype, const unsigned char * s, size_t ns)
|
||||
{
|
||||
|
@ -1297,7 +1213,6 @@ char * pgpArmorWrap(int atype, const unsigned char * s, size_t ns)
|
|||
int lc;
|
||||
|
||||
nt = ((ns + 2) / 3) * 4;
|
||||
/*@-globs@*/
|
||||
/* Add additional bytes necessary for eol string(s). */
|
||||
if (b64encode_chars_per_line > 0 && b64encode_eolstr != NULL) {
|
||||
lc = (nt + b64encode_chars_per_line - 1) / b64encode_chars_per_line;
|
||||
|
@ -1305,18 +1220,14 @@ char * pgpArmorWrap(int atype, const unsigned char * s, size_t ns)
|
|||
++lc;
|
||||
nt += lc * strlen(b64encode_eolstr);
|
||||
}
|
||||
/*@=globs@*/
|
||||
|
||||
nt += 512; /* XXX slop for armor and crc */
|
||||
|
||||
/*@-boundswrite@*/
|
||||
val = t = xmalloc(nt + 1);
|
||||
*t = '\0';
|
||||
t = stpcpy(t, "-----BEGIN PGP ");
|
||||
t = stpcpy(t, pgpValStr(pgpArmorTbl, atype));
|
||||
/*@-globs@*/
|
||||
t = stpcpy( stpcpy(t, "-----\nVersion: rpm-"), VERSION);
|
||||
/*@=globs@*/
|
||||
t = stpcpy(t, " (beecrypt-4.1.2)\n\n");
|
||||
|
||||
if ((enc = b64encode(s, ns)) != NULL) {
|
||||
|
@ -1332,9 +1243,7 @@ char * pgpArmorWrap(int atype, const unsigned char * s, size_t ns)
|
|||
t = stpcpy(t, "-----END PGP ");
|
||||
t = stpcpy(t, pgpValStr(pgpArmorTbl, atype));
|
||||
t = stpcpy(t, "-----\n");
|
||||
/*@=boundswrite@*/
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
/*@=boundsread@*/
|
||||
|
|
154
rpmio/rpmpgp.h
154
rpmio/rpmpgp.h
|
@ -13,20 +13,18 @@
|
|||
#include <string.h>
|
||||
|
||||
#if !defined(_BEECRYPT_API_H)
|
||||
/*@-redef@*/
|
||||
typedef unsigned char byte;
|
||||
/*@=redef@*/
|
||||
#endif /* _BEECRYPT_API_H */
|
||||
|
||||
/**
|
||||
*/
|
||||
typedef /*@abstract@*/ struct DIGEST_CTX_s * DIGEST_CTX;
|
||||
typedef struct DIGEST_CTX_s * DIGEST_CTX;
|
||||
|
||||
/**
|
||||
*/
|
||||
typedef const struct pgpValTbl_s {
|
||||
int val;
|
||||
/*@observer@*/ const char * str;
|
||||
const char * str;
|
||||
} * pgpValTbl;
|
||||
|
||||
/**
|
||||
|
@ -64,7 +62,6 @@ typedef enum pgpTag_e {
|
|||
|
||||
/**
|
||||
*/
|
||||
/*@observer@*/ /*@unchecked@*/ /*@unused@*/
|
||||
extern struct pgpValTbl_s pgpTagTbl[];
|
||||
|
||||
/**
|
||||
|
@ -114,7 +111,6 @@ typedef struct pgpPktPubkey_s {
|
|||
* There are a number of possible meanings for a signature, which are
|
||||
* specified in a signature type octet in any given signature.
|
||||
*/
|
||||
/*@-typeuse@*/
|
||||
typedef enum pgpSigType_e {
|
||||
PGPSIGTYPE_BINARY = 0x00, /*!< Binary document */
|
||||
PGPSIGTYPE_TEXT = 0x01, /*!< Canonical text document */
|
||||
|
@ -134,11 +130,9 @@ typedef enum pgpSigType_e {
|
|||
PGPSIGTYPE_CERT_REVOKE = 0x30, /*!< Certification revocation */
|
||||
PGPSIGTYPE_TIMESTAMP = 0x40 /*!< Timestamp */
|
||||
} pgpSigType;
|
||||
/*@=typeuse@*/
|
||||
|
||||
/**
|
||||
*/
|
||||
/*@observer@*/ /*@unchecked@*/ /*@unused@*/
|
||||
extern struct pgpValTbl_s pgpSigTypeTbl[];
|
||||
|
||||
/**
|
||||
|
@ -164,7 +158,6 @@ extern struct pgpValTbl_s pgpSigTypeTbl[];
|
|||
* encryption. Implementations SHOULD implement RSA keys.
|
||||
* Implementations MAY implement any other algorithm.
|
||||
*/
|
||||
/*@-typeuse@*/
|
||||
typedef enum pgpPubkeyAlgo_e {
|
||||
PGPPUBKEYALGO_RSA = 1, /*!< RSA */
|
||||
PGPPUBKEYALGO_RSA_ENCRYPT = 2, /*!< RSA(Encrypt-Only) */
|
||||
|
@ -176,11 +169,9 @@ typedef enum pgpPubkeyAlgo_e {
|
|||
PGPPUBKEYALGO_ELGAMAL = 20, /*!< Elgamal */
|
||||
PGPPUBKEYALGO_DH = 21 /*!< Diffie-Hellman (X9.42) */
|
||||
} pgpPubkeyAlgo;
|
||||
/*@=typeuse@*/
|
||||
|
||||
/**
|
||||
*/
|
||||
/*@observer@*/ /*@unchecked@*/ /*@unused@*/
|
||||
extern struct pgpValTbl_s pgpPubkeyTbl[];
|
||||
|
||||
/**
|
||||
|
@ -207,7 +198,6 @@ extern struct pgpValTbl_s pgpPubkeyTbl[];
|
|||
* implement IDEA and CAST5. Implementations MAY implement any other
|
||||
* algorithm.
|
||||
*/
|
||||
/*@-typeuse@*/
|
||||
typedef enum pgpSymkeyAlgo_e {
|
||||
PGPSYMKEYALGO_PLAINTEXT = 0, /*!< Plaintext */
|
||||
PGPSYMKEYALGO_IDEA = 1, /*!< IDEA */
|
||||
|
@ -222,12 +212,10 @@ typedef enum pgpSymkeyAlgo_e {
|
|||
PGPSYMKEYALGO_TWOFISH = 10, /*!< TWOFISH(256-bit key) */
|
||||
PGPSYMKEYALGO_NOENCRYPT = 110 /*!< no encryption */
|
||||
} pgpSymkeyAlgo;
|
||||
/*@=typeuse@*/
|
||||
|
||||
/**
|
||||
* Symmetric key (string, value) pairs.
|
||||
*/
|
||||
/*@observer@*/ /*@unchecked@*/ /*@unused@*/
|
||||
extern struct pgpValTbl_s pgpSymkeyTbl[];
|
||||
|
||||
/**
|
||||
|
@ -245,19 +233,16 @@ extern struct pgpValTbl_s pgpSymkeyTbl[];
|
|||
* Implementations MUST implement uncompressed data. Implementations
|
||||
* SHOULD implement ZIP. Implementations MAY implement ZLIB.
|
||||
*/
|
||||
/*@-typeuse@*/
|
||||
typedef enum pgpCompressAlgo_e {
|
||||
PGPCOMPRESSALGO_NONE = 0, /*!< Uncompressed */
|
||||
PGPCOMPRESSALGO_ZIP = 1, /*!< ZIP */
|
||||
PGPCOMPRESSALGO_ZLIB = 2, /*!< ZLIB */
|
||||
PGPCOMPRESSALGO_BZIP2 = 3 /*!< BZIP2 */
|
||||
} pgpCompressAlgo;
|
||||
/*@=typeuse@*/
|
||||
|
||||
/**
|
||||
* Compression (string, value) pairs.
|
||||
*/
|
||||
/*@observer@*/ /*@unchecked@*/ /*@unused@*/
|
||||
extern struct pgpValTbl_s pgpCompressionTbl[];
|
||||
|
||||
/**
|
||||
|
@ -296,7 +281,6 @@ typedef enum pgpHashAlgo_e {
|
|||
/**
|
||||
* Hash (string, value) pairs.
|
||||
*/
|
||||
/*@observer@*/ /*@unchecked@*/ /*@unused@*/
|
||||
extern struct pgpValTbl_s pgpHashTbl[];
|
||||
|
||||
/**
|
||||
|
@ -426,7 +410,6 @@ typedef struct pgpPktSigV4_s {
|
|||
* marked critical but is unknown to the evaluating software, the
|
||||
* evaluator SHOULD consider the signature to be in error.
|
||||
*/
|
||||
/*@-typeuse@*/
|
||||
typedef enum pgpSubType_e {
|
||||
PGPSUBTYPE_NONE = 0, /*!< none */
|
||||
PGPSUBTYPE_SIG_CREATE_TIME = 2, /*!< signature creation time */
|
||||
|
@ -467,12 +450,10 @@ typedef enum pgpSubType_e {
|
|||
|
||||
PGPSUBTYPE_CRITICAL = 128 /*!< critical subpacket marker */
|
||||
} pgpSubType;
|
||||
/*@=typeuse@*/
|
||||
|
||||
/**
|
||||
* Subtype (string, value) pairs.
|
||||
*/
|
||||
/*@observer@*/ /*@unchecked@*/ /*@unused@*/
|
||||
extern struct pgpValTbl_s pgpSubTypeTbl[];
|
||||
|
||||
/**
|
||||
|
@ -926,7 +907,6 @@ union pgpPktPre_u {
|
|||
|
||||
/**
|
||||
*/
|
||||
/*@-typeuse@*/
|
||||
typedef enum pgpArmor_e {
|
||||
PGPARMOR_ERR_CRC_CHECK = -7,
|
||||
PGPARMOR_ERR_BODY_DECODE = -6,
|
||||
|
@ -945,17 +925,14 @@ typedef enum pgpArmor_e {
|
|||
PGPARMOR_PRIVKEY = 6, /*!< PRIVATE KEY BLOCK */
|
||||
PGPARMOR_SECKEY = 7 /*!< SECRET KEY BLOCK */
|
||||
} pgpArmor;
|
||||
/*@=typeuse@*/
|
||||
|
||||
/**
|
||||
* Armor (string, value) pairs.
|
||||
*/
|
||||
/*@observer@*/ /*@unchecked@*/ /*@unused@*/
|
||||
extern struct pgpValTbl_s pgpArmorTbl[];
|
||||
|
||||
/**
|
||||
*/
|
||||
/*@-typeuse@*/
|
||||
typedef enum pgpArmorKey_e {
|
||||
PGPARMORKEY_VERSION = 1, /*!< Version: */
|
||||
PGPARMORKEY_COMMENT = 2, /*!< Comment: */
|
||||
|
@ -963,12 +940,10 @@ typedef enum pgpArmorKey_e {
|
|||
PGPARMORKEY_HASH = 4, /*!< Hash: */
|
||||
PGPARMORKEY_CHARSET = 5 /*!< Charset: */
|
||||
} pgpArmorKey;
|
||||
/*@=typeuse@*/
|
||||
|
||||
/**
|
||||
* Armor key (string, value) pairs.
|
||||
*/
|
||||
/*@observer@*/ /*@unchecked@*/ /*@unused@*/
|
||||
extern struct pgpValTbl_s pgpArmorKeyTbl[];
|
||||
|
||||
/** \ingroup rpmio
|
||||
|
@ -979,7 +954,6 @@ typedef enum rpmDigestFlags_e {
|
|||
} rpmDigestFlags;
|
||||
|
||||
|
||||
/*@-fcnuse@*/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
@ -990,16 +964,13 @@ extern "C" {
|
|||
* @param nbytes no. of bytes
|
||||
* @return native-endian integer
|
||||
*/
|
||||
/*@unused@*/ static inline
|
||||
static inline
|
||||
unsigned int pgpGrab(const byte *s, int nbytes)
|
||||
/*@*/
|
||||
{
|
||||
unsigned int i = 0;
|
||||
int nb = (nbytes <= sizeof(i) ? nbytes : sizeof(i));
|
||||
/*@-boundsread@*/
|
||||
while (nb--)
|
||||
i = (i << 8) | *s++;
|
||||
/*@=boundsread@*/
|
||||
return i;
|
||||
}
|
||||
|
||||
|
@ -1009,11 +980,9 @@ unsigned int pgpGrab(const byte *s, int nbytes)
|
|||
* @retval *lenp no. of bytes in packet
|
||||
* @return no. of bytes in length prefix
|
||||
*/
|
||||
/*@unused@*/ static inline
|
||||
int pgpLen(const byte *s, /*@out@*/ unsigned int *lenp)
|
||||
/*@modifies *lenp @*/
|
||||
static inline
|
||||
int pgpLen(const byte *s, unsigned int *lenp)
|
||||
{
|
||||
/*@-boundswrite@*/
|
||||
if (*s < 192) {
|
||||
(*lenp) = *s++;
|
||||
return 1;
|
||||
|
@ -1024,7 +993,6 @@ int pgpLen(const byte *s, /*@out@*/ unsigned int *lenp)
|
|||
(*lenp) = pgpGrab(s+1, 4);
|
||||
return 5;
|
||||
}
|
||||
/*@=boundswrite@*/
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1032,10 +1000,8 @@ int pgpLen(const byte *s, /*@out@*/ unsigned int *lenp)
|
|||
* @param p pointer to multiprecision integer
|
||||
* @return no. of bits
|
||||
*/
|
||||
/*@unused@*/ static inline
|
||||
static inline
|
||||
unsigned int pgpMpiBits(const byte *p)
|
||||
/*@requires maxRead(p) >= 1 @*/
|
||||
/*@*/
|
||||
{
|
||||
return ((p[0] << 8) | p[1]);
|
||||
}
|
||||
|
@ -1045,10 +1011,8 @@ unsigned int pgpMpiBits(const byte *p)
|
|||
* @param p pointer to multiprecision integer
|
||||
* @return no. of bytes
|
||||
*/
|
||||
/*@unused@*/ static inline
|
||||
static inline
|
||||
unsigned int pgpMpiLen(const byte *p)
|
||||
/*@requires maxRead(p) >= 1 @*/
|
||||
/*@*/
|
||||
{
|
||||
return (2 + ((pgpMpiBits(p)+7)>>3));
|
||||
}
|
||||
|
@ -1060,12 +1024,10 @@ unsigned int pgpMpiLen(const byte *p)
|
|||
* @param nbytes no. of bytes
|
||||
* @return target buffer
|
||||
*/
|
||||
/*@unused@*/ static inline
|
||||
char * pgpHexCvt(/*@returned@*/ char *t, const byte *s, int nbytes)
|
||||
/*@modifies *t @*/
|
||||
static inline
|
||||
char * pgpHexCvt(char *t, const byte *s, int nbytes)
|
||||
{
|
||||
static char hex[] = "0123456789abcdef";
|
||||
/*@-boundswrite@*/
|
||||
while (nbytes-- > 0) {
|
||||
unsigned int i;
|
||||
i = *s++;
|
||||
|
@ -1073,7 +1035,6 @@ char * pgpHexCvt(/*@returned@*/ char *t, const byte *s, int nbytes)
|
|||
*t++ = hex[ (i ) & 0xf ];
|
||||
}
|
||||
*t = '\0';
|
||||
/*@=boundswrite@*/
|
||||
return t;
|
||||
}
|
||||
|
||||
|
@ -1084,9 +1045,8 @@ char * pgpHexCvt(/*@returned@*/ char *t, const byte *s, int nbytes)
|
|||
* @param plen no. of bytes
|
||||
* @return hex formatted string
|
||||
*/
|
||||
/*@unused@*/ static inline /*@observer@*/
|
||||
static inline
|
||||
char * pgpHexStr(const byte *p, unsigned int plen)
|
||||
/*@*/
|
||||
{
|
||||
static char prbuf[8*BUFSIZ]; /* XXX ick */
|
||||
char *t = prbuf;
|
||||
|
@ -1100,10 +1060,8 @@ char * pgpHexStr(const byte *p, unsigned int plen)
|
|||
* @param p bytes
|
||||
* @return hex formatted string
|
||||
*/
|
||||
/*@unused@*/ static inline /*@observer@*/
|
||||
static inline
|
||||
const char * pgpMpiStr(const byte *p)
|
||||
/*@requires maxRead(p) >= 3 @*/
|
||||
/*@*/
|
||||
{
|
||||
static char prbuf[8*BUFSIZ]; /* XXX ick */
|
||||
char *t = prbuf;
|
||||
|
@ -1119,9 +1077,8 @@ const char * pgpMpiStr(const byte *p)
|
|||
* @param val byte value to lookup
|
||||
* @return string value of byte
|
||||
*/
|
||||
/*@unused@*/ static inline /*@observer@*/
|
||||
static inline
|
||||
const char * pgpValStr(pgpValTbl vs, byte val)
|
||||
/*@*/
|
||||
{
|
||||
do {
|
||||
if (vs->val == val)
|
||||
|
@ -1137,9 +1094,8 @@ const char * pgpValStr(pgpValTbl vs, byte val)
|
|||
* @param se end-of-string address
|
||||
* @return byte value
|
||||
*/
|
||||
/*@unused@*/ static inline
|
||||
static inline
|
||||
int pgpValTok(pgpValTbl vs, const char * s, const char * se)
|
||||
/*@*/
|
||||
{
|
||||
do {
|
||||
int vlen = strlen(vs->str);
|
||||
|
@ -1149,16 +1105,13 @@ int pgpValTok(pgpValTbl vs, const char * s, const char * se)
|
|||
return vs->val;
|
||||
}
|
||||
|
||||
/*@-exportlocal@*/
|
||||
/**
|
||||
* Print an OpenPGP value.
|
||||
* @param pre output prefix
|
||||
* @param vs table of (string,value) pairs
|
||||
* @param val byte value to print
|
||||
*/
|
||||
void pgpPrtVal(const char * pre, pgpValTbl vs, byte val)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies fileSystem @*/;
|
||||
void pgpPrtVal(const char * pre, pgpValTbl vs, byte val);
|
||||
|
||||
/**
|
||||
* Print/parse an OpenPGP subtype packet.
|
||||
|
@ -1167,9 +1120,7 @@ void pgpPrtVal(const char * pre, pgpValTbl vs, byte val)
|
|||
* @param sigtype signature type
|
||||
* @return 0 on success
|
||||
*/
|
||||
int pgpPrtSubType(const byte *h, unsigned int hlen, pgpSigType sigtype)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies fileSystem @*/;
|
||||
int pgpPrtSubType(const byte *h, unsigned int hlen, pgpSigType sigtype);
|
||||
|
||||
/**
|
||||
* Print/parse an OpenPGP signature packet.
|
||||
|
@ -1178,9 +1129,7 @@ int pgpPrtSubType(const byte *h, unsigned int hlen, pgpSigType sigtype)
|
|||
* @param hlen packet length (no. of bytes)
|
||||
* @return 0 on success
|
||||
*/
|
||||
int pgpPrtSig(pgpTag tag, const byte *h, unsigned int hlen)
|
||||
/*@globals fileSystem, internalState @*/
|
||||
/*@modifies fileSystem, internalState @*/;
|
||||
int pgpPrtSig(pgpTag tag, const byte *h, unsigned int hlen);
|
||||
|
||||
/**
|
||||
* Print/parse an OpenPGP key packet.
|
||||
|
@ -1189,9 +1138,7 @@ int pgpPrtSig(pgpTag tag, const byte *h, unsigned int hlen)
|
|||
* @param hlen packet length (no. of bytes)
|
||||
* @return 0 on success
|
||||
*/
|
||||
int pgpPrtKey(pgpTag tag, const byte *h, unsigned int hlen)
|
||||
/*@globals fileSystem, internalState @*/
|
||||
/*@modifies fileSystem, internalState @*/;
|
||||
int pgpPrtKey(pgpTag tag, const byte *h, unsigned int hlen);
|
||||
|
||||
/**
|
||||
* Print/parse an OpenPGP userid packet.
|
||||
|
@ -1200,9 +1147,7 @@ int pgpPrtKey(pgpTag tag, const byte *h, unsigned int hlen)
|
|||
* @param hlen packet length (no. of bytes)
|
||||
* @return 0 on success
|
||||
*/
|
||||
int pgpPrtUserID(pgpTag tag, const byte *h, unsigned int hlen)
|
||||
/*@globals fileSystem, internalState @*/
|
||||
/*@modifies fileSystem, internalState @*/;
|
||||
int pgpPrtUserID(pgpTag tag, const byte *h, unsigned int hlen);
|
||||
|
||||
/**
|
||||
* Print/parse an OpenPGP comment packet.
|
||||
|
@ -1211,9 +1156,7 @@ int pgpPrtUserID(pgpTag tag, const byte *h, unsigned int hlen)
|
|||
* @param hlen packet length (no. of bytes)
|
||||
* @return 0 on success
|
||||
*/
|
||||
int pgpPrtComment(pgpTag tag, const byte *h, unsigned int hlen)
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies fileSystem @*/;
|
||||
int pgpPrtComment(pgpTag tag, const byte *h, unsigned int hlen);
|
||||
|
||||
/**
|
||||
* Calculate OpenPGP public key fingerprint.
|
||||
|
@ -1224,8 +1167,7 @@ int pgpPrtComment(pgpTag tag, const byte *h, unsigned int hlen)
|
|||
* @return 0 on sucess, else -1
|
||||
*/
|
||||
int pgpPubkeyFingerprint(const byte * pkt, unsigned int pktlen,
|
||||
/*@out@*/ byte * keyid)
|
||||
/*@modifies *keyid @*/;
|
||||
byte * keyid);
|
||||
|
||||
/**
|
||||
* Print/parse next OpenPGP packet.
|
||||
|
@ -1233,10 +1175,7 @@ int pgpPubkeyFingerprint(const byte * pkt, unsigned int pktlen,
|
|||
* @param pleft no. bytes remaining
|
||||
* @return -1 on error, otherwise this packet length
|
||||
*/
|
||||
int pgpPrtPkt(const byte *pkt, unsigned int pleft)
|
||||
/*@globals fileSystem, internalState @*/
|
||||
/*@modifies fileSystem, internalState @*/;
|
||||
/*@=exportlocal@*/
|
||||
int pgpPrtPkt(const byte *pkt, unsigned int pleft);
|
||||
|
||||
/**
|
||||
* Print/parse a OpenPGP packet(s).
|
||||
|
@ -1246,9 +1185,7 @@ int pgpPrtPkt(const byte *pkt, unsigned int pleft)
|
|||
* @param printing should packets be printed?
|
||||
* @return -1 on error, 0 on success
|
||||
*/
|
||||
int pgpPrtPkts(const byte *pkts, unsigned int pktlen, pgpDig dig, int printing)
|
||||
/*@globals fileSystem, internalState @*/
|
||||
/*@modifies dig, fileSystem, internalState @*/;
|
||||
int pgpPrtPkts(const byte *pkts, unsigned int pktlen, pgpDig dig, int printing);
|
||||
|
||||
/**
|
||||
* Parse armored OpenPGP packets from a file.
|
||||
|
@ -1258,9 +1195,7 @@ int pgpPrtPkts(const byte *pkts, unsigned int pktlen, pgpDig dig, int printing)
|
|||
* @return type of armor found
|
||||
*/
|
||||
pgpArmor pgpReadPkts(const char * fn,
|
||||
/*@out@*/ const byte ** pkt, /*@out@*/ size_t * pktlen)
|
||||
/*@globals h_errno, fileSystem, internalState @*/
|
||||
/*@modifies *pkt, *pktlen, fileSystem, internalState @*/;
|
||||
const byte ** pkt, size_t * pktlen);
|
||||
|
||||
/**
|
||||
* Wrap a OpenPGP packets in ascii armor for transport.
|
||||
|
@ -1269,45 +1204,36 @@ pgpArmor pgpReadPkts(const char * fn,
|
|||
* @param ns binary pkt data length
|
||||
* @return formatted string
|
||||
*/
|
||||
char * pgpArmorWrap(int atype, const unsigned char * s, size_t ns)
|
||||
/*@*/;
|
||||
char * pgpArmorWrap(int atype, const unsigned char * s, size_t ns);
|
||||
|
||||
/**
|
||||
* Create a container for parsed OpenPGP packates.
|
||||
* @return container
|
||||
*/
|
||||
/*@only@*/
|
||||
pgpDig pgpNewDig(void)
|
||||
/*@*/;
|
||||
pgpDig pgpNewDig(void);
|
||||
|
||||
/**
|
||||
* Release (malloc'd) data from container.
|
||||
* @param dig container
|
||||
*/
|
||||
void pgpCleanDig(/*@null@*/ pgpDig dig)
|
||||
/*@modifies dig @*/;
|
||||
void pgpCleanDig(pgpDig dig);
|
||||
|
||||
/**
|
||||
* Destroy a container for parsed OpenPGP packates.
|
||||
* @param dig container
|
||||
* @return NULL always
|
||||
*/
|
||||
/*@only@*/ /*@null@*/
|
||||
pgpDig pgpFreeDig(/*@only@*/ /*@null@*/ pgpDig dig)
|
||||
/*@modifies dig @*/;
|
||||
pgpDig pgpFreeDig(pgpDig dig);
|
||||
|
||||
/**
|
||||
* Is buffer at beginning of an OpenPGP packet?
|
||||
* @param p buffer
|
||||
* @return 1 if an OpenPGP packet, 0 otherwise
|
||||
*/
|
||||
/*@unused@*/ static inline
|
||||
static inline
|
||||
int pgpIsPkt(const byte * p)
|
||||
/*@*/
|
||||
{
|
||||
/*@-boundsread@*/
|
||||
unsigned int val = *p++;
|
||||
/*@=boundsread@*/
|
||||
pgpTag tag;
|
||||
int rc;
|
||||
|
||||
|
@ -1363,17 +1289,14 @@ int pgpIsPkt(const byte * p)
|
|||
* @param len no. of bytes
|
||||
* @return crc of buffer
|
||||
*/
|
||||
/*@unused@*/ static inline
|
||||
static inline
|
||||
unsigned int pgpCRC(const byte *octets, size_t len)
|
||||
/*@*/
|
||||
{
|
||||
unsigned int crc = CRC24_INIT;
|
||||
int i;
|
||||
|
||||
while (len--) {
|
||||
/*@-boundsread@*/
|
||||
crc ^= (*octets++) << 16;
|
||||
/*@=boundsread@*/
|
||||
for (i = 0; i < 8; i++) {
|
||||
crc <<= 1;
|
||||
if (crc & 0x1000000)
|
||||
|
@ -1388,9 +1311,7 @@ unsigned int pgpCRC(const byte *octets, size_t len)
|
|||
* @param octx existing digest context
|
||||
* @return duplicated digest context
|
||||
*/
|
||||
/*@only@*/
|
||||
DIGEST_CTX rpmDigestDup(DIGEST_CTX octx)
|
||||
/*@*/;
|
||||
DIGEST_CTX rpmDigestDup(DIGEST_CTX octx);
|
||||
|
||||
/** \ingroup rpmio
|
||||
* Initialize digest.
|
||||
|
@ -1399,9 +1320,7 @@ DIGEST_CTX rpmDigestDup(DIGEST_CTX octx)
|
|||
* @param flags bit(s) to control digest operation
|
||||
* @return digest context
|
||||
*/
|
||||
/*@only@*/ /*@null@*/
|
||||
DIGEST_CTX rpmDigestInit(pgpHashAlgo hashalgo, rpmDigestFlags flags)
|
||||
/*@*/;
|
||||
DIGEST_CTX rpmDigestInit(pgpHashAlgo hashalgo, rpmDigestFlags flags);
|
||||
|
||||
/** \ingroup rpmio
|
||||
* Update context with next plain text buffer.
|
||||
|
@ -1410,8 +1329,7 @@ DIGEST_CTX rpmDigestInit(pgpHashAlgo hashalgo, rpmDigestFlags flags)
|
|||
* @param len no. bytes of data
|
||||
* @return 0 on success
|
||||
*/
|
||||
int rpmDigestUpdate(/*@null@*/ DIGEST_CTX ctx, const void * data, size_t len)
|
||||
/*@modifies ctx @*/;
|
||||
int rpmDigestUpdate(DIGEST_CTX ctx, const void * data, size_t len);
|
||||
|
||||
/** \ingroup rpmio
|
||||
* Return digest and destroy context.
|
||||
|
@ -1424,14 +1342,12 @@ int rpmDigestUpdate(/*@null@*/ DIGEST_CTX ctx, const void * data, size_t len)
|
|||
* @param asAscii return digest as ascii string?
|
||||
* @return 0 on success
|
||||
*/
|
||||
int rpmDigestFinal(/*@only@*/ /*@null@*/ DIGEST_CTX ctx,
|
||||
/*@null@*/ /*@out@*/ void ** datap,
|
||||
/*@null@*/ /*@out@*/ size_t * lenp, int asAscii)
|
||||
/*@modifies *datap, *lenp @*/;
|
||||
int rpmDigestFinal(DIGEST_CTX ctx,
|
||||
void ** datap,
|
||||
size_t * lenp, int asAscii);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/*@=fcnuse@*/
|
||||
|
||||
#endif /* H_RPMPGP */
|
||||
|
|
260
rpmio/rpmrpc.c
260
rpmio/rpmrpc.c
|
@ -16,27 +16,21 @@
|
|||
#include "ugid.h"
|
||||
#include "debug.h"
|
||||
|
||||
/*@access DIR @*/
|
||||
/*@access FD_t @*/
|
||||
/*@access urlinfo @*/
|
||||
|
||||
/**
|
||||
* Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
|
||||
* @param p memory to free
|
||||
* @retval NULL always
|
||||
*/
|
||||
/*@unused@*/ static inline /*@null@*/ void *
|
||||
_free(/*@only@*/ /*@null@*/ /*@out@*/ const void * p)
|
||||
/*@modifies p@*/
|
||||
static inline void *
|
||||
_free(const void * p)
|
||||
{
|
||||
if (p != NULL) free((void *)p);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* =============================================================== */
|
||||
static int ftpMkdir(const char * path, /*@unused@*/ mode_t mode)
|
||||
/*@globals h_errno, fileSystem, internalState @*/
|
||||
/*@modifies fileSystem, internalState @*/
|
||||
static int ftpMkdir(const char * path, mode_t mode)
|
||||
{
|
||||
int rc;
|
||||
if ((rc = ftpCmd("MKD", path, NULL)) != 0)
|
||||
|
@ -51,22 +45,16 @@ static int ftpMkdir(const char * path, /*@unused@*/ mode_t mode)
|
|||
}
|
||||
|
||||
static int ftpChdir(const char * path)
|
||||
/*@globals h_errno, fileSystem, internalState @*/
|
||||
/*@modifies fileSystem, internalState @*/
|
||||
{
|
||||
return ftpCmd("CWD", path, NULL);
|
||||
}
|
||||
|
||||
static int ftpRmdir(const char * path)
|
||||
/*@globals h_errno, fileSystem, internalState @*/
|
||||
/*@modifies fileSystem, internalState @*/
|
||||
{
|
||||
return ftpCmd("RMD", path, NULL);
|
||||
}
|
||||
|
||||
static int ftpRename(const char * oldpath, const char * newpath)
|
||||
/*@globals h_errno, fileSystem, internalState @*/
|
||||
/*@modifies fileSystem, internalState @*/
|
||||
{
|
||||
int rc;
|
||||
if ((rc = ftpCmd("RNFR", oldpath, NULL)) != 0)
|
||||
|
@ -75,8 +63,6 @@ static int ftpRename(const char * oldpath, const char * newpath)
|
|||
}
|
||||
|
||||
static int ftpUnlink(const char * path)
|
||||
/*@globals h_errno, fileSystem, internalState @*/
|
||||
/*@modifies fileSystem, internalState @*/
|
||||
{
|
||||
return ftpCmd("DELE", path, NULL);
|
||||
}
|
||||
|
@ -90,23 +76,22 @@ int Mkdir (const char * path, mode_t mode)
|
|||
switch (ut) {
|
||||
case URL_IS_FTP:
|
||||
return ftpMkdir(path, mode);
|
||||
/*@notreached@*/ break;
|
||||
break;
|
||||
case URL_IS_HTTPS:
|
||||
case URL_IS_HTTP:
|
||||
#ifdef WITH_NEON
|
||||
return davMkdir(path, mode);
|
||||
#endif
|
||||
/*@notreached@*/ break;
|
||||
break;
|
||||
case URL_IS_PATH:
|
||||
path = lpath;
|
||||
/*@fallthrough@*/
|
||||
case URL_IS_UNKNOWN:
|
||||
break;
|
||||
case URL_IS_DASH:
|
||||
case URL_IS_HKP:
|
||||
default:
|
||||
return -2;
|
||||
/*@notreached@*/ break;
|
||||
break;
|
||||
}
|
||||
return mkdir(path, mode);
|
||||
}
|
||||
|
@ -119,7 +104,7 @@ int Chdir (const char * path)
|
|||
switch (ut) {
|
||||
case URL_IS_FTP:
|
||||
return ftpChdir(path);
|
||||
/*@notreached@*/ break;
|
||||
break;
|
||||
case URL_IS_HTTPS:
|
||||
case URL_IS_HTTP:
|
||||
#ifdef NOTYET
|
||||
|
@ -127,17 +112,16 @@ int Chdir (const char * path)
|
|||
#else
|
||||
return -2;
|
||||
#endif
|
||||
/*@notreached@*/ break;
|
||||
break;
|
||||
case URL_IS_PATH:
|
||||
path = lpath;
|
||||
/*@fallthrough@*/
|
||||
case URL_IS_UNKNOWN:
|
||||
break;
|
||||
case URL_IS_DASH:
|
||||
case URL_IS_HKP:
|
||||
default:
|
||||
return -2;
|
||||
/*@notreached@*/ break;
|
||||
break;
|
||||
}
|
||||
return chdir(path);
|
||||
}
|
||||
|
@ -150,23 +134,22 @@ int Rmdir (const char * path)
|
|||
switch (ut) {
|
||||
case URL_IS_FTP:
|
||||
return ftpRmdir(path);
|
||||
/*@notreached@*/ break;
|
||||
break;
|
||||
case URL_IS_HTTPS:
|
||||
case URL_IS_HTTP:
|
||||
#ifdef WITH_NEON
|
||||
return davRmdir(path);
|
||||
#endif
|
||||
/*@notreached@*/ break;
|
||||
break;
|
||||
case URL_IS_PATH:
|
||||
path = lpath;
|
||||
/*@fallthrough@*/
|
||||
case URL_IS_UNKNOWN:
|
||||
break;
|
||||
case URL_IS_DASH:
|
||||
case URL_IS_HKP:
|
||||
default:
|
||||
return -2;
|
||||
/*@notreached@*/ break;
|
||||
break;
|
||||
}
|
||||
return rmdir(path);
|
||||
}
|
||||
|
@ -189,7 +172,7 @@ int Rename (const char * oldpath, const char * newpath)
|
|||
#ifdef WITH_NEON
|
||||
return davRename(oldpath, newpath);
|
||||
#endif
|
||||
/*@notreached@*/ break;
|
||||
break;
|
||||
case URL_IS_FTP: /* XXX WRONG WRONG WRONG */
|
||||
case URL_IS_PATH:
|
||||
case URL_IS_UNKNOWN:
|
||||
|
@ -198,7 +181,7 @@ int Rename (const char * oldpath, const char * newpath)
|
|||
case URL_IS_HKP:
|
||||
default:
|
||||
return -2;
|
||||
/*@notreached@*/ break;
|
||||
break;
|
||||
}
|
||||
|
||||
newut = urlPath(newpath, &ne);
|
||||
|
@ -210,7 +193,7 @@ fprintf(stderr, "*** rename old %*s new %*s\n", (int)(oe - oldpath), oldpath, (i
|
|||
!xstrncasecmp(oldpath, newpath, (oe - oldpath))))
|
||||
return -2;
|
||||
return ftpRename(oldpath, newpath);
|
||||
/*@notreached@*/ break;
|
||||
break;
|
||||
case URL_IS_HTTPS: /* XXX WRONG WRONG WRONG */
|
||||
case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
|
||||
case URL_IS_PATH:
|
||||
|
@ -223,7 +206,7 @@ fprintf(stderr, "*** rename old %*s new %*s\n", (int)(oe - oldpath), oldpath, (i
|
|||
case URL_IS_HKP:
|
||||
default:
|
||||
return -2;
|
||||
/*@notreached@*/ break;
|
||||
break;
|
||||
}
|
||||
return rename(oldpath, newpath);
|
||||
}
|
||||
|
@ -246,7 +229,7 @@ int Link (const char * oldpath, const char * newpath)
|
|||
case URL_IS_HKP:
|
||||
default:
|
||||
return -2;
|
||||
/*@notreached@*/ break;
|
||||
break;
|
||||
}
|
||||
|
||||
newut = urlPath(newpath, &ne);
|
||||
|
@ -269,7 +252,7 @@ fprintf(stderr, "*** link old %*s new %*s\n", (int)(oe - oldpath), oldpath, (int
|
|||
case URL_IS_HKP:
|
||||
default:
|
||||
return -2;
|
||||
/*@notreached@*/ break;
|
||||
break;
|
||||
}
|
||||
return link(oldpath, newpath);
|
||||
}
|
||||
|
@ -283,23 +266,22 @@ int Unlink(const char * path) {
|
|||
switch (ut) {
|
||||
case URL_IS_FTP:
|
||||
return ftpUnlink(path);
|
||||
/*@notreached@*/ break;
|
||||
break;
|
||||
case URL_IS_HTTPS:
|
||||
case URL_IS_HTTP:
|
||||
#ifdef WITH_NEON
|
||||
return davUnlink(path);
|
||||
#endif
|
||||
/*@notreached@*/ break;
|
||||
break;
|
||||
case URL_IS_PATH:
|
||||
path = lpath;
|
||||
/*@fallthrough@*/
|
||||
case URL_IS_UNKNOWN:
|
||||
break;
|
||||
case URL_IS_DASH:
|
||||
case URL_IS_HKP:
|
||||
default:
|
||||
return -2;
|
||||
/*@notreached@*/ break;
|
||||
break;
|
||||
}
|
||||
return unlink(path);
|
||||
}
|
||||
|
@ -312,26 +294,18 @@ int Unlink(const char * path) {
|
|||
/*
|
||||
* FIXME: this is broken. It depends on mc not crossing border on month!
|
||||
*/
|
||||
/*@unchecked@*/
|
||||
static int current_mday;
|
||||
/*@unchecked@*/
|
||||
static int current_mon;
|
||||
/*@unchecked@*/
|
||||
static int current_year;
|
||||
|
||||
/* Following stuff (parse_ls_lga) is used by ftpfs and extfs */
|
||||
#define MAXCOLS 30
|
||||
|
||||
/*@unchecked@*/
|
||||
static char *columns [MAXCOLS]; /* Points to the string in column n */
|
||||
/*@unchecked@*/
|
||||
static int column_ptr [MAXCOLS]; /* Index from 0 to the starting positions of the columns */
|
||||
|
||||
/*@-boundswrite@*/
|
||||
static int
|
||||
vfs_split_text (char *p)
|
||||
/*@globals columns, column_ptr @*/
|
||||
/*@modifies *p, columns, column_ptr @*/
|
||||
{
|
||||
char *original = p;
|
||||
int numcols;
|
||||
|
@ -349,41 +323,31 @@ vfs_split_text (char *p)
|
|||
}
|
||||
return numcols;
|
||||
}
|
||||
/*@=boundswrite@*/
|
||||
|
||||
/*@-boundsread@*/
|
||||
static int
|
||||
is_num (int idx)
|
||||
/*@*/
|
||||
{
|
||||
if (!columns [idx] || columns [idx][0] < '0' || columns [idx][0] > '9')
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
/*@=boundsread@*/
|
||||
|
||||
/*@-boundsread@*/
|
||||
static int
|
||||
is_dos_date(/*@null@*/ const char *str)
|
||||
/*@*/
|
||||
is_dos_date(const char *str)
|
||||
{
|
||||
if (str != NULL && strlen(str) == 8 &&
|
||||
str[2] == str[5] && strchr("\\-/", (int)str[2]) != NULL)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
/*@=boundsread@*/
|
||||
|
||||
static int
|
||||
is_week (/*@null@*/ const char * str, /*@out@*/ struct tm * tim)
|
||||
/*@modifies *tim @*/
|
||||
is_week (const char * str, struct tm * tim)
|
||||
{
|
||||
/*@observer@*/ static const char * week = "SunMonTueWedThuFriSat";
|
||||
static const char * week = "SunMonTueWedThuFriSat";
|
||||
const char * pos;
|
||||
|
||||
/*@-observertrans -mayaliasunique@*/
|
||||
if (str != NULL && (pos=strstr(week, str)) != NULL) {
|
||||
/*@=observertrans =mayaliasunique@*/
|
||||
if (tim != NULL)
|
||||
tim->tm_wday = (pos - week)/3;
|
||||
return 1;
|
||||
|
@ -392,15 +356,12 @@ is_week (/*@null@*/ const char * str, /*@out@*/ struct tm * tim)
|
|||
}
|
||||
|
||||
static int
|
||||
is_month (/*@null@*/ const char * str, /*@out@*/ struct tm * tim)
|
||||
/*@modifies *tim @*/
|
||||
is_month (const char * str, struct tm * tim)
|
||||
{
|
||||
/*@observer@*/ static const char * month = "JanFebMarAprMayJunJulAugSepOctNovDec";
|
||||
static const char * month = "JanFebMarAprMayJunJulAugSepOctNovDec";
|
||||
const char * pos;
|
||||
|
||||
/*@-observertrans -mayaliasunique@*/
|
||||
if (str != NULL && (pos = strstr(month, str)) != NULL) {
|
||||
/*@=observertrans -mayaliasunique@*/
|
||||
if (tim != NULL)
|
||||
tim->tm_mon = (pos - month)/3;
|
||||
return 1;
|
||||
|
@ -409,8 +370,7 @@ is_month (/*@null@*/ const char * str, /*@out@*/ struct tm * tim)
|
|||
}
|
||||
|
||||
static int
|
||||
is_time (/*@null@*/ const char * str, /*@out@*/ struct tm * tim)
|
||||
/*@modifies *tim @*/
|
||||
is_time (const char * str, struct tm * tim)
|
||||
{
|
||||
const char * p, * p2;
|
||||
|
||||
|
@ -428,8 +388,7 @@ is_time (/*@null@*/ const char * str, /*@out@*/ struct tm * tim)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int is_year(/*@null@*/ const char * str, /*@out@*/ struct tm * tim)
|
||||
/*@modifies *tim @*/
|
||||
static int is_year(const char * str, struct tm * tim)
|
||||
{
|
||||
long year;
|
||||
|
||||
|
@ -461,7 +420,6 @@ static int is_year(/*@null@*/ const char * str, /*@out@*/ struct tm * tim)
|
|||
|
||||
static int
|
||||
vfs_parse_filetype (char c)
|
||||
/*@*/
|
||||
{
|
||||
switch (c) {
|
||||
case 'd': return S_IFDIR;
|
||||
|
@ -480,7 +438,6 @@ vfs_parse_filetype (char c)
|
|||
}
|
||||
|
||||
static int vfs_parse_filemode (const char *p)
|
||||
/*@*/
|
||||
{ /* converts rw-rw-rw- into 0666 */
|
||||
int res = 0;
|
||||
switch (*(p++)) {
|
||||
|
@ -538,9 +495,7 @@ static int vfs_parse_filemode (const char *p)
|
|||
return res;
|
||||
}
|
||||
|
||||
/*@-boundswrite@*/
|
||||
static int vfs_parse_filedate(int idx, /*@out@*/ time_t *t)
|
||||
/*@modifies *t @*/
|
||||
static int vfs_parse_filedate(int idx, time_t *t)
|
||||
{ /* This thing parses from idx in columns[] array */
|
||||
|
||||
char *p;
|
||||
|
@ -585,9 +540,7 @@ static int vfs_parse_filedate(int idx, /*@out@*/ time_t *t)
|
|||
|
||||
/* Here just this special case with MM-DD-YY */
|
||||
if (is_dos_date(p)){
|
||||
/*@-mods@*/
|
||||
p[2] = p[5] = '-';
|
||||
/*@=mods@*/
|
||||
|
||||
memset(d, 0, sizeof(d));
|
||||
if (sscanf(p, "%2d-%2d-%2d", &d[0], &d[1], &d[2]) == 3){
|
||||
|
@ -646,14 +599,11 @@ static int vfs_parse_filedate(int idx, /*@out@*/ time_t *t)
|
|||
*t = 0;
|
||||
return idx;
|
||||
}
|
||||
/*@=boundswrite@*/
|
||||
|
||||
/*@-boundswrite@*/
|
||||
static int
|
||||
vfs_parse_ls_lga (char * p, /*@out@*/ struct stat * st,
|
||||
/*@out@*/ const char ** filename,
|
||||
/*@out@*/ const char ** linkname)
|
||||
/*@modifies *p, *st, *filename, *linkname @*/
|
||||
vfs_parse_ls_lga (char * p, struct stat * st,
|
||||
const char ** filename,
|
||||
const char ** linkname)
|
||||
{
|
||||
int idx, idx2, num_cols;
|
||||
int i;
|
||||
|
@ -676,13 +626,11 @@ vfs_parse_ls_lga (char * p, /*@out@*/ struct stat * st,
|
|||
if (strlen (p) <= 8 || p [8] != ']')
|
||||
goto error;
|
||||
/* Should parse here the Notwell permissions :) */
|
||||
/*@-unrecog@*/
|
||||
if (S_ISDIR (st->st_mode))
|
||||
st->st_mode |= (S_IRUSR | S_IRGRP | S_IROTH | S_IWUSR | S_IXUSR | S_IXGRP | S_IXOTH);
|
||||
else
|
||||
st->st_mode |= (S_IRUSR | S_IRGRP | S_IROTH | S_IWUSR);
|
||||
p += 9;
|
||||
/*@=unrecog@*/
|
||||
} else {
|
||||
if ((i = vfs_parse_filemode(p)) == -1)
|
||||
goto error;
|
||||
|
@ -846,13 +794,10 @@ error:
|
|||
}
|
||||
#endif
|
||||
|
||||
/*@-usereleased@*/
|
||||
if (p_copy != p) /* Carefull! */
|
||||
/*@=usereleased@*/
|
||||
g_free (p_copy);
|
||||
return 0;
|
||||
}
|
||||
/*@=boundswrite@*/
|
||||
|
||||
typedef enum {
|
||||
DO_FTP_STAT = 1,
|
||||
|
@ -864,20 +809,17 @@ typedef enum {
|
|||
|
||||
/**
|
||||
*/
|
||||
/*@unchecked@*/
|
||||
static size_t ftpBufAlloced = 0;
|
||||
|
||||
/**
|
||||
*/
|
||||
/*@unchecked@*/
|
||||
static /*@only@*/ char * ftpBuf = NULL;
|
||||
static char * ftpBuf = NULL;
|
||||
|
||||
#define alloca_strdup(_s) strcpy(alloca(strlen(_s)+1), (_s))
|
||||
|
||||
/*@-boundswrite@*/
|
||||
static int ftpNLST(const char * url, ftpSysCall_t ftpSysCall,
|
||||
/*@out@*/ /*@null@*/ struct stat * st,
|
||||
/*@out@*/ /*@null@*/ char * rlbuf, size_t rlbufsiz)
|
||||
struct stat * st,
|
||||
char * rlbuf, size_t rlbufsiz)
|
||||
/*@globals ftpBufAlloced, ftpBuf,
|
||||
h_errno, fileSystem, internalState @*/
|
||||
/*@modifies *st, *rlbuf, ftpBufAlloced, ftpBuf,
|
||||
|
@ -910,14 +852,12 @@ static int ftpNLST(const char * url, ftpSysCall_t ftpSysCall,
|
|||
break;
|
||||
default:
|
||||
urldn = alloca_strdup(url);
|
||||
/*@-branchstate@*/
|
||||
if ((bn = strrchr(urldn, '/')) == NULL)
|
||||
return -2;
|
||||
else if (bn == path)
|
||||
bn = ".";
|
||||
else
|
||||
*bn++ = '\0';
|
||||
/*@=branchstate@*/
|
||||
nbn = strlen(bn);
|
||||
|
||||
rc = ftpChdir(urldn); /* XXX don't care about CWD */
|
||||
|
@ -980,44 +920,44 @@ static int ftpNLST(const char * url, ftpSysCall_t ftpSysCall,
|
|||
while (*se && *se != '\n') se++;
|
||||
if (se > s && se[-1] == '\r') se[-1] = '\0';
|
||||
if (*se == '\0')
|
||||
/*@innerbreak@*/ break;
|
||||
break;
|
||||
*se++ = '\0';
|
||||
|
||||
if (!strncmp(s, "total ", sizeof("total ")-1))
|
||||
/*@innercontinue@*/ continue;
|
||||
continue;
|
||||
|
||||
o = NULL;
|
||||
for (bingo = 0, n = se; n >= s; n--) {
|
||||
switch (*n) {
|
||||
case '\0':
|
||||
oe = ne = n;
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
case ' ':
|
||||
if (o || !(n[-3] == ' ' && n[-2] == '-' && n[-1] == '>')) {
|
||||
while (*(++n) == ' ')
|
||||
{};
|
||||
bingo++;
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
}
|
||||
for (o = n + 1; *o == ' '; o++)
|
||||
{};
|
||||
n -= 3;
|
||||
ne = n;
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
default:
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
}
|
||||
if (bingo)
|
||||
/*@innerbreak@*/ break;
|
||||
break;
|
||||
}
|
||||
|
||||
if (nbn != (ne - n)) /* Same name length? */
|
||||
/*@innercontinue@*/ continue;
|
||||
continue;
|
||||
if (strncmp(n, bn, nbn)) /* Same name? */
|
||||
/*@innercontinue@*/ continue;
|
||||
continue;
|
||||
|
||||
moretodo = 0;
|
||||
/*@innerbreak@*/ break;
|
||||
break;
|
||||
}
|
||||
|
||||
if (moretodo && se > s) {
|
||||
|
@ -1034,7 +974,6 @@ static int ftpNLST(const char * url, ftpSysCall_t ftpSysCall,
|
|||
if (o && oe) {
|
||||
/* XXX FIXME: symlink, replace urldn/bn from [o,oe) and restart */
|
||||
}
|
||||
/*@fallthrough@*/
|
||||
case DO_FTP_LSTAT:
|
||||
if (st == NULL || !(n && ne)) {
|
||||
rc = -1;
|
||||
|
@ -1066,11 +1005,9 @@ exit:
|
|||
(void) ufdClose(fd);
|
||||
return rc;
|
||||
}
|
||||
/*@=boundswrite@*/
|
||||
|
||||
static const char * statstr(const struct stat * st,
|
||||
/*@returned@*/ /*@out@*/ char * buf)
|
||||
/*@modifies *buf @*/
|
||||
char * buf)
|
||||
{
|
||||
sprintf(buf,
|
||||
"*** dev %x ino %x mode %0o nlink %d uid %d gid %d rdev %x size %x\n",
|
||||
|
@ -1085,13 +1022,10 @@ static const char * statstr(const struct stat * st,
|
|||
return buf;
|
||||
}
|
||||
|
||||
/*@unchecked@*/
|
||||
static int ftp_st_ino = 0xdead0000;
|
||||
|
||||
/* FIXME: borked for path with trailing '/' */
|
||||
static int ftpStat(const char * path, /*@out@*/ struct stat *st)
|
||||
/*@globals ftp_st_ino, h_errno, fileSystem, internalState @*/
|
||||
/*@modifies *st, ftp_st_ino, fileSystem, internalState @*/
|
||||
static int ftpStat(const char * path, struct stat *st)
|
||||
{
|
||||
char buf[1024];
|
||||
int rc;
|
||||
|
@ -1105,9 +1039,7 @@ fprintf(stderr, "*** ftpStat(%s) rc %d\n%s", path, rc, statstr(st, buf));
|
|||
}
|
||||
|
||||
/* FIXME: borked for path with trailing '/' */
|
||||
static int ftpLstat(const char * path, /*@out@*/ struct stat *st)
|
||||
/*@globals ftp_st_ino, h_errno, fileSystem, internalState @*/
|
||||
/*@modifies *st, ftp_st_ino, fileSystem, internalState @*/
|
||||
static int ftpLstat(const char * path, struct stat *st)
|
||||
{
|
||||
char buf[1024];
|
||||
int rc;
|
||||
|
@ -1120,9 +1052,7 @@ fprintf(stderr, "*** ftpLstat(%s) rc %d\n%s\n", path, rc, statstr(st, buf));
|
|||
return rc;
|
||||
}
|
||||
|
||||
static int ftpReadlink(const char * path, /*@out@*/ char * buf, size_t bufsiz)
|
||||
/*@globals h_errno, fileSystem, internalState @*/
|
||||
/*@modifies *buf, fileSystem, internalState @*/
|
||||
static int ftpReadlink(const char * path, char * buf, size_t bufsiz)
|
||||
{
|
||||
int rc;
|
||||
rc = ftpNLST(path, DO_FTP_READLINK, NULL, buf, bufsiz);
|
||||
|
@ -1131,11 +1061,7 @@ fprintf(stderr, "*** ftpReadlink(%s) rc %d\n", path, rc);
|
|||
return rc;
|
||||
}
|
||||
|
||||
/*@-boundswrite@*/
|
||||
/*@null@*/
|
||||
static DIR * ftpOpendir(const char * path)
|
||||
/*@globals h_errno, fileSystem, internalState @*/
|
||||
/*@modifies fileSystem, internalState @*/
|
||||
{
|
||||
AVDIR avdir;
|
||||
struct dirent * dp;
|
||||
|
@ -1167,7 +1093,7 @@ fprintf(stderr, "*** ftpOpendir(%s)\n", path);
|
|||
switch (c) {
|
||||
case '/':
|
||||
sb = se;
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
case '\r':
|
||||
if (sb == NULL) {
|
||||
for (sb = se; sb > s && sb[-1] != ' '; sb--)
|
||||
|
@ -1179,41 +1105,33 @@ fprintf(stderr, "*** ftpOpendir(%s)\n", path);
|
|||
if (*se == '\n') se++;
|
||||
sb = NULL;
|
||||
s = se;
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
default:
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
nb += sizeof(*avdir) + sizeof(*dp) + ((ac + 1) * sizeof(*av)) + (ac + 1);
|
||||
avdir = xcalloc(1, nb);
|
||||
/*@-abstract@*/
|
||||
dp = (struct dirent *) (avdir + 1);
|
||||
av = (const char **) (dp + 1);
|
||||
dt = (unsigned char *) (av + (ac + 1));
|
||||
t = (char *) (dt + ac + 1);
|
||||
/*@=abstract@*/
|
||||
|
||||
avdir->fd = avmagicdir;
|
||||
/*@-usereleased@*/
|
||||
avdir->data = (char *) dp;
|
||||
/*@=usereleased@*/
|
||||
avdir->allocation = nb;
|
||||
avdir->size = ac;
|
||||
avdir->offset = -1;
|
||||
avdir->filepos = 0;
|
||||
|
||||
#if defined(HAVE_PTHREAD_H)
|
||||
/*@-moduncon -noeffectuncon@*/
|
||||
(void) pthread_mutex_init(&avdir->lock, NULL);
|
||||
/*@=moduncon =noeffectuncon@*/
|
||||
#endif
|
||||
|
||||
ac = 0;
|
||||
/*@-dependenttrans -unrecog@*/
|
||||
dt[ac] = DT_DIR; av[ac++] = t; t = stpcpy(t, "."); t++;
|
||||
dt[ac] = DT_DIR; av[ac++] = t; t = stpcpy(t, ".."); t++;
|
||||
/*@=dependenttrans =unrecog@*/
|
||||
sb = NULL;
|
||||
s = se = ftpBuf;
|
||||
while ((c = *se) != '\0') {
|
||||
|
@ -1221,40 +1139,36 @@ fprintf(stderr, "*** ftpOpendir(%s)\n", path);
|
|||
switch (c) {
|
||||
case '/':
|
||||
sb = se;
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
case '\r':
|
||||
/*@-dependenttrans@*/
|
||||
av[ac] = t;
|
||||
/*@=dependenttrans@*/
|
||||
if (sb == NULL) {
|
||||
/*@-unrecog@*/
|
||||
switch(*s) {
|
||||
case 'p':
|
||||
dt[ac] = DT_FIFO;
|
||||
/*@innerbreak@*/ break;
|
||||
break;
|
||||
case 'c':
|
||||
dt[ac] = DT_CHR;
|
||||
/*@innerbreak@*/ break;
|
||||
break;
|
||||
case 'd':
|
||||
dt[ac] = DT_DIR;
|
||||
/*@innerbreak@*/ break;
|
||||
break;
|
||||
case 'b':
|
||||
dt[ac] = DT_BLK;
|
||||
/*@innerbreak@*/ break;
|
||||
break;
|
||||
case '-':
|
||||
dt[ac] = DT_REG;
|
||||
/*@innerbreak@*/ break;
|
||||
break;
|
||||
case 'l':
|
||||
dt[ac] = DT_LNK;
|
||||
/*@innerbreak@*/ break;
|
||||
break;
|
||||
case 's':
|
||||
dt[ac] = DT_SOCK;
|
||||
/*@innerbreak@*/ break;
|
||||
break;
|
||||
default:
|
||||
dt[ac] = DT_UNKNOWN;
|
||||
/*@innerbreak@*/ break;
|
||||
break;
|
||||
}
|
||||
/*@=unrecog@*/
|
||||
for (sb = se; sb > s && sb[-1] != ' '; sb--)
|
||||
{};
|
||||
}
|
||||
|
@ -1264,18 +1178,15 @@ fprintf(stderr, "*** ftpOpendir(%s)\n", path);
|
|||
if (*se == '\n') se++;
|
||||
sb = NULL;
|
||||
s = se;
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
default:
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
av[ac] = NULL;
|
||||
|
||||
/*@-kepttrans@*/
|
||||
return (DIR *) avdir;
|
||||
/*@=kepttrans@*/
|
||||
}
|
||||
/*@=boundswrite@*/
|
||||
|
||||
int Stat(const char * path, struct stat * st)
|
||||
{
|
||||
|
@ -1287,23 +1198,22 @@ fprintf(stderr, "*** Stat(%s,%p)\n", path, st);
|
|||
switch (ut) {
|
||||
case URL_IS_FTP:
|
||||
return ftpStat(path, st);
|
||||
/*@notreached@*/ break;
|
||||
break;
|
||||
case URL_IS_HTTPS:
|
||||
case URL_IS_HTTP:
|
||||
#ifdef WITH_NEON
|
||||
return davStat(path, st);
|
||||
#endif
|
||||
/*@notreached@*/ break;
|
||||
break;
|
||||
case URL_IS_PATH:
|
||||
path = lpath;
|
||||
/*@fallthrough@*/
|
||||
case URL_IS_UNKNOWN:
|
||||
break;
|
||||
case URL_IS_DASH:
|
||||
case URL_IS_HKP:
|
||||
default:
|
||||
return -2;
|
||||
/*@notreached@*/ break;
|
||||
break;
|
||||
}
|
||||
return stat(path, st);
|
||||
}
|
||||
|
@ -1318,23 +1228,22 @@ fprintf(stderr, "*** Lstat(%s,%p)\n", path, st);
|
|||
switch (ut) {
|
||||
case URL_IS_FTP:
|
||||
return ftpLstat(path, st);
|
||||
/*@notreached@*/ break;
|
||||
break;
|
||||
case URL_IS_HTTPS:
|
||||
case URL_IS_HTTP:
|
||||
#ifdef WITH_NEON
|
||||
return davLstat(path, st);
|
||||
#endif
|
||||
/*@notreached@*/ break;
|
||||
break;
|
||||
case URL_IS_PATH:
|
||||
path = lpath;
|
||||
/*@fallthrough@*/
|
||||
case URL_IS_UNKNOWN:
|
||||
break;
|
||||
case URL_IS_DASH:
|
||||
case URL_IS_HKP:
|
||||
default:
|
||||
return -2;
|
||||
/*@notreached@*/ break;
|
||||
break;
|
||||
}
|
||||
return lstat(path, st);
|
||||
}
|
||||
|
@ -1347,7 +1256,7 @@ int Readlink(const char * path, char * buf, size_t bufsiz)
|
|||
switch (ut) {
|
||||
case URL_IS_FTP:
|
||||
return ftpReadlink(path, buf, bufsiz);
|
||||
/*@notreached@*/ break;
|
||||
break;
|
||||
case URL_IS_HTTPS:
|
||||
case URL_IS_HTTP:
|
||||
#ifdef NOTYET
|
||||
|
@ -1355,21 +1264,19 @@ int Readlink(const char * path, char * buf, size_t bufsiz)
|
|||
#else
|
||||
return -2;
|
||||
#endif
|
||||
/*@notreached@*/ break;
|
||||
break;
|
||||
case URL_IS_PATH:
|
||||
path = lpath;
|
||||
/*@fallthrough@*/
|
||||
case URL_IS_UNKNOWN:
|
||||
break;
|
||||
case URL_IS_DASH:
|
||||
case URL_IS_HKP:
|
||||
default:
|
||||
return -2;
|
||||
/*@notreached@*/ break;
|
||||
break;
|
||||
}
|
||||
/*@-compdef@*/ /* FIX: *buf is undefined */
|
||||
/* FIX: *buf is undefined */
|
||||
return readlink(path, buf, bufsiz);
|
||||
/*@=compdef@*/
|
||||
}
|
||||
|
||||
int Access(const char * path, int amode)
|
||||
|
@ -1385,14 +1292,13 @@ fprintf(stderr, "*** Access(%s,%d)\n", path, amode);
|
|||
case URL_IS_FTP: /* XXX WRONG WRONG WRONG */
|
||||
case URL_IS_PATH:
|
||||
path = lpath;
|
||||
/*@fallthrough@*/
|
||||
case URL_IS_UNKNOWN:
|
||||
break;
|
||||
case URL_IS_DASH:
|
||||
case URL_IS_HKP:
|
||||
default:
|
||||
return -2;
|
||||
/*@notreached@*/ break;
|
||||
break;
|
||||
}
|
||||
return access(path, amode);
|
||||
}
|
||||
|
@ -1438,7 +1344,7 @@ int Glob_pattern_p (const char * pattern, int quote)
|
|||
return (0);
|
||||
}
|
||||
|
||||
int Glob_error(/*@unused@*/const char * epath, /*@unused@*/ int eerrno)
|
||||
int Glob_error(/*@unused@*/const char * epath, int eerrno)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
@ -1449,34 +1355,29 @@ int Glob(const char *pattern, int flags,
|
|||
const char * lpath;
|
||||
int ut = urlPath(pattern, &lpath);
|
||||
|
||||
/*@-castfcnptr@*/
|
||||
if (_rpmio_debug)
|
||||
fprintf(stderr, "*** Glob(%s,0x%x,%p,%p)\n", pattern, (unsigned)flags, (void *)errfunc, pglob);
|
||||
/*@=castfcnptr@*/
|
||||
switch (ut) {
|
||||
case URL_IS_HTTPS:
|
||||
case URL_IS_HTTP:
|
||||
case URL_IS_FTP:
|
||||
/*@-type@*/
|
||||
pglob->gl_closedir = (void *) Closedir;
|
||||
pglob->gl_readdir = (void *) Readdir;
|
||||
pglob->gl_opendir = (void *) Opendir;
|
||||
pglob->gl_lstat = Lstat;
|
||||
pglob->gl_stat = Stat;
|
||||
/*@=type@*/
|
||||
flags |= GLOB_ALTDIRFUNC;
|
||||
flags &= ~GLOB_TILDE;
|
||||
break;
|
||||
case URL_IS_PATH:
|
||||
pattern = lpath;
|
||||
/*@fallthrough@*/
|
||||
case URL_IS_UNKNOWN:
|
||||
break;
|
||||
case URL_IS_DASH:
|
||||
case URL_IS_HKP:
|
||||
default:
|
||||
return -2;
|
||||
/*@notreached@*/ break;
|
||||
break;
|
||||
}
|
||||
return glob(pattern, flags, errfunc, pglob);
|
||||
}
|
||||
|
@ -1498,27 +1399,24 @@ fprintf(stderr, "*** Opendir(%s)\n", path);
|
|||
switch (ut) {
|
||||
case URL_IS_FTP:
|
||||
return ftpOpendir(path);
|
||||
/*@notreached@*/ break;
|
||||
break;
|
||||
case URL_IS_HTTPS:
|
||||
case URL_IS_HTTP:
|
||||
#ifdef WITH_NEON
|
||||
return davOpendir(path);
|
||||
#endif
|
||||
/*@notreached@*/ break;
|
||||
break;
|
||||
case URL_IS_PATH:
|
||||
path = lpath;
|
||||
/*@fallthrough@*/
|
||||
case URL_IS_UNKNOWN:
|
||||
break;
|
||||
case URL_IS_DASH:
|
||||
case URL_IS_HKP:
|
||||
default:
|
||||
return NULL;
|
||||
/*@notreached@*/ break;
|
||||
break;
|
||||
}
|
||||
/*@-dependenttrans@*/
|
||||
return opendir(path);
|
||||
/*@=dependenttrans@*/
|
||||
}
|
||||
|
||||
struct dirent * Readdir(DIR * dir)
|
||||
|
|
|
@ -19,13 +19,9 @@
|
|||
#endif
|
||||
|
||||
#ifndef PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
|
||||
/*@unchecked@*/
|
||||
static pthread_mutex_t rpmsigTbl_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
#else
|
||||
/*@unchecked@*/
|
||||
/*@-type@*/
|
||||
static pthread_mutex_t rpmsigTbl_lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
|
||||
/*@=type@*/
|
||||
#endif
|
||||
|
||||
#define DO_LOCK() pthread_mutex_lock(&rpmsigTbl_lock);
|
||||
|
@ -56,8 +52,8 @@ static pthread_mutex_t rpmsigTbl_lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
|
|||
#define DO_LOCK()
|
||||
#define DO_UNLOCK()
|
||||
#define INIT_LOCK()
|
||||
#define ADD_REF(__tbl) /*@-noeffect@*/ (0) /*@=noeffect@*/
|
||||
#define SUB_REF(__tbl) /*@-noeffect@*/ (0) /*@=noeffect@*/
|
||||
#define ADD_REF(__tbl) (0)
|
||||
#define SUB_REF(__tbl) (0)
|
||||
#define CLEANUP_HANDLER(__handler, __arg, __oldtypeptr)
|
||||
#define CLEANUP_RESET(__execute, __oldtype)
|
||||
|
||||
|
@ -72,16 +68,11 @@ static pthread_mutex_t rpmsigTbl_lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
|
|||
#include "debug.h"
|
||||
|
||||
#define _RPMSQ_DEBUG 0
|
||||
/*@unchecked@*/
|
||||
int _rpmsq_debug = _RPMSQ_DEBUG;
|
||||
|
||||
/*@unchecked@*/
|
||||
static struct rpmsqElem rpmsqRock;
|
||||
|
||||
/*@-compmempass@*/
|
||||
/*@unchecked@*/
|
||||
rpmsq rpmsqQueue = &rpmsqRock;
|
||||
/*@=compmempass@*/
|
||||
|
||||
int rpmsqInsert(void * elem, void * prev)
|
||||
{
|
||||
|
@ -99,9 +90,7 @@ fprintf(stderr, " Insert(%p): %p\n", ME(), sq);
|
|||
sq->reaped = 0;
|
||||
sq->status = 0;
|
||||
sq->reaper = 1;
|
||||
/*@-bounds@*/
|
||||
sq->pipes[0] = sq->pipes[1] = -1;
|
||||
/*@=bounds@*/
|
||||
|
||||
sq->id = ME();
|
||||
ret = pthread_mutex_init(&sq->mutex, NULL);
|
||||
|
@ -132,11 +121,9 @@ fprintf(stderr, " Remove(%p): %p\n", ME(), sq);
|
|||
ret = pthread_mutex_destroy(&sq->mutex);
|
||||
|
||||
sq->id = NULL;
|
||||
/*@-bounds@*/
|
||||
if (sq->pipes[1]) ret = close(sq->pipes[1]);
|
||||
if (sq->pipes[0]) ret = close(sq->pipes[0]);
|
||||
sq->pipes[0] = sq->pipes[1] = -1;
|
||||
/*@=bounds@*/
|
||||
#ifdef NOTYET /* rpmpsmWait debugging message needs */
|
||||
sq->reaper = 1;
|
||||
sq->status = 0;
|
||||
|
@ -149,11 +136,8 @@ fprintf(stderr, " Remove(%p): %p\n", ME(), sq);
|
|||
return ret;
|
||||
}
|
||||
|
||||
/*@unchecked@*/
|
||||
sigset_t rpmsqCaught;
|
||||
|
||||
/*@unchecked@*/
|
||||
/*@-fullinitblock@*/
|
||||
static struct rpmsig_s {
|
||||
int signum;
|
||||
void (*handler) (int signum, void * info, void * context);
|
||||
|
@ -174,10 +158,9 @@ static struct rpmsig_s {
|
|||
#define rpmsigTbl_sigpipe (&rpmsigTbl[5])
|
||||
{ -1, NULL },
|
||||
};
|
||||
/*@=fullinitblock@*/
|
||||
|
||||
void rpmsqAction(int signum,
|
||||
/*@unused@*/ void * info, /*@unused@*/ void * context)
|
||||
void * info, void * context)
|
||||
{
|
||||
int save = errno;
|
||||
rpmsig tbl;
|
||||
|
@ -197,7 +180,7 @@ void rpmsqAction(int signum,
|
|||
|
||||
/* XXX errno set to ECHILD/EINVAL/EINTR. */
|
||||
if (reaped <= 0)
|
||||
/*@innerbreak@*/ break;
|
||||
break;
|
||||
|
||||
/* XXX insque(3)/remque(3) are dequeue, not ring. */
|
||||
for (sq = rpmsqQueue->q_forw;
|
||||
|
@ -207,7 +190,7 @@ void rpmsqAction(int signum,
|
|||
int ret;
|
||||
|
||||
if (sq->child != reaped)
|
||||
/*@innercontinue@*/ continue;
|
||||
continue;
|
||||
sq->reaped = reaped;
|
||||
sq->status = status;
|
||||
|
||||
|
@ -218,21 +201,19 @@ void rpmsqAction(int signum,
|
|||
*/
|
||||
ret = pthread_mutex_unlock(&sq->mutex);
|
||||
|
||||
/*@innerbreak@*/ break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
default:
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
errno = save;
|
||||
}
|
||||
|
||||
int rpmsqEnable(int signum, /*@null@*/ rpmsqAction_t handler)
|
||||
/*@globals rpmsigTbl @*/
|
||||
/*@modifies rpmsigTbl @*/
|
||||
int rpmsqEnable(int signum, rpmsqAction_t handler)
|
||||
{
|
||||
int tblsignum = (signum >= 0 ? signum : -signum);
|
||||
struct sigaction sa;
|
||||
|
@ -309,11 +290,9 @@ fprintf(stderr, " Enable(%p): %p\n", ME(), sq);
|
|||
if (!nothreads) {
|
||||
if(pthread_mutex_lock(&sq->mutex)) {
|
||||
/* Yack we did not get the lock, lets just give up */
|
||||
/*@-bounds@*/
|
||||
xx = close(sq->pipes[0]);
|
||||
xx = close(sq->pipes[1]);
|
||||
sq->pipes[0] = sq->pipes[1] = -1;
|
||||
/*@=bounds@*/
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
@ -321,22 +300,18 @@ fprintf(stderr, " Enable(%p): %p\n", ME(), sq);
|
|||
pid = fork();
|
||||
if (pid < (pid_t) 0) { /* fork failed. */
|
||||
sq->child = (pid_t)-1;
|
||||
/*@-bounds@*/
|
||||
xx = close(sq->pipes[0]);
|
||||
xx = close(sq->pipes[1]);
|
||||
sq->pipes[0] = sq->pipes[1] = -1;
|
||||
/*@=bounds@*/
|
||||
goto out;
|
||||
} else if (pid == (pid_t) 0) { /* Child. */
|
||||
int yy;
|
||||
|
||||
/* Block to permit parent time to wait. */
|
||||
/*@-bounds@*/
|
||||
xx = close(sq->pipes[1]);
|
||||
xx = read(sq->pipes[0], &yy, sizeof(yy));
|
||||
xx = close(sq->pipes[0]);
|
||||
sq->pipes[0] = sq->pipes[1] = -1;
|
||||
/*@=bounds@*/
|
||||
|
||||
#ifdef _RPMSQ_DEBUG
|
||||
if (_rpmsq_debug)
|
||||
|
@ -366,8 +341,6 @@ out:
|
|||
* @return 0 on success
|
||||
*/
|
||||
static int rpmsqWaitUnregister(rpmsq sq)
|
||||
/*@globals fileSystem, internalState @*/
|
||||
/*@modifies sq, fileSystem, internalState @*/
|
||||
{
|
||||
int nothreads = 0;
|
||||
int ret = 0;
|
||||
|
@ -377,19 +350,16 @@ static int rpmsqWaitUnregister(rpmsq sq)
|
|||
ret = sighold(SIGCHLD);
|
||||
|
||||
/* Start the child, linux often runs child before parent. */
|
||||
/*@-bounds@*/
|
||||
if (sq->pipes[0] >= 0)
|
||||
xx = close(sq->pipes[0]);
|
||||
if (sq->pipes[1] >= 0)
|
||||
xx = close(sq->pipes[1]);
|
||||
sq->pipes[0] = sq->pipes[1] = -1;
|
||||
/*@=bounds@*/
|
||||
|
||||
/* Put a stopwatch on the time spent waiting to measure performance gain. */
|
||||
(void) rpmswEnter(&sq->op, -1);
|
||||
|
||||
/* Wait for handler to receive SIGCHLD. */
|
||||
/*@-infloops@*/
|
||||
while (ret == 0 && sq->reaped != sq->child) {
|
||||
if (nothreads)
|
||||
/* Note that sigpause re-enables SIGCHLD. */
|
||||
|
@ -406,7 +376,6 @@ static int rpmsqWaitUnregister(rpmsq sq)
|
|||
xx = sighold(SIGCHLD);
|
||||
}
|
||||
}
|
||||
/*@=infloops@*/
|
||||
|
||||
/* Accumulate stopwatch time spent waiting, potential performance gain. */
|
||||
sq->ms_scriptlets += rpmswExit(&sq->op, -1)/1000;
|
||||
|
@ -492,8 +461,6 @@ int rpmsqThreadEqual(void * thread)
|
|||
*/
|
||||
static void
|
||||
sigchld_cancel (void *arg)
|
||||
/*@globals rpmsigTbl, fileSystem, internalState @*/
|
||||
/*@modifies rpmsigTbl, fileSystem, internalState @*/
|
||||
{
|
||||
pid_t child = *(pid_t *) arg;
|
||||
pid_t result;
|
||||
|
@ -517,8 +484,6 @@ sigchld_cancel (void *arg)
|
|||
*/
|
||||
int
|
||||
rpmsqExecve (const char ** argv)
|
||||
/*@globals rpmsigTbl @*/
|
||||
/*@modifies rpmsigTbl @*/
|
||||
{
|
||||
int oldtype;
|
||||
int status = -1;
|
||||
|
|
|
@ -22,13 +22,9 @@ typedef struct rpmsqElem * rpmsq;
|
|||
* @param info (siginfo_t) signal info
|
||||
* @param context signal context
|
||||
*/
|
||||
typedef void (*rpmsqAction_t) (int signum, void * info, void * context)
|
||||
/*@*/;
|
||||
typedef void (*rpmsqAction_t) (int signum, void * info, void * context);
|
||||
|
||||
/*@-redecl@*/
|
||||
/*@unchecked@*/
|
||||
extern int _rpmsq_debug;
|
||||
/*@=redecl@*/
|
||||
|
||||
/**
|
||||
* SIGCHLD queue element.
|
||||
|
@ -43,18 +39,13 @@ struct rpmsqElem {
|
|||
rpmtime_t ms_scriptlets; /*!< Accumulated script duration (msecs). */
|
||||
int reaper; /*!< Register SIGCHLD handler? */
|
||||
int pipes[2]; /*!< Parent/child interlock. */
|
||||
/*@shared@*/
|
||||
void * id; /*!< Blocking thread id (pthread_t). */
|
||||
pthread_mutex_t mutex; /*!< Signal delivery to thread condvar. */
|
||||
pthread_cond_t cond;
|
||||
};
|
||||
|
||||
/*@-exportlocal@*/
|
||||
/*@unchecked@*/
|
||||
extern rpmsq rpmsqQueue;
|
||||
/*@=exportlocal@*/
|
||||
|
||||
/*@unchecked@*/
|
||||
extern sigset_t rpmsqCaught;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -67,22 +58,14 @@ extern "C" {
|
|||
* @param prev previous node from queue
|
||||
* @return 0 on success
|
||||
*/
|
||||
/*@-exportlocal@*/
|
||||
int rpmsqInsert(/*@null@*/ void * elem, /*@null@*/ void * prev)
|
||||
/*@globals systemState @*/
|
||||
/*@modifies elem, prev, systemState @*/;
|
||||
/*@=exportlocal@*/
|
||||
int rpmsqInsert(void * elem, void * prev);
|
||||
|
||||
/**
|
||||
* Remove node from queue.
|
||||
* @param elem node to link
|
||||
* @return 0 on success
|
||||
*/
|
||||
/*@-exportlocal@*/
|
||||
int rpmsqRemove(/*@null@*/ void * elem)
|
||||
/*@globals fileSystem, internalState @*/
|
||||
/*@modifies elem, fileSystem, internalState @*/;
|
||||
/*@=exportlocal@*/
|
||||
int rpmsqRemove(void * elem);
|
||||
|
||||
/**
|
||||
* Default signal handler.
|
||||
|
@ -90,11 +73,7 @@ int rpmsqRemove(/*@null@*/ void * elem)
|
|||
* @param info (siginfo_t) signal info
|
||||
* @param context signal context
|
||||
*/
|
||||
/*@-exportlocal@*/
|
||||
void rpmsqAction(int signum, void * info, void * context)
|
||||
/*@globals rpmsqCaught, rpmsqQueue, errno, fileSystem @*/
|
||||
/*@modifies rpmsqCaught, rpmsqQueue, errno, fileSystem @*/;
|
||||
/*@=exportlocal@*/
|
||||
void rpmsqAction(int signum, void * info, void * context);
|
||||
|
||||
/**
|
||||
* Enable or disable a signal handler.
|
||||
|
@ -102,27 +81,21 @@ void rpmsqAction(int signum, void * info, void * context)
|
|||
* @param handler sa_sigaction handler (or NULL to use rpmsqHandler())
|
||||
* @return no. of refs, -1 on error
|
||||
*/
|
||||
int rpmsqEnable(int signum, /*@null@*/ rpmsqAction_t handler)
|
||||
/*@globals rpmsqCaught, rpmsqQueue, fileSystem, internalState @*/
|
||||
/*@modifies rpmsqCaught, rpmsqQueue, fileSystem, internalState @*/;
|
||||
int rpmsqEnable(int signum, rpmsqAction_t handler);
|
||||
|
||||
/**
|
||||
* Fork a child process.
|
||||
* @param sq scriptlet queue element
|
||||
* @return fork(2) pid
|
||||
*/
|
||||
pid_t rpmsqFork(rpmsq sq)
|
||||
/*@globals fileSystem, internalState @*/
|
||||
/*@modifies sq, fileSystem, internalState @*/;
|
||||
pid_t rpmsqFork(rpmsq sq);
|
||||
|
||||
/**
|
||||
* Wait for child process to be reaped.
|
||||
* @param sq scriptlet queue element
|
||||
* @return reaped child pid
|
||||
*/
|
||||
pid_t rpmsqWait(rpmsq sq)
|
||||
/*@globals fileSystem, internalState @*/
|
||||
/*@modifies sq, fileSystem, internalState @*/;
|
||||
pid_t rpmsqWait(rpmsq sq);
|
||||
|
||||
/**
|
||||
* Call a function in a thread.
|
||||
|
@ -130,34 +103,26 @@ pid_t rpmsqWait(rpmsq sq)
|
|||
* @param arg function argument
|
||||
* @return thread pointer (NULL on error)
|
||||
*/
|
||||
void * rpmsqThread(void * (*start) (void * arg), void * arg)
|
||||
/*@globals internalState @*/
|
||||
/*@modifies internalState @*/;
|
||||
void * rpmsqThread(void * (*start) (void * arg), void * arg);
|
||||
|
||||
/**
|
||||
* Wait for thread to terminate.
|
||||
* @param thread thread
|
||||
* @return 0 on success
|
||||
*/
|
||||
int rpmsqJoin(/*@null@*/ void * thread)
|
||||
/*@globals internalState @*/
|
||||
/*@modifies internalState @*/;
|
||||
int rpmsqJoin(void * thread);
|
||||
|
||||
/**
|
||||
* Compare thread with current thread.
|
||||
* @param thread thread
|
||||
* @return 0 if not equal
|
||||
*/
|
||||
int rpmsqThreadEqual(/*@null@*/ void * thread)
|
||||
/*@globals internalState @*/
|
||||
/*@modifies internalState @*/;
|
||||
int rpmsqThreadEqual(void * thread);
|
||||
|
||||
/**
|
||||
* Execute a command, returning its status.
|
||||
*/
|
||||
int rpmsqExecve (const char ** argv)
|
||||
/*@globals fileSystem, internalState @*/
|
||||
/*@modifies fileSystem, internalState @*/;
|
||||
int rpmsqExecve (const char ** argv);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -6,16 +6,12 @@
|
|||
#include <rpmsw.h>
|
||||
#include "debug.h"
|
||||
|
||||
/*@unchecked@*/
|
||||
static rpmtime_t rpmsw_overhead = 0;
|
||||
|
||||
/*@unchecked@*/
|
||||
static rpmtime_t rpmsw_cycles = 1;
|
||||
|
||||
/*@unchecked@*/
|
||||
static int rpmsw_type = 0;
|
||||
|
||||
/*@unchecked@*/
|
||||
static int rpmsw_initialized = 0;
|
||||
|
||||
#if defined(__i386__)
|
||||
|
@ -95,9 +91,8 @@ rpmsw rpmswNow(rpmsw sw)
|
|||
* @return difference in milli-seconds
|
||||
*/
|
||||
static inline
|
||||
rpmtime_t tvsub(/*@null@*/ const struct timeval * etv,
|
||||
/*@null@*/ const struct timeval * btv)
|
||||
/*@*/
|
||||
rpmtime_t tvsub(const struct timeval * etv,
|
||||
const struct timeval * btv)
|
||||
{
|
||||
time_t secs, usecs;
|
||||
if (etv == NULL || btv == NULL) return 0;
|
||||
|
@ -134,8 +129,6 @@ rpmtime_t rpmswDiff(rpmsw end, rpmsw begin)
|
|||
|
||||
#if defined(HP_TIMING_NOW)
|
||||
static rpmtime_t rpmswCalibrate(void)
|
||||
/*@globals internalState @*/
|
||||
/*@modifies internalState @*/
|
||||
{
|
||||
struct rpmsw_s begin, end;
|
||||
rpmtime_t ticks;
|
||||
|
@ -143,9 +136,7 @@ static rpmtime_t rpmswCalibrate(void)
|
|||
int rc;
|
||||
int i;
|
||||
|
||||
/*@-uniondef@*/
|
||||
(void) rpmswNow(&begin);
|
||||
/*@=uniondef@*/
|
||||
req.tv_sec = 0;
|
||||
req.tv_nsec = 20 * 1000 * 1000;
|
||||
for (i = 0; i < 100; i++) {
|
||||
|
@ -156,9 +147,7 @@ static rpmtime_t rpmswCalibrate(void)
|
|||
break;
|
||||
req = rem; /* structure assignment */
|
||||
}
|
||||
/*@-uniondef@*/
|
||||
ticks = rpmswDiff(rpmswNow(&end), &begin);
|
||||
/*@=uniondef@*/
|
||||
|
||||
return ticks;
|
||||
}
|
||||
|
@ -194,9 +183,7 @@ rpmtime_t rpmswInit(void)
|
|||
|
||||
/* Start wall clock. */
|
||||
rpmsw_type = 0;
|
||||
/*@-uniondef@*/
|
||||
(void) rpmswNow(&begin);
|
||||
/*@=uniondef@*/
|
||||
|
||||
/* Get no. of cycles while doing nanosleep. */
|
||||
rpmsw_type = 1;
|
||||
|
@ -207,9 +194,7 @@ rpmtime_t rpmswInit(void)
|
|||
|
||||
/* Compute wall clock delta in usecs. */
|
||||
rpmsw_type = 0;
|
||||
/*@-uniondef@*/
|
||||
sum_usecs += rpmswDiff(rpmswNow(&end), &begin);
|
||||
/*@=uniondef@*/
|
||||
rpmsw_type = 1;
|
||||
|
||||
/* Compute cycles/usec */
|
||||
|
@ -219,10 +204,8 @@ rpmtime_t rpmswInit(void)
|
|||
#endif
|
||||
|
||||
/* Calculate timing overhead in usecs. */
|
||||
/*@-uniondef@*/
|
||||
(void) rpmswNow(&begin);
|
||||
sum_overhead += rpmswDiff(rpmswNow(&end), &begin);
|
||||
/*@=uniondef@*/
|
||||
|
||||
rpmsw_overhead = sum_overhead/(i+1);
|
||||
|
||||
|
@ -241,9 +224,7 @@ int rpmswEnter(rpmop op, ssize_t rc)
|
|||
op->bytes = 0;
|
||||
op->usecs = 0;
|
||||
}
|
||||
/*@-uniondef@*/
|
||||
(void) rpmswNow(&op->begin);
|
||||
/*@=uniondef@*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -254,9 +235,7 @@ rpmtime_t rpmswExit(rpmop op, ssize_t rc)
|
|||
if (op == NULL)
|
||||
return 0;
|
||||
|
||||
/*@-uniondef@*/
|
||||
op->usecs += rpmswDiff(rpmswNow(&end), &op->begin);
|
||||
/*@=uniondef@*/
|
||||
if (rc > 0)
|
||||
op->bytes += rc;
|
||||
op->begin = end; /* structure assignment */
|
||||
|
|
|
@ -45,31 +45,19 @@ extern "C" {
|
|||
* @param *sw time stamp
|
||||
* @return 0 on success
|
||||
*/
|
||||
/*@-exportlocal@*/
|
||||
/*@null@*/
|
||||
rpmsw rpmswNow(/*@returned@*/ rpmsw sw)
|
||||
/*@globals internalState @*/
|
||||
/*@modifies sw, internalState @*/;
|
||||
/*@=exportlocal@*/
|
||||
rpmsw rpmswNow(rpmsw sw);
|
||||
|
||||
/** Return benchmark time stamp difference.
|
||||
* @param *end end time stamp
|
||||
* @param *begin begin time stamp
|
||||
* @return difference in micro-seconds
|
||||
*/
|
||||
/*@-exportlocal@*/
|
||||
rpmtime_t rpmswDiff(/*@null@*/ rpmsw end, /*@null@*/ rpmsw begin)
|
||||
/*@*/;
|
||||
/*@=exportlocal@*/
|
||||
rpmtime_t rpmswDiff(rpmsw end, rpmsw begin);
|
||||
|
||||
/** Return benchmark time stamp overhead.
|
||||
* @return overhead in micro-seconds
|
||||
*/
|
||||
/*@-exportlocal@*/
|
||||
rpmtime_t rpmswInit(void)
|
||||
/*@globals internalState @*/
|
||||
/*@modifies internalState @*/;
|
||||
/*@=exportlocal@*/
|
||||
rpmtime_t rpmswInit(void);
|
||||
|
||||
/** \ingroup rpmio
|
||||
* Enter timed operation.
|
||||
|
@ -77,9 +65,7 @@ rpmtime_t rpmswInit(void)
|
|||
* @param rc -1 clears usec counter
|
||||
* @return 0 always
|
||||
*/
|
||||
int rpmswEnter(/*@null@*/ rpmop op, ssize_t rc)
|
||||
/*@globals internalState @*/
|
||||
/*@modifies *op, internalState @*/;
|
||||
int rpmswEnter(rpmop op, ssize_t rc);
|
||||
|
||||
/** \ingroup rpmio
|
||||
* Exit timed operation.
|
||||
|
@ -87,9 +73,7 @@ int rpmswEnter(/*@null@*/ rpmop op, ssize_t rc)
|
|||
* @param rc per-operation data (e.g. bytes transferred)
|
||||
* @return cumulative usecs for operation
|
||||
*/
|
||||
rpmtime_t rpmswExit(/*@null@*/ rpmop op, ssize_t rc)
|
||||
/*@globals internalState @*/
|
||||
/*@modifies op, internalState @*/;
|
||||
rpmtime_t rpmswExit(rpmop op, ssize_t rc);
|
||||
|
||||
/** \ingroup rpmio
|
||||
* Sum statistic counters.
|
||||
|
@ -97,8 +81,7 @@ rpmtime_t rpmswExit(/*@null@*/ rpmop op, ssize_t rc)
|
|||
* @param from operation statistics
|
||||
* @return cumulative usecs for operation
|
||||
*/
|
||||
rpmtime_t rpmswAdd(/*@null@*/ rpmop to, /*@null@*/ rpmop from)
|
||||
/*@modifies to @*/;
|
||||
rpmtime_t rpmswAdd(rpmop to, rpmop from);
|
||||
|
||||
/** \ingroup rpmio
|
||||
* Subtract statistic counters.
|
||||
|
@ -106,8 +89,7 @@ rpmtime_t rpmswAdd(/*@null@*/ rpmop to, /*@null@*/ rpmop from)
|
|||
* @param from operation statistics
|
||||
* @return cumulative usecs for operation
|
||||
*/
|
||||
rpmtime_t rpmswSub(rpmop to, rpmop from)
|
||||
/*@modifies to @*/;
|
||||
rpmtime_t rpmswSub(rpmop to, rpmop from);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -23,28 +23,20 @@ typedef enum urltype_e {
|
|||
#define URLMAGIC 0xd00b1ed0
|
||||
#define URLSANE(u) assert(u && u->magic == URLMAGIC)
|
||||
|
||||
typedef /*@abstract@*/ /*@refcounted@*/ struct urlinfo_s * urlinfo;
|
||||
typedef struct urlinfo_s * urlinfo;
|
||||
|
||||
/**
|
||||
* URL control structure.
|
||||
*/
|
||||
struct urlinfo_s {
|
||||
/*@refs@*/ int nrefs; /*!< no. of references */
|
||||
/*@owned@*/ /*@relnull@*/
|
||||
int nrefs; /*!< no. of references */
|
||||
const char * url; /*!< copy of original url */
|
||||
/*@owned@*/ /*@relnull@*/
|
||||
const char * scheme; /*!< URI scheme. */
|
||||
/*@owned@*/ /*@null@*/
|
||||
const char * user; /*!< URI user. */
|
||||
/*@owned@*/ /*@null@*/
|
||||
const char * password; /*!< URI password. */
|
||||
/*@owned@*/ /*@relnull@*/
|
||||
const char * host; /*!< URI host. */
|
||||
/*@owned@*/ /*@null@*/
|
||||
const char * portstr; /*!< URI port string. */
|
||||
/*@owned@*/ /*@null@*/
|
||||
const char * proxyu; /*!< FTP: proxy user */
|
||||
/*@owned@*/ /*@null@*/
|
||||
const char * proxyh; /*!< FTP/HTTP: proxy host */
|
||||
int proxyp; /*!< FTP/HTTP: proxy port */
|
||||
int port; /*!< URI port. */
|
||||
|
@ -52,11 +44,8 @@ struct urlinfo_s {
|
|||
FD_t ctrl; /*!< control channel */
|
||||
FD_t data; /*!< per-xfer data channel */
|
||||
|
||||
/*@relnull@*/
|
||||
void * capabilities; /*!< neon: ne_server_capabilities ptr */
|
||||
/*@relnull@*/
|
||||
void * lockstore; /*!< neon: ne_lock_store ptr */
|
||||
/*@relnull@*/
|
||||
void * sess; /*!< neon: ne_session ptr */
|
||||
off_t current; /*!< neon: current body offset. */
|
||||
off_t total; /*!< neon: total body length. */
|
||||
|
@ -71,7 +60,6 @@ typedef enum {
|
|||
#endif
|
||||
|
||||
int bufAlloced; /*!< sizeof I/O buffer */
|
||||
/*@owned@*/
|
||||
char * buf; /*!< I/O buffer */
|
||||
int openError; /*!< Type of open failure */
|
||||
int httpVersion;
|
||||
|
@ -83,18 +71,13 @@ typedef enum {
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*@unchecked@*/
|
||||
extern int _url_count; /*!< No. of cached URL's. */
|
||||
|
||||
/*@unchecked@*/
|
||||
/*@only@*/ /*@null@*/
|
||||
extern urlinfo * _url_cache; /*!< URL cache. */
|
||||
|
||||
/*@unchecked@*/
|
||||
extern int _url_iobuf_size; /*!< Initial size of URL I/O buffer. */
|
||||
#define RPMURL_IOBUF_SIZE 4096
|
||||
|
||||
/*@unchecked@*/
|
||||
extern int _url_debug; /*!< URL debugging? */
|
||||
#define RPMURL_DEBUG_IO 0x40000000
|
||||
#define RPMURL_DEBUG_REFS 0x20000000
|
||||
|
@ -105,10 +88,10 @@ extern int _url_debug; /*!< URL debugging? */
|
|||
* @param msg debugging identifier (unused)
|
||||
* @return new instance
|
||||
*/
|
||||
/*@unused@*/ urlinfo urlNew(const char * msg) /*@*/;
|
||||
urlinfo urlNew(const char * msg) ;
|
||||
|
||||
/** @todo Remove debugging entry from the ABI. */
|
||||
urlinfo XurlNew(const char * msg, const char * file, unsigned line) /*@*/;
|
||||
urlinfo XurlNew(const char * msg, const char * file, unsigned line) ;
|
||||
#define urlNew(_msg) XurlNew(_msg, __FILE__, __LINE__)
|
||||
|
||||
/**
|
||||
|
@ -117,12 +100,10 @@ urlinfo XurlNew(const char * msg, const char * file, unsigned line) /*@*/;
|
|||
* @param msg debugging identifier (unused)
|
||||
* @return referenced instance
|
||||
*/
|
||||
/*@unused@*/ urlinfo urlLink(urlinfo u, const char * msg)
|
||||
/*@modifies u @*/;
|
||||
urlinfo urlLink(urlinfo u, const char * msg);
|
||||
|
||||
/** @todo Remove debugging entry from the ABI. */
|
||||
urlinfo XurlLink(urlinfo u, const char * msg, const char * file, unsigned line)
|
||||
/*@modifies u @*/;
|
||||
urlinfo XurlLink(urlinfo u, const char * msg, const char * file, unsigned line);
|
||||
#define urlLink(_u, _msg) XurlLink(_u, _msg, __FILE__, __LINE__)
|
||||
|
||||
/**
|
||||
|
@ -131,31 +112,24 @@ urlinfo XurlLink(urlinfo u, const char * msg, const char * file, unsigned line)
|
|||
* @param msg debugging identifier (unused)
|
||||
* @return dereferenced instance (NULL if freed)
|
||||
*/
|
||||
/*@unused@*/ urlinfo urlFree( /*@killref@*/ urlinfo u, const char * msg)
|
||||
/*@globals fileSystem, internalState @*/
|
||||
/*@modifies u, fileSystem, internalState @*/;
|
||||
urlinfo urlFree( urlinfo u, const char * msg);
|
||||
|
||||
/** @todo Remove debugging entry from the ABI. */
|
||||
urlinfo XurlFree( /*@killref@*/ urlinfo u, const char * msg,
|
||||
const char * file, unsigned line)
|
||||
/*@globals fileSystem, internalState @*/
|
||||
/*@modifies u, fileSystem, internalState @*/;
|
||||
urlinfo XurlFree( urlinfo u, const char * msg,
|
||||
const char * file, unsigned line);
|
||||
#define urlFree(_u, _msg) XurlFree(_u, _msg, __FILE__, __LINE__)
|
||||
|
||||
/**
|
||||
* Free cached URL control structures.
|
||||
*/
|
||||
void urlFreeCache(void)
|
||||
/*@globals _url_cache, _url_count, fileSystem, internalState @*/
|
||||
/*@modifies _url_cache, _url_count, fileSystem, internalState @*/;
|
||||
void urlFreeCache(void);
|
||||
|
||||
/**
|
||||
* Return type of URL.
|
||||
* @param url url string
|
||||
* @return type of url
|
||||
*/
|
||||
urltype urlIsURL(const char * url)
|
||||
/*@*/;
|
||||
urltype urlIsURL(const char * url);
|
||||
|
||||
/**
|
||||
* Return path component of URL.
|
||||
|
@ -163,11 +137,7 @@ urltype urlIsURL(const char * url)
|
|||
* @retval pathp pointer to path component of url
|
||||
* @return type of url
|
||||
*/
|
||||
/*@-incondefs@*/
|
||||
urltype urlPath(const char * url, /*@out@*/ const char ** pathp)
|
||||
/*@ensures maxSet(*pathp) == 0 /\ maxRead(*pathp) == 0 @*/
|
||||
/*@modifies *pathp @*/;
|
||||
/*@=incondefs@*/
|
||||
urltype urlPath(const char * url, const char ** pathp);
|
||||
|
||||
/**
|
||||
* Parse URL string into a control structure.
|
||||
|
@ -175,9 +145,7 @@ urltype urlPath(const char * url, /*@out@*/ const char ** pathp)
|
|||
* @retval uret address of new control instance pointer
|
||||
* @return 0 on success, -1 on error
|
||||
*/
|
||||
int urlSplit(const char * url, /*@out@*/ urlinfo * uret)
|
||||
/*@globals h_errno, internalState @*/
|
||||
/*@modifies *uret, internalState @*/;
|
||||
int urlSplit(const char * url, urlinfo * uret);
|
||||
|
||||
/**
|
||||
* Copy data from URL to local file.
|
||||
|
@ -185,9 +153,7 @@ int urlSplit(const char * url, /*@out@*/ urlinfo * uret)
|
|||
* @param dest file name of destination
|
||||
* @return 0 on success, otherwise FTPERR_* code
|
||||
*/
|
||||
int urlGetFile(const char * url, /*@null@*/ const char * dest)
|
||||
/*@globals h_errno, fileSystem, internalState @*/
|
||||
/*@modifies fileSystem, internalState @*/;
|
||||
int urlGetFile(const char * url, const char * dest);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -17,10 +17,8 @@ int xstrcasecmp(const char * s1, const char * s2)
|
|||
|
||||
do
|
||||
{
|
||||
/*@-boundsread@*/
|
||||
c1 = xtolower (*p1++);
|
||||
c2 = xtolower (*p2++);
|
||||
/*@=boundsread@*/
|
||||
if (c1 == '\0')
|
||||
break;
|
||||
}
|
||||
|
@ -40,10 +38,8 @@ int xstrncasecmp(const char *s1, const char *s2, size_t n)
|
|||
|
||||
do
|
||||
{
|
||||
/*@-boundsread@*/
|
||||
c1 = xtolower (*p1++);
|
||||
c2 = xtolower (*p2++);
|
||||
/*@=boundsread@*/
|
||||
if (c1 == '\0' || c1 != c2)
|
||||
break;
|
||||
} while (--n > 0);
|
||||
|
|
10
rpmio/tax.c
10
rpmio/tax.c
|
@ -40,12 +40,10 @@ AjjDx3lJnQBXUDmxM484YXLXZjWFXCiY8GJt6whjf7/2c3rIoT3Z7PQpEvPmM\
|
|||
* @param nbytes no. of bytes
|
||||
* @return target buffer
|
||||
*/
|
||||
/*@unused@*/ static inline
|
||||
char * pgpHexCvt(/*@returned@*/ char *t, const byte *s, int nbytes)
|
||||
/*@modifies *t @*/
|
||||
static inline
|
||||
char * pgpHexCvt(char *t, const byte *s, int nbytes)
|
||||
{
|
||||
static char hex[] = "0123456789abcdef";
|
||||
/*@-boundswrite@*/
|
||||
while (nbytes-- > 0) {
|
||||
unsigned int i;
|
||||
i = *s++;
|
||||
|
@ -53,7 +51,6 @@ char * pgpHexCvt(/*@returned@*/ char *t, const byte *s, int nbytes)
|
|||
*t++ = hex[ (i ) & 0xf ];
|
||||
}
|
||||
*t = '\0';
|
||||
/*@=boundswrite@*/
|
||||
return t;
|
||||
}
|
||||
|
||||
|
@ -64,9 +61,8 @@ char * pgpHexCvt(/*@returned@*/ char *t, const byte *s, int nbytes)
|
|||
* @param plen no. of bytes
|
||||
* @return hex formatted string
|
||||
*/
|
||||
/*@unused@*/ static inline /*@observer@*/
|
||||
static inline
|
||||
char * pgpHexStr(const byte *p, unsigned int plen)
|
||||
/*@*/
|
||||
{
|
||||
static char prbuf[2048];
|
||||
char *t = prbuf;
|
||||
|
|
|
@ -60,9 +60,9 @@ main(int argc, const char *argv[])
|
|||
switch (rc) {
|
||||
case 'v':
|
||||
rpmIncreaseVerbosity();
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
default:
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ _dav_debug = -1;
|
|||
printDir(ftppath);
|
||||
printDir(httppath);
|
||||
|
||||
/*@i@*/ urlFreeCache();
|
||||
urlFreeCache();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
#include "debug.h"
|
||||
|
||||
/*@unchecked@*/
|
||||
static int _fts_debug = 0;
|
||||
|
||||
#if 0
|
||||
|
@ -153,9 +152,9 @@ main(int argc, const char *argv[])
|
|||
switch (rc) {
|
||||
case 'v':
|
||||
rpmIncreaseVerbosity();
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
default:
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -174,7 +173,7 @@ _dav_debug = 1;
|
|||
ftsWalk(httpspath);
|
||||
#endif
|
||||
|
||||
/*@i@*/ urlFreeCache();
|
||||
urlFreeCache();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -61,9 +61,9 @@ main(int argc, const char *argv[])
|
|||
switch (rc) {
|
||||
case 'v':
|
||||
rpmIncreaseVerbosity();
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
default:
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ _dav_debug = 1;
|
|||
readFile(httpspath);
|
||||
#endif
|
||||
|
||||
/*@i@*/ urlFreeCache();
|
||||
urlFreeCache();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -75,9 +75,9 @@ main(int argc, const char *argv[])
|
|||
switch (rc) {
|
||||
case 'v':
|
||||
rpmIncreaseVerbosity();
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
default:
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -116,9 +116,9 @@ main(int argc, const char *argv[])
|
|||
switch (rc) {
|
||||
case 'v':
|
||||
rpmIncreaseVerbosity();
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
default:
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -129,7 +129,7 @@ main(int argc, const char *argv[])
|
|||
|
||||
readKeys(hkppath);
|
||||
|
||||
/*@i@*/ urlFreeCache();
|
||||
urlFreeCache();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -104,10 +104,8 @@ fprintf(stderr, " D: "), mpfprintln(stderr, ysize, D);
|
|||
|
||||
if (result) {
|
||||
mpsetx(b->size, result, ysize, A);
|
||||
/*@-usedef@*/
|
||||
if (*A & 0x80000000)
|
||||
(void) mpneg(b->size, result);
|
||||
/*@=usedef@*/
|
||||
while (--k > 0)
|
||||
mpadd(b->size, result, result);
|
||||
}
|
||||
|
@ -397,10 +395,8 @@ fprintf(stderr, " D: "), mpfprintln(stderr, ysize, D);
|
|||
if (result)
|
||||
{
|
||||
mpsetx(b->size, result, ysize, D);
|
||||
/*@-usedef@*/
|
||||
if (*D & 0x80000000)
|
||||
(void) mpadd(b->size, result, b->modl);
|
||||
/*@=usedef@*/
|
||||
}
|
||||
|
||||
fprintf(stderr, "=== EXIT: "), mpfprintln(stderr, b->size, result);
|
||||
|
@ -477,7 +473,7 @@ main(int argc, const char * argv[])
|
|||
while ((rc = poptGetNextOpt(optCon)) > 0) {
|
||||
switch (rc) {
|
||||
default:
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -121,9 +121,9 @@ main(int argc, const char *argv[])
|
|||
switch (rc) {
|
||||
case 'v':
|
||||
rpmIncreaseVerbosity();
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
default:
|
||||
/*@switchbreak@*/ break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -144,7 +144,7 @@ _dav_debug = -1;
|
|||
doFile(httpspath);
|
||||
#endif
|
||||
|
||||
/*@i@*/ urlFreeCache();
|
||||
urlFreeCache();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -35,8 +35,7 @@ main (int argc, const char *argv[])
|
|||
const char * fn;
|
||||
int rc, ec = 0;
|
||||
|
||||
while ((rc = poptGetNextOpt(optCon)) > 0)
|
||||
;
|
||||
while ((rc = poptGetNextOpt(optCon)) > 0);
|
||||
|
||||
if ((args = poptGetArgs(optCon)) != NULL)
|
||||
while ((fn = *args++) != NULL) {
|
||||
|
|
34
rpmio/ugid.c
34
rpmio/ugid.c
|
@ -15,7 +15,7 @@
|
|||
|
||||
int unameToUid(const char * thisUname, uid_t * uid)
|
||||
{
|
||||
/*@only@*/ static char * lastUname = NULL;
|
||||
static char * lastUname = NULL;
|
||||
static size_t lastUnameLen = 0;
|
||||
static size_t lastUnameAlloced;
|
||||
static uid_t lastUid;
|
||||
|
@ -26,9 +26,7 @@ int unameToUid(const char * thisUname, uid_t * uid)
|
|||
lastUnameLen = 0;
|
||||
return -1;
|
||||
} else if (strcmp(thisUname, "root") == 0) {
|
||||
/*@-boundswrite@*/
|
||||
*uid = 0;
|
||||
/*@=boundswrite@*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -40,15 +38,12 @@ int unameToUid(const char * thisUname, uid_t * uid)
|
|||
lastUnameAlloced = thisUnameLen + 10;
|
||||
lastUname = xrealloc(lastUname, lastUnameAlloced); /* XXX memory leak */
|
||||
}
|
||||
/*@-boundswrite@*/
|
||||
strcpy(lastUname, thisUname);
|
||||
/*@=boundswrite@*/
|
||||
|
||||
pwent = getpwnam(thisUname);
|
||||
if (pwent == NULL) {
|
||||
/*@-internalglobs@*/ /* FIX: shrug */
|
||||
/* FIX: shrug */
|
||||
endpwent();
|
||||
/*@=internalglobs@*/
|
||||
pwent = getpwnam(thisUname);
|
||||
if (pwent == NULL) return -1;
|
||||
}
|
||||
|
@ -56,16 +51,14 @@ int unameToUid(const char * thisUname, uid_t * uid)
|
|||
lastUid = pwent->pw_uid;
|
||||
}
|
||||
|
||||
/*@-boundswrite@*/
|
||||
*uid = lastUid;
|
||||
/*@=boundswrite@*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int gnameToGid(const char * thisGname, gid_t * gid)
|
||||
{
|
||||
/*@only@*/ static char * lastGname = NULL;
|
||||
static char * lastGname = NULL;
|
||||
static size_t lastGnameLen = 0;
|
||||
static size_t lastGnameAlloced;
|
||||
static gid_t lastGid;
|
||||
|
@ -76,9 +69,7 @@ int gnameToGid(const char * thisGname, gid_t * gid)
|
|||
lastGnameLen = 0;
|
||||
return -1;
|
||||
} else if (strcmp(thisGname, "root") == 0) {
|
||||
/*@-boundswrite@*/
|
||||
*gid = 0;
|
||||
/*@=boundswrite@*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -90,28 +81,21 @@ int gnameToGid(const char * thisGname, gid_t * gid)
|
|||
lastGnameAlloced = thisGnameLen + 10;
|
||||
lastGname = xrealloc(lastGname, lastGnameAlloced); /* XXX memory leak */
|
||||
}
|
||||
/*@-boundswrite@*/
|
||||
strcpy(lastGname, thisGname);
|
||||
/*@=boundswrite@*/
|
||||
|
||||
grent = getgrnam(thisGname);
|
||||
if (grent == NULL) {
|
||||
/*@-internalglobs@*/ /* FIX: shrug */
|
||||
/* FIX: shrug */
|
||||
endgrent();
|
||||
/*@=internalglobs@*/
|
||||
grent = getgrnam(thisGname);
|
||||
if (grent == NULL) {
|
||||
/* XXX The filesystem package needs group/lock w/o getgrnam. */
|
||||
if (strcmp(thisGname, "lock") == 0) {
|
||||
/*@-boundswrite@*/
|
||||
*gid = lastGid = 54;
|
||||
/*@=boundswrite@*/
|
||||
return 0;
|
||||
} else
|
||||
if (strcmp(thisGname, "mail") == 0) {
|
||||
/*@-boundswrite@*/
|
||||
*gid = lastGid = 12;
|
||||
/*@=boundswrite@*/
|
||||
return 0;
|
||||
} else
|
||||
return -1;
|
||||
|
@ -120,9 +104,7 @@ int gnameToGid(const char * thisGname, gid_t * gid)
|
|||
lastGid = grent->gr_gid;
|
||||
}
|
||||
|
||||
/*@-boundswrite@*/
|
||||
*gid = lastGid;
|
||||
/*@=boundswrite@*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -130,7 +112,7 @@ int gnameToGid(const char * thisGname, gid_t * gid)
|
|||
char * uidToUname(uid_t uid)
|
||||
{
|
||||
static uid_t lastUid = (uid_t) -1;
|
||||
/*@only@*/ static char * lastUname = NULL;
|
||||
static char * lastUname = NULL;
|
||||
static size_t lastUnameLen = 0;
|
||||
|
||||
if (uid == (uid_t) -1) {
|
||||
|
@ -152,9 +134,7 @@ char * uidToUname(uid_t uid)
|
|||
lastUnameLen = len + 20;
|
||||
lastUname = xrealloc(lastUname, lastUnameLen);
|
||||
}
|
||||
/*@-boundswrite@*/
|
||||
strcpy(lastUname, pwent->pw_name);
|
||||
/*@=boundswrite@*/
|
||||
|
||||
return lastUname;
|
||||
}
|
||||
|
@ -163,7 +143,7 @@ char * uidToUname(uid_t uid)
|
|||
char * gidToGname(gid_t gid)
|
||||
{
|
||||
static gid_t lastGid = (gid_t) -1;
|
||||
/*@only@*/ static char * lastGname = NULL;
|
||||
static char * lastGname = NULL;
|
||||
static size_t lastGnameLen = 0;
|
||||
|
||||
if (gid == (gid_t) -1) {
|
||||
|
@ -185,9 +165,7 @@ char * gidToGname(gid_t gid)
|
|||
lastGnameLen = len + 20;
|
||||
lastGname = xrealloc(lastGname, lastGnameLen);
|
||||
}
|
||||
/*@-boundswrite@*/
|
||||
strcpy(lastGname, grent->gr_name);
|
||||
/*@=boundswrite@*/
|
||||
|
||||
return lastGname;
|
||||
}
|
||||
|
|
13
rpmio/ugid.h
13
rpmio/ugid.h
|
@ -13,19 +13,14 @@ extern "C" {
|
|||
* These may be called w/ a NULL argument to flush the cache -- they return
|
||||
* -1 if the user can't be found.
|
||||
*/
|
||||
int unameToUid(const char * thisUname, /*@out@*/ uid_t * uid)
|
||||
/*@modifies *uid @*/;
|
||||
int gnameToGid(const char * thisGname, /*@out@*/ gid_t * gid)
|
||||
/*@modifies *gid @*/;
|
||||
int unameToUid(const char * thisUname, uid_t * uid);
|
||||
int gnameToGid(const char * thisGname, gid_t * gid);
|
||||
|
||||
/*
|
||||
* Call w/ -1 to flush the cache, returns NULL if the user can't be found.
|
||||
*/
|
||||
/*@observer@*/ /*@null@*/ char * uidToUname(uid_t uid)
|
||||
/*@*/;
|
||||
/*@unused@*/
|
||||
/*@observer@*/ /*@null@*/ char * gidToGname(gid_t gid)
|
||||
/*@*/;
|
||||
char * uidToUname(uid_t uid);
|
||||
char * gidToGname(gid_t gid);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
67
rpmio/url.c
67
rpmio/url.c
|
@ -13,7 +13,6 @@
|
|||
#include "debug.h"
|
||||
|
||||
/*@access FD_t@*/ /* XXX compared with NULL */
|
||||
/*@access urlinfo@*/
|
||||
|
||||
#ifndef IPPORT_FTP
|
||||
#define IPPORT_FTP 21
|
||||
|
@ -30,12 +29,10 @@
|
|||
|
||||
/**
|
||||
*/
|
||||
/*@unchecked@*/
|
||||
int _url_iobuf_size = RPMURL_IOBUF_SIZE;
|
||||
|
||||
/**
|
||||
*/
|
||||
/*@unchecked@*/
|
||||
int _url_debug = 0;
|
||||
|
||||
#define URLDBG(_f, _m, _x) if ((_url_debug | (_f)) & (_m)) fprintf _x
|
||||
|
@ -45,13 +42,10 @@ int _url_debug = 0;
|
|||
|
||||
/**
|
||||
*/
|
||||
/*@unchecked@*/
|
||||
/*@only@*/ /*@null@*/
|
||||
urlinfo *_url_cache = NULL;
|
||||
|
||||
/**
|
||||
*/
|
||||
/*@unchecked@*/
|
||||
int _url_count = 0;
|
||||
|
||||
/**
|
||||
|
@ -59,8 +53,8 @@ int _url_count = 0;
|
|||
* @param p memory to free
|
||||
* @retval NULL always
|
||||
*/
|
||||
/*@unused@*/ static inline /*@null@*/ void *
|
||||
_free(/*@only@*/ /*@null@*/ const void * p) /*@modifies p@*/
|
||||
static inline void *
|
||||
_free(const void * p)
|
||||
{
|
||||
if (p != NULL) free((void *)p);
|
||||
return NULL;
|
||||
|
@ -70,10 +64,8 @@ urlinfo XurlLink(urlinfo u, const char *msg, const char *file, unsigned line)
|
|||
{
|
||||
URLSANE(u);
|
||||
u->nrefs++;
|
||||
/*@-modfilesys@*/
|
||||
URLDBGREFS(0, (stderr, "--> url %p ++ %d %s at %s:%u\n", u, u->nrefs, msg, file, line));
|
||||
/*@=modfilesys@*/
|
||||
/*@-refcounttrans@*/ return u; /*@=refcounttrans@*/
|
||||
return u;
|
||||
}
|
||||
|
||||
urlinfo XurlNew(const char *msg, const char *file, unsigned line)
|
||||
|
@ -103,28 +95,24 @@ urlinfo XurlFree(urlinfo u, const char *msg, const char *file, unsigned line)
|
|||
URLSANE(u);
|
||||
URLDBGREFS(0, (stderr, "--> url %p -- %d %s at %s:%u\n", u, u->nrefs, msg, file, line));
|
||||
if (--u->nrefs > 0)
|
||||
/*@-refcounttrans -retalias@*/ return u; /*@=refcounttrans =retalias@*/
|
||||
return u;
|
||||
if (u->ctrl) {
|
||||
#ifndef NOTYET
|
||||
void * fp = fdGetFp(u->ctrl);
|
||||
/*@-branchstate@*/
|
||||
if (fp) {
|
||||
fdPush(u->ctrl, fpio, fp, -1); /* Push fpio onto stack */
|
||||
(void) Fclose(u->ctrl);
|
||||
} else if (fdio->_fileno(u->ctrl) >= 0)
|
||||
xx = fdio->close(u->ctrl);
|
||||
/*@=branchstate@*/
|
||||
#else
|
||||
(void) Fclose(u->ctrl);
|
||||
#endif
|
||||
|
||||
u->ctrl = fdio->_fdderef(u->ctrl, "persist ctrl (urlFree)", file, line);
|
||||
/*@-usereleased@*/
|
||||
if (u->ctrl)
|
||||
fprintf(stderr, _("warning: u %p ctrl %p nrefs != 0 (%s %s)\n"),
|
||||
u, u->ctrl, (u->host ? u->host : ""),
|
||||
(u->scheme ? u->scheme : ""));
|
||||
/*@=usereleased@*/
|
||||
}
|
||||
if (u->data) {
|
||||
#ifndef NOTYET
|
||||
|
@ -139,12 +127,10 @@ URLDBGREFS(0, (stderr, "--> url %p -- %d %s at %s:%u\n", u, u->nrefs, msg, file,
|
|||
#endif
|
||||
|
||||
u->data = fdio->_fdderef(u->data, "persist data (urlFree)", file, line);
|
||||
/*@-usereleased@*/
|
||||
if (u->data)
|
||||
fprintf(stderr, _("warning: u %p data %p nrefs != 0 (%s %s)\n"),
|
||||
u, u->data, (u->host ? u->host : ""),
|
||||
(u->scheme ? u->scheme : ""));
|
||||
/*@=usereleased@*/
|
||||
}
|
||||
if (u->sess != NULL) {
|
||||
#ifdef WITH_NEON
|
||||
|
@ -163,11 +149,10 @@ URLDBGREFS(0, (stderr, "--> url %p -- %d %s at %s:%u\n", u, u->nrefs, msg, file,
|
|||
u->proxyu = _free((void *)u->proxyu);
|
||||
u->proxyh = _free((void *)u->proxyh);
|
||||
|
||||
/*@-refcounttrans@*/ u = _free(u); /*@-refcounttrans@*/
|
||||
u = _free(u);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*@-boundswrite@*/
|
||||
void urlFreeCache(void)
|
||||
{
|
||||
if (_url_cache) {
|
||||
|
@ -186,10 +171,8 @@ void urlFreeCache(void)
|
|||
_url_cache = _free(_url_cache);
|
||||
_url_count = 0;
|
||||
}
|
||||
/*@=boundswrite@*/
|
||||
|
||||
static int urlStrcmp(/*@null@*/ const char * str1, /*@null@*/ const char * str2)
|
||||
/*@*/
|
||||
static int urlStrcmp(const char * str1, const char * str2)
|
||||
{
|
||||
if (str1)
|
||||
if (str2)
|
||||
|
@ -199,11 +182,7 @@ static int urlStrcmp(/*@null@*/ const char * str1, /*@null@*/ const char * str2)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*@-boundswrite@*/
|
||||
/*@-mods@*/
|
||||
static void urlFind(/*@null@*/ /*@in@*/ /*@out@*/ urlinfo * uret, int mustAsk)
|
||||
/*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
|
||||
/*@modifies *uret, rpmGlobalMacroContext, fileSystem, internalState @*/
|
||||
static void urlFind(urlinfo * uret, int mustAsk)
|
||||
{
|
||||
urlinfo u;
|
||||
int ucx;
|
||||
|
@ -257,9 +236,7 @@ static void urlFind(/*@null@*/ /*@in@*/ /*@out@*/ urlinfo * uret, int mustAsk)
|
|||
if (_url_cache) /* XXX always true */
|
||||
u = urlLink(_url_cache[ucx], "_url_cache");
|
||||
*uret = u;
|
||||
/*@-usereleased@*/
|
||||
u = urlFree(u, "_url_cache (urlFind)");
|
||||
/*@=usereleased@*/
|
||||
|
||||
/* Zap proxy host and port in case they have been reset */
|
||||
u->proxyp = -1;
|
||||
|
@ -275,9 +252,7 @@ static void urlFind(/*@null@*/ /*@in@*/ /*@out@*/ urlinfo * uret, int mustAsk)
|
|||
prompt = alloca(strlen(host) + strlen(user) + 256);
|
||||
sprintf(prompt, _("Password for %s@%s: "), user, host);
|
||||
u->password = _free(u->password);
|
||||
/*@-dependenttrans -moduncon @*/
|
||||
u->password = /*@-unrecog@*/ getpass(prompt) /*@=unrecog@*/;
|
||||
/*@=dependenttrans =moduncon @*/
|
||||
u->password = getpass(prompt);
|
||||
if (u->password)
|
||||
u->password = xstrdup(u->password);
|
||||
}
|
||||
|
@ -285,7 +260,6 @@ static void urlFind(/*@null@*/ /*@in@*/ /*@out@*/ urlinfo * uret, int mustAsk)
|
|||
if (u->proxyh == NULL) {
|
||||
const char *proxy = rpmExpand("%{_ftpproxy}", NULL);
|
||||
if (proxy && *proxy != '%') {
|
||||
/*@observer@*/
|
||||
const char * host = (u->host ? u->host : "");
|
||||
const char *uu = (u->user ? u->user : "anonymous");
|
||||
char *nu = xmalloc(strlen(uu) + sizeof("@") + strlen(host));
|
||||
|
@ -341,14 +315,10 @@ static void urlFind(/*@null@*/ /*@in@*/ /*@out@*/ urlinfo * uret, int mustAsk)
|
|||
|
||||
return;
|
||||
}
|
||||
/*@=mods@*/
|
||||
/*@=boundswrite@*/
|
||||
|
||||
/**
|
||||
*/
|
||||
/*@observer@*/ /*@unchecked@*/
|
||||
static struct urlstring {
|
||||
/*@observer@*/ /*@null@*/
|
||||
const char * leadin;
|
||||
urltype ret;
|
||||
} urlstrings[] = {
|
||||
|
@ -365,7 +335,6 @@ urltype urlIsURL(const char * url)
|
|||
{
|
||||
struct urlstring *us;
|
||||
|
||||
/*@-boundsread@*/
|
||||
if (url && *url) {
|
||||
for (us = urlstrings; us->leadin != NULL; us++) {
|
||||
if (strncmp(url, us->leadin, strlen(us->leadin)))
|
||||
|
@ -373,12 +342,10 @@ urltype urlIsURL(const char * url)
|
|||
return us->ret;
|
||||
}
|
||||
}
|
||||
/*@=boundsread@*/
|
||||
|
||||
return URL_IS_UNKNOWN;
|
||||
}
|
||||
|
||||
/*@-boundswrite@*/
|
||||
/* Return path portion of url (or pointer to NUL if url == NULL) */
|
||||
urltype urlPath(const char * url, const char ** pathp)
|
||||
{
|
||||
|
@ -387,7 +354,6 @@ urltype urlPath(const char * url, const char ** pathp)
|
|||
|
||||
path = url;
|
||||
urltype = urlIsURL(url);
|
||||
/*@-branchstate@*/
|
||||
switch (urltype) {
|
||||
case URL_IS_FTP:
|
||||
url += sizeof("ftp://") - 1;
|
||||
|
@ -421,14 +387,10 @@ urltype urlPath(const char * url, const char ** pathp)
|
|||
path = "";
|
||||
break;
|
||||
}
|
||||
/*@=branchstate@*/
|
||||
if (pathp)
|
||||
/*@-observertrans@*/
|
||||
*pathp = path;
|
||||
/*@=observertrans@*/
|
||||
return urltype;
|
||||
}
|
||||
/*@=boundswrite@*/
|
||||
|
||||
/*
|
||||
* Split URL into components. The URL can look like
|
||||
|
@ -436,8 +398,6 @@ urltype urlPath(const char * url, const char ** pathp)
|
|||
* or as in RFC2732 for IPv6 address
|
||||
* service://user:password@[ip:v6:ad:dr:es:s]:port/path
|
||||
*/
|
||||
/*@-bounds@*/
|
||||
/*@-modfilesys@*/
|
||||
int urlSplit(const char * url, urlinfo *uret)
|
||||
{
|
||||
urlinfo u;
|
||||
|
@ -477,7 +437,6 @@ int urlSplit(const char * url, urlinfo *uret)
|
|||
/* Look for ...@host... */
|
||||
fe = f = s;
|
||||
while (*fe && *fe != '@') fe++;
|
||||
/*@-branchstate@*/
|
||||
if (*fe == '@') {
|
||||
s = fe + 1;
|
||||
*fe = '\0';
|
||||
|
@ -489,7 +448,6 @@ int urlSplit(const char * url, urlinfo *uret)
|
|||
}
|
||||
u->user = xstrdup(f);
|
||||
}
|
||||
/*@=branchstate@*/
|
||||
|
||||
/* Look for ...host:port or [v6addr]:port*/
|
||||
fe = f = s;
|
||||
|
@ -518,10 +476,8 @@ int urlSplit(const char * url, urlinfo *uret)
|
|||
|
||||
if (u->port < 0 && u->scheme != NULL) {
|
||||
struct servent *serv;
|
||||
/*@-multithreaded -moduncon @*/
|
||||
/* HACK hkp:// might lookup "pgpkeyserver" */
|
||||
serv = getservbyname(u->scheme, "tcp");
|
||||
/*@=multithreaded =moduncon @*/
|
||||
if (serv != NULL)
|
||||
u->port = ntohs(serv->s_port);
|
||||
else if (u->urltype == URL_IS_FTP)
|
||||
|
@ -537,14 +493,11 @@ int urlSplit(const char * url, urlinfo *uret)
|
|||
myurl = _free(myurl);
|
||||
if (uret) {
|
||||
*uret = u;
|
||||
/*@-globs -mods @*/ /* FIX: rpmGlobalMacroContext not in <rpmlib.h> */
|
||||
/* FIX: rpmGlobalMacroContext not in <rpmlib.h> */
|
||||
urlFind(uret, 0);
|
||||
/*@=globs =mods @*/
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*@=modfilesys@*/
|
||||
/*@=bounds@*/
|
||||
|
||||
int urlGetFile(const char * url, const char * dest)
|
||||
{
|
||||
|
@ -595,7 +548,7 @@ fprintf(stderr, "*** urlGetFile sfd %p %s tfd %p %s\n", sfd, url, (tfd ? tfd : N
|
|||
if ((rc = ufdGetFile(sfd, tfd))) {
|
||||
(void) Unlink(dest);
|
||||
/* XXX FIXME: sfd possibly closed by copyData */
|
||||
/*@-usereleased@*/ (void) Fclose(sfd) /*@=usereleased@*/ ;
|
||||
(void) Fclose(sfd) ;
|
||||
}
|
||||
sfd = NULL; /* XXX Fclose(sfd) done by ufdGetFile */
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue