+/*ARGSUSED*/
+int
+toggle_logging(argc, argv)
+ int argc;
+ char *argv[];
+{
+ int pid;
+ char buf[BUFSIZ];
+
+ if (log_file == (FILE *) NULL) {
+ pid = getpid();
+ if (!whoami) {
+ char *whoami;
+ Put_message("I've lost my SENSE of DIRECTION! I have no IDEA who I AM!");
+ Put_message("My God... You've turned him into a DEMOCRAT!!");
+ Put_message(" -- Doonesbury");
+ Put_message("");
+ Put_message("translation: your log file can be found in \"/usr/tmp/a.out.pid\".");
+ whoami = "a.out";
+ (void) sprintf(buf, "/usr/tmp/%s-log.%d", whoami, pid);
+ }
+ else
+ (void) sprintf(buf, "/usr/tmp/%s-log.%d", whoami, pid);
+
+ /* open the file */
+ log_file = fopen(&buf,"a");
+
+ if (log_file == (FILE *) NULL)
+ Put_message("Open of log file failed. Logging is not on.");
+ else
+ Put_message("Log file successfully opened.");
+ }
+ else { /* log_file is a valid pointer; turn off logging. */
+ (void) fflush(log_file);
+ (void) fclose(log_file);
+ log_file = (FILE *) NULL;
+ Put_message("Logging off.");
+ }
+ return(DM_NORMAL);
+}
+