]>
Commit | Line | Data |
---|---|---|
e2a67c78 | 1 | /* |
2 | * $Source$ | |
3 | * $Author$ | |
4 | * $Header$ | |
5 | * | |
6 | * Copyright (C) 1987 by the Massachusetts Institute of Technology | |
babbc197 | 7 | * For copying and distribution information, please see the file |
8 | * <mit-copyright.h>. | |
e2a67c78 | 9 | * |
10 | * This routine is part of the client library. It handles | |
babbc197 | 11 | * creating a connection to the sms server. |
e2a67c78 | 12 | */ |
13 | ||
14 | #ifndef lint | |
15 | static char *rcsid_sms_connect_c = "$Header$"; | |
16 | #endif lint | |
17 | ||
babbc197 | 18 | #include <mit-copyright.h> |
e2a67c78 | 19 | #include "sms_private.h" |
20 | ||
21 | /* | |
22 | * Open a connection to the sms server. | |
23 | */ | |
24 | ||
bba84689 | 25 | int sms_connect(server) |
26 | char *server; | |
e2a67c78 | 27 | { |
83e80378 | 28 | extern int errno; |
6c00b7c4 | 29 | |
83e80378 | 30 | if (!sms_inited) sms_init(); |
31 | if (_sms_conn) return SMS_ALREADY_CONNECTED; | |
32 | ||
33 | /* | |
a4af6a7e | 34 | * XXX should do a hesiod call to find the sms machine name & service |
35 | * number/name. | |
36 | */ | |
83e80378 | 37 | errno = 0; |
bba84689 | 38 | if (!server || (strlen(server) == 0)) |
39 | server = SMS_GDB_SERV; | |
40 | _sms_conn = start_server_connection(server, ""); | |
a4af6a7e | 41 | if (_sms_conn == NULL) |
83e80378 | 42 | return errno; |
a4af6a7e | 43 | if (connection_status(_sms_conn) == CON_STOPPED) { |
44 | register status = connection_errno(_sms_conn); | |
355e74e0 | 45 | if (!status) status = SMS_CANT_CONNECT; |
a4af6a7e | 46 | sms_disconnect(); |
47 | return status; | |
83e80378 | 48 | } |
49 | return 0; | |
e2a67c78 | 50 | } |
51 | ||
52 | int sms_disconnect() | |
53 | { | |
83e80378 | 54 | CHECK_CONNECTED; |
55 | _sms_conn = sever_connection(_sms_conn); | |
56 | return 0; | |
e2a67c78 | 57 | } |
58 | ||
59 | int sms_noop() | |
60 | { | |
83e80378 | 61 | int status; |
62 | sms_params param_st; | |
63 | struct sms_params *params = NULL; | |
64 | struct sms_params *reply = NULL; | |
e2a67c78 | 65 | |
83e80378 | 66 | CHECK_CONNECTED; |
67 | params = ¶m_st; | |
89371417 | 68 | params->sms_version_no = sending_version_no; |
83e80378 | 69 | params->sms_procno = SMS_NOOP; |
70 | params->sms_argc = 0; | |
71 | params->sms_argl = NULL; | |
72 | params->sms_argv = NULL; | |
e2a67c78 | 73 | |
83e80378 | 74 | if ((status = sms_do_call(params, &reply)) == 0) |
75 | status = reply->sms_status; | |
ca401c43 | 76 | |
83e80378 | 77 | sms_destroy_reply(reply); |
6c00b7c4 | 78 | |
83e80378 | 79 | return status; |
6c00b7c4 | 80 | } |