Changeset 4e29ecb for zephyr.c


Ignore:
Timestamp:
Mar 24, 2011, 4:56:24 PM (13 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, release-1.10, release-1.8, release-1.9
Children:
3a3863e
Parents:
5d56a27
Message:
Add zuser_realm and use it

We do not consistently (or correctly) extract the realm from a zuser.
Add a function and use it instead of ad-hoc strchr munging.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • zephyr.c

    r5d56a27 r4e29ecb  
    771771      char *buff;
    772772      owl_zwrite zw;
    773       char *realm;
    774773
    775774      tmp = short_zuser(retnotice->z_recipient);
     
    804803      zw.class = g_strdup(retnotice->z_class);
    805804      zw.inst  = g_strdup(retnotice->z_class_inst);
    806       realm = strchr(retnotice->z_recipient, '@');
    807       if(realm) {
    808         zw.realm = g_strdup(realm + 1);
    809       } else {
    810         zw.realm = g_strdup(owl_zephyr_get_realm());
    811       }
     805      zw.realm = g_strdup(zuser_realm(retnotice->z_recipient));
    812806      zw.opcode = g_strdup(retnotice->z_opcode);
    813807      zw.zsig   = g_strdup("");
     
    11871181  }
    11881182  return g_strdup_printf("%s@%s", in, owl_zephyr_get_realm());
     1183}
     1184
     1185/* Return the realm of the zephyr user name. Caller does /not/ free the return.
     1186 * The string is valid at least as long as the input is.
     1187 */
     1188const char *zuser_realm(const char *in)
     1189{
     1190  char *ptr = strrchr(in, '@');
     1191  /* If the name has an @ and does not end with @, use that. Otherwise, take
     1192   * the default realm. */
     1193  return (ptr && ptr[1]) ? (ptr+1) : owl_zephyr_get_realm();
    11891194}
    11901195
Note: See TracChangeset for help on using the changeset viewer.