]> andersk Git - moira.git/blobdiff - server/mr_util.c
After synchronizing with opssrc as it was on 8/4/92.
[moira.git] / server / mr_util.c
index 18f7c5a0f26d97534cb99d980776d9275e73d199..ca0c888d462dd5e4784b6704c5e00d4e81717363 100644 (file)
@@ -4,19 +4,20 @@
  *     $Header$
  *
  *     Copyright (C) 1987 by the Massachusetts Institute of Technology
- *
+ *     For copying and distribution information, please see the file
+ *     <mit-copyright.h>.
  */
 
 #ifndef lint
-static char *rcsid_sms_util_c = "$Header$";
+static char *rcsid_mr_util_c = "$Header$";
 #endif lint
 
-#include "sms_server.h"
+#include <mit-copyright.h>
+#include "mr_server.h"
 
 #include <ctype.h>
 #include <strings.h>
 #include <sys/types.h>
-#include <zephyr/zephyr.h>
 
 extern char *whoami;
 
@@ -73,7 +74,7 @@ log_args(tag, version, argc, argv)
        com_err(whoami, 0, "%s", buf);
 }
        
-void sms_com_err(whoami, code, fmt, pvar)
+void mr_com_err(whoami, code, fmt, pvar)
        char *whoami;
        int code;
        char *fmt;
@@ -97,21 +98,32 @@ void sms_com_err(whoami, code, fmt, pvar)
 }
 
 
-/* sms_trim_args: passed an argument vector, it will trim any trailing
- * spaces on the args by writing a null into the string.
+/* mr_trim_args: passed an argument vector, it will trim any trailing
+ * spaces on the args by writing a null into the string.  If an argument
+ * appears to be binary instead of ASCII, it will not be trimmed.
  */
 
-int sms_trim_args(argc, argv)
+int mr_trim_args(argc, argv)
 int argc;
 char **argv;
 {
     register char **arg;
-    register char *p, *lastch;
+    register unsigned char *p, *lastch;
 
     for (arg = argv; argc--; arg++) {
-       for (lastch = p = *arg; *p; p++)
-         if (!isspace(*p))
-           lastch = p;
+       for (lastch = p = *arg; *p; p++) {
+           /* If any byte in the string has the high bit set, assume
+            * that it is binary and we do not want to trim it.
+            * Setting p = lastch will cause us not to trim the string
+            * when we break out of this inner loop.
+            */
+           if (*p >= 0x80) {
+               p = lastch;
+               break;
+           }
+           if (!isspace(*p))
+             lastch = p;
+       }
        if (p != lastch) {
            if (isspace(*lastch))
              *lastch = 0;
@@ -123,42 +135,19 @@ char **argv;
 }
 
 
-trim(s)
-register char *s;
-{
-    register char *p;
-
-    for (p = s; *s; s++)
-      if (*s != ' ')
-       p = s;
-    if (p != s) {
-       if (*p == ' ')
-         *p = 0;
-       else
-         p[1] = 0;
-    }
-}
-
-
-/* Sends a zephyrgram of class "SMS", instance as a parameter.  Ignores
- * errors while sending message.
- */
+/* returns a copy of the argv and all of it's strings */
 
-send_zgram(inst, msg)
-char *inst;
-char *msg;
+char **mr_copy_args(argv, argc)
+char **argv;
+int argc;
 {
-    ZNotice_t znotice;
-
-    bzero (&znotice, sizeof (znotice));
-    znotice.z_kind = UNSAFE;
-    znotice.z_class = "SMS";
-    znotice.z_class_inst = inst;
-    znotice.z_default_format = "SMS $instance:\n $message\n";
-    (void) ZInitialize ();
-    znotice.z_message = msg;
-    znotice.z_message_len = strlen(msg) + 1;
-    znotice.z_opcode = "";
-    znotice.z_recipient = "";
-    ZSendNotice(&znotice, ZNOAUTH);
+    char **a;
+    int i;
+
+    a = (char **) malloc(argc * sizeof(char *));
+    if (a == 0)
+      return(a);
+    for (i = 0; i < argc; i++)
+      a[i] = strsave(argv[i]);
+    return(a);
 }
This page took 0.043847 seconds and 4 git commands to generate.