void Tokenizer::SkipWhites(WhiteSkipping aIncludeNewLines) { if (!CheckWhite() && (aIncludeNewLines == DONT_INCLUDE_NEW_LINE || !CheckEOL())) { return; } nsACString::const_char_iterator rollback = mRollback; while (CheckWhite() || (aIncludeNewLines == INCLUDE_NEW_LINE && CheckEOL())) { } mHasFailed = false; mRollback = rollback; }
static int MakePS(int help) { char *token; int device; if (help) { p_stderr("gist: ps command syntax:\n ps psout\n"); p_stderr(" Opens a PostScript file psout for output.\n"); p_stderr(" Subsequent send commands will write to psout,\n"); p_stderr(" unless the send to list is modified (see send).\n"); return 0; } token= strtok(0, " \t\n"); if (!token) { p_stderr("gist: (SYNTAX) psout name missing in ps command\n"); return 0; } if (CheckEOL("ps")) return 0; device= FindDevice(); if (device>=8) return 0; CreatePS(device, token); return 0; }
static int MakeX(int help) { char *token, *server; int dpi, device, defDPI; if (help) { p_stderr("gist: display command syntax:\n "); p_stderr("display host:server.screen [dpi]\n"); p_stderr(" Connects to the specified X server.\n"); p_stderr(" Subsequent draw commands will write to server,\n"); p_stderr(" unless the draw to list is modified (see draw).\n"); p_stderr(" If specified, 40<=dpi<=200 (default 100).\n"); return 0; } token= strtok(0, " \t\n"); if (!token) { p_stderr("gist: (SYNTAX) cgmoutput name missing in cgm command\n"); return 0; } server= token; token= strtok(0, " \t\n"); if (token) { char *suffix; dpi= (int)strtol(token, &suffix, 0); if (*suffix) { p_stderr("gist: (SYNTAX) dpi unintelligble in display command\n"); return 0; } if (dpi<40 && dpi>200) { p_stderr( "gist: (SYNTAX) dpi not between 40 and 200 in display command\n"); return 0; } if (CheckEOL("display")) return 0; } else { dpi= 100; } device= FindDevice(); if (device>=8) return 0; defDPI= defaultDPI; defaultDPI= dpi; CreateX(device, server); defaultDPI= defDPI; return 0; }
static int MakeCGM(int help) { char *token, *cgmout; long size= 0; int device; if (help) { p_stderr("gist: cgm command syntax:\n cgm cgmout [size]\n"); p_stderr(" Opens a CGM file cgmout for output.\n"); p_stderr(" The size (default 1000000) is the maximum size of a\n"); p_stderr(" single file in the output family, in bytes.\n"); p_stderr(" Subsequent send commands will write to cgmout,\n"); p_stderr(" unless the send to list is modified (see send).\n"); return 0; } token= strtok(0, " \t\n"); if (!token) { p_stderr("gist: (SYNTAX) cgmout name missing in cgm command\n"); return 0; } cgmout= token; token= strtok(0, " \t\n"); if (token) { char *suffix; size= strtol(token, &suffix, 0); if (*suffix) { p_stderr("gist: (SYNTAX) size unintelligble in cgm command\n"); return 0; } if (CheckEOL("cgm")) return 0; } device= FindDevice(); if (device>=8) return 0; if (!CreateCGM(device, cgmout) && size>0) ((CGMEngine *)outEngines[device])->fileSize= size; return 0; }
static int Special(int help) { if (help) { char msg[80]; sprintf(msg, "gist: n%c command syntax:\n n%c\n", cSuffix, cSuffix); p_stderr(msg); if (cSuffix=='f') p_stderr(" Forward n (default 1) pages, then draw\n"); else if (cSuffix=='b') p_stderr(" Backward n (default 1) pages, then draw\n"); else p_stderr(" Go to page n (default 1), then draw\n"); return 0; } if (CheckEOL("nf, nb, or ng")) return 0; DoSpecial(nPrefix, cSuffix); return 0; }
//****************************************************************************** /// Prints the analogue value read from the zone, calls CheckEOL() to determine the value void HTTPPrint_EOLValue (WORD num) { char EOLOutput[5]; Zone_States Ignore; WORD EOLValue; // Set a flag to indicate not finished curHTTP.callbackPos = 1; // Make sure there's enough output space if(TCPIsPutReady(sktHTTP) < (unsigned int)5) return; Ignore = CheckEOL(num, &EOLValue); uitoa(EOLValue, EOLOutput); TCPPutArray(sktHTTP, (BYTE*)EOLOutput, (WORD) strlen(EOLOutput)); // Indicate that we're done curHTTP.callbackPos = 0x00; return; }
static int OpenIn(int help) { char *token; if (help) { p_stderr("gist: open command syntax:\n open cgminput\n"); p_stderr(" Closes the current CGM input file, then opens cgminput.\n"); p_stderr(" Only a Gist-compliant binary CGM file is legal.\n"); p_stderr(" The cgminput may be the first file of a family.\n"); p_stderr(" Subsequent page numbers refer to this input file.\n"); return 0; } token= strtok(0, " \t\n"); if (!token) { p_stderr("gist: (SYNTAX) cgminput name missing in open command\n"); return 0; } if (CheckEOL("open")) return 0; if (no_warnings) no_warnings= 1; /* one warning per file family */ OpenCGM(token); return 0; }
Zone_States IsZoneTriggered (int ZoneID) { Zone_States TheZoneState, PreviousZoneState; WORD Ignore; //ensure zone is not bypassed or isolated, if so return nothing if ((ZoneConfig[ZoneID].IsIsolated) || (ZoneConfig[ZoneID].IsBypassed)) return StateNothing; // What is the previous state if (ZoneConfig[ZoneID].IsTampered) PreviousZoneState = StateTamper; else if (ZoneConfig[ZoneID].IsTriggered) PreviousZoneState = StateTrigger; else PreviousZoneState = StateNormal; // Determine the state of the zone TheZoneState = CheckEOL(ZoneID, &Ignore); //If the state is the same as the previous check and bounce timer not active return nothing. if ((PreviousZoneState == TheZoneState ) && (ZoneConfig[ZoneID].BounceDelay == (unsigned) 0)) return StateNothing; // *** TAMPER *** // Zone is Tampered if (TheZoneState == StateTamper) { ZoneConfig[ZoneID].IsTampered = TRUE; ZoneConfig[ZoneID].BounceDelay = 0; // Will cause a loop always returning StateTamper if left out // find out what Areas the zone is a part of and set them to tampered for(iCount = 0; iCount < AREACOUNT; iCount++) { if (isZoneMemberOfArea(ZoneID, iCount)) { AreaConfig[iCount].IsTampered = TRUE; #if defined(DEBUG_UART) putrsUART((ROM char*)" Area "); uitoa(iCount, xPLMsgKey); putsUART(xPLMsgKey); putrsUART((ROM char*)" is Tampered. \r\n"); #endif }// isZoneMemberOfArea(ZoneID, iCount) }// iCount return StateTamper; } // StateTamper // Return from Tamper if (PreviousZoneState == StateTamper) { ZoneConfig[ZoneID].IsTampered = FALSE; ZoneConfig[ZoneID].BounceDelay = 0; // find out what Areas the zone is a part and set tamper to false if no other zones in the area are tampered for(iCount = 0; iCount < AREACOUNT; iCount++) { if (isZoneMemberOfArea(ZoneID, iCount)) { for(i2Count=0; i2Count < ZONECOUNT; i2Count++) { if ((i2Count != ZoneID) && isZoneMemberOfArea(i2Count, iCount)) { if( ZoneConfig[i2Count].IsTampered == TRUE) { i2Count = 1; break; }// is triggered }// is member of the zone }//i2Count, Area in question if (i2Count >= ZONECOUNT) { // no zones in the area found to be triggered AreaConfig[iCount].IsTampered = FALSE; #if defined(DEBUG_UART) putrsUART((ROM char*)" Area "); uitoa(iCount, xPLMsgKey); putsUART(xPLMsgKey); putrsUART((ROM char*)" is not tampered. \r\n"); #endif }// i2Count >= ZONECOUNT }// isZoneMemberOfArea(ZoneID, iCount) }// iCount // When changing from Tampered to Triggered this will generate a Triggered event after the tamper cleared event ZoneConfig[ZoneID].IsTriggered = FALSE; // Return as normal even if triggered to ensure message sequence is correct return StateNormal; } // *** BOUNCE / TRIGGER CLEARED *** //Every time we return from Triggered to Normal there is a delay of .5 Second, this limits bouncing speed. //If BounceTimer not expired return Nothing. If we are bouncing it will only send 2 msg per 1/2 second. Do not change previous state if (ZoneConfig[ZoneID].BounceDelay > (unsigned) 1) { ZoneConfig[ZoneID].BounceDelay--; if (TheZoneState == StateTrigger) ZoneConfig[ZoneID].BounceDelay = 0; return StateNothing; } //if BounceTimer is expired clear BounceTimer if (ZoneConfig[ZoneID].BounceDelay == (unsigned) 1) { // if state = Trigger then return nothing as we have bounced back (Trigger, Normal Trigger) if (TheZoneState == StateTrigger) { ZoneConfig[ZoneID].BounceDelay = 0; #if defined(DEBUG_UART) putrsUART((ROM char*)" Bounce prevented. Zone "); uitoa(ZoneID, xPLMsgKey); putsUART(xPLMsgKey); putrsUART((ROM char*)" remains triggered.\r\n"); #endif return StateNothing; } // if state = normal return Normal and set the state flag on the zone if (TheZoneState == StateNormal) { ZoneConfig[ZoneID].BounceDelay = 0; ZoneConfig[ZoneID].IsTriggered = FALSE; ZoneConfig[ZoneID].IsTampered = FALSE; #if defined(DEBUG_UART) putrsUART((ROM char*)" Bounce Cleared. Zone "); uitoa(ZoneID, xPLMsgKey); putsUART(xPLMsgKey); putrsUART((ROM char*)" is normal. \r\n"); #endif // find out what Areas the zone is a part and set triggered to false if no other zones in the area // are also triggered at the same time for(iCount = 0; iCount < AREACOUNT; iCount++) { if (isZoneMemberOfArea(ZoneID, iCount)) { for(i2Count=0; i2Count < ZONECOUNT; i2Count++) { if ((i2Count != ZoneID) && isZoneMemberOfArea(i2Count, iCount)) { if( ZoneConfig[i2Count].IsTriggered == TRUE) { i2Count = 1; break; }// is triggered }// is member of the zone }//i2Count, Area in question if (i2Count >= ZONECOUNT) { // no zones in the area found to be triggered AreaConfig[iCount].IsTriggered = FALSE; #if defined(DEBUG_UART) putrsUART((ROM char*)" Area "); uitoa(iCount, xPLMsgKey); putsUART(xPLMsgKey); putrsUART((ROM char*)" is normal. \r\n"); #endif }// i2Count >= ZONECOUNT }// isZoneMemberOfArea(ZoneID, iCount) }// iCount return StateNormal; } } //If current state Normal, set the BounceTimer, return Nothing if (TheZoneState == StateNormal) { ZoneConfig[ZoneID].BounceDelay = BOUNCEDELAY; #if defined(DEBUG_UART) if (ZoneID == 0) putrsUART((ROM char*)" Bounce Set. \r\n"); #endif return StateNothing; } // *** TRIGGER *** //The only thing left should be a normal trigger, return trigger and set the state flag on the zone if (TheZoneState == StateTrigger) { ZoneConfig[ZoneID].BounceDelay = 0; ZoneConfig[ZoneID].IsTriggered = TRUE; #if defined(DEBUG_UART) putrsUART((ROM char*)"Zone "); uitoa(ZoneID, xPLMsgKey); putsUART(xPLMsgKey); putrsUART((ROM char*)"triggered. "); #endif // find out what Areas the zone is a part of and set them to triggered for(iCount = 0; iCount < AREACOUNT; iCount++) { if (isZoneMemberOfArea(ZoneID, iCount)) { AreaConfig[iCount].IsTriggered = TRUE; #if defined(DEBUG_UART) putrsUART((ROM char*)" Area "); uitoa(iCount, xPLMsgKey); putsUART(xPLMsgKey); putrsUART((ROM char*)" is Triggered. \r\n"); #endif }// isZoneMemberOfArea(ZoneID, iCount) }// iCount return StateTrigger; } } //IsZoneTriggered
static int EPS(int help) { char *token; int device; if (help) { p_stderr("gist: eps command syntax:\n eps epsout\n"); p_stderr(" Open an Encapsulated PostScript file epsout, write\n"); p_stderr(" the current page to it, then close epsout.\n"); p_stderr(" (Note that an EPS file can have only a single page.)\n"); return 0; } token= strtok(0, " \t\n"); if (!token) { p_stderr("gist: (SYNTAX) epsout name missing in eps command\n"); return 0; } if (CheckEOL("eps")) return 0; device= FindDevice(); if (device>=8) return 0; device= FindDevice(); if (device>=8) return 0; outEngines[device]= GpPSEngine("CGM Viewer", cgmLandscape, 0, "_tmp.eps"); if (!outEngines[device]) { Warning(gistError, ""); Warning("Unable to create PostScript engine ", token); return 0; } GpPreempt(outEngines[device]); nPage[0]= mPage[0]= CGMRelative(0); sPage[0]= 1; nPageGroups= 1; /* First read does PS part, second computes EPS preview */ if (!ReadCGM(mPage, nPage, sPage, nPageGroups)) { GpPreempt(0); outEngines[device]= EPSPreview(outEngines[device], token); if (outEngines[device]) { GpPreempt(outEngines[device]); ReadCGM(mPage, nPage, sPage, nPageGroups); } else { Warning("memory manager failed creating EPS engine ", token); return 0; } } if (outEngines[device]) { GpPreempt(0); GpKillEngine(outEngines[device]); outEngines[device]= 0; } return 0; }