static krb5_error_code parse_list(struct fileptr *f, unsigned *lineno, krb5_config_binding **parent, const char **error_message) { char buf[BUFSIZ]; krb5_error_code ret; krb5_config_binding *b = NULL; unsigned beg_lineno = *lineno; while(config_fgets(buf, sizeof(buf), f) != NULL) { char *p; ++*lineno; buf[strcspn(buf, "\r\n")] = '\0'; p = buf; while(isspace((unsigned char)*p)) ++p; if (*p == '#' || *p == ';' || *p == '\0') continue; while(isspace((unsigned char)*p)) ++p; if (*p == '}') return 0; if (*p == '\0') continue; ret = parse_binding (f, lineno, p, &b, parent, error_message); if (ret) return ret; } *lineno = beg_lineno; *error_message = "unclosed {"; return KRB5_CONFIG_BADFORMAT; }
int Snes9xConfig::parse_joypad (xmlNodePtr node) { xmlAttrPtr attr; int joypad_number = -1; int retval = 0; /* Try to read joypad number */ for (attr = node->properties; attr; attr = attr->next) { if (!xmlStrcasecmp (attr->name, BAD_CAST "number")) { joypad_number = atoi ((char *) attr->children->content); if (joypad_number < 0 || joypad_number > (NUM_JOYPADS - 1)) return 1; } } for (xmlNodePtr i = node->children; i; i = i->next) { if (!xmlStrcasecmp (i->name, BAD_CAST "binding")) { retval = parse_binding (i, joypad_number) || retval; } } return retval; }
static krb5_error_code krb5_config_parse_debug (struct fileptr *f, krb5_config_section **res, unsigned *lineno, const char **error_message) { krb5_config_section *s = NULL; krb5_config_binding *b = NULL; char buf[BUFSIZ]; krb5_error_code ret; while (config_fgets(buf, sizeof(buf), f) != NULL) { char *p; ++*lineno; if(buf[strlen(buf) - 1] == '\n') buf[strlen(buf) - 1] = '\0'; p = buf; while(isspace((unsigned char)*p)) ++p; if (*p == '#' || *p == ';') continue; if (*p == '[') { ret = parse_section(p, &s, res, error_message); if (ret) return ret; b = NULL; } else if (*p == '}') { *error_message = "unmatched }"; return EINVAL; /* XXX */ } else if(*p != '\0') { if (s == NULL) { *error_message = "binding before section"; return EINVAL; } ret = parse_binding(f, lineno, p, &b, &s->u.list, error_message); if (ret) return ret; } } return 0; }
int Snes9xConfig::parse_controls (xmlNodePtr node) { int retval = 0; for (xmlNodePtr i = node->children; i; i = i->next) { if (!xmlStrcasecmp (i->name, BAD_CAST "joypad")) retval = parse_joypad (i) || retval; if (!xmlStrcasecmp (i->name, BAD_CAST "binding")) retval = parse_binding (i, -1) || retval; #ifdef USE_JOYSTICK if (!xmlStrcasecmp (i->name, BAD_CAST "calibration")) retval = parse_calibration (i) || retval; #endif } return retval; }
constexpr auto parse_let_remote(String<'r', 'e', 'm', 'o', 't', 'e', ' ', _str...>) { constexpr auto binding = String<_str...>::split(zero{}, comma_s{}).trim_ends(); constexpr auto body_str = String<'{'>::append(String<_str...>::after_fst(String<','>{}).trim_ends()).append(String<'}'>{}); return parse_phase::LetRemote<std::decay_t<decltype(parse_binding(binding))>, std::decay_t<decltype(parse_statement(body_str))>>{}; }