Index: ChangeLog
===================================================================
--- ChangeLog	(revision 4b464a43720ec7191ae97a55c10c3e66721ed93f)
+++ ChangeLog	(revision 56330ff446252c0365171404538ca1092326c051)
@@ -16,4 +16,6 @@
 	Renamed pretty_sender to short_zuser and renamed long_sender to
              long_zuser
+	Moved zsig generation to the zwrite object
+	Print the zsig used for outgoing messages
 	
 1.2.2
Index: functions.c
===================================================================
--- functions.c	(revision 4b464a43720ec7191ae97a55c10c3e66721ed93f)
+++ functions.c	(revision 56330ff446252c0365171404538ca1092326c051)
@@ -80,5 +80,5 @@
 }
 
-void owl_function_make_outgoing_zephyr(char *header, char *body, char *zwriteline) {
+void owl_function_make_outgoing_zephyr(char *header, char *body, char *zwriteline, char *zsig) {
   owl_message *m;
   int followlast;
@@ -94,5 +94,5 @@
    * Right now this only works for one recipient */
   tobuff=owl_malloc(strlen(owl_zwrite_get_recip_n(&z, 0))+100);
-  sprintf(tobuff, "Zephyr sent to %s", owl_zwrite_get_recip_n(&z, 0));
+  sprintf(tobuff, "Zephyr sent to %s  (Zsig: %s)", owl_zwrite_get_recip_n(&z, 0), zsig);
 
   /* create the message */
@@ -129,4 +129,5 @@
   owl_global_set_needrefresh(&g);
   owl_free(tobuff);
+  owl_zwrite_free(&z);
 }
 
@@ -153,6 +154,5 @@
   /* create and setup the editwin */
   e=owl_global_get_typwin(&g);
-  owl_editwin_new_style(e, OWL_EDITWIN_STYLE_MULTILINE,
-			owl_global_get_msg_history(&g));
+  owl_editwin_new_style(e, OWL_EDITWIN_STYLE_MULTILINE, owl_global_get_msg_history(&g));
 
   if (!owl_global_get_lockout_ctrld(&g)) {
@@ -183,9 +183,9 @@
   owl_function_makemsg("Waiting for ack...");
 
-  /* display the message as an admin message in the receive window */
+  /* display the message as an outgoing message in the receive window */
   if (owl_global_is_displayoutgoing(&g) && owl_zwrite_is_personal(&z)) {
     owl_zwrite_get_recipstr(&z, buff);
     tmpbuff = owl_sprintf("Message sent to %s", buff);
-    owl_function_make_outgoing_zephyr(tmpbuff, owl_editwin_get_text(owl_global_get_typwin(&g)), line);
+    owl_function_make_outgoing_zephyr(tmpbuff, owl_editwin_get_text(owl_global_get_typwin(&g)), line, owl_zwrite_get_zsig(&z));
     owl_free(tmpbuff);
   }
Index: owl.h
===================================================================
--- owl.h	(revision 4b464a43720ec7191ae97a55c10c3e66721ed93f)
+++ owl.h	(revision 56330ff446252c0365171404538ca1092326c051)
@@ -219,4 +219,5 @@
   char realm[LINE];
   char opcode[LINE];
+  char *zsig;
   owl_list recips;
   int cc;
Index: zephyr.c
===================================================================
--- zephyr.c	(revision 4b464a43720ec7191ae97a55c10c3e66721ed93f)
+++ zephyr.c	(revision 56330ff446252c0365171404538ca1092326c051)
@@ -6,5 +6,4 @@
 #include <zephyr/zephyr.h>
 #include <com_err.h>
-#include <pwd.h>
 #include "owl.h"
 
@@ -259,46 +258,4 @@
   int ret;
   ZNotice_t notice;
-  char *ptr;
-  struct passwd *pw;
-  char zsigtmp[LINE];
-  char *zsigexec, *zsigowlvar, *zsigzvar;
-  
-  zsigexec = owl_global_get_zsig_exec(&g);
-  zsigowlvar = owl_global_get_zsig(&g);
-  zsigzvar = ZGetVariable("zwrite-signature");
-
-  if (zsig) {
-    strcpy(zsigtmp, zsig);
-  } else if (zsigowlvar && *zsigowlvar) {
-    strncpy(zsigtmp, zsigowlvar, LINE);
-  } else if (zsigexec && *zsigexec) {
-    FILE *file;
-    char buff[LINE];
-    strcpy(zsigtmp, "");
-    file=popen(zsigexec, "r");
-    if (!file) {
-      if (zsigzvar && *zsigzvar) {
-	strncpy(zsigtmp, zsigzvar, LINE);
-      }
-    } else {
-      while (fgets(buff, LINE, file)) { /* wrong sizing */
-	strcat(zsigtmp, buff);
-      }
-      pclose(file);
-      if (zsigtmp[strlen(zsigtmp)-1]=='\n') {
-	zsigtmp[strlen(zsigtmp)-1]='\0';
-      }
-    }
-  } else if (zsigzvar) {
-    strncpy(zsigtmp, zsigzvar, LINE);
-  } else if (((pw=getpwuid(getuid()))!=NULL) && (pw->pw_gecos)) {
-    strncpy(zsigtmp, pw->pw_gecos, LINE);
-    ptr=strchr(zsigtmp, ',');
-    if (ptr) {
-      ptr[0]='\0';
-    }
-  } else {
-    strcpy(zsigtmp, "");
-  }
     
   memset(&notice, 0, sizeof(notice));
@@ -317,8 +274,8 @@
   if (opcode) notice.z_opcode=opcode;
 
-  notice.z_message_len=strlen(zsigtmp)+1+strlen(message);
+  notice.z_message_len=strlen(zsig)+1+strlen(message);
   notice.z_message=owl_malloc(notice.z_message_len+10);
-  strcpy(notice.z_message, zsigtmp);
-  memcpy(notice.z_message+strlen(zsigtmp)+1, message, strlen(message));
+  strcpy(notice.z_message, zsig);
+  memcpy(notice.z_message+strlen(zsig)+1, message, strlen(message));
 
   /* ret=ZSendNotice(&notice, ZAUTH); */
Index: zwrite.c
===================================================================
--- zwrite.c	(revision 4b464a43720ec7191ae97a55c10c3e66721ed93f)
+++ zwrite.c	(revision 56330ff446252c0365171404538ca1092326c051)
@@ -1,3 +1,6 @@
 #include <string.h>
+#include <pwd.h>
+#include <sys/types.h>
+#include <unistd.h>
 #include "owl.h"
 
@@ -17,4 +20,6 @@
   int argc, badargs, myargc;
   char **argv, **myargv;
+  char *zsigexec, *zsigowlvar, *zsigzvar, *ptr;
+  struct passwd *pw;
 
   badargs=0;
@@ -25,4 +30,5 @@
   strcpy(z->inst, "personal");
   strcpy(z->opcode, "");
+  z->zsig=owl_strdup("");
   z->cc=0;
   z->noping=0;
@@ -103,4 +109,46 @@
   }
 
+  /* set a zsig */
+  zsigexec = owl_global_get_zsig_exec(&g);
+  zsigowlvar = owl_global_get_zsig(&g);
+  zsigzvar = ZGetVariable("zwrite-signature");
+
+  if (zsigowlvar && *zsigowlvar) {
+    owl_free(z->zsig);
+    z->zsig=strdup(zsigowlvar);
+  } else if (zsigexec && *zsigexec) {
+    FILE *file;
+    char buff[LINE];
+
+    file=popen(zsigexec, "r");
+    if (!file) {
+      if (zsigzvar && *zsigzvar) {
+	owl_free(z->zsig);
+	z->zsig=owl_strdup(zsigzvar);
+      }
+    } else {
+      owl_free(z->zsig);
+      z->zsig=owl_malloc(LINE);
+      strcpy(z->zsig, "");
+      while (fgets(buff, LINE, file)) { /* wrong sizing */
+	strcat(z->zsig, buff);
+      }
+      pclose(file);
+      if (z->zsig[strlen(z->zsig)-1]=='\n') {
+	z->zsig[strlen(z->zsig)-1]='\0';
+      }
+    }
+  } else if (zsigzvar) {
+    owl_free(z->zsig);
+    z->zsig=owl_strdup(zsigzvar);
+  } else if (((pw=getpwuid(getuid()))!=NULL) && (pw->pw_gecos)) {
+    owl_free(z->zsig);
+    z->zsig=strdup(pw->pw_gecos);
+    ptr=strchr(z->zsig, ',');
+    if (ptr) {
+      ptr[0]='\0';
+    }
+  }
+
   return(0);
 }
@@ -160,7 +208,7 @@
       }
       if (z->cc) {
-	send_zephyr(z->opcode, NULL, z->class, z->inst, to, tmpmsg);
+	send_zephyr(z->opcode, z->zsig, z->class, z->inst, to, tmpmsg);
       } else {
-	send_zephyr(z->opcode, NULL, z->class, z->inst, to, msg);
+	send_zephyr(z->opcode, z->zsig, z->class, z->inst, to, msg);
       }
     }
@@ -190,4 +238,8 @@
 }
 
+char *owl_zwrite_get_zsig(owl_zwrite *z) {
+  return(z->zsig);
+}
+
 void owl_zwrite_get_recipstr(owl_zwrite *z, char *buff) {
   int i, j;
@@ -225,3 +277,4 @@
 void owl_zwrite_free(owl_zwrite *z) {
   owl_list_free_all(&(z->recips), &owl_free);
-}
+  owl_free(z->zsig);
+}
