[pkg-fso-commits] [SCM] Automatic Display Manager branch, bug540201, updated. debian/0.6-1-38-g11bdc2d
Enrico Zini
enrico at enricozini.org
Wed Jul 6 08:38:16 UTC 2011
The following commit has been merged in the bug540201 branch:
commit 8de41af478ea1fd01a0979ae5500810dd37321fe
Author: Enrico Zini <enrico at enricozini.org>
Date: Wed Jul 6 10:18:25 2011 +0200
Added strerror-like function for nodm error codes
diff --git a/common.c b/common.c
index a26d5fe..656af4b 100644
--- a/common.c
+++ b/common.c
@@ -29,3 +29,29 @@ const char* getenv_with_default(const char* envname, const char* def)
else
return def;
}
+
+const char* nodm_strerror(int code)
+{
+ switch (code)
+ {
+ case E_SUCCESS: return "success";
+ case E_NOPERM: return "permission denied";
+ case E_USAGE: return "invalid command syntax";
+ case E_BAD_ARG: return "invalid argument to option";
+ case E_PASSWD_NOTFOUND: return "not found password file";
+ case E_SHADOW_NOTFOUND: return "not found shadow password file";
+ case E_GROUP_NOTFOUND: return "not found group file";
+ case E_GSHADOW_NOTFOUND: return "not found shadow group file";
+ case E_CMD_NOEXEC: return "can't run command/shell";
+ case E_CMD_NOTFOUND: return "can't find command/shell to run";
+ case E_PROGRAMMING: return "Programming error";
+ case E_PAM_ERROR: return "something wrong talking with PAM";
+ case E_OS_ERROR: return "something wrong talking with the Operating System";
+ case E_XLIB_ERROR: return "Xlib error";
+ case E_X_SERVER_DIED: return "Server died";
+ case E_X_SERVER_TIMEOUT: return "Server not ready before timeout";
+ case E_X_SERVER_CONNECT: return "Could not connect to X server";
+ case E_SESSION_DIED: return "X session died";
+ default: return "unknown error";
+ }
+}
diff --git a/common.h b/common.h
index 9d9443b..63f791a 100644
--- a/common.h
+++ b/common.h
@@ -57,5 +57,7 @@ const char* getenv_with_default(const char* envname, const char* def);
*/
#define bounded_strcpy(dst, src) (snprintf(dst, sizeof(dst), "%s", (src)) < sizeof(dst))
+/// Return the string description of an exit code
+const char* nodm_strerror(int code);
#endif
diff --git a/test-xsession.c b/test-xsession.c
index fff7e34..b42b4bc 100644
--- a/test-xsession.c
+++ b/test-xsession.c
@@ -81,9 +81,16 @@ int main(int argc, char* argv[])
goto cleanup;
}
+ // TODO:
+ // - test a wrong xserver command line (dying X server)
+ // - test a wrong username (dying X session)
+ // - start everything fine then kill the X server
+
nodm_display_manager_cleanup(&dm);
cleanup:
+ if (res != E_SUCCESS)
+ fprintf(stderr, "Error: %s\n", nodm_strerror(res));
log_end();
return res;
}
--
Automatic Display Manager
More information about the pkg-fso-commits
mailing list