Bool sameString(unsigned char* stringOne, unsigned char* stringTwo) { //int length = Strlen(stringOne); //if (length != Strlen(stringTwo)) //{ // return FALSE; //} int i = 0; while (stringOne[i] != '\0' || stringTwo[i] != '\0') { WriteDebugInfo("in while"); WriteDebugInfo(stringOne); WriteDebugInfo(stringTwo); if (stringTwo[i] != stringOne[i]) { if (stringOne[i] != '\0') { WriteDebugInfo("1 niet 0"); } if (stringOne[i+1] == '\0') { WriteDebugInfo("1 wel 0"); } WriteDebugInfo("in while"); return FALSE; } i++; } return TRUE; }
int main(int argc, char* argv[]) { if (argc >= 2) { LOGIT = false; PrintLog((DEST,"%s",WindowsName[WhatWindowsVer()])); WinVer(); InitVars(CSP_NAME, &iWinVer, &iCryptVer, &MAXKEYLEN); if (WhatWindowsVer() >= WINXP) CSP_NAME[0] = '\0'; else strcpy(CSP_NAME,MS_ENHANCED_PROV); DebugLog((DEST,"CSP=%s WinVer=%d CryptVer=%d MaxKeyLen=%d",CSP_NAME, iWinVer, iCryptVer, MAXKEYLEN)); iProv = arProv[iProv]; switch(argv[1][1]) // second character of the first parameter -e = 'e' { case 'e': Encrypt(argv[2],argv[3], argv[4]); break; case 'd': Decrypt(argv[2],argv[3], argv[4]); break; case 'k': CreateKey(argv[2], MAXKEYLEN); break; case 'l': ListProviders(); break; case 'x': WriteDebugInfo(); break; case 'v': Version(); break; case 'r': LOGIT = true; DEBUGIT = true; if (argc == 3) DeleteContainer(argv[2]); else DeleteContainer(CTX); LOGIT = false; DEBUGIT = false; break; case 'c': LOGIT = true; DEBUGIT = true; if (argc == 3) CreateContainer(argv[2]); else CreateContainer(CTX); LOGIT = false; DEBUGIT = false; break; default: Usage(); break; } } else Usage(); return(0); }
enum Command getCommand() { unsigned char getAngleX[] = {"getanglex"}; unsigned char getAngleY[] = {"getangley"}; unsigned char getAngleZ[] = {"getanglez"}; unsigned char getOsTime[] = {"getostime\0"}; unsigned char getDistanceToGround[] = {"getdtg"}; unsigned char getAllCommands0[] = {"?"}; unsigned char getAllCommands1[] = {"--help"}; unsigned char getAllCommands2[] = {"--h"}; unsigned char getStatusAllTasks[] = {"getstatustasks"}; unsigned char stopTaskWithId[] = {"stoptask"}; unsigned char* lrc = lastReceivedCommand(); char c2[10]; Itoa(Strlen(lrc),c2,10); WriteDebugInfo(c2); WriteDebugInfo("<-\n\r"); Itoa(Strlen(stopTaskWithId),c2,10); WriteDebugInfo(c2); WriteDebugInfo(lrc); WriteDebugInfo("<-\n\r"); //check if there are spaces in lrc int i; int spacePosition[COMMANDLENGTH]; int amountOfSpaces = 0; int lengthLrc = Strlen(lrc); for (i=0;i<lengthLrc;i++) { if (lrc[i] == ' ') { spacePosition[amountOfSpaces] = i; amountOfSpaces++; } } //get first command unsigned char firstCommand[spacePosition[0]+1]; if (amountOfSpaces > 0) { int j; for (j=0;j<spacePosition[0];j++) { firstCommand[j] = lrc[j]; } firstCommand[j] = '\0'; } if (sameString(getAngleX,lrc)) { return CommandRotationX; } else if (sameString(getAngleY,lrc)) { return CommandRotationY; } else if (sameString(getAngleZ,lrc)) { return CommandRotationZ; } else if (sameString(getOsTime,lrc)) { return commandOsTime; } else if (sameString(getDistanceToGround,lrc)) { return commandDistanceToGround; } else if (sameString(getAllCommands0,lrc) || sameString(getAllCommands1,lrc) || sameString(getAllCommands2,lrc)) { return CommandHelp; } else if (sameString(getStatusAllTasks,lrc)) { return CommandAllTaskStatus; } else if (sameString(stopTaskWithId,firstCommand)) { //get fisrt parameter unsigned char firstParam[spacePosition[1]-(spacePosition[0])]; if (amountOfSpaces > 1) { int j; for (j=spacePosition[1]+1;j<spacePosition[1]-(spacePosition[0]);j++) { firstParam[j-spacePosition[0]+1] = lrc[j-spacePosition[0]]; } firstParam[j-spacePosition[0]] = '\0'; } char c[10]; Itoa(spacePosition[1],c,10); getFirstParameter(firstParam); return CommandStopTaskWithId; } else if (lrc[0] != '\0'){ WriteDebugInformation(lrc,DirectDebug); WriteDebugInformation("Not a valid command.\n\r/>", DirectDebug); clearLastCommand(); } return CommandNoCommand; }
/* ================ idEvent::Alloc ================ */ idEvent *idEvent::Alloc( const idEventDef *evdef, int numargs, va_list args ) { idEvent *ev; size_t size; const char *format; idEventArg *arg; byte *dataPtr; int i; const char *materialName; if ( FreeEvents.IsListEmpty() ) { WriteDebugInfo( ); gameLocal.Error( "idEvent::Alloc : No more free events for '%s' event.", evdef->GetName() ); } ev = FreeEvents.Next(); ev->eventNode.Remove(); ev->eventdef = evdef; if ( numargs != evdef->GetNumArgs() ) { gameLocal.Error( "idEvent::Alloc : Wrong number of args for '%s' event.", evdef->GetName() ); } size = evdef->GetArgSize(); if ( size ) { ev->data = eventDataAllocator.Alloc( size ); memset( ev->data, 0, size ); } else { ev->data = NULL; } format = evdef->GetArgFormat(); for( i = 0; i < numargs; i++ ) { arg = va_arg( args, idEventArg * ); if ( format[ i ] != arg->type ) { // RAVEN BEGIN // abahr: type checking change as per Jim D. if ( ( format[ i ] == D_EVENT_ENTITY_NULL ) && ( arg->type == D_EVENT_ENTITY ) ) { // these types are identical, so allow them } else if ( ( arg->type == D_EVENT_INTEGER ) && ( arg->value == 0 ) ) { if ( ( format[ i ] == D_EVENT_ENTITY ) || ( format[ i ] == D_EVENT_ENTITY_NULL ) || ( format[ i ] == D_EVENT_TRACE ) ) { // when NULL is passed in for an entity or trace, it gets cast as an integer 0, so don't give an error when it happens } else { gameLocal.Error( "idEvent::Alloc : Wrong type passed in for arg # %d on '%s' event.", i, evdef->GetName() ); } } else { gameLocal.Error( "idEvent::Alloc : Wrong type passed in for arg # %d on '%s' event.", i, evdef->GetName() ); } // RAVEN END } dataPtr = &ev->data[ evdef->GetArgOffset( i ) ]; switch( format[ i ] ) { case D_EVENT_FLOAT : case D_EVENT_INTEGER : *reinterpret_cast<int *>( dataPtr ) = arg->value; break; case D_EVENT_VECTOR : if ( arg->value ) { *reinterpret_cast<idVec3 *>( dataPtr ) = *reinterpret_cast<const idVec3 *>( arg->value ); } break; case D_EVENT_STRING : if ( arg->value ) { idStr::Copynz( reinterpret_cast<char *>( dataPtr ), reinterpret_cast<const char *>( arg->value ), MAX_STRING_LEN ); } break; // RAVEN BEGIN // abahr: type checking change as per Jim D. // jshepard: TODO FIXME HACK this never ever produces desired, positive results. Events should be built to prepare for null entities, especially when dealing with // script events. This will throw a warning, and events should be prepared to deal with null entities. case D_EVENT_ENTITY : if ( reinterpret_cast<idEntity *>( arg->value ) == NULL ) { gameLocal.Warning( "idEvent::Alloc : NULL entity passed in to event function that expects a non-NULL pointer on arg # %d on '%s' event.", i, evdef->GetName() ); } *reinterpret_cast< idEntityPtr<idEntity> * >( dataPtr ) = reinterpret_cast<idEntity *>( arg->value ); break; case D_EVENT_ENTITY_NULL : *reinterpret_cast< idEntityPtr<idEntity> * >( dataPtr ) = reinterpret_cast<idEntity *>( arg->value ); break; //RAVEN END case D_EVENT_TRACE : if ( arg->value ) { *reinterpret_cast<bool *>( dataPtr ) = true; *reinterpret_cast<trace_t *>( dataPtr + sizeof( bool ) ) = *reinterpret_cast<const trace_t *>( arg->value ); // save off the material as a string since the pointer won't be valid in save games. // since we save off the entire trace_t structure, if the material is NULL here, // it will be NULL when we process it, so we don't need to save off anything in that case. if ( reinterpret_cast<const trace_t *>( arg->value )->c.material ) { materialName = reinterpret_cast<const trace_t *>( arg->value )->c.material->GetName(); idStr::Copynz( reinterpret_cast<char *>( dataPtr + sizeof( bool ) + sizeof( trace_t ) ), materialName, MAX_STRING_LEN ); } } else { *reinterpret_cast<bool *>( dataPtr ) = false; } break; default : gameLocal.Error( "idEvent::Alloc : Invalid arg format '%s' string for '%s' event.", format, evdef->GetName() ); break; } } return ev; }