ALPM
view release on metacpan or search on metacpan
return dep;
} else {
return alpm_dep_from_string(SvPV_nolen(rv));
}
}
SV*
c2p_conflict(void *p)
{
alpm_conflict_t *c;
HV *hv;
hv = newHV();
c = p;
hv_store(hv, "package1", 8, newSVpv(c->package1, 0), 0);
hv_store(hv, "package2", 8, newSVpv(c->package2, 0), 0);
hv_store(hv, "reason", 6, c2p_depend(c->reason), 0);
return newRV_noinc((SV*)hv);
}
static SV*
c2p_file(alpm_file_t *file){
HV *hv;
hv = newHV();
hv_store(hv, "name", 4, newSVpv(file->name, 0), 0);
hv_store(hv, "size", 4, newSViv(file->size), 0);
hv_store(hv, "mode", 4, newSViv(file->mode), 0);
return newRV_noinc((SV*)hv);
}
SV*
c2p_filelist(void *flistPtr){
alpm_filelist_t *flist;
AV *av;
int i;
flist = flistPtr;
av = newAV();
for(i = 0; i < flist->count; i++){
av_push(av, c2p_file(flist->files + i));
}
return newRV_noinc((SV*)av);
}
/*
This deals with only raw bits, which is bad form, but I prefer the design.
If the alpm_siglevel_t bitflag enum was not so strange, I wouldn't have
chosen to do this.
The bit flags are separated into two halves with a special case of the
"default value" where bit 32 (the MSB) is on. Reading from LSB to MSB,
the package flags consist of the first four bits. 6 unused bits follow.
The database flags consist of the next four bits. 17 unused bits follow.
Finally, the bit flag for ALPM_USE_DEFAULT is the MSB.
Here is the form of the package and database bitmask. Remember the
database flags are shifted to the left by 10 places.
BIT DESCRIPTION
1 Signature checking is enabled for packages or databases respectively.
2 Signature checking is optional, used only when available.
3 MARGINAL_OK?
4 UNKNOWN_OK?
A setting of TrustAll in pacman.conf enables MARGINAL_OK and UNKNOWN_OK.
These two flags are not enabled separately from one another.
ALPM_SIG_USE_DEFAULT is the default value when set_default_siglevel is never
called but I have no idea what that could mean when this is the value of the default.
This seems to be a circular argument with no end.
*/
#define MASK_ENABLE 1
#define MASK_OPT 3
#define MASK_TRUSTALL 12
#define MASK_ALL 15
#define OFFSET_DB 10
static
SV* truststring(unsigned long siglvl)
{
SV *str;
if(!(siglvl & MASK_ENABLE)){
return newSVpv("never", 0);
}else if(!(~siglvl & MASK_OPT)){
str = newSVpv("optional", 0);
}else{
str = newSVpv("required", 0);
}
if(!(~siglvl & MASK_TRUSTALL)){
sv_catpv(str, " trustall");
}
return str;
}
/* converts siglevel bitflags into a string (default/never) or hashref of strings */
SV*
c2p_siglevel(alpm_siglevel_t sig)
{
HV *hv;
if(sig & ALPM_SIG_USE_DEFAULT){
return newSVpv("default", 7);
}
hv = newHV();
hv_store(hv, "pkg", 3, truststring(sig & MASK_ALL), 0);
hv_store(hv, "db", 2, truststring((sig >> OFFSET_DB) & MASK_ALL), 0);
return newRV_noinc((SV*)hv);
}
static unsigned long
trustmask(char *str, STRLEN len)
{
unsigned long flags;
if(len == 5 && strncmp(str, "never", 5) == 0){
return 0;
}
( run in 0.536 second using v1.01-cache-2.11-cpan-99c4e6809bf )