]>
Commit | Line | Data |
---|---|---|
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 = ¶m_st; | |
62 | params->sms_procno = SMS_NOOP; | |
63 | params->sms_argc = 0; | |
64 | params->sms_argl = NULL; | |
65 | params->sms_argv = NULL; | |
66 | ||
67 | if ((status = sms_do_call(params, &reply)) == 0) | |
68 | status = reply->sms_status; | |
69 | ||
70 | sms_destroy_reply(reply); | |
71 | ||
72 | return status; | |
73 | } | |
74 | ||
75 | /* | |
76 | * Local Variables: | |
77 | * mode: c | |
78 | * c-indent-level: 4 | |
79 | * c-continued-statement-offset: 4 | |
80 | * c-brace-offset: -4 | |
81 | * c-argdecl-indent: 4 | |
82 | * c-label-offset: -4 | |
83 | * End: | |
84 | */ |