Index: ChangeLog
===================================================================
--- ChangeLog	(revision d09e5a1609d038695dbc6bc34a8177935a9bf7ea)
+++ ChangeLog	(revision 31e48a31baadb6973aeafc691fec373040f39690)
@@ -73,4 +73,6 @@
 	Added basic AIM support, including the "aimlogin", "aimwrite" and
 	   "aimlogout" commands
+	New built-in filters 'aim' and 'zephyr'.
+	Do ZResetAuthentication() before zlog_in and zlog_out as well.
 	
 1.2.8
Index: commands.c
===================================================================
--- commands.c	(revision 0ff8fb572754799e77ac2cf2d386b7699f995257)
+++ commands.c	(revision 31e48a31baadb6973aeafc691fec373040f39690)
@@ -1236,5 +1236,5 @@
       owl_global_set_tty(&g, argv[2]);
     }
-    owl_function_zlog_in();
+    owl_zephyr_zlog_in();
   } else if (!strcmp(argv[1], "out")) {
     if (argc!=2) {
@@ -1242,5 +1242,5 @@
       return(NULL);
     }
-    owl_function_zlog_out();
+    owl_zephyr_zlog_out();
   } else {
     owl_function_makemsg("Invalid subcommand for zlog");
@@ -1250,6 +1250,6 @@
 
 
-void owl_command_zlog_out() {
-  owl_function_zlog_out();
+void owl_command_zlog_out(void) {
+  owl_zephyr_zlog_out();
 }
 
Index: functions.c
===================================================================
--- functions.c	(revision 0ff8fb572754799e77ac2cf2d386b7699f995257)
+++ functions.c	(revision 31e48a31baadb6973aeafc691fec373040f39690)
@@ -693,5 +693,5 @@
   /* zlog out if we need to */
   if (owl_global_is_shutdownlogout(&g)) {
-    owl_function_zlog_out();
+    owl_zephyr_zlog_out();
   }
 
@@ -711,52 +711,4 @@
   owl_function_debugmsg("Quitting Owl");
   exit(0);
-}
-
-
-void owl_function_zlog_in()
-{
-  char *exposure, *eset;
-  int ret;
-
-  eset=EXPOSE_REALMVIS;
-  exposure=ZGetVariable("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;
-  }
-   
-  ret=ZSetLocation(eset);
-  if (ret != ZERR_NONE) {
-    /*
-      char buff[LINE];
-      sprintf(buff, "Error setting location: %s", error_message(ret));
-      owl_function_makemsg(buff);
-    */
-  }
-}
-
-void owl_function_zlog_out()
-{
-  int ret;
-  
-  ret=ZUnsetLocation();
-  if (ret != ZERR_NONE) {
-    /*
-      char buff[LINE];
-      sprintf(buff, "Error unsetting location: %s", error_message(ret));
-      owl_function_makemsg(buff);
-    */
-  }
 }
 
Index: owl.c
===================================================================
--- owl.c	(revision d09e5a1609d038695dbc6bc34a8177935a9bf7ea)
+++ owl.c	(revision 31e48a31baadb6973aeafc691fec373040f39690)
@@ -167,4 +167,12 @@
 
   f=malloc(sizeof(owl_filter));
+  owl_filter_init_fromstring(f, "aim", "type ^aim$");
+  owl_list_append_element(owl_global_get_filterlist(&g), f);
+
+  f=malloc(sizeof(owl_filter));
+  owl_filter_init_fromstring(f, "zephyr", "type ^zephyr$");
+  owl_list_append_element(owl_global_get_filterlist(&g), f);
+
+  f=malloc(sizeof(owl_filter));
   owl_filter_init_fromstring(f, "none", "false");
   owl_list_append_element(owl_global_get_filterlist(&g), f);
@@ -212,5 +220,5 @@
   /* zlog in if we need to */
   if (owl_global_is_startuplogin(&g)) {
-    owl_function_zlog_in();
+    owl_zephyr_zlog_in();
   }
 
Index: owl_prototypes.h
===================================================================
--- owl_prototypes.h	(revision 0ff8fb572754799e77ac2cf2d386b7699f995257)
+++ owl_prototypes.h	(revision 31e48a31baadb6973aeafc691fec373040f39690)
@@ -80,5 +80,5 @@
 extern char *owl_command_term(int argc, char **argv, char *buff);
 extern char *owl_command_zlog(int argc, char **argv, char *buff);
-extern void owl_command_zlog_out();
+extern void owl_command_zlog_out(void);
 extern char *owl_command_subscribe(int argc, char **argv, char *buff);
 extern char *owl_command_unsubscribe(int argc, char **argv, char *buff);
@@ -309,6 +309,4 @@
 extern void owl_function_zaway_off();
 extern void owl_function_quit();
-extern void owl_function_zlog_in();
-extern void owl_function_zlog_out();
 extern void owl_function_makemsg(char *fmt, ...);
 extern void owl_function_errormsg(char *fmt, ...);
@@ -931,4 +929,6 @@
 extern void owl_zephyr_delsub(char *filename, char *class, char *inst, char *recip);
 extern char *owl_zephyr_makesubline(char *class, char *inst, char *recip);
+extern void owl_zephyr_zlog_in(void);
+extern void owl_zephyr_zlog_out(void);
 
 /* -------------------------------- zwrite.c -------------------------------- */
Index: zephyr.c
===================================================================
--- zephyr.c	(revision 8262340da7afa4c7f9e0d5bdcfee0e8006bf087d)
+++ zephyr.c	(revision 31e48a31baadb6973aeafc691fec373040f39690)
@@ -12,5 +12,6 @@
 Code_t ZResetAuthentication();
 
-int owl_zephyr_loadsubs(char *filename) {
+int owl_zephyr_loadsubs(char *filename)
+{
   /* return 0  on success
    *        -1 on file error
@@ -84,5 +85,6 @@
 }
 
-int owl_zephyr_loadloginsubs(char *filename) {
+int owl_zephyr_loadloginsubs(char *filename)
+{
   FILE *file;
   ZSubscription_t subs[3001];
@@ -139,5 +141,6 @@
 }
 
-void unsuball() {
+void unsuball()
+{
   int ret;
 
@@ -149,5 +152,6 @@
 }
 
-int owl_zephyr_sub(char *class, char *inst, char *recip) {
+int owl_zephyr_sub(char *class, char *inst, char *recip)
+{
   ZSubscription_t subs[5];
   int ret;
@@ -166,5 +170,6 @@
 
 
-int owl_zephyr_unsub(char *class, char *inst, char *recip) {
+int owl_zephyr_unsub(char *class, char *inst, char *recip)
+{
   ZSubscription_t subs[5];
   int ret;
@@ -183,5 +188,6 @@
 
 
-char *owl_zephyr_get_field(ZNotice_t *n, int j, int *k) {
+char *owl_zephyr_get_field(ZNotice_t *n, int j, int *k)
+{
   /* return a pointer to the Jth field, place the length in k.  If the
      field doesn't exist return an emtpy string */
@@ -212,5 +218,6 @@
 
 
-int owl_zephyr_get_num_fields(ZNotice_t *n) {
+int owl_zephyr_get_num_fields(ZNotice_t *n)
+{
   int i, fields;
 
@@ -224,5 +231,6 @@
 
 
-char *owl_zephyr_get_message(ZNotice_t *n, int *k) {
+char *owl_zephyr_get_message(ZNotice_t *n, int *k)
+{
   /* return a pointer to the message, place the message length in k */
   if (!strcasecmp(n->z_opcode, "ping")) {
@@ -235,5 +243,6 @@
 
 
-char *owl_zephyr_get_zsig(ZNotice_t *n, int *k) {
+char *owl_zephyr_get_zsig(ZNotice_t *n, int *k)
+{
   /* return a pointer to the zsig if there is one */
 
@@ -247,5 +256,6 @@
 
 
-int send_zephyr(char *opcode, char *zsig, char *class, char *instance, char *recipient, char *message) {
+int send_zephyr(char *opcode, char *zsig, char *class, char *instance, char *recipient, char *message)
+{
   int ret;
   ZNotice_t notice;
@@ -287,13 +297,16 @@
 }
 
-Code_t send_zephyr_helper(ZNotice_t *notice, char *buf, int len, int wait) {
+Code_t send_zephyr_helper(ZNotice_t *notice, char *buf, int len, int wait)
+{
   return(ZSendPacket(buf, len, 0));
 }
 
-void send_ping(char *to) {
+void send_ping(char *to)
+{
   send_zephyr("PING", "", "MESSAGE", "PERSONAL", to, "");
 }
 
-void owl_zephyr_handle_ack(ZNotice_t *retnotice) {
+void owl_zephyr_handle_ack(ZNotice_t *retnotice)
+{
   char *tmp;
   
@@ -331,5 +344,6 @@
 }
 
-int owl_zephyr_notice_is_ack(ZNotice_t *n) {
+int owl_zephyr_notice_is_ack(ZNotice_t *n)
+{
   if (n->z_kind == SERVNAK || n->z_kind == SERVACK || n->z_kind == HMACK) {
     if (!strcasecmp(n->z_class, LOGIN_CLASS)) return(0);
@@ -339,5 +353,6 @@
 }
   
-void owl_zephyr_zaway(owl_message *m) {
+void owl_zephyr_zaway(owl_message *m)
+{
   char *tmpbuff, *myuser, *to;
   
@@ -380,5 +395,6 @@
 
 
-void owl_zephyr_hackaway_cr(ZNotice_t *n) {
+void owl_zephyr_hackaway_cr(ZNotice_t *n)
+{
   /* replace \r's with ' '.  Gross-ish */
   int i;
@@ -391,5 +407,6 @@
 }
 
-void owl_zephyr_zlocate(char *user, char *out, int auth) {
+void owl_zephyr_zlocate(char *user, char *out, int auth)
+{
   int ret, numlocs;
   int one = 1;
@@ -419,5 +436,6 @@
 }
 
-void owl_zephyr_addsub(char *filename, char *class, char *inst, char *recip) {
+void owl_zephyr_addsub(char *filename, char *class, char *inst, char *recip)
+{
   char *line, subsfile[LINE], buff[LINE];
   FILE *file;
@@ -461,5 +479,6 @@
 }
 
-void owl_zephyr_delsub(char *filename, char *class, char *inst, char *recip) {
+void owl_zephyr_delsub(char *filename, char *class, char *inst, char *recip)
+{
   char *line, subsfile[LINE], buff[LINE], *text;
   char backupfilename[LINE];
@@ -527,5 +546,6 @@
 }
 
-char *owl_zephyr_makesubline(char *class, char *inst, char *recip) {
+char *owl_zephyr_makesubline(char *class, char *inst, char *recip)
+{
   /* caller must free the return */
   char *out;
@@ -535,2 +555,54 @@
   return(out);
 }
+
+
+void owl_zephyr_zlog_in(void)
+{
+  char *exposure, *eset;
+  int ret;
+
+  ZResetAuthentication();
+    
+  eset=EXPOSE_REALMVIS;
+  exposure=ZGetVariable("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;
+  }
+   
+  ret=ZSetLocation(eset);
+  if (ret != ZERR_NONE) {
+    /*
+      char buff[LINE];
+      sprintf(buff, "Error setting location: %s", error_message(ret));
+      owl_function_makemsg(buff);
+    */
+  }
+}
+
+void owl_zephyr_zlog_out(void)
+{
+  int ret;
+
+  ZResetAuthentication();
+  ret=ZUnsetLocation();
+  if (ret != ZERR_NONE) {
+    /*
+      char buff[LINE];
+      sprintf(buff, "Error unsetting location: %s", error_message(ret));
+      owl_function_makemsg(buff);
+    */
+  }
+}
+
