diff options
author | jbj <devnull@localhost> | 2004-10-21 18:40:56 +0000 |
---|---|---|
committer | jbj <devnull@localhost> | 2004-10-21 18:40:56 +0000 |
commit | b7f251ae164590335bfca52c9dfce56a9e9c6512 (patch) | |
tree | cf49b6c2517eaa5ffe542ed2073af361e7dc4018 /build | |
parent | 2083dadd4c6e57010bb703da6699ebfd0bda85be (diff) | |
download | librpm-tizen-b7f251ae164590335bfca52c9dfce56a9e9c6512.tar.gz librpm-tizen-b7f251ae164590335bfca52c9dfce56a9e9c6512.tar.bz2 librpm-tizen-b7f251ae164590335bfca52c9dfce56a9e9c6512.zip |
- port to internal file-4.10 libmagic rather than libfmagic.
CVS patchset: 7500
CVS date: 2004/10/21 18:40:56
Diffstat (limited to 'build')
-rw-r--r-- | build/.splintrc | 2 | ||||
-rw-r--r-- | build/parsePreamble.c | 2 | ||||
-rw-r--r-- | build/rpmfc.c | 36 | ||||
-rw-r--r-- | build/rpmfc.h | 9 |
4 files changed, 26 insertions, 23 deletions
diff --git a/build/.splintrc b/build/.splintrc index 548a24588..0a85588cf 100644 --- a/build/.splintrc +++ b/build/.splintrc @@ -1,4 +1,4 @@ --I. -I.. -I../lib -I../rpmdb -I../rpmio -I../beecrypt -I../popt -I../elfutils/libelf -DHAVE_CONFIG_H -D_GNU_SOURCE +-I. -I.. -I../file/src -I../lib -I../rpmdb -I../rpmio -I../beecrypt -I../popt -I../elfutils/libelf -DHAVE_CONFIG_H -D_GNU_SOURCE +partial +forcehints diff --git a/build/parsePreamble.c b/build/parsePreamble.c index 00ca9c6b0..b4ff9c683 100644 --- a/build/parsePreamble.c +++ b/build/parsePreamble.c @@ -780,7 +780,7 @@ static struct PreambleRec_s preambleList[] = { {RPMTAG_RHNPLATFORM, 0, 0, 1, "rhnplatform"}, {RPMTAG_DISTTAG, 0, 0, 0, "disttag"}, /*@-nullassign@*/ /* LCL: can't add null annotation */ - {0, 0, 0, 0} + {0, 0, 0, 0, 0} /*@=nullassign@*/ }; diff --git a/build/rpmfc.c b/build/rpmfc.c index 04e980042..660215c76 100644 --- a/build/rpmfc.c +++ b/build/rpmfc.c @@ -16,7 +16,6 @@ #include "debug.h" -/*@access fmagic @*/ /*@access rpmds @*/ /** @@ -1151,9 +1150,8 @@ int rpmfcClassify(rpmfc fc, ARGV_t argv) size_t slen; int fcolor; int xx; -fmagic fm = global_fmagic; -int action = 0; -int wid = 0; /* XXX don't prepend filename: */ + int msflags = 0; /* XXX what MAGIC_FOO flags? */ + magic_t ms = NULL; if (fc == NULL || argv == NULL) return 0; @@ -1168,27 +1166,30 @@ int wid = 0; /* XXX don't prepend filename: */ xx = argvAdd(&fc->cdict, ""); xx = argvAdd(&fc->cdict, "directory"); -/*@-assignexpose@*/ - fm->magicfile = default_magicfile; -/*@=assignexpose@*/ - /* XXX TODO fm->flags = ??? */ + ms = magic_open(msflags); + /* XXX check errors. */ + + xx = magic_load(ms, "/usr/lib/rpm/magic"); + /* XXX check errors. */ - xx = fmagicSetup(fm, fm->magicfile, action); for (fc->ix = 0; fc->ix < fc->nfiles; fc->ix++) { + const char * ftype; + s = argv[fc->ix]; assert(s != NULL); slen = strlen(s); - fm->obp = fm->obuf; - *fm->obp = '\0'; - fm->nob = sizeof(fm->obuf); - xx = fmagicProcess(fm, s, wid); - /* XXX all files with extension ".pm" are perl modules for now. */ +/*@-branchstate@*/ if (slen >= sizeof(".pm") && !strcmp(s+slen-(sizeof(".pm")-1), ".pm")) - strcpy(fm->obuf, "Perl5 module source text"); + ftype = "Perl5 module source text"; + else { + ftype = magic_file(ms, s); +assert(ftype != NULL); + } +/*@=branchstate@*/ - se = fm->obuf; + se = ftype; rpmMessage(RPMMESS_DEBUG, "%s: %s\n", s, se); xx = argvAdd(&fc->fn, s); @@ -1222,7 +1223,8 @@ assert(se != NULL); fcav = argvFree(fcav); - /* XXX TODO dump fmagic baggage. */ + if (ms != NULL) + magic_close(ms); return 0; } diff --git a/build/rpmfc.h b/build/rpmfc.h index 3d5cd97f4..f7dcb8802 100644 --- a/build/rpmfc.h +++ b/build/rpmfc.h @@ -1,7 +1,8 @@ #ifndef _H_RPMFC_ #define _H_RPMFC_ -#include "rpmfile.h" +#undef FILE_RCSID +#include "magic.h" /*@-exportlocal@*/ /*@unchecked@*/ @@ -10,7 +11,7 @@ extern int _rpmfc_debug; /** */ -typedef struct rpmfc_s * rpmfc; +typedef /*@abstract@*/ struct rpmfc_s * rpmfc; /** */ @@ -163,8 +164,8 @@ rpmfc rpmfcNew(void) */ /*@-exportlocal@*/ int rpmfcClassify(rpmfc fc, ARGV_t argv) - /*@globals global_fmagic, fileSystem, internalState @*/ - /*@modifies fc, global_fmagic, fileSystem, internalState @*/; + /*@globals fileSystem, internalState @*/ + /*@modifies fc, fileSystem, internalState @*/; /*@=exportlocal@*/ /** |