]>
Commit | Line | Data |
---|---|---|
e2a67c78 | 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 | ||
e2a67c78 | 16 | #include "sms_private.h" |
17 | ||
18 | /* | |
19 | * Open a connection to the sms server. | |
20 | */ | |
21 | ||
22 | int sms_connect() | |
23 | { | |
83e80378 | 24 | extern int errno; |
6c00b7c4 | 25 | |
83e80378 | 26 | if (!sms_inited) sms_init(); |
27 | if (_sms_conn) return SMS_ALREADY_CONNECTED; | |
28 | ||
29 | /* | |
a4af6a7e | 30 | * XXX should do a hesiod call to find the sms machine name & service |
31 | * number/name. | |
32 | */ | |
83e80378 | 33 | errno = 0; |
34 | _sms_conn = start_server_connection(SMS_GDB_SERV, ""); | |
a4af6a7e | 35 | if (_sms_conn == NULL) |
83e80378 | 36 | return errno; |
a4af6a7e | 37 | if (connection_status(_sms_conn) == CON_STOPPED) { |
38 | register status = connection_errno(_sms_conn); | |
355e74e0 | 39 | if (!status) status = SMS_CANT_CONNECT; |
a4af6a7e | 40 | sms_disconnect(); |
41 | return status; | |
83e80378 | 42 | } |
43 | return 0; | |
e2a67c78 | 44 | } |
45 | ||
46 | int sms_disconnect() | |
47 | { | |
83e80378 | 48 | CHECK_CONNECTED; |
49 | _sms_conn = sever_connection(_sms_conn); | |
50 | return 0; | |
e2a67c78 | 51 | } |
52 | ||
53 | int sms_noop() | |
54 | { | |
83e80378 | 55 | int status; |
56 | sms_params param_st; | |
57 | struct sms_params *params = NULL; | |
58 | struct sms_params *reply = NULL; | |
e2a67c78 | 59 | |
83e80378 | 60 | CHECK_CONNECTED; |
61 | params = ¶m_st; | |
89371417 | 62 | params->sms_version_no = sending_version_no; |
83e80378 | 63 | params->sms_procno = SMS_NOOP; |
64 | params->sms_argc = 0; | |
65 | params->sms_argl = NULL; | |
66 | params->sms_argv = NULL; | |
e2a67c78 | 67 | |
83e80378 | 68 | if ((status = sms_do_call(params, &reply)) == 0) |
69 | status = reply->sms_status; | |
ca401c43 | 70 | |
83e80378 | 71 | sms_destroy_reply(reply); |
6c00b7c4 | 72 | |
83e80378 | 73 | return status; |
6c00b7c4 | 74 | } |
83e80378 | 75 | |
76 | /* | |
77 | * Local Variables: | |
78 | * mode: c | |
79 | * c-indent-level: 4 | |
80 | * c-continued-statement-offset: 4 | |
81 | * c-brace-offset: -4 | |
82 | * c-argdecl-indent: 4 | |
83 | * c-label-offset: -4 | |
84 | * End: | |
85 | */ |