libxbps: two new functions to get the pkgver and arch components in a filename.

- xbps_binpkg_pkgver() returns a heap allocated string with the pkgver component.
- xbps_binpkg_arch() returns a heap allocated string with the architecture component.

A basename, full path or relative path is supported, i.e:

	/path/to/foo-1.0_1.x86_64.xbps
	../../foo/blah-0.1_1.x86_64.xbps
	baz-0.1_1.x86_64.xbps
This commit is contained in:
Juan RP
2014-09-05 20:59:00 +02:00
parent e2470f8697
commit 5863ec17fe
2 changed files with 116 additions and 1 deletions

View File

@@ -1713,6 +1713,30 @@ char *xbps_pkgpattern_name(const char *pattern);
*/
const char *xbps_pkg_version(const char *pkg);
/**
* Gets the pkgname/version componentn of a binary package string,
* i.e <b>foo-2.0_1.<arch>.xbps</b>.
*
* @param[in] pkg Package string.
*
* @return A pointer to a malloc(ed) string with the pkgver component,
* NULL if it couldn't find the version component. The pointer should
* be free(3)d when it's no longer needed.
*/
char *xbps_binpkg_pkgver(const char *pkg);
/**
* Gets the architecture component of a binary package string,
* i.e <b><pkgver>.<arch>.xbps</b>.
*
* @param[in] pkg Package string.
*
* @return A pointer to a malloc(ed) string with the architecture component,
* NULL if it couldn't find the version component. The pointer should
* be free(3)d when it's no longer needed.
*/
char *xbps_binpkg_arch(const char *pkg);
/**
* Gets the package version of a package pattern string specified by
* the \a pattern argument.