Lines Matching full:token
48 /* Maximum length of a token in a key map line. */
281 /* Checks if a character represents a token separator.
282 * Returns a non-zero value if ch is a token separator.
283 * Returns zero value if ch is not a token separator.
334 /* Gets first token from a string.
335 * line - String to get token from. End of the string should be
337 * token - String where to copy token. Token, copied to this
339 * token string must be large enough to fit token of any size.
341 * the 'token' parameter.
343 * a pointer to the line string, advanced past the found token.
346 kcm_get_token(const char* line, char* token, size_t max_token_len) {
351 // Calc token length
356 memcpy(token, token_starts, token_len);
357 token[token_len] = '\0';
361 /* Checks if token represents a comment.
362 * Returns non-zero value if token represents a comment, or zero otherwise.
365 kcm_is_token_comment(const char* token) {
366 return '#' == *token;
388 /* Gets unsigned short hexadecimal value for a token.
389 * token - Token to get hexadecimal value for. Note that this
391 * represented by the token string.
392 * val - Upon success contains hexadecimal value for the token.
396 kcm_get_ushort_hex_val(const char* token, unsigned short* val) {
397 int hex_val = hex2int(token, strlen(token));
398 // Make sure token format was ok and value doesn't exceed unsigned short.
408 /* Gets a character or hexadecimal value represented by a token.
409 * token - Token to get value from.
411 * value represented by a token.
415 kcm_get_char_or_hex_val(const char* token, unsigned short* val) {
416 // For chars token must begin with ' followed by character followed by '
417 if ('\'' == *token) {
418 if ('\0' == token[1] || '\'' != token[2] || '\0' != token[3]) {
421 *val = token[1];
424 // Make sure that hex token is prefixed with "0x"
425 if (('0' != *token) || ('x' != token[1])) {
429 return kcm_get_ushort_hex_val(token + 2, val);
433 /* Gets first token for the line and calculates its value.
434 * line - Line to get token's value from.
436 * value represented by the first token in the line.
438 * advanced past the found token.
442 char token[KCM_MAX_TOKEN_LEN];
443 line = kcm_get_token(line, token, KCM_MAX_TOKEN_LEN);
445 // Token must be a char, or a hex number.
446 if (kcm_get_char_or_hex_val(token, val)) {
469 char token[KCM_MAX_TOKEN_LEN];
472 // Get first token, and see if it's an empty, or a comment line.
473 line = kcm_get_token(line, token, KCM_MAX_TOKEN_LEN);
474 if ((NULL == line) || kcm_is_token_comment(token)) {
480 if ('[' == token[0]) {
485 // First token is key code.
486 if (kcm_get_key_code(token, &key_entry->code)) {
488 kcm_file_path, token, line_index);
492 // 2-nd token is display character, which is ignored.
500 // 3-rd token is number.
508 // 4-th token is base.
516 // 5-th token is caps.
524 // 6-th token is fn.
532 // 7-th token is caps_fn.
541 // except (may be) a comment token.
542 line = kcm_get_token(line, token, KCM_MAX_TOKEN_LEN);
543 if ((NULL == line) || kcm_is_token_comment(token)) {