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