/* Add a AA context to the URL tree ** -------------------------------- ** Each node in the AA URL tree is a list of the modules we must call ** for this particular node. */ PUBLIC void * HTAA_updateNode (BOOL proxy_access, char const * scheme, const char * realm, const char * url, void * context) { HTUTree * tree = NULL; HTAAModule * module = NULL; if (!scheme || !url) { HTTRACE(AUTH_TRACE, "Auth Engine. Bad argument\n"); return NULL; } HTTRACE(AUTH_TRACE, "Auth Engine. Adding 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 NULL; } /* 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 NULL; } } /* Find a matching AA element or create a new one */ { char * path = HTParse(url, "", PARSE_PATH | PARSE_PUNCTUATION); HTAAElement * element = NULL; BOOL status; if ((element = (HTAAElement *) HTUTree_findNode(tree, realm, path)) && element->scheme && !strcasecomp (element->scheme, scheme)) status = HTAA_updateElement(element, scheme, context); else { /* create the new element */ element = HTAA_newElement(scheme, context); status = HTUTree_addNode(tree, realm, path, element); } HT_FREE(path); return status==YES ? element->context : NULL; } }
PRIVATE BOOL HTNewsCache_update (HTRequest * request, const char * url, HTArray * array) { HTUTree * tree = NULL; if (request && url) { char * newshost = NULL; if (!strncasecomp(url, "news:", 5)) { HTUserProfile * up = HTRequest_userProfile(request); StrAllocCopy(newshost, HTUserProfile_news(up)); } else if (!strncasecomp(url, "nntp:", 5)) { newshost = HTParse(url, "", PARSE_HOST); } /* ** If the news server was found then update the data entry. Otherwise ** create a new entry */ if (newshost) { char * colon = strchr(newshost, ':'); int port = NEWS_PORT; if (colon ) { *(colon++) = '\0'; /* Chop off port number */ port = atoi(colon); } tree = HTUTree_new(NEWS_TREE, newshost, port, HTNewsCache_delete); HT_FREE(newshost); if (!tree) { HTTRACE(PROT_TRACE, "News Cache.. Can't create tree\n"); return NO; } /* Add new cache information to the tree */ { HTNewsCache * element = NULL; BOOL status; if ((element=(HTNewsCache *) HTUTree_findNode(tree, "", "/"))){ element->cache = array; status = YES; } else { element = HTNewsCache_new(url, array); status = HTUTree_addNode(tree, "", "/", element); } return status; } } } return NO; }
/* 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; } }