]> git.sur5r.net Git - ngadmin/blobdiff - lib/src/misc.c
Factorize string related functions
[ngadmin] / lib / src / misc.c
index 39abde3ef9e29ac90016bec34bff54cc8daa70a6..5baee9e9694be848c83957bdaa6b7b3823d558c0 100644 (file)
@@ -3,12 +3,36 @@
 
 #include <nsdp/attr.h>
 #include <nsdp/protocol.h>
-#include <nsdp/misc.h>
+#include <nsdp/str.h>
 
 #include "lib.h"
 #include "network.h"
 
 
+static const char* const liberror_str_tab[] = {
+       [-ERR_OK] = "no error",
+       [-ERR_NET] = "network error",
+       [-ERR_NOTLOG] "not logged",
+       [-ERR_DENIED] = "access denied",
+       [-ERR_BADPASS] = "bad password",
+       [-ERR_BADID] = "bad id",
+       [-ERR_INVARG] = "invalid argument",
+       [-ERR_TIMEOUT] = "timeout",
+       [-ERR_MEM] = "out of memory",
+       [-ERR_NOTIMPL] = "not implemented",
+       [-ERR_BADREPLY] = "bad reply",
+       [-ERR_INVOP] = "invalid operation",
+       [-ERR_UNKNOWN] = "unknown error",
+       NULL
+};
+
+
+const char* ngadmin_errorStr (int error)
+{
+       return getValueStr(liberror_str_tab, -ERR_OK, -ERR_UNKNOWN, -error);
+}
+
+
 int ngadmin_setName (struct ngadmin *nga, const char *name)
 {
        List *attr;