3 * This routine is part of the client library. It handles
4 * the protocol operations: invoking an update and getting the
5 * Moira message of the day.
7 * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
8 * For copying and distribution information, please see the file
12 #include <mit-copyright.h>
14 #include "mr_private.h"
23 /* Invoke a DCM update. */
25 int mr_do_update(void)
28 mr_params params, reply;
31 params.u.mr_procno = MR_DO_UPDATE;
33 params.mr_argl = NULL;
34 params.mr_argv = NULL;
36 if ((status = mr_do_call(¶ms, &reply)) == MR_SUCCESS)
37 status = reply.u.mr_status;
39 mr_destroy_reply(reply);
45 /* Get the Moira motd. This returns a Moira status, and motd will either
46 * point to NULL or the motd in a static buffer.
49 int mr_motd(char **motd)
52 mr_params params, reply;
53 static char *buffer = NULL;
57 params.u.mr_procno = MR_MOTD;
59 params.mr_argl = NULL;
60 params.mr_argv = NULL;
62 if ((status = mr_do_call(¶ms, &reply)))
65 while ((status = reply.u.mr_status) == MR_MORE_DATA)
67 if (reply.mr_argc > 0)
69 buffer = realloc(buffer, reply.mr_argl[0] + 1);
75 strcpy(buffer, reply.mr_argv[0]);
78 mr_destroy_reply(reply);
79 if (mr_receive(_mr_conn, &reply) != MR_SUCCESS)
86 mr_destroy_reply(reply);
91 /* Exchange query version info with the server. */
93 int mr_version(int version)
96 mr_params params, reply;
101 sprintf(vbuf, "%d", version);
103 params.u.mr_procno = MR_SETVERSION;
105 params.mr_argl = NULL;
106 params.mr_argv = &arg;
108 status = mr_do_call(¶ms, &reply);
111 if (status == MR_SUCCESS)
113 status = reply.u.mr_status;
115 if (status == MR_VERSION_LOW && getenv("MOIRA_LOW_VERSION_WARNING"))
116 fprintf(stderr, "Warning: This client is out of date.\n");
118 mr_destroy_reply(reply);