diff options
-rw-r--r-- | URPM.xs | 76 |
1 files changed, 25 insertions, 51 deletions
@@ -1428,46 +1428,34 @@ Pkg_DESTROY(pkg) void Pkg_name(pkg) URPM::Package pkg + ALIAS: + version = 1 + release = 2 + arch = 3 PPCODE: if (pkg->info) { - char *name; - char *version; - - get_fullname_parts(pkg, &name, &version, NULL, NULL, NULL); - if (version - name < 1) croak("invalid fullname"); - mXPUSHs(newSVpv(name, version-name-1)); - } else if (pkg->h) { - mXPUSHs(newSVpv(get_name(pkg->h, RPMTAG_NAME), 0)); - } - -void -Pkg_version(pkg) - URPM::Package pkg - PPCODE: - if (pkg->info) { - char *version; - char *release; - - get_fullname_parts(pkg, NULL, &version, &release, NULL, NULL); - if (release - version < 1) croak("invalid fullname"); - mXPUSHs(newSVpv(version, release-version-1)); - } else if (pkg->h) { - mXPUSHs(newSVpv(get_name(pkg->h, RPMTAG_VERSION), 0)); - } - -void -Pkg_release(pkg) - URPM::Package pkg - PPCODE: - if (pkg->info) { - char *release; - char *arch; - - get_fullname_parts(pkg, NULL, NULL, &release, &arch, NULL); - if (arch - release < 1) croak("invalid fullname"); - mXPUSHs(newSVpv(release, arch-release-1)); + char *name, *version, *release, *arch, *eos; + char *res; + STRLEN end; + + get_fullname_parts(pkg, &name, &version, &release, &arch, &eos); + switch (ix) { + case 1: res = version; end = release - version; break; + case 2: res = release; end = arch-release; break; + case 3: res = arch; end = eos-arch+1; break; + default: res = name; end = version - name; + } + if (end < 1) croak("invalid fullname"); + mXPUSHs(newSVpv(res, end-1)); } else if (pkg->h) { - mXPUSHs(newSVpv(get_name(pkg->h, RPMTAG_RELEASE), 0)); + char *str; + switch (ix) { + case 1: str = get_name(pkg->h, RPMTAG_VERSION); break; + case 2: str = get_name(pkg->h, RPMTAG_RELEASE); break; + case 3: str = get_arch(pkg->h); break; + default: str = get_name(pkg->h, RPMTAG_NAME); + } + mXPUSHs(newSVpv(str, 0)); } void @@ -1503,20 +1491,6 @@ Pkg_EVR(pkg) free(s); } -void -Pkg_arch(pkg) - URPM::Package pkg - PPCODE: - if (pkg->info) { - char *arch; - char *eos; - - get_fullname_parts(pkg, NULL, NULL, NULL, &arch, &eos); - mXPUSHs(newSVpv(arch, eos-arch)); - } else if (pkg->h) { - mXPUSHs(newSVpv(get_arch(pkg->h), 0)); - } - int Pkg_is_arch_compat__XS(pkg) URPM::Package pkg |