int goodString(char * str, int forFilename) { char *c; int ret = 1; for (c = str; *c; c++) if (!goodChar(*c, forFilename)) { ret = 0; break; } if (!ret) logException(27,str,0); return ret; }
void pfPrcHelper::writeHexStream(size_t length, const unsigned char* data) { // Remember that the comments need to remain valid UTF-8, so only characters // between 0x20 and 0x7F can be displayed... size_t i; for (i=0; i<(length / 16); i++) { const unsigned char* ln = &data[i * 16]; file->writeStr( ST::format("{_02X} {_02X} {_02X} {_02X} {_02X} {_02X} {_02X} {_02X} " "{_02X} {_02X} {_02X} {_02X} {_02X} {_02X} {_02X} {_02X} ", ln[0x0], ln[0x1], ln[0x2], ln[0x3], ln[0x4], ln[0x5], ln[0x6], ln[0x7], ln[0x8], ln[0x9], ln[0xA], ln[0xB], ln[0xC], ln[0xD], ln[0xE], ln[0xF] )); file->writeStr( ST::format(" <!-- {c}{c}{c}{c}{c}{c}{c}{c}{c}{c}{c}{c}{c}{c}{c}{c} -->\n", goodChar(ln[0x0]) ? ln[0x0] : '.', goodChar(ln[0x1]) ? ln[0x1] : '.', goodChar(ln[0x2]) ? ln[0x2] : '.', goodChar(ln[0x3]) ? ln[0x3] : '.', goodChar(ln[0x4]) ? ln[0x4] : '.', goodChar(ln[0x5]) ? ln[0x5] : '.', goodChar(ln[0x6]) ? ln[0x6] : '.', goodChar(ln[0x7]) ? ln[0x7] : '.', goodChar(ln[0x8]) ? ln[0x8] : '.', goodChar(ln[0x9]) ? ln[0x9] : '.', goodChar(ln[0xA]) ? ln[0xA] : '.', goodChar(ln[0xB]) ? ln[0xB] : '.', goodChar(ln[0xC]) ? ln[0xC] : '.', goodChar(ln[0xD]) ? ln[0xD] : '.', goodChar(ln[0xE]) ? ln[0xE] : '.', goodChar(ln[0xF]) ? ln[0xF] : '.' )); } if ((length % 16) != 0) { const unsigned char* ln = &data[(length / 16) * 16]; for (i=0; i<(length % 16); i++) file->writeStr(ST::format("{_02X} ", ln[i])); for (; i<16; i++) file->writeStr(" "); file->writeStr(" <!-- "); for (i=0; i<(length % 16); i++) file->writeStr( ST::format("{c}", goodChar(ln[i]) ? ln[i] : '.')); for (; i<16; i++) file->writeStr(" "); file->writeStr(" -->\n"); } }