]>
Commit | Line | Data |
---|---|---|
de56407f | 1 | /* |
2 | * $Source$ | |
3 | * $Author$ | |
4 | * $Header$ | |
5 | * | |
5f9f27e4 | 6 | * Copyright (C) 1987, 1989 by the Massachusetts Institute of Technology |
babbc197 | 7 | * For copying and distribution information, please see the file |
8 | * <mit-copyright.h>. | |
de56407f | 9 | * |
10 | * This routine is part of the client library. It handles | |
5f9f27e4 | 11 | * the protocol operations: invoking an update and getting the |
12 | * SMS message of the day. | |
de56407f | 13 | */ |
14 | ||
15 | #ifndef lint | |
16 | static char *rcsid_sms_do_update_c = "$Header$"; | |
17 | #endif lint | |
18 | ||
babbc197 | 19 | #include <mit-copyright.h> |
de56407f | 20 | #include "sms_private.h" |
21 | ||
5f9f27e4 | 22 | |
23 | /* Invoke a DCM update. */ | |
24 | ||
de56407f | 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 = ¶m_st; | |
89371417 | 34 | params->sms_version_no = sending_version_no; |
de56407f | 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 | ||
5f9f27e4 | 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. | |
de56407f | 51 | */ |
5f9f27e4 | 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 = ¶m_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 | return(status); | |
96 | } |