示例#1
0
/*	Delete a AA context from the URL tree
**	-------------------------------------
**	Each node in the AA URL tree is a list of the modules we must call
**	for this particular node.
*/
PUBLIC BOOL HTAA_deleteNode (BOOL proxy_access, char const * scheme,
			     const char * realm, const char * url)
{
    HTUTree * tree = NULL;
    HTAAModule * module = NULL;
    if (!scheme || !url) {
	HTTRACE(AUTH_TRACE, "Auth Engine. Bad argument\n");
	return NO;
    }
    HTTRACE(AUTH_TRACE, "Auth Engine. Deleting info for `%s'\n" _ url);

    /* Find the AA module with this name */
    if ((module = HTAA_findModule(scheme)) == NULL) {
	HTTRACE(AUTH_TRACE, "Auth Engine. Module `%s\' not registered\n" _ 
			       scheme ? scheme : "<null>");
	return NO;
    }

    /* Find an existing URL Tree or create a new one */
    {
	char * host = HTParse(url, "", PARSE_HOST);
	char * colon = strchr(host, ':');
	int port = DEFAULT_PORT;
	if (colon ) {
	    *(colon++) = '\0';			     /* Chop off port number */
	    port = atoi(colon);
	}
	tree = HTUTree_new(proxy_access ? AA_PROXY_TREE : AA_TREE,
			   host, port, HTAA_deleteElement);
	HT_FREE(host);
	if (!tree) {
	    HTTRACE(AUTH_TRACE, "Auth Engine. Can't create tree\n");
	    return NO;
	}
    }

    /* Delete any existing node */
    {
	char * path = HTParse(url, "", PARSE_PATH | PARSE_PUNCTUATION);
	BOOL status = HTUTree_deleteNode(tree, realm, path);
	HT_FREE(path);
	return status;
    }
}
示例#2
0
int HTUTree_deleteNode_tcl(ClientData clientData, Tcl_Interp *interp, 
			 int argc, char **argv) {
  if (argc == 4) {
    char *tree_key = argv[1];
    const char *realm = argv[2];
    const char *path = argv[3];
    if ( tree_key && realm && path) {
      Tcl_HashEntry *tree_entry = Tcl_FindHashEntry(&HTableUTree, tree_key);
      if ( tree_entry) {
	HTUTree *tree = Tcl_GetHashValue(tree_entry);
	
	BOOL result = HTUTree_deleteNode(tree, realm, path);
	Tcl_AppendResult(interp, result ? "YES" : "NO", NULL);
	return TCL_OK;
      }
    }
    Tcl_AppendResult(interp, bad_vars, NULL);
    return TCL_ERROR;
  }
  Tcl_AppendResult(interp, bad_vars, NULL);
  return TCL_ERROR;
}