]> andersk Git - moira.git/blob - lib/mr_connect.c
b86ec892579752d3cac55facaf53ad3078f5cd7d
[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         sms_disconnect();
40         return status;
41     }
42     return 0;
43 }
44         
45 int sms_disconnect()
46 {
47     CHECK_CONNECTED;
48     _sms_conn = sever_connection(_sms_conn);
49     return 0;
50 }
51
52 int sms_noop()
53 {
54     int status;
55     sms_params param_st;
56     struct sms_params *params = NULL;
57     struct sms_params *reply = NULL;
58
59     CHECK_CONNECTED;
60     params = &param_st;
61     params->sms_procno = SMS_NOOP;
62     params->sms_argc = 0;
63     params->sms_argl = NULL;
64     params->sms_argv = NULL;
65         
66     if ((status = sms_do_call(params, &reply)) == 0)
67         status = reply->sms_status;
68         
69     sms_destroy_reply(reply);
70
71     return status;
72 }
73
74 /*
75  * Local Variables:
76  * mode: c
77  * c-indent-level: 4
78  * c-continued-statement-offset: 4
79  * c-brace-offset: -4
80  * c-argdecl-indent: 4
81  * c-label-offset: -4
82  * End:
83  */
This page took 0.029453 seconds and 3 git commands to generate.