static int processUcsCharOperands (DataFile *file, void *data) { TextTableData *ttd = data; DataOperand string; if (getDataOperand(file, &string, "character string")) { if (string.length == 1) { DataOperand representation; if (getDataOperand(file, &representation, "braille representation")) { if (representation.length == 1) { unsigned char dots; if (testBrailleRepresentation(file, representation.characters[0], &dots)) { if (!setTextTableCharacter(ttd, string.characters[0], dots)) return 0; } } else { reportDataError(file, "multi-cell braille representation not supported"); } } } else { reportDataError(file, "multi-character string not supported"); } } return 1; }
static int processPropertyAssignment ( DataFile *file, const DataString *name, char **value, const ProfileActivationData *pad ) { unsigned int index; for (index=0; index<pad->profile->properties.count; index+=1) { if (isKeyword(pad->profile->properties.array[index].name, name->characters, name->length)) { char **v = &pad->values[index]; if (*v) { reportDataError(file, "property assigned more than once: %s:%.*"PRIws, pad->profile->category, name->length, name->characters); free(*v); } *v = *value; *value = NULL; return 1; } } reportDataError(file, "unknown property: %s:%.*"PRIws, pad->profile->category, name->length, name->characters); return 1; }
static int getUnicodeCharacter (DataFile *file, wchar_t *character, const char *description) { DataOperand string; if (getDataOperand(file, &string, description)) { if (string.length > 2) { if ((string.characters[0] == WC_C('U')) && (string.characters[1] == WC_C('+'))) { const wchar_t *digit = &string.characters[2]; int length = string.length - 2; *character = 0; while (length) { int value; int shift; if (!isHexadecimalDigit(*digit++, &value, &shift)) break; *character <<= shift; *character |= value; length -= 1; } if (!length) return 1; } } reportDataError(file, "invalid Unicode character: %.*" PRIws, string.length, string.characters); } return 0; }
static int testBrailleRepresentation (DataFile *file, wchar_t representation, unsigned char *dots) { if ((representation & ~UNICODE_CELL_MASK) == UNICODE_BRAILLE_ROW) { *dots = representation & UNICODE_CELL_MASK; return 1; } else { reportDataError(file, "invalid braille representation"); } return 0; }
static DATA_OPERANDS_PROCESSOR(processEncodingOperands) { DataOperand encoding; if (getDataOperand(file, &encoding, "character encoding name")) { if (!isKeyword(WS_C("UTF-8"), encoding.characters, encoding.length)) { reportDataError(file, "unsupported character encoding: %.*" PRIws, encoding.length, encoding.characters); } } return 1; }
static int processEncodingOperands (DataFile *file, void *data) { DataOperand encoding; if (getDataOperand(file, &encoding, "character encoding name")) { if (!isKeyword(WS_C("UTF-8"), encoding.characters, encoding.length)) { reportDataError(file, "unsupported character encoding: %.*" PRIws, encoding.length, encoding.characters); } } return 1; }
static DATA_OPERANDS_PROCESSOR(processUcsBlockOperands) { DataOperand action; if (getDataOperand(file, &action, "UCS block action")) { const wchar_t *expected = inUcsBlock? WS_C("END"): WS_C("START"); if (isKeyword(expected, action.characters, action.length)) { inUcsBlock = !inUcsBlock; } else { reportDataError(file, "unexpected UCS block action: %.*" PRIws " (expecting %" PRIws ")", action.length, action.characters, expected); } } return 1; }
static int getCharacterOperand (DataFile *file, wchar_t *character) { DataString string; const char *description = "unicode character"; if (getDataString(file, &string, 0, description)) { if (!(string.characters[0] & ~UNICODE_CHARACTER_MASK)) { *character = string.characters[0]; return 1; } else { reportDataError(file, "invalid %s: %.*" PRIws, description, string.length, string.characters); } } return 0; }
static int getByteOperand (DataFile *file, unsigned char *byte) { DataString string; const char *description = "local character"; if (getDataString(file, &string, 1, description)) { if ((string.length == 1) && iswLatin1(string.characters[0])) { *byte = string.characters[0]; return 1; } else { reportDataError(file, "invalid %s: %.*" PRIws, description, string.length, string.characters); } } return 0; }
static int getDotsOperand (DataFile *file, unsigned char *dots) { if (findDataOperand(file, "cell")) { wchar_t character; if (getDataCharacter(file, &character)) { int noDots = 0; wchar_t enclosed = (character == WC_C('('))? WC_C(')'): 0; *dots = 0; if (!enclosed) { if (wcschr(WS_C("0"), character)) { noDots = 1; } else { ungetDataCharacters(file, 1); } } while (getDataCharacter(file, &character)) { int space = iswspace(character); if (enclosed) { if (character == enclosed) { enclosed = 0; break; } if (space) continue; } else if (space) { ungetDataCharacters(file, 1); break; } { int dot; if (noDots || !brlDotNumberToIndex(character, &dot)) { reportDataError(file, "invalid dot number: %.1" PRIws, &character); return 0; } { unsigned char bit = brlDotBits[dot]; if (*dots & bit) { reportDataError(file, "duplicate dot number: %.1" PRIws, &character); return 0; } *dots |= bit; } } } if (enclosed) { reportDataError(file, "incomplete cell"); return 0; } return 1; } } return 0; }