#define SOLVER_SOLUTION_REPLACE_VENDORCHANGE -104
#define SOLVER_SOLUTION_REPLACE_NAMECHANGE -105
-typedef struct chksum Chksum;
typedef void *AppObjectPtr;
typedef Id DepId;
%extend Chksum {
Chksum(Id type) {
- return (Chksum *)solv_chksum_create(type);
+ return solv_chksum_create(type);
}
Chksum(Id type, const char *hex) {
unsigned char buf[64];
return 0;
if (solv_hex2bin(&hex, buf, sizeof(buf)) != l || hex[0])
return 0;
- return (Chksum *)solv_chksum_create_from_bin(type, buf);
+ return solv_chksum_create_from_bin(type, buf);
}
~Chksum() {
solv_chksum_free($self, 0);
}
Id const type;
%{
- SWIGINTERN Id Chksum_type_get(Chksum *chksum) {
- return solv_chksum_get_type(chksum);
+ SWIGINTERN Id Chksum_type_get(Chksum *chk) {
+ return solv_chksum_get_type(chk);
}
%}
void add(const char *str) {
{
char buf[1024];
const unsigned char *sum;
- void *h;
+ Chksum *h;
int l;
h = solv_chksum_create(chksumtype);
calc_checksum_fp(FILE *fp, Id chktype, unsigned char *out)
{
char buf[4096];
- void *h = solv_chksum_create(chktype);
+ Chksum *h = solv_chksum_create(chktype);
int l;
solv_chksum_add(h, CHKSUM_IDENT, strlen(CHKSUM_IDENT));
void
calc_checksum_stat(struct stat *stb, Id chktype, unsigned char *cookie, unsigned char *out)
{
- void *h = solv_chksum_create(chktype);
+ Chksum *h = solv_chksum_create(chktype);
solv_chksum_add(h, CHKSUM_IDENT, strlen(CHKSUM_IDENT));
if (cookie)
solv_chksum_add(h, cookie, 32);
Solvable *s;
int l, fd;
struct stat stb;
- void *pkgidhandle = 0;
+ Chksum *pkgidchk = 0;
data = repo_add_repodata(repo, flags);
if ((fd = open(flags & REPO_USE_ROOTDIR ? pool_prepend_rootdir_tmp(pool, fn) : fn, O_RDONLY, 0)) < 0)
ignoreline = 0;
s = pool_id2solvable(pool, repo_add_solvable(repo));
if (flags & ARCH_ADD_WITH_PKGID)
- pkgidhandle = solv_chksum_create(REPOKEY_TYPE_MD5);
+ pkgidchk = solv_chksum_create(REPOKEY_TYPE_MD5);
while (getsentry(&th, line, sizeof(line)))
{
l = strlen(line);
if (l == 0)
continue;
- if (pkgidhandle)
- solv_chksum_add(pkgidhandle, line, l);
+ if (pkgidchk)
+ solv_chksum_add(pkgidchk, line, l);
if (line[l - 1] != '\n')
{
ignoreline = 1;
if (!s)
{
pool_error(pool, -1, "%s: not an arch package", fn);
- if (pkgidhandle)
- solv_chksum_free(pkgidhandle, 0);
+ if (pkgidchk)
+ solv_chksum_free(pkgidchk, 0);
return 0;
}
if (s && !s->name)
repodata_set_location(data, s - pool->solvables, 0, 0, fn);
if (S_ISREG(stb.st_mode))
repodata_set_num(data, s - pool->solvables, SOLVABLE_DOWNLOADSIZE, (unsigned long long)stb.st_size);
- if (pkgidhandle)
+ if (pkgidchk)
{
unsigned char pkgid[16];
- solv_chksum_free(pkgidhandle, pkgid);
+ solv_chksum_free(pkgidchk, pkgid);
repodata_set_bin_checksum(data, s - pool->solvables, SOLVABLE_PKGID, REPOKEY_TYPE_MD5, pkgid);
- pkgidhandle = 0;
+ pkgidchk = 0;
}
}
- if (pkgidhandle)
- solv_chksum_free(pkgidhandle, 0);
+ if (pkgidchk)
+ solv_chksum_free(pkgidchk, 0);
if (!(flags & REPO_NO_INTERNALIZE))
repodata_internalize(data);
return s ? s - pool->solvables : 0;
gotpkgid = 0;
if (flags & DEBS_ADD_WITH_PKGID)
{
- void *handle = solv_chksum_create(REPOKEY_TYPE_MD5);
- solv_chksum_add(handle, ctgz, clen);
- solv_chksum_free(handle, pkgid);
+ Chksum *chk = solv_chksum_create(REPOKEY_TYPE_MD5);
+ solv_chksum_add(chk, ctgz, clen);
+ solv_chksum_free(chk, pkgid);
gotpkgid = 1;
}
if (ctgz[0] != 0x1f || ctgz[1] != 0x8b)
* hash the final trailer
* create a "sigdata" block suitable for a call to solv_pgpverify */
static void
-pgpsig_makesigdata(struct pgpsig *sig, unsigned char *p, int l, unsigned char *pubkey, int pubkeyl, unsigned char *userid, int useridl, void *h)
+pgpsig_makesigdata(struct pgpsig *sig, unsigned char *p, int l, unsigned char *pubkey, int pubkeyl, unsigned char *userid, int useridl, Chksum *h)
{
int type = sig->type;
unsigned char b[6];
if (p[0] == 3 && l >= 10)
{
unsigned int ex;
- void *h;
+ Chksum *h;
maxsigcr = kcr = p[1] << 24 | p[2] << 16 | p[3] << 8 | p[4];
ex = 0;
if (p[5] || p[6])
}
else if (p[0] == 4 && l >= 6)
{
- void *h;
+ Chksum *h;
unsigned char hdr[3];
unsigned char fp[20];
char fpx[40 + 1];
htype = pgphashalgo2type(sig.hashalgo);
if (htype && sig.mpioff)
{
- void *h = solv_chksum_create(htype);
+ Chksum *h = solv_chksum_create(htype);
pgpsig_makesigdata(&sig, p, l, pubkey, pubkeyl, userid, useridl, h);
solv_chksum_free(h, 0);
}
}
Id
-solvsig_verify(Solvsig *ss, Repo *repo, void *chk)
+solvsig_verify(Solvsig *ss, Repo *repo, Chksum *chk)
{
struct pgpsig pgpsig;
void *chk2;
*/
#include "repo.h"
+#include "chksum.h"
#define ADD_KEYDIR_WITH_DOTFILES (1 << 8)
#define ADD_WITH_SUBKEYS (1 << 9)
Solvsig *solvsig_create(FILE *fp);
void solvsig_free(Solvsig *ss);
-Id solvsig_verify(Solvsig *ss, Repo *repo, void *chk);
+Id solvsig_verify(Solvsig *ss, Repo *repo, Chksum *chk);
Id repo_verify_sigdata(Repo *repo, unsigned char *sigdata, int sigdatal, const char *keyid);
unsigned char hdrid[32];
int pkgidtype, leadsigidtype, hdridtype;
Id chksumtype = 0;
- void *chksumh = 0;
- void *leadsigchksumh = 0;
+ Chksum *chksumh = 0;
+ Chksum *leadsigchksumh = 0;
int forcebinary = 0;
data = repo_add_repodata(repo, flags);
Strqueue sq;
Queue q;
int i;
- void *chk;
+ Chksum *chk;
const unsigned char *md5;
int md5l;
const char *s;
{
Strqueue sq;
Queue q;
- void *chk;
+ Chksum *chk;
const unsigned char *md5;
int i, md5l;
const char *s;
testcase_solutionid(Solver *solv, Id problem, Id solution)
{
Id intid;
- void *chk;
+ Chksum *chk;
const unsigned char *md5;
int md5l;
const char *s;
#include "sha1.h"
#include "sha2.h"
-struct ctxhandle {
+struct _Chksum {
Id type;
int done;
unsigned char result[64];
} c;
};
-void *
+Chksum *
solv_chksum_create(Id type)
{
- struct ctxhandle *h;
- h = solv_calloc(1, sizeof(*h));
- h->type = type;
+ Chksum *chk;
+ chk = solv_calloc(1, sizeof(*chk));
+ chk->type = type;
switch(type)
{
case REPOKEY_TYPE_MD5:
- solv_MD5_Init(&h->c.md5);
- return h;
+ solv_MD5_Init(&chk->c.md5);
+ return chk;
case REPOKEY_TYPE_SHA1:
- solv_SHA1_Init(&h->c.sha1);
- return h;
+ solv_SHA1_Init(&chk->c.sha1);
+ return chk;
case REPOKEY_TYPE_SHA256:
- solv_SHA256_Init(&h->c.sha256);
- return h;
+ solv_SHA256_Init(&chk->c.sha256);
+ return chk;
default:
break;
}
- free(h);
+ free(chk);
return 0;
}
-void *
-solv_chksum_create_clone(void *handle)
+Chksum *
+solv_chksum_create_clone(Chksum *chk)
{
- return solv_memdup(handle, sizeof(struct ctxhandle));
+ return solv_memdup(chk, sizeof(*chk));
}
int
}
}
-void *
+Chksum *
solv_chksum_create_from_bin(Id type, const unsigned char *buf)
{
- struct ctxhandle *h;
+ Chksum *chk;
int l = solv_chksum_len(type);
if (buf == 0 || l == 0)
return 0;
- h = solv_calloc(1, sizeof(*h));
- h->type = type;
- h->done = 1;
- memcpy(h->result, buf, l);
- return h;
+ chk = solv_calloc(1, sizeof(*chk));
+ chk->type = type;
+ chk->done = 1;
+ memcpy(chk->result, buf, l);
+ return chk;
}
void
-solv_chksum_add(void *handle, const void *data, int len)
+solv_chksum_add(Chksum *chk, const void *data, int len)
{
- struct ctxhandle *h = handle;
- if (h->done)
+ if (chk->done)
return;
- switch(h->type)
+ switch(chk->type)
{
case REPOKEY_TYPE_MD5:
- solv_MD5_Update(&h->c.md5, (void *)data, len);
+ solv_MD5_Update(&chk->c.md5, (void *)data, len);
return;
case REPOKEY_TYPE_SHA1:
- solv_SHA1_Update(&h->c.sha1, data, len);
+ solv_SHA1_Update(&chk->c.sha1, data, len);
return;
case REPOKEY_TYPE_SHA256:
- solv_SHA256_Update(&h->c.sha256, data, len);
+ solv_SHA256_Update(&chk->c.sha256, data, len);
return;
default:
return;
}
const unsigned char *
-solv_chksum_get(void *handle, int *lenp)
+solv_chksum_get(Chksum *chk, int *lenp)
{
- struct ctxhandle *h = handle;
- if (h->done)
+ if (chk->done)
{
if (lenp)
- *lenp = solv_chksum_len(h->type);
- return h->result;
+ *lenp = solv_chksum_len(chk->type);
+ return chk->result;
}
- switch(h->type)
+ switch(chk->type)
{
case REPOKEY_TYPE_MD5:
- solv_MD5_Final(h->result, &h->c.md5);
- h->done = 1;
+ solv_MD5_Final(chk->result, &chk->c.md5);
+ chk->done = 1;
if (lenp)
*lenp = 16;
- return h->result;
+ return chk->result;
case REPOKEY_TYPE_SHA1:
- solv_SHA1_Final(&h->c.sha1, h->result);
- h->done = 1;
+ solv_SHA1_Final(&chk->c.sha1, chk->result);
+ chk->done = 1;
if (lenp)
*lenp = 20;
- return h->result;
+ return chk->result;
case REPOKEY_TYPE_SHA256:
- solv_SHA256_Final(h->result, &h->c.sha256);
- h->done = 1;
+ solv_SHA256_Final(chk->result, &chk->c.sha256);
+ chk->done = 1;
if (lenp)
*lenp = 32;
- return h->result;
+ return chk->result;
default:
if (lenp)
*lenp = 0;
}
Id
-solv_chksum_get_type(void *handle)
+solv_chksum_get_type(Chksum *chk)
{
- struct ctxhandle *h = handle;
- return h->type;
+ return chk->type;
}
int
-solv_chksum_isfinished(void *handle)
+solv_chksum_isfinished(Chksum *chk)
{
- struct ctxhandle *h = handle;
- return h->done != 0;
+ return chk->done != 0;
}
const char *
}
void *
-solv_chksum_free(void *handle, unsigned char *cp)
+solv_chksum_free(Chksum *chk, unsigned char *cp)
{
if (cp)
{
const unsigned char *res;
int l;
- res = solv_chksum_get(handle, &l);
+ res = solv_chksum_get(chk, &l);
if (l && res)
memcpy(cp, res, l);
}
- solv_free(handle);
+ solv_free(chk);
return 0;
}
extern "C" {
#endif
-void *solv_chksum_create(Id type);
-void *solv_chksum_create_clone(void *handle);
-void *solv_chksum_create_from_bin(Id type, const unsigned char *buf);
-void solv_chksum_add(void *handle, const void *data, int len);
-Id solv_chksum_get_type(void *handle);
-int solv_chksum_isfinished(void *handle);
-const unsigned char *solv_chksum_get(void *handle, int *lenp);
-void *solv_chksum_free(void *handle, unsigned char *cp);
+struct _Chksum;
+typedef struct _Chksum Chksum;
+
+Chksum *solv_chksum_create(Id type);
+Chksum *solv_chksum_create_clone(Chksum *chk);
+Chksum *solv_chksum_create_from_bin(Id type, const unsigned char *buf);
+void solv_chksum_add(Chksum *chk, const void *data, int len);
+Id solv_chksum_get_type(Chksum *chk);
+int solv_chksum_isfinished(Chksum *chk);
+const unsigned char *solv_chksum_get(Chksum *chk, int *lenp);
+void *solv_chksum_free(Chksum *chk, unsigned char *cp);
const char *solv_chksum_type2str(Id type);
Id solv_chksum_str2type(const char *str);
int solv_chksum_len(Id type);