54a55
>  * 26.11.05 Added XML output [Marion DESNAULT]
192a194
> #define STAT_OPT_XML      3
204a207
>     {STAT_OPT_XML, "xml", NULL},
227a231
>     int xml_report;
254a259
>     xml_report = 0;
304a310,313
>                 case STAT_OPT_XML:
>                     ap_set_content_type(r, "text/xml");
>                     xml_report = 1;
>                     break;
393c402
<     if (!short_report) {
---
>     if (!short_report && !xml_report) {
416a426,446
>     else if (xml_report) {
>         ap_rputs("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n", r);
>         if (ap_extended_status)
>             ap_rputs("<server-status extended=\"true\">\n", r);
>         else
>             ap_rputs("<server-status extended=\"false\">\n", r);
>         ap_rprintf(r, "<host>%s</host>\n", ap_get_server_name(r));
>         ap_rputs("<server>\n", r);
>         ap_rprintf(r, "<version>%s</version>\n", ap_get_server_version());
>         ap_rprintf(r, "<build>%s</build>\n", ap_get_server_built());
>         ap_rputs("</server>\n", r);
>         ap_rputs("<time>\n", r);
>         ap_rprintf(r, "<current>%d</current>\n", (int) (nowtime/1000000));
>         ap_rprintf(r, "<restart>%d</restart>\n",
>                    (int) (ap_scoreboard_image->global->restart_time/1000000));
>         ap_rputs("</time>\n", r);
>         ap_rputs("<status>\n", r);
>         ap_rprintf(r, "<parentGeneration>%u</parentGeneration>\n",
>                    (int) ap_my_generation);
>         ap_rprintf(r, "<uptime>%ld</uptime>\n", (long) up_time);
>     }
444c474,510
<         else { /* !short_report */
---
>         else if (xml_report) {
>             ap_rprintf(r, "<accesses>%lu</accesses>\n", count);
>             ap_rprintf(r, "<traffic>%lu</traffic>\n", kbcount);
> 
> #ifdef HAVE_TIMES
>             /* Allow for OS/2 not having CPU stats */
>             ap_rputs("<cpu>\n", r);
>             ap_rprintf(r, "<usage u=\"%g\" s=\"%g\" cu=\"%g\" cs=\"%g\" />\n",
>                        tu / tick, ts / tick, tcu / tick, tcs / tick);
> 
>             if (ts || tu || tcu || tcs)
>                 ap_rprintf(r, "<load>%.3g</load>\n",
>                            (tu + ts + tcu + tcs) / tick / up_time * 100.);
>             ap_rputs("</cpu>\n", r);
> #endif
> 
>             ap_rputs("<stats>\n", r);
> 
>             if (up_time > 0)
>                 ap_rprintf(r, "<requestsPerSecond>%.3g</requestsPerSecond>\n",
>                            (float) count / (float) up_time);
> 
>             if (up_time > 0) {
>                 ap_rprintf(r, "<bytesPerSecond>%lu</bytesPerSecond>\n",
>                            (unsigned long)(KBYTE * (float) kbcount
>                                                  / (float) up_time));
>             }
> 
>             if (count > 0) {
>                 ap_rprintf(r, "<bytesPerRequest>%lu</bytesPerRequest>\n",
>                            (unsigned long)(KBYTE * (float) kbcount
>                                                  / (float) count));
>             }
> 
>             ap_rputs("</stats>\n", r);
>         }
>         else { /* !short_report && !xml_report */
479c545,552
<     if (!short_report)
---
>     if (xml_report)
>         ap_rputs("<scoreboard>\n", r);
> 
>     if (short_report)
>         ap_rprintf(r, "BusyWorkers: %d\nIdleWorkers: %d\n", busy, ready);
>     else if (xml_report)
>         ap_rprintf(r, "<busy>%d</busy>\n<idle>%d</idle>\n", busy, ready);
>     else
482,483d554
<     else
<         ap_rprintf(r, "BusyWorkers: %d\nIdleWorkers: %d\n", busy, ready);
486,488c557
<     if (!short_report)
<         ap_rputs("</dl><pre>", r);
<     else
---
>     if (short_report)
489a559,562
>     else if (xml_report)
>         ap_rputs("<raw>", r);
>     else
>         ap_rputs("</dl><pre>", r);
496c569
<                 && !short_report)
---
>                 && !short_report && !xml_report)
501c574,577
<     if (short_report)
---
>     if (xml_report)
>         ap_rputs("</raw>\n</scoreboard>\n</status>", r);
> 
>     if (short_report || xml_report)
547c623,625
<         if (no_table_report)
---
>         if (xml_report)
>             ap_rputs("<requests>\n", r);
>         else if (no_table_report)
597c675,725
<                 if (no_table_report) {
---
>                 if (xml_report) {
>                     if (ws_record->status == SERVER_DEAD)
>                         ap_rprintf(r,
>                                    "<request srvChild=\"%d\" srvGen=\"%d\" srvPid=\"-\" "
>                                    "accConn=\"%d\" accChild=\"%lu\" accSlot=\"%lu\" ",
>                                    i, (int)worker_generation,
>                                    (int)conn_lres, my_lres, lres);
>                     else
>                         ap_rprintf(r,
>                                    "<request srvChild=\"%d\" srvGen=\"%d\" srvPid=\"%" 
>                                    APR_PID_T_FMT
>                                    "\" accConn=\"%d\" accChild=\"%lu\" accSlot=\"%lu\" ",
>                                    i, (int)worker_generation,
>                                    worker_pid,
>                                    (int)conn_lres,
>                                    my_lres, lres);
> 
>                     ap_rprintf(r, "mode=\"%d\" ", ws_record->status);
> 
>                     ap_rprintf(r,
> #ifdef HAVE_TIMES
>                                "cpu=\"%.2f\" "
> #endif
>                                "ss=\"%ld\" req=\"%ld\" ",
> #ifdef HAVE_TIMES
>                                (ws_record->times.tms_utime +
>                                 ws_record->times.tms_stime +
>                                 ws_record->times.tms_cutime +
>                                 ws_record->times.tms_cstime) / tick,
> #endif
>                                (long)apr_time_sec(nowtime -
>                                                   ws_record->last_used),
>                                (long)req_time);
> 
>                     ap_rprintf(r, "conn=\"%lu\" child=\"%lu\" slot=\"%lu\" ",
>                                (unsigned long)conn_bytes, (unsigned long) my_bytes,
>                                (unsigned long)bytes);
> 
>                     if (ws_record->status == SERVER_BUSY_READ)
>                         ap_rprintf(r, "clientIP=\"?\" vhost=\"?\" methodurl=\"..reading..\" />\n");
>                     else
>                         ap_rprintf(r, "clientIP=\"%s\" vhost=\"%s\" methodurl=\"%s\" />\n",
>                                    ap_escape_html(r->pool,
>                                                   ws_record->client),
>                                    ap_escape_html(r->pool,
>                                                   ws_record->vhost),
>                                    ap_escape_html(r->pool,
>                                                   ap_escape_logitem(r->pool,
>                                                                     ws_record->request)));
>                 }
>                 else if (no_table_report) {
681c809
<                 else { /* !no_table_report */
---
>                 else { /* !no_table_report && !xml_report */
773c901
<         if (!no_table_report) {
---
>         if (!no_table_report && !xml_report) {
796c924
<         if (!short_report) {
---
>         if (!short_report && !xml_report) {
813c941,943
<     if (!short_report) {
---
>     if (xml_report)
>         ap_rputs("</requests>\n</server-status>\n", r);
>     else if (!short_report) {
