]> andersk Git - moira.git/blob - lib/mr_ops.c
26239e7bdb63fb284bdf5541cc1d761fc37a1fed
[moira.git] / lib / mr_ops.c
1 /*
2  *      $Source$
3  *      $Author$
4  *      $Header$
5  *
6  *      Copyright (C) 1987, 1989 by the Massachusetts Institute of Technology
7  *      For copying and distribution information, please see the file
8  *      <mit-copyright.h>.
9  *      
10  *      This routine is part of the client library.  It handles
11  *      the protocol operations: invoking an update and getting the
12  *      SMS message of the day.
13  */
14
15 #ifndef lint
16 static char *rcsid_sms_do_update_c = "$Header$";
17 #endif lint
18
19 #include <mit-copyright.h>
20 #include "sms_private.h"
21
22
23 /* Invoke a DCM update. */
24
25 int sms_do_update()
26 {
27     int status;
28     sms_params param_st;
29     struct sms_params *params = NULL;
30     struct sms_params *reply = NULL;
31
32     CHECK_CONNECTED;
33     params = &param_st;
34     params->sms_version_no = sending_version_no;
35     params->sms_procno = SMS_DO_UPDATE;
36     params->sms_argc = 0;
37     params->sms_argl = NULL;
38     params->sms_argv = NULL;
39         
40     if ((status = sms_do_call(params, &reply)) == 0)
41         status = reply->sms_status;
42         
43     sms_destroy_reply(reply);
44
45     return status;
46 }
47
48
49 /* Get the SMS motd.  This returns an SMS status, and motd will either
50  * point to NULL or the motd in a static buffer.
51  */
52
53 int sms_motd(motd)
54 char **motd;
55 {
56     int status;
57     sms_params param_st;
58     struct sms_params *params = NULL;
59     struct sms_params *reply = NULL;
60     static char buffer[1024];
61
62     *motd = NULL;
63     CHECK_CONNECTED;
64     params = &param_st;
65     params->sms_version_no = sending_version_no;
66     params->sms_procno = SMS_MOTD;
67     params->sms_argc = 0;
68     params->sms_argl = NULL;
69     params->sms_argv = NULL;
70         
71     if ((status = sms_do_call(params, &reply)))
72       goto punt;
73
74     while ((status = reply->sms_status) == SMS_MORE_DATA) {
75         if (reply->sms_argc > 0) {
76             strncpy(buffer, reply->sms_argv[0], sizeof(buffer));
77             *motd = buffer;
78         }
79         sms_destroy_reply(reply);
80         reply = NULL;
81
82         initialize_operation(_sms_recv_op, sms_start_recv, &reply,
83                              (int (*)())NULL);
84         queue_operation(_sms_conn, CON_INPUT, _sms_recv_op);
85
86         complete_operation(_sms_recv_op);
87         if (OP_STATUS(_sms_recv_op) != OP_COMPLETE) {
88             sms_disconnect();
89             status = SMS_ABORTED;
90             return(status);
91         }
92     }   
93  punt:
94     sms_destroy_reply(reply);
95     /* for backwards compatability */
96     if (status == SMS_UNKNOWN_PROC)
97       return(0);
98     else
99       return(status);
100 }
This page took 0.056039 seconds and 3 git commands to generate.