]>
Commit | Line | Data |
---|---|---|
7ac48069 | 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 | |
7ac48069 | 16 | #include <string.h> |
17 | ||
18 | RCSID("$Header$"); | |
5f9f27e4 | 19 | |
20 | /* Invoke a DCM update. */ | |
21 | ||
5eaef520 | 22 | int mr_do_update(void) |
de56407f | 23 | { |
5eaef520 | 24 | int status; |
25 | mr_params param_st; | |
26 | struct mr_params *params = NULL; | |
27 | struct mr_params *reply = NULL; | |
de56407f | 28 | |
5eaef520 | 29 | CHECK_CONNECTED; |
30 | params = ¶m_st; | |
31 | params->mr_version_no = sending_version_no; | |
32 | params->mr_procno = MR_DO_UPDATE; | |
33 | params->mr_argc = 0; | |
34 | params->mr_argl = NULL; | |
35 | params->mr_argv = NULL; | |
36 | ||
37 | if ((status = mr_do_call(params, &reply)) == 0) | |
38 | status = reply->mr_status; | |
39 | ||
40 | mr_destroy_reply(reply); | |
41 | ||
42 | return status; | |
de56407f | 43 | } |
44 | ||
5f9f27e4 | 45 | |
59ec8dae | 46 | /* Get the Moira motd. This returns a Moira status, and motd will either |
5f9f27e4 | 47 | * point to NULL or the motd in a static buffer. |
de56407f | 48 | */ |
5f9f27e4 | 49 | |
5eaef520 | 50 | int mr_motd(char **motd) |
5f9f27e4 | 51 | { |
5eaef520 | 52 | int status; |
53 | mr_params param_st; | |
54 | struct mr_params *params = NULL; | |
55 | struct mr_params *reply = NULL; | |
56 | static char buffer[1024]; | |
57 | ||
58 | *motd = NULL; | |
59 | CHECK_CONNECTED; | |
60 | params = ¶m_st; | |
61 | params->mr_version_no = sending_version_no; | |
62 | params->mr_procno = MR_MOTD; | |
63 | params->mr_argc = 0; | |
64 | params->mr_argl = NULL; | |
65 | params->mr_argv = NULL; | |
66 | ||
67 | if ((status = mr_do_call(params, &reply))) | |
68 | goto punt; | |
69 | ||
70 | while ((status = reply->mr_status) == MR_MORE_DATA) | |
71 | { | |
72 | if (reply->mr_argc > 0) | |
73 | { | |
74 | strncpy(buffer, reply->mr_argv[0], sizeof(buffer)); | |
75 | *motd = buffer; | |
5f9f27e4 | 76 | } |
5eaef520 | 77 | mr_destroy_reply(reply); |
78 | reply = NULL; | |
79 | ||
80 | initialize_operation(_mr_recv_op, mr_start_recv, &reply, NULL); | |
81 | queue_operation(_mr_conn, CON_INPUT, _mr_recv_op); | |
82 | ||
7ac48069 | 83 | complete_operation(_mr_recv_op); |
5eaef520 | 84 | if (OP_STATUS(_mr_recv_op) != OP_COMPLETE) |
85 | { | |
86 | mr_disconnect(); | |
87 | status = MR_ABORTED; | |
88 | return status; | |
5f9f27e4 | 89 | } |
5eaef520 | 90 | } |
91 | punt: | |
92 | mr_destroy_reply(reply); | |
93 | /* for backwards compatability */ | |
94 | if (status == MR_UNKNOWN_PROC) | |
95 | return 0; | |
96 | else | |
97 | return status; | |
5f9f27e4 | 98 | } |