[2934] in BarnOwl Developers

home help back first fref pref prev next nref lref last post

[PATCH 5/5] refactor owl_zephyr_zlog_in and report errors in owl_zephyr_zlog_{in,out}

daemon@ATHENA.MIT.EDU (Karl Ramm)
Fri Feb 25 21:24:35 2011

From: Karl Ramm <kcr@1ts.org>
To: barnowl-dev@mit.edu
Cc: Karl Ramm <kcr@1ts.org>
Date: Fri, 25 Feb 2011 21:24:21 -0500
In-Reply-To: <uussjvbr0tc.fsf@1ts.org>

Use the function ZParseExposureLevel thoughtfully provided by the library,
and see what happens when we actually report errors that occur here.
---
 zephyr.c |   49 ++++++++++++++++---------------------------------
 1 files changed, 16 insertions(+), 33 deletions(-)

diff --git a/zephyr.c b/zephyr.c
index 155146c..84b3c4c 100644
--- a/zephyr.c
+++ b/zephyr.c
@@ -1025,50 +1025,33 @@ char *owl_zephyr_makesubline(const char *class, const char *inst, const char *re
 void owl_zephyr_zlog_in(void)
 {
 #ifdef HAVE_LIBZEPHYR
-  const char *exposure, *eset;
-  int ret;
+  char *exposure, *eset;
+  Code_t ret;
 
   ZResetAuthentication();
-    
-  eset=EXPOSE_REALMVIS;
-  exposure=ZGetVariable(zstr("exposure"));
-  if (exposure==NULL) {
-    eset=EXPOSE_REALMVIS;
-  } else if (!strcasecmp(exposure,EXPOSE_NONE)) {
-    eset = EXPOSE_NONE;
-  } else if (!strcasecmp(exposure,EXPOSE_OPSTAFF)) {
-    eset = EXPOSE_OPSTAFF;
-  } else if (!strcasecmp(exposure,EXPOSE_REALMVIS)) {
-    eset = EXPOSE_REALMVIS;
-  } else if (!strcasecmp(exposure,EXPOSE_REALMANN)) {
-    eset = EXPOSE_REALMANN;
-  } else if (!strcasecmp(exposure,EXPOSE_NETVIS)) {
-    eset = EXPOSE_NETVIS;
-  } else if (!strcasecmp(exposure,EXPOSE_NETANN)) {
-    eset = EXPOSE_NETANN;
-  }
+
+  eset = EXPOSE_REALMVIS;
+  exposure = ZGetVariable(zstr("exposure"));
+  if (exposure)
+    exposure = ZParseExposureLevel(exposure);
+  if (exposure)
+    eset = exposure;
    
-  ret=ZSetLocation(zstr(eset));
-  if (ret != ZERR_NONE) {
-    /*
-      owl_function_makemsg("Error setting location: %s", error_message(ret));
-    */
-  }
+  ret = ZSetLocation(eset);
+  if (ret != ZERR_NONE)
+    owl_function_error("Error setting location: %s", error_message(ret));
 #endif
 }
 
 void owl_zephyr_zlog_out(void)
 {
 #ifdef HAVE_LIBZEPHYR
-  int ret;
+  Code_t ret;
 
   ZResetAuthentication();
-  ret=ZUnsetLocation();
-  if (ret != ZERR_NONE) {
-    /*
-      owl_function_makemsg("Error unsetting location: %s", error_message(ret));
-    */
-  }
+  ret = ZUnsetLocation();
+  if (ret != ZERR_NONE)
+    owl_function_error("Error unsetting location: %s", error_message(ret));
 #endif
 }
 
-- 
1.7.2.3


home help back first fref pref prev next nref lref last post