Beispiel #1
0
tree
xml_html_parser::parse_doctype () {
  s += 9;
  tree dt= tuple ("doctype");
  skip_space ();
  dt << parse_name ();
  skip_space ();
  if (test (s, "SYSTEM")) dt << parse_system ();
  else if (test (s, "PUBLIC")) dt << parse_public ();
  skip_space ();

  if (test (s, "[")) {
    s += 1;
    while (s) {
      skip_space ();
      if (test (s, "]")) { s += 1; break; }
      else if (test (s, "<!ELEMENT")) dt << parse_element ();
      else if (test (s, "<!ATTLIST")) dt << parse_cdata ();
      else if (test (s, "<!ENTITY")) parse_entity_decl ();
      else if (test (s, "<!NOTATION")) a << parse_notation ();
      else if (test (s, "<?")) dt << parse_pi ();
      else if (test (s, "<!--")) dt << parse_comment ();
      else if (s[0] == '&' || s[0] == '%') (void) parse_entity ();
      else s += 1;
    }
  }

  skip_space ();
  if (test (s, ">")) s += 1;
  return dt;
}
Beispiel #2
0
void
xml_html_parser::parse_entity_decl () {
  s += 8;
  skip_space ();
  bool parameter= test (s, "%");
  if (parameter) { s += 1; skip_space (); }
  string name= parse_name ();
  if (parameter) name= "%" * name * ";";
  else name= "&" * name * ";";
  skip_space ();

  if (test (s, "SYSTEM") || test (s, "PUBLIC")) {
    // TODO: allow for loading of external entities using wget
    if (test (s, "SYSTEM")) (void) parse_system ();
    else (void) parse_public ();
    skip_space ();
    if (test (s, "NDATA")) {
      s += 5;
      skip_space ();
      (void) parse_name ();
    }
  }
  else {
    string val= parse_quoted ();
    val= expand_entities (val);
    entities (name) = val;
    // cout << name << " := " << val << "\n";
  }

  skip_space ();
  if (test (s, ">")) s += 1;
}
Beispiel #3
0
static utility_retcode_t parse_one_header(struct rtsp_response *response)
{
	utility_retcode_t ret = UTILITY_SUCCESS;
	char *start_value;
	char *header_name = response->current_header.name;
	char *header_value = response->current_header.value;

	FUNC_ENTER;

	ret = utility_copy_token(header_name,
				 MAX_HEADER_NAME_LEN,
				 response->parsep,
				 ": ",
				 NULL);
	if (UTILITY_SUCCESS != ret) {
		ERRR("Failed to copy header name\n");
		goto out;
	}

	start_value = begin_token(response->parsep, ": ");
	ret = utility_copy_token(header_value,
				 MAX_HEADER_VALUE_LEN,
				 start_value,
				 "\r\n",
				 NULL);
	if (UTILITY_SUCCESS != ret) {
		ERRR("Failed to copy header value\n");
		goto out;
	}

	DEBG("Found header name: \"%s\" value: \"%s\"\n",
	     header_name, header_value);

	if (0 == syscalls_strcmp(header_name, "Content-Length")) {
		ret = parse_content_length(response);
	} else if (0 == syscalls_strcmp(header_name, "Apple-Response")) {
		ret = parse_apple_response(response);
	} else if (0 == syscalls_strcmp(header_name, "Audio-Jack-Status")) {
		ret = parse_audio_jack_status(response);
	} else if (0 == syscalls_strcmp(header_name, "Session")) {
		ret = parse_session(response);
	} else if (0 == syscalls_strcmp(header_name, "Transport")) {
		ret = parse_transport(response);
	} else if (0 == syscalls_strcmp(header_name, "Public")) {
		ret = parse_public(response);
	} else {
		parse_unknown_header(response);
	}

out:
	FUNC_RETURN;
	return ret;
}
Beispiel #4
0
int check_for_directive(struct _asm_context *asm_context, char *token)
{
  if (strcasecmp(token, "org") == 0)
  {
    if (parse_org(asm_context) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "align") == 0)
  {
    if (parse_align(asm_context) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "name") == 0)
  {
    if (parse_name(asm_context) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "public") == 0)
  {
    if (parse_public(asm_context) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "db") == 0 ||
      strcasecmp(token, "dc8") == 0 ||
      strcasecmp(token, "ascii") == 0)
  {
    if (parse_db(asm_context, 0) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "asciiz") == 0)
  {
    if (parse_db(asm_context, 1) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "dc") == 0)
  {
    if (parse_dc(asm_context) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "dq") == 0)
  {
    if (parse_dq(asm_context) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "dw") == 0 || strcasecmp(token, "dc16") == 0)
  {
    if (parse_dc16(asm_context) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "dl") == 0 || strcasecmp(token, "dc32") == 0)
  {
    if (parse_dc32(asm_context) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "dc64") == 0)
  {
    if (parse_dc64(asm_context) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "ds") == 0 || strcasecmp(token, "ds8") == 0)
  {
    if (parse_ds(asm_context,1) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "ds16") == 0)
  {
    if (parse_ds(asm_context,2) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "ds32") == 0)
  {
    if (parse_ds(asm_context,4) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "resb") == 0)
  {
    if (parse_resb(asm_context,1) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "resw") == 0)
  {
    if (parse_resb(asm_context,2) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "end") == 0)
  {
    return 2;
  }
    else
  if (strcasecmp(token, "big_endian") == 0)
  {
    asm_context->memory.endian = ENDIAN_BIG;
    return 1;
  }
    else
  if (strcasecmp(token, "little_endian") == 0)
  {
    asm_context->memory.endian = ENDIAN_LITTLE;
    return 1;
  }

  if (asm_context->parse_directive != NULL)
  {
    int ret = asm_context->parse_directive(asm_context, token);
    if (ret == 0) { return 1; }   // Found and used
    if (ret == -1) { return -1; } // Found and there was a problem
  }

  int n = 0;
  while (cpu_list[n].name != NULL)
  {
    if (strcasecmp(token, cpu_list[n].name) == 0)
    {
      configure_cpu(asm_context, n);

#if 0
      if (strcmp(token, "65816") == 0)
      {
        asm_context->parse_directive = parse_directive_65816;
      }
        else
#endif
      {
        asm_context->parse_directive = NULL;
      }

      return 1;
    }
    n++;
  }

  return 0;
}
Beispiel #5
0
int check_for_directive(struct _asm_context *asm_context, char *token)
{
  if (strcasecmp(token, "org") == 0)
  {
    if (parse_org(asm_context) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "align") == 0)
  {
    if (parse_align(asm_context) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "name") == 0)
  {
    if (parse_name(asm_context) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "public") == 0)
  {
    if (parse_public(asm_context) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "db") == 0 ||
      strcasecmp(token, "dc8") == 0 ||
      strcasecmp(token, "ascii") == 0)
  {
    if (parse_db(asm_context, 0) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "asciiz") == 0)
  {
    if (parse_db(asm_context, 1) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "dc") == 0)
  {
    if (parse_dc(asm_context) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "dw") == 0 || strcasecmp(token, "dc16") == 0)
  {
    if (parse_dw(asm_context) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "dl") == 0 || strcasecmp(token, "dc32") == 0)
  {
    if (parse_dl(asm_context) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "ds") == 0 || strcasecmp(token, "ds8") == 0)
  {
    if (parse_ds(asm_context,1) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "ds16") == 0)
  {
    if (parse_ds(asm_context,2) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "resb") == 0)
  {
    if (parse_resb(asm_context,1) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "resw") == 0)
  {
    if (parse_resb(asm_context,2) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "end") == 0)
  {
    return 2;
  }
    else
  if (strcasecmp(token, "big_endian") == 0)
  {
    asm_context->memory.endian=ENDIAN_BIG;
  }
    else
  if (strcasecmp(token, "little_endian") == 0)
  {
    asm_context->memory.endian=ENDIAN_LITTLE;
  }

  int n = 0;
  while (cpu_list[n].name != NULL)
  {
    if (strcasecmp(token, cpu_list[n].name) == 0)
    {
      asm_context->cpu_type = cpu_list[n].type;
      asm_context->memory.endian = cpu_list[n].default_endian;
      asm_context->bytes_per_address = cpu_list[n].bytes_per_address;
      asm_context->is_dollar_hex = cpu_list[n].is_dollar_hex;
      asm_context->can_tick_end_string = cpu_list[n].can_tick_end_string;
      asm_context->parse_instruction = cpu_list[n].parse_instruction;
      asm_context->list_output = cpu_list[n].list_output;
      asm_context->cpu_list_index = n;
      return 1;
    }
    n++;
  }

  return 0;
}