]> andersk Git - moira.git/blobdiff - lib/mr_connect.c
use sms_complete_operation() which checks alternate input as well
[moira.git] / lib / mr_connect.c
index b86ec892579752d3cac55facaf53ad3078f5cd7d..1dc75ce593e3fb962c440a9eb5805ecc82dea69c 100644 (file)
@@ -4,24 +4,32 @@
  *     $Header$
  *
  *     Copyright (C) 1987 by the Massachusetts Institute of Technology
+ *     For copying and distribution information, please see the file
+ *     <mit-copyright.h>.
  *     
  *     This routine is part of the client library.  It handles
- * creating a connection to the sms server.
+ *     creating a connection to the sms server.
  */
 
 #ifndef lint
 static char *rcsid_sms_connect_c = "$Header$";
 #endif lint
 
+#include <mit-copyright.h>
 #include "sms_private.h"
+#include <strings.h>
+
+static char *sms_server_host = 0;
 
 /*
  * Open a connection to the sms server.
  */
 
-int sms_connect()
+int sms_connect(server)
+char *server;
 {
     extern int errno;
+    char *p;
        
     if (!sms_inited) sms_init();
     if (_sms_conn) return SMS_ALREADY_CONNECTED;
@@ -31,14 +39,26 @@ int sms_connect()
      * number/name.
      */
     errno = 0;
-    _sms_conn = start_server_connection(SMS_GDB_SERV, ""); 
+    if (!server || (strlen(server) == 0))
+      server = SMS_GDB_SERV;
+    _sms_conn = start_server_connection(server, ""); 
     if (_sms_conn == NULL)
        return errno;
     if (connection_status(_sms_conn) == CON_STOPPED) {
        register status = connection_errno(_sms_conn);
+       if (!status) status = SMS_CANT_CONNECT;
        sms_disconnect();
        return status;
     }
+
+    /*
+     * stash hostname for later use
+     */
+
+    sms_server_host = strsave(server);
+    if (p = index(sms_server_host, ':'))
+       *p = 0;
+    sms_server_host = canonicalize_hostname(sms_server_host);
     return 0;
 }
        
@@ -46,9 +66,22 @@ int sms_disconnect()
 {
     CHECK_CONNECTED;
     _sms_conn = sever_connection(_sms_conn);
+    free(sms_server_host);
+    sms_server_host = 0;
     return 0;
 }
 
+int sms_host(host, size)
+  char *host;
+  int size;
+{
+    CHECK_CONNECTED;
+
+    /* If we are connected, sms_server_host points to a valid string. */
+    strncpy(host, sms_server_host, size);
+    return(0);
+}
+
 int sms_noop()
 {
     int status;
@@ -58,6 +91,7 @@ int sms_noop()
 
     CHECK_CONNECTED;
     params = &param_st;
+    params->sms_version_no = sending_version_no;
     params->sms_procno = SMS_NOOP;
     params->sms_argc = 0;
     params->sms_argl = NULL;
@@ -70,14 +104,3 @@ int sms_noop()
 
     return status;
 }
-
-/*
- * Local Variables:
- * mode: c
- * c-indent-level: 4
- * c-continued-statement-offset: 4
- * c-brace-offset: -4
- * c-argdecl-indent: 4
- * c-label-offset: -4
- * End:
- */
This page took 0.072763 seconds and 4 git commands to generate.