2002-10-14 22:52:45 +08:00
|
|
|
#ifndef _H_RPMFC_
|
|
|
|
#define _H_RPMFC_
|
|
|
|
|
2004-10-22 02:40:56 +08:00
|
|
|
#undef FILE_RCSID
|
|
|
|
#include "magic.h"
|
2002-12-01 05:42:24 +08:00
|
|
|
|
2002-11-27 06:44:47 +08:00
|
|
|
/*@-exportlocal@*/
|
2002-12-01 05:42:24 +08:00
|
|
|
/*@unchecked@*/
|
2002-10-20 06:48:25 +08:00
|
|
|
extern int _rpmfc_debug;
|
2002-11-27 06:44:47 +08:00
|
|
|
/*@=exportlocal@*/
|
2002-10-20 06:48:25 +08:00
|
|
|
|
2002-12-03 10:57:02 +08:00
|
|
|
/**
|
|
|
|
*/
|
2004-10-22 02:40:56 +08:00
|
|
|
typedef /*@abstract@*/ struct rpmfc_s * rpmfc;
|
2002-10-14 22:52:45 +08:00
|
|
|
|
2002-12-03 10:57:02 +08:00
|
|
|
/**
|
|
|
|
*/
|
2002-10-16 02:44:16 +08:00
|
|
|
struct rpmfc_s {
|
2002-10-20 06:48:25 +08:00
|
|
|
int nfiles; /*!< no. of files */
|
|
|
|
int fknown; /*!< no. of classified files */
|
|
|
|
int fwhite; /*!< no. of "white" files */
|
|
|
|
int ix; /*!< current file index */
|
2002-12-13 03:16:45 +08:00
|
|
|
int skipProv; /*!< Don't auto-generate Provides:? */
|
|
|
|
int skipReq; /*!< Don't auto-generate Requires:? */
|
|
|
|
int tracked; /*!< Versioned Provides: tracking dependency added? */
|
2005-02-14 09:34:12 +08:00
|
|
|
size_t brlen; /*!< strlen(spec->buildRoot) */
|
2002-10-22 03:29:23 +08:00
|
|
|
|
2002-10-20 06:48:25 +08:00
|
|
|
ARGV_t fn; /*!< (#files) file names */
|
|
|
|
ARGI_t fcolor; /*!< (#files) file colors */
|
|
|
|
ARGI_t fcdictx; /*!< (#files) file class dictionary indices */
|
|
|
|
ARGI_t fddictx; /*!< (#files) file depends dictionary start */
|
|
|
|
ARGI_t fddictn; /*!< (#files) file depends dictionary no. entries */
|
|
|
|
ARGV_t cdict; /*!< (#classes) file class dictionary */
|
|
|
|
ARGV_t ddict; /*!< (#dependencies) file depends dictionary */
|
|
|
|
ARGI_t ddictx; /*!< (#dependencies) file->dependency mapping */
|
2002-10-22 03:29:23 +08:00
|
|
|
|
2002-12-08 05:27:09 +08:00
|
|
|
/*@relnull@*/
|
2002-12-07 13:48:45 +08:00
|
|
|
rpmds provides; /*!< (#provides) package provides */
|
2002-12-08 05:27:09 +08:00
|
|
|
/*@relnull@*/
|
2002-12-07 13:48:45 +08:00
|
|
|
rpmds requires; /*!< (#requires) package requires */
|
2002-10-22 03:29:23 +08:00
|
|
|
|
|
|
|
StringBuf sb_java; /*!< concatenated list of java colored files. */
|
|
|
|
StringBuf sb_perl; /*!< concatenated list of perl colored files. */
|
|
|
|
StringBuf sb_python;/*!< concatenated list of python colored files. */
|
|
|
|
|
2002-10-14 22:52:45 +08:00
|
|
|
};
|
|
|
|
|
2002-12-03 10:57:02 +08:00
|
|
|
/**
|
|
|
|
*/
|
2002-10-14 22:52:45 +08:00
|
|
|
enum FCOLOR_e {
|
|
|
|
RPMFC_BLACK = 0,
|
|
|
|
RPMFC_ELF32 = (1 << 0),
|
|
|
|
RPMFC_ELF64 = (1 << 1),
|
2002-10-16 02:44:16 +08:00
|
|
|
#define RPMFC_ELF (RPMFC_ELF32|RPMFC_ELF64)
|
|
|
|
|
2002-12-28 02:01:00 +08:00
|
|
|
RPMFC_MODULE = (1 << 7),
|
2002-10-16 02:44:16 +08:00
|
|
|
RPMFC_EXECUTABLE = (1 << 8),
|
|
|
|
RPMFC_SCRIPT = (1 << 9),
|
|
|
|
RPMFC_TEXT = (1 << 10),
|
|
|
|
RPMFC_DATA = (1 << 11), /* XXX unused */
|
|
|
|
RPMFC_DOCUMENT = (1 << 12),
|
|
|
|
RPMFC_STATIC = (1 << 13),
|
|
|
|
RPMFC_NOTSTRIPPED = (1 << 14),
|
|
|
|
RPMFC_COMPRESSED = (1 << 15),
|
|
|
|
|
|
|
|
RPMFC_DIRECTORY = (1 << 16),
|
|
|
|
RPMFC_SYMLINK = (1 << 17),
|
|
|
|
RPMFC_DEVICE = (1 << 18),
|
|
|
|
RPMFC_LIBRARY = (1 << 19),
|
|
|
|
RPMFC_ARCHIVE = (1 << 20),
|
|
|
|
RPMFC_FONT = (1 << 21),
|
|
|
|
RPMFC_IMAGE = (1 << 22),
|
|
|
|
RPMFC_MANPAGE = (1 << 23),
|
2002-10-14 22:52:45 +08:00
|
|
|
|
2002-10-20 06:48:25 +08:00
|
|
|
RPMFC_PERL = (1 << 24),
|
|
|
|
RPMFC_JAVA = (1 << 25),
|
|
|
|
RPMFC_PYTHON = (1 << 26),
|
|
|
|
RPMFC_PHP = (1 << 27),
|
|
|
|
RPMFC_TCL = (1 << 28),
|
|
|
|
|
2002-10-14 22:52:45 +08:00
|
|
|
RPMFC_WHITE = (1 << 29),
|
|
|
|
RPMFC_INCLUDE = (1 << 30),
|
|
|
|
RPMFC_ERROR = (1 << 31)
|
|
|
|
};
|
|
|
|
typedef enum FCOLOR_e FCOLOR_t;
|
|
|
|
|
2002-12-03 10:57:02 +08:00
|
|
|
/**
|
|
|
|
*/
|
2002-10-16 02:44:16 +08:00
|
|
|
struct rpmfcTokens_s {
|
2002-10-14 22:52:45 +08:00
|
|
|
/*@observer@*/
|
|
|
|
const char * token;
|
|
|
|
int colors;
|
|
|
|
};
|
|
|
|
|
2002-12-08 05:27:09 +08:00
|
|
|
/**
|
|
|
|
*/
|
2002-10-16 02:44:16 +08:00
|
|
|
typedef struct rpmfcTokens_s * rpmfcToken;
|
2002-10-14 22:52:45 +08:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2002-10-22 03:29:23 +08:00
|
|
|
/**
|
2002-12-25 01:06:35 +08:00
|
|
|
* Return helper output.
|
|
|
|
* @param av helper argv (with possible macros)
|
|
|
|
* @param sb_stdin helper input
|
|
|
|
* @retval *sb_stdoutp helper output
|
|
|
|
* @param failnonzero IS non-zero helper exit status a failure?
|
2002-10-22 03:29:23 +08:00
|
|
|
*/
|
2002-11-06 06:45:02 +08:00
|
|
|
int rpmfcExec(ARGV_t av, StringBuf sb_stdin, /*@out@*/ StringBuf * sb_stdoutp,
|
2002-10-22 03:29:23 +08:00
|
|
|
int failnonzero)
|
2003-05-09 04:39:29 +08:00
|
|
|
/*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
|
2002-11-06 06:45:02 +08:00
|
|
|
/*@modifies *sb_stdoutp, rpmGlobalMacroContext,
|
2002-12-29 07:17:06 +08:00
|
|
|
fileSystem, internalState @*/
|
|
|
|
/*@requires maxSet(sb_stdoutp) >= 0 @*/;
|
2002-10-22 03:29:23 +08:00
|
|
|
|
2002-10-14 22:52:45 +08:00
|
|
|
/**
|
2002-12-25 01:06:35 +08:00
|
|
|
* Return file color given file(1) string.
|
|
|
|
* @param fmstr file(1) string
|
|
|
|
* @return file color
|
2002-10-14 22:52:45 +08:00
|
|
|
*/
|
2002-11-27 06:44:47 +08:00
|
|
|
/*@-exportlocal@*/
|
2002-10-16 02:44:16 +08:00
|
|
|
int rpmfcColoring(const char * fmstr)
|
2002-10-14 22:52:45 +08:00
|
|
|
/*@*/;
|
2002-11-27 06:44:47 +08:00
|
|
|
/*@=exportlocal@*/
|
2002-10-14 22:52:45 +08:00
|
|
|
|
|
|
|
/**
|
2002-12-25 01:06:35 +08:00
|
|
|
* Print results of file classification.
|
|
|
|
* @todo Remove debugging routine.
|
|
|
|
* @param msg message prefix (NULL for none)
|
2002-12-03 10:57:02 +08:00
|
|
|
* @param fc file classifier
|
2002-12-25 01:06:35 +08:00
|
|
|
* @param fp output file handle (NULL for stderr)
|
2002-10-14 22:52:45 +08:00
|
|
|
*/
|
2002-12-21 09:31:24 +08:00
|
|
|
/*@-exportlocal@*/
|
2002-12-25 01:06:35 +08:00
|
|
|
void rpmfcPrint(/*@null@*/ const char * msg, rpmfc fc, /*@null@*/ FILE * fp)
|
2002-10-14 22:52:45 +08:00
|
|
|
/*@globals fileSystem @*/
|
2002-12-08 05:27:09 +08:00
|
|
|
/*@modifies *fp, fc, fileSystem @*/;
|
2002-12-21 09:31:24 +08:00
|
|
|
/*@=exportlocal@*/
|
2002-12-08 05:27:09 +08:00
|
|
|
|
2002-10-14 22:52:45 +08:00
|
|
|
/**
|
2002-12-03 10:57:02 +08:00
|
|
|
* Destroy a file classifier.
|
|
|
|
* @param fc file classifier
|
|
|
|
* @return NULL always
|
2002-10-14 22:52:45 +08:00
|
|
|
*/
|
2002-12-08 05:27:09 +08:00
|
|
|
/*@-exportlocal@*/
|
2002-10-14 22:52:45 +08:00
|
|
|
/*@null@*/
|
2002-10-16 02:44:16 +08:00
|
|
|
rpmfc rpmfcFree(/*@only@*/ /*@null@*/ rpmfc fc)
|
2002-10-14 22:52:45 +08:00
|
|
|
/*@modifies fc @*/;
|
2002-12-08 05:27:09 +08:00
|
|
|
/*@=exportlocal@*/
|
2002-10-14 22:52:45 +08:00
|
|
|
|
|
|
|
/**
|
2002-12-03 10:57:02 +08:00
|
|
|
* Create a file classifier.
|
|
|
|
* @return new file classifier
|
2002-10-14 22:52:45 +08:00
|
|
|
*/
|
2002-12-08 05:27:09 +08:00
|
|
|
/*@-exportlocal@*/
|
2002-10-16 02:44:16 +08:00
|
|
|
rpmfc rpmfcNew(void)
|
2002-10-14 22:52:45 +08:00
|
|
|
/*@*/;
|
2002-12-08 05:27:09 +08:00
|
|
|
/*@=exportlocal@*/
|
2002-10-14 22:52:45 +08:00
|
|
|
|
|
|
|
/**
|
2002-10-20 06:48:25 +08:00
|
|
|
* Build file class dictionary and mappings.
|
2002-12-03 10:57:02 +08:00
|
|
|
* @param fc file classifier
|
2002-12-08 05:27:09 +08:00
|
|
|
* @param argv files to classify
|
2005-03-20 04:07:12 +08:00
|
|
|
* @param fmode files mode_t array (or NULL)
|
2002-12-03 10:57:02 +08:00
|
|
|
* @return 0 on success
|
2002-10-14 22:52:45 +08:00
|
|
|
*/
|
2002-12-08 05:27:09 +08:00
|
|
|
/*@-exportlocal@*/
|
2005-03-20 04:07:12 +08:00
|
|
|
int rpmfcClassify(rpmfc fc, ARGV_t argv, /*@null@*/ int16_t * fmode)
|
2004-10-22 02:40:56 +08:00
|
|
|
/*@globals fileSystem, internalState @*/
|
|
|
|
/*@modifies fc, fileSystem, internalState @*/;
|
2002-12-08 05:27:09 +08:00
|
|
|
/*@=exportlocal@*/
|
2002-10-14 22:52:45 +08:00
|
|
|
|
2002-10-20 06:48:25 +08:00
|
|
|
/**
|
2002-12-03 10:57:02 +08:00
|
|
|
* Build file/package dependency dictionary and mappings.
|
|
|
|
* @param fc file classifier
|
|
|
|
* @return 0 on success
|
2002-10-20 06:48:25 +08:00
|
|
|
*/
|
2002-12-08 05:27:09 +08:00
|
|
|
/*@-exportlocal@*/
|
2002-10-20 06:48:25 +08:00
|
|
|
int rpmfcApply(rpmfc fc)
|
|
|
|
/*@modifies fc @*/;
|
2002-12-08 05:27:09 +08:00
|
|
|
/*@=exportlocal@*/
|
2002-10-20 06:48:25 +08:00
|
|
|
|
2002-12-03 10:57:02 +08:00
|
|
|
/**
|
|
|
|
* Generate package dependencies.
|
|
|
|
* @param spec spec file control
|
|
|
|
* @param pkg package control
|
|
|
|
* @return 0 on success
|
|
|
|
*/
|
|
|
|
int rpmfcGenerateDepends(const Spec spec, Package pkg)
|
2003-05-09 04:39:29 +08:00
|
|
|
/*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
|
2002-12-03 10:57:02 +08:00
|
|
|
/*@modifies pkg->cpioList, pkg->header,
|
|
|
|
rpmGlobalMacroContext, fileSystem, internalState @*/;
|
|
|
|
|
2002-10-14 22:52:45 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* _H_RPMFC_ */
|