[78] in bug-owl

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

Re: info --full patch

daemon@ATHENA.MIT.EDU (Jeremy Daniel)
Sun Aug 25 19:40:36 2002

To: bug-owl@MIT.EDU
From: Jeremy Daniel <jdaniel@MIT.EDU>
Date: 25 Aug 2002 19:37:21 -0400
In-Reply-To: <bug-owl:76@unknown-discuss-server>
Message-ID: <skeznva7bny.fsf@multics.mit.edu>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii

Here's the patch again since the old one no longer applies cleanly
with today's changes.  I still would like to be able to reply to
zaways like in my other patch but that one needs more rewriting in
order to work.  So let me know if you'd take it if I redid it.

/mit/jdaniel/project/owl/build-cvs/patches/info_full.patch
-----
Index: commands.c
===================================================================
RCS file: /mit/ktools/src/owl/repository/owl/commands.c,v
retrieving revision 1.15
diff -u -r1.15 commands.c
--- commands.c	2002/08/17 19:23:02	1.15
+++ commands.c	2002/08/25 14:47:12
@@ -175,9 +175,12 @@
 	      "suppressed to be received again.\n\n"
 	      "SEE ALSO:  zpunt, show zpunts\n"),
 
-  OWLCMD_VOID("info", owl_command_info, OWL_CTX_INTERACTIVE,
+  OWLCMD_ARGS("info", owl_command_info, OWL_CTX_INTERACTIVE,
 	      "display detailed information about the current message",
-	      "", ""),
+	      "info [--full]", 
+              "Display detailed information about the current message.\n"
+              "If --full is specified fields will not be truncated at 30\n"
+              "characters and will not have their newlines replaced with ~.\n"),
   
   OWLCMD_ARGS("help", owl_command_help, OWL_CTX_INTERACTIVE,
 	      "display help on using owl",
@@ -702,8 +705,19 @@
 
 };
 
-void owl_command_info() {
-  owl_function_info();
+char *owl_command_info(int argc, char **argv, char *buff) {
+  int type=0;
+  while (argc>1) {
+    if (argc>=1 && !strcmp(argv[1], "--full")) {
+      type=1;
+      argc-=1; argv+=1; 
+    } else {
+      owl_function_makemsg("Invalid arguments to command 'info'.");
+      return(NULL);
+    }
+  }
+  owl_function_info(type);
+  return NULL;
 }
 
 char *owl_command_help(int argc, char **argv, char *buff) {
Index: functions.c
===================================================================
RCS file: /mit/ktools/src/owl/repository/owl/functions.c,v
retrieving revision 1.23
diff -u -r1.23 functions.c
--- functions.c	2002/08/25 19:02:14	1.23
+++ functions.c	2002/08/25 23:14:12
@@ -1083,10 +1083,13 @@
   owl_function_popless_text(buff);
 }
 
-void owl_function_info() {
+void owl_function_info(int type) {
+  /* if type = 0 then truncate fields.
+   * if type = 1 then display complete fields
+   */
   owl_message *m;
   ZNotice_t *n;
-  char buff[5000], tmpbuff[1024];
+  char buff[5000], tmpbuff[1024], tmpbuff2[1024];
   char *ptr;
   int i, j, fields, len;
   owl_view *v;
@@ -1183,15 +1186,15 @@
   sprintf(buff, "%sNum other : %i\n", buff, n->z_num_other_fields);
   sprintf(buff, "%sMsg Len   : %i\n", buff, n->z_message_len);
 
-  sprintf(buff, "%sFields    : %i\n", buff, owl_zephyr_get_num_fields(n));
-
   fields=owl_zephyr_get_num_fields(n);
+  sprintf(buff, "%sFields    : %i\n", buff, fields);
+
   for (i=0; i<fields; i++) {
     sprintf(buff, "%sField %i   : ", buff, i+1);
 
     ptr=owl_zephyr_get_field(n, i+1, &len);
     if (!ptr) break;
-    if (len<30) {
+    if (type==1 || len<30) {
       strncpy(tmpbuff, ptr, len);
       tmpbuff[len]='\0';
     } else {
@@ -1202,14 +1205,37 @@
 
     /* just for testing for now */
     for (j=0; j<strlen(tmpbuff); j++) {
-      if (tmpbuff[j]=='\n') tmpbuff[j]='~';
+      if (tmpbuff[j]=='\n') {
+        if (type == 0) {
+          tmpbuff[j]='~';
+        } else {
+          strcpy(tmpbuff2, tmpbuff);
+          ptr = tmpbuff2+(j+1);
+          tmpbuff[j+1]='\0';
+          strcat(tmpbuff, "            ");
+          strcat(tmpbuff, ptr);
+          j+=12;
+        }
+      }
       if (tmpbuff[j]=='\r') tmpbuff[j]='!';
     }
 
     strcat(buff, tmpbuff);
     strcat(buff, "\n");
+  }
+  ptr = n->z_default_format;
+  strcpy(tmpbuff, ptr);
+  for (j=0; j<strlen(tmpbuff); j++) {
+    if (tmpbuff[j]=='\n') {
+      strcpy(tmpbuff2, tmpbuff);
+      ptr = tmpbuff2+(j+1);
+      tmpbuff[j+1]='\0';
+      strcat(tmpbuff, "            ");
+      strcat(tmpbuff, ptr);
+      j+=12;
+    }
   }
-  sprintf(buff, "%sDefault Fm: %s\n", buff, n->z_default_format);
+  sprintf(buff, "%sDefault Fm: %s\n", buff, tmpbuff);
 	
   owl_function_popless_text(buff);
 }

-- 


				Jer


------------------------------------------------------------------
Tulgey Wood - tulgeywood@attbi.com     Cell Phone: 617-429-8573 / 
4 Farragut Ave (617-629-3983)             jdaniel-phone@mit.edu
Somerville, MA 02144-1709              AIM: jdanielmit      
                                    
Zephyr athena users over the web:  http://webzephyr.mit.edu/

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