API cs_version_ex(): since we already broke API compatibility, we are not afraid to break cs_version() too. this replaces cs_version() with cs_version_ex()

This commit is contained in:
Nguyen Anh Quynh 2013-12-28 13:59:09 +08:00
parent a09bd630cf
commit b90cb993ed
2 changed files with 8 additions and 22 deletions

8
cs.c
View File

@ -19,13 +19,7 @@ cs_err (*arch_option[MAX_ARCH]) (cs_struct*, cs_opt_type, size_t value);
unsigned int all_arch = 0; unsigned int all_arch = 0;
void cs_version(int *major, int *minor) unsigned int cs_version(int *major, int *minor)
{
*major = CS_API_MAJOR;
*minor = CS_API_MINOR;
}
unsigned int cs_version_ex(int *major, int *minor)
{ {
if (major != NULL && minor != NULL) { if (major != NULL && minor != NULL) {
*major = CS_API_MAJOR; *major = CS_API_MAJOR;

View File

@ -17,7 +17,7 @@ extern "C" {
#define CS_API_MINOR 1 #define CS_API_MINOR 1
// Macro to create combined version which can be compared to // Macro to create combined version which can be compared to
// result of cs_version_ex() API. // result of cs_version() API.
#define CS_MAKE_VERSION(major, minor) ((major << 8) + minor) #define CS_MAKE_VERSION(major, minor) ((major << 8) + minor)
// Handle using with all API // Handle using with all API
@ -141,32 +141,24 @@ typedef enum cs_err {
CS_ERR_DETAIL, // Information is unavailable because detail option is OFF CS_ERR_DETAIL, // Information is unavailable because detail option is OFF
} cs_err; } cs_err;
/*
Retrieve API version in major and minor numbers.
@major: major number of API version
@minor: minor number of API version
For example, first API version would return 1 in @major, and 0 in @minor
*/
void cs_version(int *major, int *minor);
/* /*
Return combined API version & major and minor version numbers. Return combined API version & major and minor version numbers.
@major: major number of API version @major: major number of API version
@minor: minor number of API version @minor: minor number of API version
@return hexical number encoding both major & minor versions, which is comparisonable. @return hexical number as (major << 8 | minor), which encodes both
major & minor versions.
NOTE: This returned value can be compared with version number made
with macro CS_MAKE_VERSION
For example, second API version would return 1 in @major, and 1 in @minor For example, second API version would return 1 in @major, and 1 in @minor
The return value would be 0x0101 The return value would be 0x0101
NOTE: if you only care about returned value, but not major and minor values, NOTE: if you only care about returned value, but not major and minor values,
set both arguments to NULL. set both @major & @minor arguments to NULL.
*/ */
unsigned int cs_version_ex(int *major, int *minor); unsigned int cs_version(int *major, int *minor);
/* /*