Esempio n. 1
0
WsBool ws_bc_add_pragma_access_path(WsBc *bc, const unsigned char *path,
                                    size_t path_len)
{
    WsBcPragma *p = add_pragma(bc, WS_BC_PRAGMA_TYPE_ACCESS_PATH);

    if (p == NULL)
        return WS_FALSE;

    if (!ws_bc_add_const_utf8_string(bc, &p->index_1, path, path_len))
        return WS_FALSE;

    return WS_TRUE;
}
Esempio n. 2
0
WsBool ws_bc_add_pragma_access_domain(WsBc *bc, const unsigned char *domain,
                                      size_t domain_len)
{
    WsBcPragma *p = add_pragma(bc, WS_BC_PRAGMA_TYPE_ACCESS_DOMAIN);

    if (p == NULL)
        return WS_FALSE;

    if (!ws_bc_add_const_utf8_string(bc, &p->index_1, domain, domain_len))
        return WS_FALSE;

    return WS_TRUE;
}
Esempio n. 3
0
WsBool ws_bc_add_pragma_user_agent_property(WsBc *bc,
        const unsigned char *name,
        size_t name_len,
        const unsigned char *property,
        size_t property_len)
{
    WsBcPragma *p = add_pragma(bc, WS_BC_PRAGMA_TYPE_USER_AGENT_PROPERTY);

    if (p == NULL)
        return WS_FALSE;

    if (!ws_bc_add_const_utf8_string(bc, &p->index_1, name, name_len)
            || !ws_bc_add_const_utf8_string(bc, &p->index_2, property, property_len))
        return WS_FALSE;

    return WS_TRUE;
}
Esempio n. 4
0
element * parse_AND_pragmas(char * orig_buffer, items * input, int begin, int end, int * _index)
{
  item Item;
  element * Pragmas, * p;
  int index, old_index;

  Pragmas = NULL;

  Pragmas = create_pragmas(-1, -1, -1, -1, -1, AND, 10);

  /*
  if (begin < 0)
    begin = 0;
  if (end < 0)
    end = input->number_of_items - 1;
  */

  index = begin;

  if (DEBUG_PRAGMAS)
    printf("Entering 'parse_AND_pragmas' with [%i, %i]\n", begin, end);

  if (begin > end)
    {
      if (DEBUG_PRAGMAS)
	printf("Exiting 'parse_AND_pragmas'\n");
      *_index = -1;
      return Pragmas;
    }

  old_index = index;
  while (index <= end)
    {
      old_index = index;
      Item = input->data[index];

      switch (Item.type)
	{
	case PRAGMA_IF: 
	  if (DEBUG_PRAGMAS)
	    printf("#if detected in 'parse_AND_pragmas' at %i\n", 
		   get_line_number(orig_buffer, Item.begin));

	  old_index = index;
	  p = parse_OR_pragmas(orig_buffer, input, old_index, end, &index);
	  p->pid = old_index;
	  add_pragma(Pragmas, p);

	  index++;

	  if (DEBUG_PRAGMAS)
	    printf("#if clause starting at %i was added successfully, next pragma number is %i\n", 
		   get_line_number(orig_buffer, Item.begin), 
		   index);
	  break;

	case PRAGMA_ELSE:
	case PRAGMA_ENDIF:
	  printf("#else or #endif appear without #if at %i\n", 
		 get_line_number(orig_buffer, Item.begin));
  	  exit(-1);
	  break;

	case PRAGMA_OTHER:
	case STRING:
	case LITERAL:
	case COMMENT:
	case OTHER:
	case ESCSEQ:
	  printf("Internal error in pragmas handling: more pragma types are present than should be\n");
	  exit(-1);
	}
    }

  if (DEBUG_PRAGMAS)
    printf("Exiting 'parse_AND_pragmas'\n");

  *_index = index;
  return Pragmas;
}
Esempio n. 5
0
element * parse_OR_pragmas(char * orig_buffer, items * input, int begin, int end, int * _index)
{
  item oldItem, Item;
  element * Pragmas, * p;
  int oldindex, index, x;
  int done;

  if (DEBUG_PRAGMAS)
    printf("Entering 'parse_OR_pragmas' with [%i, %i]\n", begin, end);

  Pragmas = NULL;

  Pragmas = create_pragmas(-1, -1, -1, -1, -1, OR, 10);

  /*
  if (begin < 0)
    begin = 0;
  if (end < 0)
    end = input->number_of_items - 1;
  */

  index = begin;
  assert(begin >= 0);
  assert(begin <= end);

  done = 0;
  while (1)
    {
      oldindex = index;
      if (done)
	index = find_next_pragma(orig_buffer, input, index + 1, end);

      oldItem = input->data[oldindex];

      if (index == -1)
	{
	  printf("Cannot find matching #else or #endif for #if pragma at %i\n", 
		 get_line_number(orig_buffer, oldItem.begin));
	  exit(-1);
	}

      Item = input->data[index];

      if (DEBUG_PRAGMAS)
	printf("Parsing pragmas in 'parse_OR_pragmas' at %i\n", get_line_number(orig_buffer, Item.begin));

      if (! done)
	{
	  if (oldItem.type != PRAGMA_IF)
	    {
	      printf("%s%s%s", "Internal error in parsing pragmas: ", 
		     "call to 'parse_OR_pragmas' ", 
		     "was made without #if present\n");
	      exit(-1);
	    }
	  /*
	  p = parse_AND_pragmas(orig_buffer, input, oldindex + 1, index - 1, &x);
	  p->pid = index;
	  add_pragma(Pragmas, p);
	  */
	  done = 1;
	}
      else
	{
	  switch(Item.type)
	    {
	    case PRAGMA_IF:
	      printf("%s%s%s%i\n", 
		     "Internal error in parsing pragmas: ", 
		     "program used #if from the lower level ", 
		     "to be as in the upper level at ", 
		     get_line_number(orig_buffer, Item.begin));
	      exit(-1);

	    case PRAGMA_ELSE:
	      p = parse_AND_pragmas(orig_buffer, input, oldindex + 1, index - 1, &x);
	      p->pid = oldindex;
	      add_pragma(Pragmas, p);
	      break;

	    case PRAGMA_ENDIF:
	      if (DEBUG_PRAGMAS)
		printf("Exiting 'parse_OR_pragmas'\n");
	      p = parse_AND_pragmas(orig_buffer, input, oldindex + 1, index - 1, &x);
	      p->pid = oldindex;
	      add_pragma(Pragmas, p);
	      /*
	      p = create_pragmas(index, -1, -1, -1, -1, AND, 10);
	      add_pragma(Pragmas, p);
	      */
	      *_index = index;
	      return Pragmas;

	    case PRAGMA_OTHER:
	    case STRING:
	    case LITERAL:
	    case COMMENT:
	    case OTHER:
	    case ESCSEQ:
	      printf("Internal error in pragmas handling\n");
	      exit(-1);
	    }
	}
    }

  /* should never be reached */
  printf("Reached unreachable code\n");
  exit(-1);
}