Annotation of libwww/Library/src/HTProt.c, revision 2.3

2.1       frystyk     1: /*                                                                  HTProt.c
                      2: **     ACCESS SCHEME MANAGER
                      3: **
                      4: **     (c) COPYRIGHT MIT 1995.
                      5: **     Please first read the full copyright statement in the file COPYRIGH.
                      6: **
                      7: **
                      8: ** HISTORY:
                      9: **     6 July 95  HFN  Spawned off from HTAccess
                     10: */
                     11: 
                     12: /* Library Include files */
                     13: #include "tcp.h"
                     14: #include "HTUtils.h"
                     15: #include "HTParse.h"
                     16: #include "HTString.h"
                     17: #include "HTProt.h"                                     /* Implemented here */
                     18: 
                     19: /* Variables and typedefs local to this module */
                     20: PRIVATE HTList * protocols = NULL;           /* List of registered protocols */
                     21: 
                     22: /* --------------------------------------------------------------------------*/
                     23: /*                   Management of the HTProtocol structure                 */
                     24: /* --------------------------------------------------------------------------*/
                     25: 
                     26: /*
2.3     ! frystyk    27: **     Register a Protocol module as an active access method
2.1       frystyk    28: */
2.3     ! frystyk    29: PUBLIC BOOL HTProtocol_add ARGS1(HTProtocol *, prot)
2.1       frystyk    30: {
                     31:     if (!protocols) protocols = HTList_new();
2.3     ! frystyk    32:     HTList_addObject(protocols, (void *) prot);
2.1       frystyk    33:     return YES;
                     34: }
                     35: 
2.3     ! frystyk    36: /*
        !            37: **     Deletes a Protocol module as an active access method
        !            38: */
        !            39: PUBLIC BOOL HTProtocol_delete ARGS1(HTProtocol *, prot)
        !            40: {
        !            41:     return (protocols && prot) ?
        !            42:        HTList_removeObject(protocols, (void *) prot) : NO;
        !            43: }
2.1       frystyk    44: 
                     45: /*
                     46: **     Delete the list of registered access methods. This is called from
                     47: **     within HTLibTerminate. Written by Eric Sink, eric@spyglass.com
                     48: */
                     49: PUBLIC void HTProtocol_deleteAll NOARGS
                     50: {
                     51:     if (protocols) {
                     52:        HTList_delete(protocols);
                     53:        protocols = NULL;
                     54:     }
                     55: }
                     56: 
                     57: 
                     58: /*
                     59: **     Search registered protocols to find suitable one.
                     60: **     Return YES if found, else NO
                     61: */
2.3     ! frystyk    62: PUBLIC BOOL HTProtocol_find ARGS1(HTParentAnchor *, anchor)
2.1       frystyk    63: {
                     64:     if (anchor) {
                     65:        char *access = HTParse(HTAnchor_physical(anchor), "", PARSE_ACCESS);
                     66:        HTList *cur = protocols;
                     67:        HTProtocol *p;
                     68:        if (!cur) {
                     69:            if (TRACE)
                     70:                fprintf(TDEST, "HTProtocol.. NO PROTOCOL MODULES INITIATED\n");
                     71:        } else {
                     72:            while ((p = (HTProtocol *) HTList_nextObject(cur))) {
                     73:                if (strcmp(p->name, access)==0) {       /* Case insensitive? */
                     74:                    HTAnchor_setProtocol(anchor, p);
                     75:                    free(access);
                     76:                    return YES;
                     77:                }
                     78:            }
                     79:        }
                     80:        free(access);
                     81:     }
                     82:     return NO;
                     83: }
                     84: 

Webmaster