summaryrefslogtreecommitdiffstats
path: root/include/libimobiledevice/service.h
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2014-10-05 16:51:03 +0200
committerGravatar Martin Szulecki2014-10-05 16:51:03 +0200
commit5072dea1373b7c4789a9ea1e65d05ea30acf41ed (patch)
tree51bdd0584d727080fab86acd28bd4b360b2333bd /include/libimobiledevice/service.h
parent5552fa0fcc7501d3206fb3d3a64c1d04062ec53b (diff)
downloadlibimobiledevice-5072dea1373b7c4789a9ea1e65d05ea30acf41ed.tar.gz
libimobiledevice-5072dea1373b7c4789a9ea1e65d05ea30acf41ed.tar.bz2
Convert int16_t macro error types into enum to improve debugging/type-checking
This simple change provides various benefits for developers like compile time errors, better auto-completition in editors and the ability of a debugger to show the constant instead of just the raw value. Thanks to Aaron Burghardt for the proposal.
Diffstat (limited to 'include/libimobiledevice/service.h')
-rw-r--r--include/libimobiledevice/service.h25
1 files changed, 11 insertions, 14 deletions
diff --git a/include/libimobiledevice/service.h b/include/libimobiledevice/service.h
index acf846b..760dbb4 100644
--- a/include/libimobiledevice/service.h
+++ b/include/libimobiledevice/service.h
@@ -30,23 +30,20 @@ extern "C" {
30#include <libimobiledevice/libimobiledevice.h> 30#include <libimobiledevice/libimobiledevice.h>
31#include <libimobiledevice/lockdown.h> 31#include <libimobiledevice/lockdown.h>
32 32
33/** @name Error Codes */ 33/** Error Codes */
34/*@{*/ 34typedef enum {
35#define SERVICE_E_SUCCESS 0 35 SERVICE_E_SUCCESS = 0,
36#define SERVICE_E_INVALID_ARG -1 36 SERVICE_E_INVALID_ARG = -1,
37#define SERVICE_E_MUX_ERROR -3 37 SERVICE_E_MUX_ERROR = -3,
38#define SERVICE_E_SSL_ERROR -4 38 SERVICE_E_SSL_ERROR = -4,
39#define SERVICE_E_START_SERVICE_ERROR -5 39 SERVICE_E_START_SERVICE_ERROR = -5,
40#define SERVICE_E_UNKNOWN_ERROR -256 40 SERVICE_E_UNKNOWN_ERROR = -256
41/*@}*/ 41} service_error_t;
42
43/** Represents an error code. */
44typedef int16_t service_error_t;
45 42
46typedef struct service_client_private service_client_private; 43typedef struct service_client_private service_client_private;
47typedef service_client_private* service_client_t; /**< The client handle. */ 44typedef service_client_private* service_client_t; /**< The client handle. */
48 45
49#define SERVICE_CONSTRUCTOR(x) (int16_t (*)(idevice_t, lockdownd_service_descriptor_t, void**))(x) 46#define SERVICE_CONSTRUCTOR(x) (int32_t (*)(idevice_t, lockdownd_service_descriptor_t, void**))(x)
50 47
51/* Interface */ 48/* Interface */
52 49
@@ -79,7 +76,7 @@ service_error_t service_client_new(idevice_t device, lockdownd_service_descripto
79 * @return SERVICE_E_SUCCESS on success, or a SERVICE_E_* error code 76 * @return SERVICE_E_SUCCESS on success, or a SERVICE_E_* error code
80 * otherwise. 77 * otherwise.
81 */ 78 */
82service_error_t service_client_factory_start_service(idevice_t device, const char* service_name, void **client, const char* label, int16_t (*constructor_func)(idevice_t, lockdownd_service_descriptor_t, void**), int16_t *error_code); 79service_error_t service_client_factory_start_service(idevice_t device, const char* service_name, void **client, const char* label, int32_t (*constructor_func)(idevice_t, lockdownd_service_descriptor_t, void**), int32_t *error_code);
83 80
84/** 81/**
85 * Frees a service instance. 82 * Frees a service instance.