[277] in bug-owl

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

patch: log when recipients aren't subscribed to personal zephyrs

daemon@ATHENA.MIT.EDU (Arun A Tharuvai)
Sun Oct 26 18:30:23 2003

Date: Sun, 26 Oct 2003 18:30:15 -0500
From: Arun A Tharuvai <aatharuv@MIT.EDU>
To: owl-developers@MIT.EDU, bug-owl@MIT.EDU
Cc: aatharuv@MIT.EDU
Message-ID: <20031026233015.GG17310@multics.mit.edu>
Mail-Followup-To: owl-developers@mit.edu, bug-owl@mit.edu
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary="sdtB3X0nJg68CQEu"
Content-Disposition: inline


--sdtB3X0nJg68CQEu
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Currently, when the recipient of an outgoing personal isn't subscribed
to messages, no indication shows up in the logs. Here's a patch that
creates a function, owl_log_outgoing_zephyr_error (shamelessly stolen
from owl_log_outgoing_zephyr), to write the following:

ERROR (owl): sender

to the appropriate log files. It'll only get run if the user has
'set logging on', of course.

Arun

-- 
Arun A Tharuvai
aatharuv (at) mit (dot) edu
aat (at) alum (dot) mit (dot) edu

--sdtB3X0nJg68CQEu
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="owl-log-outgoing-errors.patch"

Index: logging.c
===================================================================
RCS file: /mit/ktools/src/owl/repository/owl/logging.c,v
retrieving revision 1.17
diff -u -r1.17 logging.c
--- logging.c	26 Oct 2003 20:23:38 -0000	1.17
+++ logging.c	26 Oct 2003 22:17:54 -0000
@@ -6,6 +6,55 @@
 
 static const char fileIdent[] = "$Id: logging.c,v 1.17 2003/10/26 20:23:38 kretch Exp $";
 
+void owl_log_outgoing_zephyr_error(char *to, char *text)
+{
+  FILE *file;
+  char filename[MAXPATHLEN], *logpath;
+  char *tobuff, *ptr="";
+
+  tobuff=owl_malloc(strlen(to)+20);
+  strcpy(tobuff, to);
+
+  /* chop off a local realm */
+  ptr=strchr(tobuff, '@');
+  if (ptr && !strncmp(ptr+1, owl_zephyr_get_realm(), strlen(owl_zephyr_get_realm()))) {
+    *ptr='\0';
+  }
+
+  /* expand ~ in path names */
+  logpath = owl_text_substitute(owl_global_get_logpath(&g), "~", 
+				owl_global_get_homedir(&g));
+
+  snprintf(filename, MAXPATHLEN, "%s/%s", logpath, tobuff);
+  file=fopen(filename, "a");
+  if (!file) {
+    owl_function_error("Unable to open file for outgoing logging");
+    owl_free(logpath);
+    return;
+  }
+  fprintf(file, "ERROR (owl): %s\n%s\n", tobuff, text);
+  if (text[strlen(text)-1]!='\n') {
+    fprintf(file, "\n");
+  }
+  fclose(file);
+
+  snprintf(filename, MAXPATHLEN, "%s/all", logpath);
+  owl_free(logpath);
+  file=fopen(filename, "a");
+  if (!file) {
+    owl_function_error("Unable to open file for outgoing logging");
+    return;
+  }
+  fprintf(file, "ERROR (owl): %s\n%s\n", tobuff, text);
+  if (text[strlen(text)-1]!='\n') {
+    fprintf(file, "\n");
+  }
+  fclose(file);
+
+  owl_free(tobuff);
+}
+
+
 void owl_log_outgoing_zephyr(char *to, char *text)
 {
   FILE *file;
Index: zephyr.c
===================================================================
RCS file: /mit/ktools/src/owl/repository/owl/zephyr.c,v
retrieving revision 1.29
diff -u -r1.29 zephyr.c
--- zephyr.c	26 Oct 2003 20:23:39 -0000	1.29
+++ zephyr.c	26 Oct 2003 23:18:30 -0000
@@ -440,6 +440,9 @@
 
       sprintf(buff, "Could not send message to %s: not logged in or subscribing to messages.\n", tmp);
       owl_function_adminmsg("", buff);
+      if (owl_global_is_logging(&g)) {
+         owl_log_outgoing_zephyr_error(tmp,"");
+      }
       owl_free(tmp);
     }
   } else {

--sdtB3X0nJg68CQEu--

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