/*****************************************************************************/ /* colors.c Access via: colors
BUILD ----- See BUILD_COLORS.COM VERSION HISTORY --------------- 19-DEC-2009 MGD v1.1.3, CGI response 31-MAY-2004 MGD v1.1.2, add RGB:(n,n,n) values to text 23-DEC-2003 MGD v1.1.1, minor conditional mods to support IA64 28-APR-1998 MGD v1.1.0, default to "standard" (216) colours 22-FEB-1997 MGD v1.0.0, quick hack */ /*****************************************************************************/ #define SOFTWAREVN "1.1.3" #define SOFTWARENM "COLORS" #ifdef __ALPHA char SoftwareID [] = SOFTWARENM " AXP-" SOFTWAREVN; #endif #ifdef __ia64 char SoftwareID [] = SOFTWARENM " IA64-" SOFTWAREVN; #endif #ifdef __VAX char SoftwareID [] = SOFTWARENM " VAX-" SOFTWAREVN; #endif #include #include #include #include #include #include #include #include #define VMSok(x) ((x) & STS$M_SUCCESS) #define VMSnok(x) !(((x) & STS$M_SUCCESS)) #define boolean int #define true 1 #define false 0 /* macro provides NULL pointer if CGI variable does not exist */ #define GetCgiVarIfExists(CharPointer,CgiVariableName) \ CharPointer = getenv(CgiVariableName) /* macro provides pointer to empty string even if CGI variable does not exist */ #define GetCgiVar(CharPointer,CgiVariableName) \ if ((CharPointer = getenv(CgiVariableName)) == NULL) \ CharPointer = ""; \ if (Debug) fprintf (stdout, "%s |%s|\n", CgiVariableName, CharPointer); char Utility [] = "COLORS"; boolean Debug, HttpHasBeenOutput; int Interval = 51; char *CgiKey1Ptr, *CgiKey2Ptr; char String [] = "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz"; /* function prototype */ TimeoutAst (); /*****************************************************************************/ /* */ main () { int status, ColorCount, Red, Green, Blue; char *BgColorPtr, *IntervalCommentPtr, *TextColorPtr; /*********/ /* begin */ /*********/ if (getenv ("COLORS$DBUG")) Debug = true; if (Debug) { fputs ("Content-Type: text/plain\n\n", stdout); system ("show symbol *"); } GetCgiVar (CgiKey1Ptr, "WWW_KEY_1"); GetCgiVar (CgiKey2Ptr, "WWW_KEY_2"); BgColorPtr = "ffffff"; if (strlen(CgiKey1Ptr) == 6) BgColorPtr = CgiKey1Ptr; else if (isdigit(CgiKey1Ptr[0])) Interval = atoi(CgiKey1Ptr); if (strlen(CgiKey2Ptr) == 6) BgColorPtr = CgiKey2Ptr; else if (isdigit(CgiKey2Ptr[0])) Interval = atoi(CgiKey2Ptr); if (Interval <= 0 || Interval >= 255) Interval = 51; if (tolower(BgColorPtr[0]) < '8' && tolower(BgColorPtr[2]) < '8' && tolower(BgColorPtr[4]) < '8') TextColorPtr = "ffffff"; else TextColorPtr = "000000"; if (Interval == 51) IntervalCommentPtr = "  ("standard" color map, 216 colors)"; else IntervalCommentPtr = "  (non-"standard" color map)"; fprintf (stdout, "Content-Type: text/html\r\n\ \r\n\ \n\ \n\ \n\ \n\ \n\ Interval: %d%s\n\

\n\ \n\ \n
\n\ \n", BgColorPtr, TextColorPtr, Interval, IntervalCommentPtr); fflush (stdout); ColorCount = 1; for (Red = 0; Red <= 255; Red += Interval) { for (Green = 0; Green <= 255; Green += Interval) { for (Blue = 0; Blue <= 255; Blue += Interval) { fprintf (stdout, "\ \ \ \n\ \n\ \n\ \\n", ColorCount++, Red & 0xff, Green & 0xff, Blue & 0xff, Red & 0xff, Green & 0xff, Blue & 0xff, Red & 0xff, Green & 0xff, Blue & 0xff, String, Red & 0xff, Green & 0xff, Blue & 0xff, String, Red & 0xff, Green & 0xff, Blue & 0xff, String, Red & 0xff, Green & 0xff, Blue & 0xff, String); } fprintf (stdout, "\n"); } } fprintf (stdout, "
%d.  #%02x%02x%02x %d,%d,%d    %s
\ %s
\ %s
\ %s
\n
\n\n\n"); exit (SS$_NORMAL); } /*****************************************************************************/