]> err.no Git - yubikey-personalization.old/commitdiff
Implement error handling in the personlization library
authorlevitte <levitte@b62f149e-849f-11dd-9899-c7ba65f7c4c7>
Sat, 4 Oct 2008 13:03:26 +0000 (13:03 +0000)
committerlevitte <levitte@b62f149e-849f-11dd-9899-c7ba65f7c4c7>
Sat, 4 Oct 2008 13:03:26 +0000 (13:03 +0000)
git-svn-id: https://yubikey-personalization.googlecode.com/svn/trunk@26 b62f149e-849f-11dd-9899-c7ba65f7c4c7

ykpers.c
ykpers.h

index de0c58dfce2165a123ff9002780b938d652f0907..095cfae22033501c734d35b56d7b8ae69dd0171b 100644 (file)
--- a/ykpers.c
+++ b/ykpers.c
@@ -271,5 +271,27 @@ int ykp_read_config(CONFIG *cfg,
                                  void *userdata),
                    void *userdata)
 {
-       return -1;
+       ykp_errno = YKP_ENOTYETIMPL;
+       return 0;
+}
+
+/* As soon as we find a way to safely detect if we're in a threaded environment
+   or not, this should be changed to support per-thread locations.  Until then,
+   we only support non-threaded applications. */
+static int _ykp_errno = 0;
+
+int * const _ykp_errno_location(void)
+{
+       return &_ykp_errno;
+}
+
+static const char *errtext[] = {
+       "",
+       "not yet implemented"
+};
+const char *ykp_strerror(int errnum)
+{
+       if (errnum < sizeof(errtext)/sizeof(errtext[0]))
+               return errtext[errnum];
+       return NULL;
 }
index 3438f2947a50f50500ceccab94b1dfbdc752d36b..6f90571816c8eea9283232c42ac43893f1d87d3b 100644 (file)
--- a/ykpers.h
+++ b/ykpers.h
@@ -49,5 +49,10 @@ int ykp_read_config(CONFIG *cfg,
                                  void *userdata),
                    void *userdata);
 
+extern int * const _ykp_errno_location(void);
+#define ykp_errno (*_ykp_errno_location())
+const char *ykp_strerror(int errnum);
+
+#define YKP_ENOTYETIMPL        0x01
 
 #endif // __YKPERS_H_INCLUDED__