]> andersk Git - moira.git/blob - lib/mr_connect.c
declared version number variable
[moira.git] / lib / mr_connect.c
1 /*
2  *      $Source$
3  *      $Author$
4  *      $Header$
5  *
6  *      Copyright (C) 1987 by the Massachusetts Institute of Technology
7  *      
8  *      This routine is part of the client library.  It handles
9  * creating a connection to the sms server.
10  */
11
12 #ifndef lint
13 static char *rcsid_sms_connect_c = "$Header$";
14 #endif lint
15
16 #include "sms_private.h"
17
18 /*
19  * Open a connection to the sms server.
20  */
21
22 int sms_connect()
23 {
24     extern int errno;
25         
26     if (!sms_inited) sms_init();
27     if (_sms_conn) return SMS_ALREADY_CONNECTED;
28                 
29     /* 
30      * XXX should do a hesiod call to find the sms machine name & service
31      * number/name.
32      */
33     errno = 0;
34     _sms_conn = start_server_connection(SMS_GDB_SERV, ""); 
35     if (_sms_conn == NULL)
36         return errno;
37     if (connection_status(_sms_conn) == CON_STOPPED) {
38         register status = connection_errno(_sms_conn);
39         if (!status) status = SMS_CANT_CONNECT;
40         sms_disconnect();
41         return status;
42     }
43     return 0;
44 }
45         
46 int sms_disconnect()
47 {
48     CHECK_CONNECTED;
49     _sms_conn = sever_connection(_sms_conn);
50     return 0;
51 }
52
53 int sms_noop()
54 {
55     int status;
56     sms_params param_st;
57     struct sms_params *params = NULL;
58     struct sms_params *reply = NULL;
59
60     CHECK_CONNECTED;
61     params = &param_st;
62     params->sms_version_no = sending_version_no;
63     params->sms_procno = SMS_NOOP;
64     params->sms_argc = 0;
65     params->sms_argl = NULL;
66     params->sms_argv = NULL;
67         
68     if ((status = sms_do_call(params, &reply)) == 0)
69         status = reply->sms_status;
70         
71     sms_destroy_reply(reply);
72
73     return status;
74 }
75
76 /*
77  * Local Variables:
78  * mode: c
79  * c-indent-level: 4
80  * c-continued-statement-offset: 4
81  * c-brace-offset: -4
82  * c-argdecl-indent: 4
83  * c-label-offset: -4
84  * End:
85  */
This page took 0.041215 seconds and 5 git commands to generate.