-/*
- * $Source$
- * $Author$
- * $Header$
+/* $Id $
*
- * Copyright (C) 1987 by the Massachusetts Institute of Technology
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
- *
- * This routine is part of the client library. It handles
- * creating a connection to the sms server.
+ * This routine is part of the client library. It handles
+ * the protocol operations: invoking an update and getting the
+ * Moira message of the day.
+ *
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#ifndef lint
-static char *rcsid_sms_do_update_c = "$Header$";
-#endif lint
-
#include <mit-copyright.h>
-#include "sms_private.h"
+#include <moira.h>
+#include "mr_private.h"
+
+#include <string.h>
+
+RCSID("$Header$");
+
+/* Invoke a DCM update. */
-int sms_do_update()
+int mr_do_update(void)
{
- int status;
- sms_params param_st;
- struct sms_params *params = NULL;
- struct sms_params *reply = NULL;
-
- CHECK_CONNECTED;
- params = ¶m_st;
- params->sms_version_no = sending_version_no;
- params->sms_procno = SMS_DO_UPDATE;
- params->sms_argc = 0;
- params->sms_argl = NULL;
- params->sms_argv = NULL;
-
- if ((status = sms_do_call(params, &reply)) == 0)
- status = reply->sms_status;
-
- sms_destroy_reply(reply);
+ int status;
+ mr_params param_st;
+ struct mr_params *params = NULL;
+ struct mr_params *reply = NULL;
- return status;
+ CHECK_CONNECTED;
+ params = ¶m_st;
+ params->mr_version_no = sending_version_no;
+ params->mr_procno = MR_DO_UPDATE;
+ params->mr_argc = 0;
+ params->mr_argl = NULL;
+ params->mr_argv = NULL;
+
+ if ((status = mr_do_call(params, &reply)) == 0)
+ status = reply->mr_status;
+
+ mr_destroy_reply(reply);
+
+ return status;
}
-/*
- * Local Variables:
- * mode: c
- * c-indent-level: 4
- * c-continued-statement-offset: 4
- * c-brace-offset: -4
- * c-argdecl-indent: 4
- * c-label-offset: -4
- * End:
+
+/* Get the Moira motd. This returns a Moira status, and motd will either
+ * point to NULL or the motd in a static buffer.
*/
+
+int mr_motd(char **motd)
+{
+ int status;
+ mr_params param_st;
+ struct mr_params *params = NULL;
+ struct mr_params *reply = NULL;
+ static char buffer[1024];
+
+ *motd = NULL;
+ CHECK_CONNECTED;
+ params = ¶m_st;
+ params->mr_version_no = sending_version_no;
+ params->mr_procno = MR_MOTD;
+ params->mr_argc = 0;
+ params->mr_argl = NULL;
+ params->mr_argv = NULL;
+
+ if ((status = mr_do_call(params, &reply)))
+ goto punt;
+
+ while ((status = reply->mr_status) == MR_MORE_DATA)
+ {
+ if (reply->mr_argc > 0)
+ {
+ strncpy(buffer, reply->mr_argv[0], sizeof(buffer));
+ *motd = buffer;
+ }
+ mr_destroy_reply(reply);
+ reply = NULL;
+
+ initialize_operation(_mr_recv_op, mr_start_recv, &reply, NULL);
+ queue_operation(_mr_conn, CON_INPUT, _mr_recv_op);
+
+ complete_operation(_mr_recv_op);
+ if (OP_STATUS(_mr_recv_op) != OP_COMPLETE)
+ {
+ mr_disconnect();
+ status = MR_ABORTED;
+ return status;
+ }
+ }
+punt:
+ mr_destroy_reply(reply);
+ /* for backwards compatability */
+ if (status == MR_UNKNOWN_PROC)
+ return 0;
+ else
+ return status;
+}