]>
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 | { | |
ca401c43 | 24 | if (!sms_inited) sms_init(); |
25 | ||
e2a67c78 | 26 | /* |
27 | * should do a hesiod call to find the sms machine name & service | |
28 | * number/name. | |
29 | */ | |
30 | ||
31 | _sms_conn = start_server_connection(SMS_GDB_SERV, "XXX"); | |
32 | /* XXX gdb doesn't give real return codes. Can we trust errno?*/ | |
33 | if (_sms_conn == NULL) { | |
ca401c43 | 34 | perror("gdb_connect"); /*XXX*/ |
e2a67c78 | 35 | return SMS_CANT_CONNECT; |
36 | } | |
37 | return 0; | |
38 | } | |
39 | ||
40 | int sms_disconnect() | |
41 | { | |
42 | if (!_sms_conn) { | |
43 | return SMS_NOT_CONNECTED; | |
44 | } | |
45 | /* Is this guaranteed NOT to fail?? I don't believe it, but.. */ | |
46 | _sms_conn = sever_connection(_sms_conn); | |
47 | return 0; | |
48 | } | |
49 | ||
50 | int sms_noop() | |
51 | { | |
52 | int status; | |
53 | struct sms_params *parms; | |
ca401c43 | 54 | struct sms_params *reply; |
55 | ||
e2a67c78 | 56 | |
57 | parms = (struct sms_params *) malloc(sizeof(*parms)); | |
58 | ||
ca401c43 | 59 | parms->sms_procno = SMS_NOOP; |
60 | parms->sms_argc = 0; | |
e2a67c78 | 61 | |
ca401c43 | 62 | if ((status = sms_do_call(parms, &reply)) || (status = reply->sms_status)) |
63 | goto punt; | |
e2a67c78 | 64 | |
ca401c43 | 65 | |
66 | punt: | |
67 | sms_destroy_reply(reply); | |
68 | ok: | |
69 | free(parms); | |
70 | return status; | |
71 | } |