static int HtmlDeCode( TCHAR * pszDst, LPCTSTR pszSrc ) { int i = 0; for (;;) { TCHAR ch = *pszSrc++; if ( ch == '+' ) { ch = ' '; } else if ( ch == '%' ) { ch = *pszSrc++; int iVal = GetHexDigit(ch); if ( ch ) { ch = *pszSrc++; if ( ch ) { ch = static_cast<TCHAR>(iVal*0x10 + GetHexDigit(ch)); if (static_cast<unsigned char>(ch) == 0xa0) ch = '\0'; } } } *pszDst++ = ch; if ( ch == 0 ) break; i++; } return( i ); }
static int HtmlDeCode( tchar * pszDst, lpctstr pszSrc ) { int i = 0; for (;;) { tchar ch = *pszSrc++; if ( ch == '+' ) { ch = ' '; } else if ( ch == '%' ) { ch = *pszSrc++; int iVal = GetHexDigit(ch); if ( ch ) { ch = *pszSrc++; if ( ch ) { ch = static_cast<tchar>(iVal*0x10 + GetHexDigit(ch)); if ((uchar)(ch) == 0xa0) ch = '\0'; } } } *pszDst++ = ch; if ( ch == 0 ) break; i++; } return( i ); }
BYTE GetTwoDigitDec(void) { BYTE oneByte; oneByte = GetHexDigit() * 10; oneByte += GetHexDigit(); return oneByte; }
BYTE GetMACByte( void ) { BYTE oneByte; oneByte = GetHexDigit() << 4; oneByte += GetHexDigit(); return oneByte; }
bool Format::FromHex(const char *psz, byte *pb, int cb) { const char *pch = psz; while (*pch != 0 && cb != 0) { byte b; if (!GetHexDigit(*pch++, &b)) { return false; } *pb = b << 4; if (!GetHexDigit(*pch++, &b)) { return false; } *pb++ |= b; cb--; } return true; }
void ProcessMenu( void ) { BYTE c; BYTE i; // Get the key value. c = ConsoleGet(); ConsolePut( c ); switch (c) { case '1': ConsolePutROMString((ROM char * const)"\r\n1=ENABLE_ALL 2=ENABLE PREV 3=ENABLE SCAN 4=DISABLE: "); while( !ConsoleIsGetReady()); c = ConsoleGet(); ConsolePut(c); switch(c) { case '1': MiApp_ConnectionMode(ENABLE_ALL_CONN); break; case '2': MiApp_ConnectionMode(ENABLE_PREV_CONN); break; case '3': MiApp_ConnectionMode(ENABLE_ACTIVE_SCAN_RSP); break; case '4': MiApp_ConnectionMode(DISABLE_ALL_CONN); break; default: break; } break; case '2': Printf("\r\nFamily Tree: "); for(i = 0; i < NUM_COORDINATOR; i++) { PrintChar(FamilyTree[i]); Printf(" "); } break; case '3': Printf("\r\nMy Routing Table: "); for(i = 0; i < NUM_COORDINATOR/8; i++) { PrintChar(RoutingTable[i]); } Printf("\r\nNeighbor Routing Table: "); for(i = 0; i < NUM_COORDINATOR; i++) { BYTE j; for(j = 0; j < NUM_COORDINATOR/8; j++) { PrintChar(NeighborRoutingTable[i][j]); } Printf(" "); } break; case '4': { WORD_VAL tempShortAddr; Printf("\r\n1=Broadcast 2=Unicast Connection 3=Unicast Addr: "); while( !ConsoleIsGetReady()); c = ConsoleGet(); ConsolePut(c); MiApp_FlushTx(); MiApp_WriteData('T'); MiApp_WriteData('e'); MiApp_WriteData('s'); MiApp_WriteData('t'); MiApp_WriteData(0x0D); MiApp_WriteData(0x0A); switch(c) { case '1': MiApp_BroadcastPacket(FALSE); TxNum++; break; case '2': Printf("\r\nConnection Index: "); while( !ConsoleIsGetReady()); c = GetHexDigit(); MiApp_UnicastConnection(c, FALSE); TxNum++; break; case '3': Printf("\r\n1=Long Address 2=Short Address: "); while( !ConsoleIsGetReady()); c = ConsoleGet(); ConsolePut(c); switch(c) { case '1': Printf("\r\nDestination Long Address: "); for(i = 0; i < MY_ADDRESS_LENGTH; i++) { tempLongAddress[MY_ADDRESS_LENGTH-1-i] = GetMACByte(); } MiApp_UnicastAddress(tempLongAddress, TRUE, FALSE); TxNum++; break; case '2': Printf("\r\nDestination Short Address: "); tempLongAddress[1] = GetMACByte(); tempLongAddress[0] = GetMACByte(); MiApp_UnicastAddress(tempLongAddress, FALSE, FALSE); TxNum++; break; default: break; } break; default: break; } } LCDTRXCount(TxNum, RxNum); break; case '5': { Printf("\r\nMSB of the Coordinator: "); i = GetMACByte(); Printf("\r\nSet MSB of this Node's Parent: "); FamilyTree[i] = GetMACByte(); } break; case '6': { Printf("\r\nSet my Routing Table: "); for(i = 0; i < NUM_COORDINATOR/8; i++) { RoutingTable[i] = GetMACByte(); Printf(" "); } } break; case '7': { BYTE j; Printf("\r\nNode Number: "); i = GetMACByte(); Printf("\r\nContent of Neighbor Routing Table: "); for(j = 0; j < NUM_COORDINATOR/8; j++) { NeighborRoutingTable[i][j] = GetMACByte(); Printf(" "); } } break; case '8': { MiApp_InitChannelHopping(0xFFFFFFFF); } break; case '9': { Printf("\r\nSocket: "); PrintChar(MiApp_EstablishConnection(0xFF, CONN_MODE_INDIRECT)); } break; case 'z': case 'Z': { DumpConnection(0xFF); } default: break; } PrintMenu(); }
/* Parse character (possibly an escape sequence). Return the unicode value of the character. *code will be assigned the opcode corresponding to the character or EMPTY if the character has no special meaning. */ static int ParseChar(ParseInfo *info, AReOpcode *code) { unsigned char c; *code = A_EMPTY; /* Assumption: info->bufInd < info->bufLen. */ /* Escape sequence? */ if (*info->str != '\\') /* No, plain character. */ return *info->str++; /* Skip '\\'. */ info->str++; /* Check end of line. */ if (info->str == info->strEnd) { AGenerateError(info, ErrTrailingBackslash); return 0; } /* Translate an escape sequence. */ c = *info->str++; if (c == 'x') { /* Hexadecimal ascii value? */ int digit1 = GetHexDigit(info); int digit2; if (digit1 < 0) return 'x'; digit2 = GetHexDigit(info); if (digit2 < 0) return digit1; else return digit1 * 16 + digit2; } if (c >= 'a' && c <= 'z') { int conv = CharConv[c - 'a']; if (conv >= CC) *code = conv; else if (conv == 0) conv = c; return conv; } if (c == '<') { *code = A_BOW; return '<'; } if (c == '>') { *code = A_EOW; return '>'; } if (c == 'D') { *code = CC + CC_COMP; return 0; } if (c == 'S') { *code = CC + 1 + CC_COMP; return 0; } if (c == 'W') { *code = CC + 2 + CC_COMP; return 0; } if (ReIsDigit(c)) { /* Octal ascii value / back reference */ if (c != '0' && (c > '7' || info->str == info->strEnd || !IsOctal(*info->str))) { /* Back reference */ *code = info->flags & A_RE_NOCASE ? A_BACKREF_I : A_BACKREF; return c > '7' ? c : c - '0'; } else { /* Octal value */ int number = c - '0'; if (info->str < info->strEnd && IsOctal(*info->str)) { number = number * 8 + (*info->str++ - '0'); if (info->str < info->strEnd && IsOctal(*info->str)) number = number * 8 + (*info->str++ - '0'); } return number; } } /* No special interpretion */ return c; }