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"
22 /* Invoke a DCM update. */
24 int mr_do_update(void)
27 mr_params params, reply;
30 params.u.mr_procno = MR_DO_UPDATE;
32 params.mr_argl = NULL;
33 params.mr_argv = NULL;
35 if ((status = mr_do_call(¶ms, &reply)) == MR_SUCCESS)
36 status = reply.u.mr_status;
38 mr_destroy_reply(reply);
44 /* Get the Moira motd. This returns a Moira status, and motd will either
45 * point to NULL or the motd in a static buffer.
48 int mr_motd(char **motd)
51 mr_params params, reply;
52 static char *buffer = NULL;
56 params.u.mr_procno = MR_MOTD;
58 params.mr_argl = NULL;
59 params.mr_argv = NULL;
61 if ((status = mr_do_call(¶ms, &reply)))
64 while ((status = reply.u.mr_status) == MR_MORE_DATA)
66 if (reply.mr_argc > 0)
68 buffer = realloc(buffer, reply.mr_argl[0] + 1);
74 strcpy(buffer, reply.mr_argv[0]);
77 mr_destroy_reply(reply);
78 if (mr_receive(_mr_conn, &reply) != MR_SUCCESS)
85 mr_destroy_reply(reply);