Changeset e778351 for zephyr.c


Ignore:
Timestamp:
Mar 25, 2011, 10:58:23 PM (13 years ago)
Author:
Jason Gross <jgross@mit.edu>
Parents:
f27b044
Message:
Ability to set exposure arbitrarily (like "zctl set exposure")

A zephyr variable 'exposure' has been added.  It defaults to the value
in ~/.zephyr.vars, if there is one, or to realm-visible.  Setting this
variable does not affect the value in ~/.zephyr.vars.

Additionally, OWLVAR_STRING_FULL has been modified to allow custom
setting of validset.

This fixes ticket # 65.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • zephyr.c

    rfe3b017 re778351  
    10191019{
    10201020#ifdef HAVE_LIBZEPHYR
    1021   char *exposure, *eset;
    10221021  Code_t ret;
    10231022
    10241023  ZResetAuthentication();
    10251024
    1026   eset = EXPOSE_REALMVIS;
    1027   exposure = ZGetVariable(zstr("exposure"));
    1028   if (exposure)
    1029     exposure = ZParseExposureLevel(exposure);
    1030   if (exposure)
    1031     eset = exposure;
    1032    
    1033   ret = ZSetLocation(eset);
     1025  ret = ZSetLocation(zstr(owl_global_get_exposure(&g)));
     1026
    10341027  if (ret != ZERR_NONE)
    10351028    owl_function_error("Error setting location: %s", error_message(ret));
     
    11531146#ifdef HAVE_LIBZEPHYR
    11541147  ZInitLocationInfo(zstr(host), zstr(val));
     1148#endif
     1149}
     1150
     1151int owl_zephyr_set_exposure(const char *exposure)
     1152{
     1153#ifdef HAVE_LIBZEPHYR
     1154  Code_t ret;
     1155  if (exposure == NULL)
     1156    return -1;
     1157  exposure = ZParseExposureLevel(zstr(exposure));
     1158  if (exposure == NULL)
     1159    return -1;
     1160  ret = ZSetLocation(zstr(exposure));
     1161  if (ret != ZERR_NONE) {
     1162    owl_function_debugmsg("Unable to set exposure location to %s (%s)", exposure, error_message(ret));
     1163    return -1; /* I don't like this.  We should return -1, because we failed,
     1164                * but the user gets a message that implies that the value they
     1165                * gave is wrong.
     1166                */
     1167  }
     1168  ret = ZSetVariable(zstr("exposure"), zstr(exposure));
     1169  if (ret != ZERR_NONE) {
     1170    owl_function_debugmsg("Unable to set exposure variable to %s (%s)", exposure, error_message(ret));
     1171    return -1; /* ditto the above comment */
     1172  }
     1173#endif
     1174  return 0;
     1175}
     1176
     1177const char *owl_zephyr_get_exposure(void)
     1178{
     1179#ifdef HAVE_LIBZEPHYR
     1180  const char *exposure = ZParseExposureLevel(ZGetVariable(zstr("exposure")));
     1181  if (exposure == NULL)
     1182    exposure = EXPOSE_REALMVIS;
     1183  return exposure;
     1184#else
     1185  return "";
    11551186#endif
    11561187}
Note: See TracChangeset for help on using the changeset viewer.