Commit 1929471d authored by Pavel Šimerda's avatar Pavel Šimerda
Browse files

platform: use NMPlatformError type instead of int

parent a6a33058
...@@ -129,6 +129,19 @@ nm_platform_get (void) ...@@ -129,6 +129,19 @@ nm_platform_get (void)
/******************************************************************/ /******************************************************************/
/**
* nm_platform_set_error:
* @error: The error code
*
* Convenience function to falsify platform->error. It can be used for example
* by functions that want to save the error, execute some operations and
* restore it.
*/
void nm_platform_set_error (NMPlatformError error)
{
platform->error = error;
}
/** /**
* nm_platform_get_error: * nm_platform_get_error:
* *
...@@ -137,7 +150,7 @@ nm_platform_get (void) ...@@ -137,7 +150,7 @@ nm_platform_get (void)
* *
* Returns: Integer error code. * Returns: Integer error code.
*/ */
int NMPlatformError
nm_platform_get_error (void) nm_platform_get_error (void)
{ {
g_assert (platform); g_assert (platform);
......
...@@ -34,6 +34,17 @@ ...@@ -34,6 +34,17 @@
/******************************************************************/ /******************************************************************/
typedef enum {
/* no error specified, sometimes this means the arguments were wrong */
NM_PLATFORM_ERROR_NONE,
/* object was not found */
NM_PLATFORM_ERROR_NOT_FOUND,
/* object already exists */
NM_PLATFORM_ERROR_EXISTS,
/* object is not a slave */
NM_PLATFORM_ERROR_NOT_SLAVE
} NMPlatformError;
typedef enum { typedef enum {
NM_LINK_TYPE_NONE, NM_LINK_TYPE_NONE,
NM_LINK_TYPE_UNKNOWN, NM_LINK_TYPE_UNKNOWN,
...@@ -117,7 +128,7 @@ typedef struct { ...@@ -117,7 +128,7 @@ typedef struct {
typedef struct { typedef struct {
GObject parent; GObject parent;
int error; NMPlatformError error;
} NMPlatform; } NMPlatform;
typedef struct { typedef struct {
...@@ -206,18 +217,6 @@ typedef struct { ...@@ -206,18 +217,6 @@ typedef struct {
#define NM_PLATFORM_IP6_ROUTE_CHANGED "ip6-route-changed" #define NM_PLATFORM_IP6_ROUTE_CHANGED "ip6-route-changed"
#define NM_PLATFORM_IP6_ROUTE_REMOVED "ip6-route-removed" #define NM_PLATFORM_IP6_ROUTE_REMOVED "ip6-route-removed"
/* NMPlatform error codes */
enum {
/* no error specified, sometimes this means the arguments were wrong */
NM_PLATFORM_ERROR_NONE,
/* object was not found */
NM_PLATFORM_ERROR_NOT_FOUND,
/* object already exists */
NM_PLATFORM_ERROR_EXISTS,
/* object is not a slave */
NM_PLATFORM_ERROR_NOT_SLAVE
};
/******************************************************************/ /******************************************************************/
GType nm_platform_get_type (void); GType nm_platform_get_type (void);
...@@ -228,7 +227,8 @@ void nm_platform_free (void); ...@@ -228,7 +227,8 @@ void nm_platform_free (void);
/******************************************************************/ /******************************************************************/
int nm_platform_get_error (void); void nm_platform_set_error (NMPlatformError error);
NMPlatformError nm_platform_get_error (void);
const char *nm_platform_get_error_msg (void); const char *nm_platform_get_error_msg (void);
gboolean nm_platform_sysctl_set (const char *path, const char *value); gboolean nm_platform_sysctl_set (const char *path, const char *value);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment