]> andersk Git - moira.git/blame - lib/mr_ops.c
Use domain of moira server instead of domain of local host when
[moira.git] / lib / mr_ops.c
CommitLineData
fa59b86f 1/* $Id$
de56407f 2 *
7ac48069 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.
5eaef520 6 *
7ac48069 7 * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
8 * For copying and distribution information, please see the file
9 * <mit-copyright.h>.
de56407f 10 */
11
babbc197 12#include <mit-copyright.h>
7ac48069 13#include <moira.h>
8defc06b 14#include "mr_private.h"
de56407f 15
a3bbcc2b 16#include <errno.h>
17#include <stdlib.h>
7ac48069 18#include <string.h>
19
20RCSID("$Header$");
5f9f27e4 21
22/* Invoke a DCM update. */
23
5eaef520 24int mr_do_update(void)
de56407f 25{
5eaef520 26 int status;
85330553 27 mr_params params, reply;
de56407f 28
5eaef520 29 CHECK_CONNECTED;
85330553 30 params.u.mr_procno = MR_DO_UPDATE;
31 params.mr_argc = 0;
32 params.mr_argl = NULL;
33 params.mr_argv = NULL;
5eaef520 34
85330553 35 if ((status = mr_do_call(&params, &reply)) == MR_SUCCESS)
36 status = reply.u.mr_status;
5eaef520 37
38 mr_destroy_reply(reply);
39
40 return status;
de56407f 41}
42
5f9f27e4 43
59ec8dae 44/* Get the Moira motd. This returns a Moira status, and motd will either
5f9f27e4 45 * point to NULL or the motd in a static buffer.
de56407f 46 */
5f9f27e4 47
5eaef520 48int mr_motd(char **motd)
5f9f27e4 49{
5eaef520 50 int status;
85330553 51 mr_params params, reply;
a3bbcc2b 52 static char *buffer = NULL;
5eaef520 53
54 *motd = NULL;
55 CHECK_CONNECTED;
85330553 56 params.u.mr_procno = MR_MOTD;
57 params.mr_argc = 0;
58 params.mr_argl = NULL;
59 params.mr_argv = NULL;
60
61 if ((status = mr_do_call(&params, &reply)))
5eaef520 62 goto punt;
63
85330553 64 while ((status = reply.u.mr_status) == MR_MORE_DATA)
5eaef520 65 {
85330553 66 if (reply.mr_argc > 0)
5eaef520 67 {
85330553 68 buffer = realloc(buffer, reply.mr_argl[0] + 1);
a3bbcc2b 69 if (!buffer)
70 {
71 mr_disconnect();
72 return ENOMEM;
73 }
85330553 74 strcpy(buffer, reply.mr_argv[0]);
5eaef520 75 *motd = buffer;
5f9f27e4 76 }
5eaef520 77 mr_destroy_reply(reply);
85330553 78 if (mr_receive(_mr_conn, &reply) != MR_SUCCESS)
5eaef520 79 {
80 mr_disconnect();
85330553 81 return MR_ABORTED;
5f9f27e4 82 }
5eaef520 83 }
84punt:
85 mr_destroy_reply(reply);
85330553 86
87 return status;
5f9f27e4 88}
This page took 0.542847 seconds and 5 git commands to generate.