Beispiel #1
0
/* Find if url/realm is in auth list. If a matching url is found, but realm is
 * NULL, it returns the first record found. If realm isn't NULL, it returns
 * the first record that matches exactly (url and realm) if any. */
static struct auth_entry *
find_auth_entry(struct uri *uri, unsigned char *realm)
{
	struct auth_entry *match = NULL, *entry;

#ifdef DEBUG_HTTP_AUTH
	DBG("find_auth_entry: url=%s realm=%s", url, realm);
#endif

	foreach (entry, auth_entry_list) {
		if (!compare_uri(entry->uri, uri, URI_HTTP_AUTH))
			continue;

		/* Found a matching url. */
		match = entry;
		if (!realm) {
			/* Since realm is NULL, stops immediatly. */
			break;
		}

		/* From RFC 2617 section 1.2:
		 *
		 * The realm value (case-sensitive), in combination with the
		 * canonical root URL (the absolute URI for the server whose
		 * abs_path is empty; see section 5.1.2 of [2]) of the server
		 * being accessed, defines the protection space. */
		if (entry->realm && !strcmp(entry->realm, realm)) {
			/* Exact match. */
			break; /* Stop here. */
		}
	}

	return match;
}
Beispiel #2
0
struct auth_entry *find_auth_entry( struct uri *uri, unsigned char *realm )
{
  struct auth_entry *match, *entry = &auth_entry_list.next[0];
  match = 0;
  if ( auth_entry_list.next != auth_entry_list.next )
  {
    entry = &entry[0];
    do
    {
      if ( compare_uri( entry->uri, &uri[0], URI_HTTP_AUTH ) )
      {
        if ( realm[0] == 0 || ( entry->realm && strcmp( (char*)entry->realm, &realm[0] ) == 0 ) )
          break;
        match = &entry[0];
      }
      entry = &entry;
    }
    while ( entry->next != auth_entry_list.next );
  }
  return match;
}
Beispiel #3
0
void
goto_mark(unsigned char mark, struct view_state *vs)
{
	int old_current_link;
#ifdef CONFIG_ECMASCRIPT
	struct ecmascript_interpreter *ecmascript;
	int ecmascript_fragile;
#endif
	struct document_view *doc_view;
	int i;

	if (!is_valid_mark_char(mark))
		return;

	i = index_from_char(mark);
	assert(is_valid_mark_index(i));

	/* TODO: Support for cross-document marks. --pasky */
	if (!marks[i] || !compare_uri(marks[i]->uri, vs->uri, 0))
		return;

	old_current_link = vs->current_link;
#ifdef CONFIG_ECMASCRIPT
	ecmascript = vs->ecmascript;
	ecmascript_fragile = vs->ecmascript_fragile;
#endif
	doc_view = vs->doc_view;

	destroy_vs(vs, 0);
	copy_vs(vs, marks[i]);

	vs->doc_view = doc_view;
	vs->doc_view->vs = vs;
#ifdef CONFIG_ECMASCRIPT
	vs->ecmascript = ecmascript;
	vs->ecmascript_fragile = ecmascript_fragile;
#endif
	vs->old_current_link = old_current_link;
}
Beispiel #4
0
static inline int
casecompare_uri(ARGS_COMPARE) {
	return (compare_uri(rdata1, rdata2));
}
Beispiel #5
0
/**
 * Helper function for #getNodeByHref(IXML_Document*,const char*).
 *
 * @param checked specifies number of symbols from href which are already
 * checked (and match) in parent node.
 */
static IXML_Node* getNodeByHrefRecursive(IXML_Node* node, const char* href,
        int checked, int* slashFlag)
{
    if (node == NULL)
    {
        //recursion exit point
        return NULL;
    }

    IXML_Node* match = NULL;
    IXML_Element* element = ixmlNode_convertToElement(node);
    int compareResult = 0;
    // ignore all nodes which are not tags, are reference tags
    // or do not have 'href' attribute
    if (element != NULL)
    {
        const char* currentUri =
            ixmlElement_getAttribute(element, OBIX_ATTR_HREF);
        if ((strcmp(ixmlElement_getTagName(element), OBIX_OBJ_REF) != 0)
                && (currentUri != NULL))
        {
            compareResult = compare_uri(currentUri, href, checked, slashFlag);
            if (compareResult == 0)
            {
                // we found the required node
                return node;
            }
        }
    }

    // check children
    // note that compareResult == 0 means that URI's
    // were not compared at all
    if (compareResult == 0)
    {
        match = getNodeByHrefRecursive(ixmlNode_getFirstChild(node),
                                       href,
                                       checked,
                                       slashFlag);
    }
    else if (compareResult > 0)
    {
        // we found part of the uri on this step
        // continue search in children the remaining address
        match = getNodeByHrefRecursive(ixmlNode_getFirstChild(node),
                                       href,
                                       compareResult,
                                       slashFlag);
    }
    // do not check children if compareResult < 0

    if (match == NULL)
    {
        match = getNodeByHrefRecursive(ixmlNode_getNextSibling(node),
                                       href,
                                       checked,
                                       slashFlag);
    }

    return match;
}