~akhil011/ubuntu/wily/monit/crypto_fix

« back to all changes in this revision

Viewing changes to src/xml.c

  • Committer: Package Import Robot
  • Author(s): Sergey B Kirpichev
  • Date: 2013-09-05 17:03:07 UTC
  • mfrom: (1.1.19)
  • Revision ID: package-import@ubuntu.com-20130905170307-ae94md1vagm60e41
Tags: 1:5.6-1
ImportedĀ UpstreamĀ versionĀ 5.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
137
137
 * @param V Format version
138
138
 */
139
139
static void status_service(Service_T S, StringBuffer_T B, short L, int V) {
140
 
        Event_T E = S->eventlist;
141
 
 
142
140
        if (V == 2)
143
141
                StringBuffer_append(B, "<service name=\"%s\"><type>%d</type>", S->name ? S->name : "", S->type);
144
142
        else
163
161
                if (S->every.type == 1)
164
162
                        StringBuffer_append(B, "<counter>%d</counter><number>%d</number>", S->every.spec.cycle.counter, S->every.spec.cycle.number);
165
163
                else
166
 
                        StringBuffer_append(B, "<cron><![CDATA[%s]]></cron>", S->every.spec.cron);
 
164
                        StringBuffer_append(B, "<cron>%s</cron>", S->every.spec.cron);
167
165
                StringBuffer_append(B, "</every>");
168
166
        }
169
167
 
170
 
        /* if the service is in error state, display first active error message to provide more details */
171
 
        while (E) {
172
 
                if ((E->state == STATE_FAILED || E->state == STATE_CHANGED) && (S->error & E->id) && E->message) {
173
 
                        StringBuffer_append(B, "<status_message><![CDATA[%s]]></status_message>", E->message);
174
 
                        break;
175
 
                }
176
 
                E = E->next;
177
 
        }
178
168
        if (L == LEVEL_FULL) {
179
169
                if (Util_hasServiceStatus(S)) {
180
170
                        if (S->type == TYPE_FILE || S->type == TYPE_DIRECTORY || S->type == TYPE_FIFO || S->type == TYPE_FILESYSTEM)
364
354
                "<id>%ld</id>"
365
355
                "<state>%d</state>"
366
356
                "<action>%d</action>"
367
 
                "<message><![CDATA[%s]]></message>",
 
357
                "<message><![CDATA[",
368
358
                tv->tv_sec,
369
359
                (long)tv->tv_usec,
370
360
                Event_get_id(E) == Event_Instance ? "Monit" : Event_get_source_name(E),
371
361
                Event_get_source_type(E),
372
362
                Event_get_id(E),
373
363
                Event_get_state(E),
374
 
                Event_get_action(E),
375
 
                Event_get_message(E));
 
364
                Event_get_action(E));
 
365
        // Escape the CDATA "]]>" stop sequence in string
 
366
        const char *msg = Event_get_message(E);
 
367
        for (int i = 0; msg[i]; i++) {
 
368
                if (msg[i] == '>' && i > 1 && (msg[i - 1] == ']' && msg[i - 2] == ']'))
 
369
                        StringBuffer_append(B, "&gt;");
 
370
                else
 
371
                        StringBuffer_append(B, "%c", msg[i]);
 
372
        }
 
373
        StringBuffer_append(B, "]]></message>");
376
374
        Service_T s = Event_get_source(E);
377
375
        if (s && s->token)
378
376
                StringBuffer_append(B, "<token>%s</token>", s->token);