]>
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 | ||
25 | int sms_connect() | |
26 | { | |
83e80378 | 27 | extern int errno; |
6c00b7c4 | 28 | |
83e80378 | 29 | if (!sms_inited) sms_init(); |
30 | if (_sms_conn) return SMS_ALREADY_CONNECTED; | |
31 | ||
32 | /* | |
a4af6a7e | 33 | * XXX should do a hesiod call to find the sms machine name & service |
34 | * number/name. | |
35 | */ | |
83e80378 | 36 | errno = 0; |
37 | _sms_conn = start_server_connection(SMS_GDB_SERV, ""); | |
a4af6a7e | 38 | if (_sms_conn == NULL) |
83e80378 | 39 | return errno; |
a4af6a7e | 40 | if (connection_status(_sms_conn) == CON_STOPPED) { |
41 | register status = connection_errno(_sms_conn); | |
355e74e0 | 42 | if (!status) status = SMS_CANT_CONNECT; |
a4af6a7e | 43 | sms_disconnect(); |
44 | return status; | |
83e80378 | 45 | } |
46 | return 0; | |
e2a67c78 | 47 | } |
48 | ||
49 | int sms_disconnect() | |
50 | { | |
83e80378 | 51 | CHECK_CONNECTED; |
52 | _sms_conn = sever_connection(_sms_conn); | |
53 | return 0; | |
e2a67c78 | 54 | } |
55 | ||
56 | int sms_noop() | |
57 | { | |
83e80378 | 58 | int status; |
59 | sms_params param_st; | |
60 | struct sms_params *params = NULL; | |
61 | struct sms_params *reply = NULL; | |
e2a67c78 | 62 | |
83e80378 | 63 | CHECK_CONNECTED; |
64 | params = ¶m_st; | |
89371417 | 65 | params->sms_version_no = sending_version_no; |
83e80378 | 66 | params->sms_procno = SMS_NOOP; |
67 | params->sms_argc = 0; | |
68 | params->sms_argl = NULL; | |
69 | params->sms_argv = NULL; | |
e2a67c78 | 70 | |
83e80378 | 71 | if ((status = sms_do_call(params, &reply)) == 0) |
72 | status = reply->sms_status; | |
ca401c43 | 73 | |
83e80378 | 74 | sms_destroy_reply(reply); |
6c00b7c4 | 75 | |
83e80378 | 76 | return status; |
6c00b7c4 | 77 | } |
83e80378 | 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 | */ |