]> andersk Git - moira.git/blobdiff - clients/moira/utils.c
Diane Delgado's changes for a fixed table-locking order
[moira.git] / clients / moira / utils.c
index f3999345e73ae1154b72b9dda8c7934c7571b71a..570a30dabab78075682ce69e60530a58bee90dea 100644 (file)
@@ -20,7 +20,7 @@
  */
 
 #include <stdio.h>
-#include <strings.h>
+#include <string.h>
 #include <moira.h>
 #include <moira_site.h>
 #include <menu.h>
 #include "defs.h"
 #include "f_defs.h"
 #include "globals.h"
-
 #include <netdb.h>             /* for gethostbyname. */
+#include <sys/types.h>
+#include <netinet/in.h>
+
 
 /*     Function Name: AddQueue
  *     Description: Adds an element to a queue
@@ -409,9 +411,9 @@ char *s;
 {
     if (IS_EMPTY(s))
        Put_message("Please use a non-empty name.");
-    else if (index(s, ' '))
+    else if (strchr(s, ' '))
        Put_message("You cannot use space (' ') in this name.");
-    else if (index(s, '*') || index(s, '?') || index(s, '['))
+    else if (strchr(s, '*') || strchr(s, '?') || strchr(s, '['))
        Put_message("Wildcards not accepted here.");
     else
        return TRUE;
@@ -498,10 +500,11 @@ char * prompt, ** pointer;
  * a difference that makes no difference, IS no difference.
  */
 
-    if (strcmp(buf, *pointer) != 0) { 
-       if (*pointer != NULL)
+    if (*pointer != NULL) {
+       if (strcmp(buf, *pointer) != 0) { 
            free(*pointer);
-       *pointer = Strsave(buf);
+           *pointer = Strsave(buf);
+       }
     }
     return(SUB_NORMAL);
 }
@@ -632,6 +635,22 @@ char *str;
        return (strcpy(newstr, str));
 }
 
+
+/* atot: convert ASCII integer unix time into human readable date string */
+
+char *atot(itime)
+char *itime;
+{
+    int time;
+    char *ct, *ctime();
+
+    time = atoi(itime);
+    ct = ctime(&time);
+    ct[24] = 0;
+    return(&ct[4]);
+}
+
+
 /*     Function Name: Print
  *     Description: prints out all the arguments on a single line.
  *     Arguments: argc, argv - the standard MR arguments.
@@ -917,6 +936,33 @@ char  **pointer;
 }
 
 
+/*     Function Name: GetAddressFromUser
+ *     Description: gets an IP address from the user
+ *     Arguments: prompt string, buffer pointer
+ *             buffer contains default value as long int
+ *     Returns: SUB_ERROR if ^C, SUB_NORMAL otherwise
+ */
+
+int GetAddressFromUser(prompt, pointer)
+char *prompt;
+char  **pointer;
+{
+    char *value, buf[256];
+    struct in_addr addr;
+    int ret;
+
+    addr.s_addr = htonl(atoi(*pointer));
+    value = strsave(inet_ntoa(addr));
+    ret = GetValueFromUser(prompt, &value);
+    if (ret == SUB_ERROR) return(SUB_ERROR);
+    addr.s_addr = inet_addr(value);
+    free(pointer);
+    sprintf(buf, "%d", ntohl(addr.s_addr));
+    *pointer = strsave(buf);
+    return(SUB_NORMAL);
+}
+
+
 do_mr_query(name, argc, argv, proc, hint)
 char *name;
 int argc;
This page took 0.036894 seconds and 4 git commands to generate.