]> andersk Git - moira.git/blame - lib/mr_connect.c
It's working better.
[moira.git] / lib / mr_connect.c
CommitLineData
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
13static char *rcsid_sms_connect_c = "$Header$";
14#endif lint
15
16#include <gdb.h>
17#include "sms_private.h"
18
19/*
20 * Open a connection to the sms server.
21 */
22
23int sms_connect()
24{
25 gdb_init(); /* Harmless if called twice. */
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) {
34 perror("gdb_connect");
35 return SMS_CANT_CONNECT;
36 }
37 return 0;
38}
39
40int 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
50int sms_noop()
51{
52 int status;
53 struct sms_params *parms;
54
55 if (!_sms_conn) {
56 return SMS_NOT_CONNECTED;
57 }
58
59 if (!sms_call_op)
60 sms_call_op = create_operation();
61
62 parms = (struct sms_params *) malloc(sizeof(*parms));
63
64 parms->procno = SMS_NOOP;
65 parms->argc = 0;
66
67 gdb_inop(sms_call_op, sms_start_call, &parms, sms_abort_call);
68 gdb_qop(_sms_conn, CON_OUTPUT, sms_call_op);
69
70 gdb_inop(sms_recv_op, sms_start_recv, &reply, sms_abort_recv);
71 gdb_qop(_sms_conn, CON_INPUT, sms_recv_op);
72
73 /* Block until operation done. */
74 gdb_cmpo(sms_call_op);
75 gdb_cmpo(sms_recv_op);
76
77 /* Look at results */
78 if (OP_STATUS(sms_recv_op) != OP_COMPLETE) {
79 return SMS_ABORTED;
80 }
81 /* should look at return code from server.. */
82 return 0;
83}
84
85
This page took 0.057468 seconds and 5 git commands to generate.