/* Collection of code snippets by Arne Vajhøj */
/* (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

#include "cgilib.h"

#ifndef  __ALPHA
globalref sys$gw_ijobcnt;
globalref sys$gw_bjobcnt;
#else
globalref sys$gl_ijobcnt;
globalref sys$gl_bjobcnt;
#endif

main(int argc,char *argv[])
{
   cgi_init(argc,argv);
   cgi_printf("content-type: text/html\n\n");
   if(strcmp(cgi_info("REQUEST_METHOD"),"HEAD")==0) exit(1);
   cgi_printf("<HTML>\n");
   cgi_printf("<HEAD>\n");
   cgi_printf("<TITLE>Number of users</TITLE>\n");
   cgi_printf("</HEAD>\n");
   cgi_printf("<BODY>\n");
#ifndef  __ALPHA
   cgi_printf("<P>The number of interactive users are    : %d</P>\n",sys$gw_ijobcnt);
   cgi_printf("<P>The number of executing batch-jobs are : %d</P>\n",sys$gw_bjobcnt);
#else
   cgi_printf("<P>The number of interactive users are    : %d\n</P>",sys$gl_ijobcnt);
   cgi_printf("<P>The number of executing batch-jobs are : %d\n</P>",sys$gl_bjobcnt);
#endif
   cgi_printf("<P>Click <A HREF=\"/htbin/showuser.exe/%d\">here</A> to reexecute</P>\n",time(NULL));
   cgi_printf("</BODY>\n");
   cgi_printf("</HTML>\n");
}
