本文整理汇总了C++中rpmlog函数的典型用法代码示例。如果您正苦于以下问题:C++ rpmlog函数的具体用法?C++ rpmlog怎么用?C++ rpmlog使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rpmlog函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fsmDebug
static void fsmDebug(const char *fpath, rpmFileAction action,
const struct stat *st)
{
rpmlog(RPMLOG_DEBUG, "%-10s %06o%3d (%4d,%4d)%6d %s\n",
fileActionString(action), (int)st->st_mode,
(int)st->st_nlink, (int)st->st_uid,
(int)st->st_gid, (int)st->st_size,
(fpath ? fpath : ""));
}
示例2: rpmluaRunScriptFile
int rpmluaRunScriptFile(rpmlua _lua, const char *filename)
{
INITSTATE(_lua, lua);
lua_State *L = lua->L;
int ret = 0;
if (luaL_loadfile(L, filename) != 0) {
rpmlog(RPMLOG_ERR, _("invalid syntax in Lua file: %s\n"),
lua_tostring(L, -1));
lua_pop(L, 1);
ret = -1;
} else if (lua_pcall(L, 0, 0, 0) != 0) {
rpmlog(RPMLOG_ERR, _("Lua script failed: %s\n"),
lua_tostring(L, -1));
lua_pop(L, 1);
ret = -1;
}
return ret;
}
示例3: fdJump
static rpmRC fdJump(FD_t fd, off_t offset)
{
if (Fseek(fd, offset, SEEK_SET) < 0) {
rpmlog(RPMLOG_ERR, _("Could not seek in file %s: %s\n"),
Fdescr(fd), Fstrerror(fd));
return RPMRC_FAIL;
}
return RPMRC_OK;
}
示例4: checkPackages
static rpmRC checkPackages(char *pkgcheck)
{
int fail = rpmExpandNumeric("%{?_nonzero_exit_pkgcheck_terminate_build}");
int xx;
rpmlog(RPMLOG_NOTICE, _("Executing \"%s\":\n"), pkgcheck);
xx = system(pkgcheck);
if (WEXITSTATUS(xx) == -1 || WEXITSTATUS(xx) == 127) {
rpmlog(RPMLOG_ERR, _("Execution of \"%s\" failed.\n"), pkgcheck);
if (fail) return RPMRC_NOTFOUND;
}
if (WEXITSTATUS(xx) != 0) {
rpmlog(RPMLOG_ERR, _("Package check \"%s\" failed.\n"), pkgcheck);
if (fail) return RPMRC_FAIL;
}
return RPMRC_OK;
}
示例5: rpmlockNew
/* External interface */
rpmlock rpmlockNew(const char *lock_path, const char *descr)
{
rpmlock lock = rpmlock_new(lock_path, descr);
if (!lock) {
rpmlog(RPMLOG_ERR, _("can't create %s lock on %s (%s)\n"),
descr, lock_path, strerror(errno));
}
return lock;
}
示例6: rpmmgFile
const char * rpmmgFile(rpmmg mg, const char *fn)
{
const char * t = NULL;
if (_rpmmg_debug)
fprintf(stderr, "--> rpmmgFile(%p, %s)\n", mg, (fn ? fn : "(nil)"));
#if defined(HAVE_MAGIC_H)
if (mg->ms) {
const char * lpath = NULL;
int ut = urlPath(fn, &lpath);
switch (ut) {
case URL_IS_FTP:
case URL_IS_HKP:
case URL_IS_HTTP:
case URL_IS_HTTPS:
{ char b[512];
size_t nb = 0;
FD_t fd;
fd = Fopen(fn, "r.ufdio");
if (fd != NULL && !Ferror(fd)) {
nb = Fread(b, 1, sizeof(b), fd);
(void) Fclose(fd);
}
if (nb > 0)
return rpmmgBuffer(mg, b, nb);
} break;
case URL_IS_DASH:
case URL_IS_MONGO: /* XXX FIXME */
break;
case URL_IS_PATH:
fn = lpath;
/*@[email protected]*/
case URL_IS_UNKNOWN:
default:
t = magic_file(mg->ms, fn);
/* XXX HACK: libmagic compiled without <pcreposix.h> spews here. */
if (t == NULL) {
const char * msg = magic_error(mg->ms);
if (strstr(msg, "regexec error 17, (match failed)") == NULL)
rpmlog(RPMLOG_ERR, _("magic_file(ms, %s) failed: %s\n"),
(fn ? fn : "(nil)"), msg);
}
break;
}
}
#endif
if (t == NULL) t = "";
t = xstrdup(t);
if (_rpmmg_debug)
fprintf(stderr, "<-- rpmmgFile(%p, %s) %s\n", mg, (fn ? fn : "(nil)"), t);
return t;
}
示例7: checkOwners
/**
* Check that file owner and group are known.
* @param urlfn file url
* @return RPMRC_OK on success
*/
static rpmRC checkOwners(const char * urlfn)
/*@globals h_errno, fileSystem, internalState @*/
/*@modifies fileSystem, internalState @*/
{
struct stat sb;
if (Lstat(urlfn, &sb)) {
rpmlog(RPMLOG_ERR, _("Bad source: %s: %s\n"),
urlfn, strerror(errno));
return RPMRC_FAIL;
}
if (!getUname(sb.st_uid) || !getGname(sb.st_gid)) {
rpmlog(RPMLOG_ERR, _("Bad owner/group: %s\n"), urlfn);
return RPMRC_FAIL;
}
return RPMRC_OK;
}
示例8: replaceSigDigests
static rpmRC replaceSigDigests(FD_t fd, const char *rpm, Header *sigp,
off_t sigStart, off_t sigTargetSize,
char *SHA1, uint8_t *MD5)
{
off_t archiveSize;
rpmRC rc = RPMRC_OK;
if (Fseek(fd, sigStart, SEEK_SET) < 0) {
rc = RPMRC_FAIL;
rpmlog(RPMLOG_ERR, _("Could not seek in file %s: %s\n"),
rpm, Fstrerror(fd));
goto exit;
}
/* Get payload size from signature tag */
archiveSize = headerGetNumber(*sigp, RPMSIGTAG_PAYLOADSIZE);
if (!archiveSize) {
archiveSize = headerGetNumber(*sigp, RPMSIGTAG_LONGARCHIVESIZE);
}
/* Replace old digests in sigh */
rc = rpmGenerateSignature(SHA1, MD5, sigTargetSize, archiveSize, fd);
if (rc != RPMRC_OK) {
rpmlog(RPMLOG_ERR, _("generateSignature failed\n"));
goto exit;
}
if (Fseek(fd, sigStart, SEEK_SET) < 0) {
rc = RPMRC_FAIL;
rpmlog(RPMLOG_ERR, _("Could not seek in file %s: %s\n"),
rpm, Fstrerror(fd));
goto exit;
}
headerFree(*sigp);
rc = rpmReadSignature(fd, sigp, RPMSIGTYPE_HEADERSIG, NULL);
if (rc != RPMRC_OK) {
rpmlog(RPMLOG_ERR, _("rpmReadSignature failed\n"));
goto exit;
}
exit:
return rc;
}
示例9: parseNoSource
static int parseNoSource(rpmSpec spec, const char * field, rpmTagVal tag)
{
const char *f, *fe;
const char *name;
int flag;
uint32_t num;
if (tag == RPMTAG_NOSOURCE) {
flag = RPMBUILD_ISSOURCE;
name = "source";
} else {
flag = RPMBUILD_ISPATCH;
name = "patch";
}
fe = field;
for (f = fe; *f != '\0'; f = fe) {
struct Source *p;
SKIPWHITE(f);
if (*f == '\0')
break;
fe = f;
SKIPNONWHITE(fe);
if (*fe != '\0') fe++;
if (parseUnsignedNum(f, &num)) {
rpmlog(RPMLOG_ERR, _("line %d: Bad number: %s\n"),
spec->lineNum, f);
return RPMRC_FAIL;
}
if (! (p = findSource(spec, num, flag))) {
rpmlog(RPMLOG_ERR, _("line %d: Bad no%s number: %u\n"),
spec->lineNum, name, num);
return RPMRC_FAIL;
}
p->flags |= RPMBUILD_ISNO;
}
return 0;
}
示例10: findPreambleTag
static int findPreambleTag(rpmSpec spec,rpmTagVal * tag,
const char ** macro, char * lang)
{
PreambleRec p;
char *s;
for (p = preambleList; p->token != NULL; p++) {
if (!(p->token && !rstrncasecmp(spec->line, p->token, p->len)))
continue;
if (p->deprecated) {
rpmlog(RPMLOG_WARNING, _("line %d: %s is deprecated: %s\n"),
spec->lineNum, p->token, spec->line);
}
break;
}
if (p == NULL || p->token == NULL)
return 1;
s = spec->line + p->len;
SKIPSPACE(s);
switch (p->type) {
default:
case 0:
/* Unless this is a source or a patch, a ':' better be next */
if (p->tag != RPMTAG_SOURCE && p->tag != RPMTAG_PATCH) {
if (*s != ':') return 1;
}
*lang = '\0';
break;
case 1: /* Parse optional ( <token> ). */
case 2:
if (*s == ':') {
/* Type 1 is multilang, 2 is qualifiers with no defaults */
strcpy(lang, (p->type == 1) ? RPMBUILD_DEFAULT_LANG : "");
break;
}
if (*s != '(') return 1;
s++;
SKIPSPACE(s);
while (!risspace(*s) && *s != ')')
*lang++ = *s++;
*lang = '\0';
SKIPSPACE(s);
if (*s != ')') return 1;
s++;
SKIPSPACE(s);
if (*s != ':') return 1;
break;
}
*tag = p->tag;
if (macro)
*macro = p->token;
return 0;
}
示例11: _specQuery
/**
* Parse a spec file, and query the resultant header.
* @param ts rpm transaction
* @param qva query args
* @param specName specfile to parse
* @param target cpu-vender-os platform for query (NULL is current)
* @return 0 on success
*/
static int _specQuery(rpmts ts, QVA_t qva, const char *specName,
/*@[email protected]*/ const char *target)
/*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
/*@modifies rpmGlobalMacroContext, fileSystem, internalState @*/
{
Spec spec = NULL;
Package pkg;
int res = 1; /* assume error */
int anyarch = (target == NULL) ? 1 : 0;
char * passPhrase = "";
int recursing = 0;
char *cookie = NULL;
int verify = 0;
int xx;
/*@[email protected]*/ /* FIX: make spec abstract */
if (parseSpec(ts, specName, "/", recursing, passPhrase,
cookie, anyarch, 1, verify)
|| (spec = rpmtsSetSpec(ts, NULL)) == NULL)
{
rpmlog(RPMLOG_ERR,
_("query of specfile %s failed, can't parse\n"),
specName);
goto exit;
}
/*@[email protected]*/
res = 0;
if (specedit) {
printNewSpecfile(spec);
goto exit;
}
switch (qva->qva_source) {
case RPMQV_SPECSRPM:
xx = initSourceHeader(spec, NULL);
xx = initSourceHeaderScriptlets(spec);
xx = qva->qva_showPackage(qva, ts, spec->sourceHeader);
break;
default:
case RPMQV_SPECFILE:
for (pkg = spec->packages; pkg != NULL; pkg = pkg->next) {
/* If no target was specified, display all packages.
* Packages with empty file lists are not produced.
*/
/* XXX DIEDIEDIE: this logic looks flawed. */
if (target == NULL || pkg->fileList != NULL)
xx = qva->qva_showPackage(qva, ts, pkg->header);
}
break;
}
exit:
spec = freeSpec(spec);
return res;
}
示例12: rpmgiInitFilter
/**
* Return rpmdb match iterator with filters (if any) set.
* @param gi generalized iterator
* @returns RPMRC_OK on success
*/
static rpmRC rpmgiInitFilter(rpmgi gi)
/*@globals rpmGlobalMacroContext, h_errno, internalState @*/
/*@modifies gi, rpmGlobalMacroContext, h_errno, internalState @*/
{
rpmRC rpmrc = RPMRC_OK;
ARGV_t av;
int got = 0;
gi->mi = rpmtsInitIterator(gi->ts, gi->tag, gi->keyp, gi->keylen);
if (_rpmgi_debug < 0)
fprintf(stderr, "*** gi %p key %p[%d]\tmi %p\n", gi, gi->keyp, (int)gi->keylen, gi->mi);
if (gi->argv != NULL)
for (av = (const char **) gi->argv; *av != NULL; av++) {
if (gi->tag == RPMDBI_PACKAGES) {
int tag = RPMTAG_NAME;
const char * pat;
char * a, * ae;
pat = a = xstrdup(*av);
tag = RPMTAG_NAME;
/* Parse for "tag=pattern" args. */
if ((ae = strchr(a, '=')) != NULL) {
*ae++ = '\0';
if (*a != '\0') { /* XXX HACK: permit '=foo' */
tag = tagValue(a);
#ifdef DYING /* XXX arbitrary tags always have a return value */
if (tag < 0) {
rpmlog(RPMLOG_NOTICE, _("unknown tag: \"%s\"\n"), a);
got = -1;
}
#endif
}
pat = ae;
got++;
}
if (got) {
if (_rpmgi_debug < 0)
fprintf(stderr, "\tav %p[%d]: \"%s\" -> %s ~= \"%s\"\n", gi->argv, (int)(av - gi->argv), *av, tagName(tag), pat);
got = rpmmiAddPattern(gi->mi, tag, RPMMIRE_DEFAULT, pat);
}
a = _free(a);
}
if (got >= 0)
continue;
gi->mi = rpmmiFree(gi->mi); /* XXX odd side effect? */
rpmrc = RPMRC_FAIL;
break;
}
return rpmrc;
}
示例13: parseNoSource
int parseNoSource(Spec spec, const char * field, rpmTag tag)
{
const char *f, *fe;
const char *name;
rpmuint32_t num, flag;
if (tag == RPMTAG_NOSOURCE) {
flag = RPMFILE_SOURCE;
name = "source";
} else {
flag = RPMFILE_PATCH;
name = "patch";
}
fe = field;
for (f = fe; *f != '\0'; f = fe) {
struct Source *p;
SKIPWHITE(f);
if (*f == '\0')
break;
fe = f;
SKIPNONWHITE(fe);
if (*fe != '\0') fe++;
if (parseNum(f, &num)) {
rpmlog(RPMLOG_ERR, _("line %d: Bad number: %s\n"),
spec->lineNum, f);
return RPMRC_FAIL;
}
if (! (p = findSource(spec, num, flag))) {
rpmlog(RPMLOG_ERR, _("line %d: Bad no%s number: %d\n"),
spec->lineNum, name, num);
return RPMRC_FAIL;
}
p->flags |= RPMFILE_GHOST;
}
return RPMRC_OK;
}
示例14: fsmMkdir
static int fsmMkdir(const char *path, mode_t mode)
{
int rc = mkdir(path, (mode & 07777));
if (_fsm_debug)
rpmlog(RPMLOG_DEBUG, " %8s (%s, 0%04o) %s\n", __func__,
path, (unsigned)(mode & 07777),
(rc < 0 ? strerror(errno) : ""));
if (rc < 0) rc = RPMERR_MKDIR_FAILED;
return rc;
}
示例15: readFile
/**
* @todo If the GPG key was known available, the md5 digest could be skipped.
*/
static int readFile(FD_t fd, const char * fn,
rpmDigestBundle plbundle, rpmDigestBundle hdrbundle)
{
unsigned char buf[4*BUFSIZ];
ssize_t count;
int rc = 1;
Header h = NULL;
char *msg = NULL;
/* Read the header from the package. */
if (rpmReadHeader(NULL, fd, &h, &msg) != RPMRC_OK) {
rpmlog(RPMLOG_ERR, _("%s: headerRead failed: %s\n"), fn, msg);
goto exit;
}
if (headerIsEntry(h, RPMTAG_HEADERIMMUTABLE)) {
struct rpmtd_s utd;
if (!headerGet(h, RPMTAG_HEADERIMMUTABLE, &utd, HEADERGET_DEFAULT)){
rpmlog(RPMLOG_ERR,
_("%s: Immutable header region could not be read. "
"Corrupted package?\n"), fn);
goto exit;
}
rpmDigestBundleUpdate(hdrbundle, rpm_header_magic, sizeof(rpm_header_magic));
rpmDigestBundleUpdate(hdrbundle, utd.data, utd.count);
rpmtdFreeData(&utd);
}
/* Read the payload from the package. */
while ((count = Fread(buf, sizeof(buf[0]), sizeof(buf), fd)) > 0) {}
if (count < 0) {
rpmlog(RPMLOG_ERR, _("%s: Fread failed: %s\n"), fn, Fstrerror(fd));
goto exit;
}
rc = 0;
exit:
free(msg);
headerFree(h);
return rc;
}