]> andersk Git - moira.git/commitdiff
added sms_motd()
authormar <mar>
Tue, 27 Jun 1989 14:30:23 +0000 (14:30 +0000)
committermar <mar>
Tue, 27 Jun 1989 14:30:23 +0000 (14:30 +0000)
lib/mr_ops.c

index 3c82f5a1b3c8aaa6c4c6aa84c83310a5f6057169..2930937b45fb5fafa0c17aa66278005251e20d01 100644 (file)
@@ -3,12 +3,13 @@
  *     $Author$
  *     $Header$
  *
- *     Copyright (C) 1987 by the Massachusetts Institute of Technology
+ *     Copyright (C) 1987, 1989 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.
+ *     the protocol operations: invoking an update and getting the
+ *     SMS message of the day.
  */
 
 #ifndef lint
@@ -18,6 +19,9 @@ static char *rcsid_sms_do_update_c = "$Header$";
 #include <mit-copyright.h>
 #include "sms_private.h"
 
+
+/* Invoke a DCM update. */
+
 int sms_do_update()
 {
     int status;
@@ -41,13 +45,52 @@ int sms_do_update()
     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 SMS motd.  This returns an SMS status, and motd will either
+ * point to NULL or the motd in a static buffer.
  */
+
+int sms_motd(motd)
+char **motd;
+{
+    int status;
+    sms_params param_st;
+    struct sms_params *params = NULL;
+    struct sms_params *reply = NULL;
+    static char buffer[1024];
+
+    *motd = NULL;
+    CHECK_CONNECTED;
+    params = &param_st;
+    params->sms_version_no = sending_version_no;
+    params->sms_procno = SMS_MOTD;
+    params->sms_argc = 0;
+    params->sms_argl = NULL;
+    params->sms_argv = NULL;
+       
+    if ((status = sms_do_call(params, &reply)))
+      goto punt;
+
+    while ((status = reply->sms_status) == SMS_MORE_DATA) {
+       if (reply->sms_argc > 0) {
+           strncpy(buffer, reply->sms_argv[0], sizeof(buffer));
+           *motd = buffer;
+       }
+       sms_destroy_reply(reply);
+       reply = NULL;
+
+       initialize_operation(_sms_recv_op, sms_start_recv, &reply,
+                            (int (*)())NULL);
+       queue_operation(_sms_conn, CON_INPUT, _sms_recv_op);
+
+       complete_operation(_sms_recv_op);
+       if (OP_STATUS(_sms_recv_op) != OP_COMPLETE) {
+           sms_disconnect();
+           status = SMS_ABORTED;
+           return(status);
+       }
+    }  
+ punt:
+    sms_destroy_reply(reply);
+    return(status);
+}
This page took 0.053538 seconds and 5 git commands to generate.