Annotation of libwww/Library/src/HTAccess.c, revision 1.54

1.1       timbl       1: /*             Access Manager                                  HTAccess.c
                      2: **             ==============
                      3: **
                      4: ** Authors
                      5: **     TBL     Tim Berners-Lee timbl@info.cern.ch
1.4       timbl       6: **     JFG     Jean-Francois Groff jfg@dxcern.cern.ch
1.1       timbl       7: **     DD      Denis DeLaRoca (310) 825-4580  <CSP1DWD@mvs.oac.ucla.edu>
                      8: ** History
                      9: **       8 Jun 92 Telnet hopping prohibited as telnet is not secure TBL
                     10: **     26 Jun 92 When over DECnet, suppressed FTP, Gopher and News. JFG
1.42      frystyk    11: **      6 Oct 92 Moved HTClientHost and HTlogfile into here. TBL
1.1       timbl      12: **     17 Dec 92 Tn3270 added, bug fix. DD
1.2       timbl      13: **      4 Feb 93 Access registration, Search escapes bad chars TBL
1.9       timbl      14: **               PARAMETERS TO HTSEARCH AND HTLOADRELATIVE CHANGED
                     15: **     28 May 93 WAIS gateway explicit if no WAIS library linked in.
1.19      timbl      16: **        Dec 93 Bug change around, more reentrant, etc
1.42      frystyk    17: **     09 May 94 logfile renamed to HTlogfile to avoid clash with WAIS
1.53      duns       18: **      8 Jul 94 Insulate free() from _free structure element.
1.2       timbl      19: ** Bugs
                     20: **     This module assumes that that the graphic object is hypertext, as it
1.9       timbl      21: **     needs to select it when it has been loaded.  A superclass needs to be
1.2       timbl      22: **     defined which accepts select and select_anchor.
1.1       timbl      23: */
                     24: 
1.9       timbl      25: #ifndef DEFAULT_WAIS_GATEWAY
1.54    ! frystyk    26: #define DEFAULT_WAIS_GATEWAY "http://ptsun00.cern.ch:7001/"
        !            27: #if 0
1.8       timbl      28: #define DEFAULT_WAIS_GATEWAY "http://info.cern.ch:8001/"
1.9       timbl      29: #endif
1.54    ! frystyk    30: #endif
1.8       timbl      31: 
1.1       timbl      32: /* Implements:
                     33: */
                     34: #include "HTAccess.h"
                     35: 
                     36: /* Uses:
                     37: */
                     38: 
                     39: #include "HTParse.h"
                     40: #include "HTUtils.h"
1.4       timbl      41: #include "HTML.h"              /* SCW */
1.2       timbl      42: 
                     43: #ifndef NO_RULES
                     44: #include "HTRules.h"
                     45: #endif
                     46: 
                     47: #include "HTList.h"
                     48: #include "HText.h"     /* See bugs above */
                     49: #include "HTAlert.h"
1.17      timbl      50: #include "HTFWriter.h" /* for cache stuff */
                     51: #include "HTTee.h"
1.46      frystyk    52: #include "HTError.h"
1.2       timbl      53: 
1.54    ! frystyk    54: /* These flags may be set to modify the operation of this module */
        !            55: PUBLIC char * HTCacheDir = NULL;  /* Root for cached files or 0 for no cache */
        !            56: PUBLIC char * HTSaveLocallyDir = SAVE_LOCALLY_HOME_DIR;         /* Save & exe files */
        !            57: PUBLIC char * HTClientHost = 0;                 /* Name of remote login host if any */
        !            58: PUBLIC FILE * HTlogfile = 0;          /* File to which to output one-liners */
1.41      luotonen   59: 
1.34      frystyk    60: PUBLIC BOOL HTForceReload = NO;        /* Force reload from cache or net */
1.12      timbl      61: PUBLIC BOOL HTSecure = NO;     /* Disable access for telnet users? */
1.27      luotonen   62: PUBLIC BOOL using_proxy = NO;  /* are we using a proxy gateway? */
1.43      luotonen   63: PUBLIC char * HTImServer = NULL;/* cern_httpd sets this to the translated URL*/
1.27      luotonen   64: PUBLIC BOOL HTImProxy = NO;    /* cern_httpd as a proxy? */
1.1       timbl      65: 
1.43      luotonen   66: 
1.2       timbl      67: /*     To generate other things, play with these:
                     68: */
                     69: 
1.15      timbl      70: /* PUBLIC HTFormat HTOutputFormat = NULL;      use request->output_format */
                     71: /* PUBLIC HTStream* HTOutputStream = NULL;     use request->output_stream */ 
1.1       timbl      72: 
                     73: PRIVATE HTList * protocols = NULL;   /* List of registered protocol descriptors */
                     74: 
1.24      timbl      75: /*     Superclass defn */
1.1       timbl      76: 
1.24      timbl      77: struct _HTStream {
                     78:        HTStreamClass * isa;
                     79:        /* ... */
                     80: };
                     81: 
1.15      timbl      82: /*     Create  a request structure
                     83: **     ---------------------------
                     84: */
                     85: 
                     86: PUBLIC HTRequest * HTRequest_new NOARGS
                     87: {
1.28      luotonen   88:     HTRequest * me = (HTRequest*) calloc(1, sizeof(*me));  /* zero fill */
1.15      timbl      89:     if (!me) outofmem(__FILE__, "HTRequest_new()");
                     90:     
1.20      luotonen   91:     me->conversions    = HTList_new(); /* No conversions registerd yet */
                     92:     me->output_format  = WWW_PRESENT;  /* default it to present to user */
                     93: 
1.15      timbl      94:     return me;
                     95: }
                     96: 
                     97: 
1.49      frystyk    98: /*     Clear  a request structure
                     99: **     ---------------------------
                    100: **     This function clears the reguest structure so that only the
                    101: **     conversions remain. Everything else is as if it was created from
                    102: **     scratch.
                    103: */
                    104: PUBLIC void HTRequest_clear ARGS1(HTRequest *, req)
                    105: {
                    106:     HTList *conversions;
                    107:     if (!req) {
                    108:        if (TRACE)
                    109:            fprintf(stderr, "Clear....... request: Bad argument!\n");
                    110:        return;
                    111:     }
                    112:     conversions = req->conversions;                 /* Save the conversions */
                    113:     HTErrorFree(req);
                    114:     HTAACleanup(req);
                    115:     FREE(req->from);
                    116:     memset(req, '\0', sizeof(HTRequest));
                    117: 
                    118:     /* Now initialize as from scratch but with the old list of conversions */
                    119:     req->conversions = conversions;
                    120:     req->output_format = WWW_PRESENT;      /* default it to present to user */
                    121: }
                    122: 
                    123: 
1.20      luotonen  124: /*     Delete a request structure
                    125: **     --------------------------
                    126: */
                    127: PUBLIC void HTRequest_delete ARGS1(HTRequest *, req)
                    128: {
                    129:     if (req) {
1.34      frystyk   130:        HTFormatDelete(req->conversions);
1.46      frystyk   131:        HTErrorFree(req);
1.34      frystyk   132:        HTAACleanup(req);
1.37      luotonen  133:        FREE(req->from);
1.34      frystyk   134:        FREE(req);
1.20      luotonen  135:     }
                    136: }
                    137: 
                    138: 
1.22      luotonen  139: PRIVATE char * method_names[(int)MAX_METHODS + 1] =
                    140: {
                    141:     "INVALID-METHOD",
                    142:     "GET",
                    143:     "HEAD",
                    144:     "POST",
                    145:     "PUT",
                    146:     "DELETE",
                    147:     "CHECKOUT",
                    148:     "CHECKIN",
                    149:     "SHOWMETHOD",
                    150:     "LINK",
                    151:     "UNLINK",
                    152:     NULL
                    153: };
                    154: 
                    155: /*     Get method enum value
                    156: **     ---------------------
                    157: */
                    158: PUBLIC HTMethod HTMethod_enum ARGS1(char *, name)
                    159: {
                    160:     if (name) {
                    161:        int i;
                    162:        for (i=1; i < (int)MAX_METHODS; i++)
                    163:            if (!strcmp(name, method_names[i]))
                    164:                return (HTMethod)i;
                    165:     }
                    166:     return METHOD_INVALID;
                    167: }
                    168: 
                    169: 
                    170: /*     Get method name
                    171: **     ---------------
                    172: */
                    173: PUBLIC char * HTMethod_name ARGS1(HTMethod, method)
                    174: {
                    175:     if ((int)method > (int)METHOD_INVALID  && 
                    176:        (int)method < (int)MAX_METHODS)
                    177:        return method_names[(int)method];
                    178:     else
                    179:        return method_names[(int)METHOD_INVALID];
                    180: }
                    181: 
                    182: 
                    183: /*     Is method in a list of method names?
                    184: **     -----------------------------------
                    185: */
                    186: PUBLIC BOOL HTMethod_inList ARGS2(HTMethod,    method,
                    187:                                  HTList *,     list)
                    188: {
                    189:     char * method_name = HTMethod_name(method);
                    190:     HTList *cur = list;
                    191:     char *item;
                    192: 
                    193:     while (NULL != (item = (char*)HTList_nextObject(cur))) {
                    194:        CTRACE(stderr, " %s", item);
                    195:        if (0==strcasecomp(item, method_name))
                    196:            return YES;
                    197:     }
                    198:     return NO; /* Not found */
                    199: }
                    200: 
                    201: 
                    202: 
                    203: 
1.20      luotonen  204: 
1.1       timbl     205: /*     Register a Protocol                             HTRegisterProtocol
                    206: **     -------------------
                    207: */
                    208: 
                    209: PUBLIC BOOL HTRegisterProtocol(protocol)
                    210:        HTProtocol * protocol;
                    211: {
                    212:     if (!protocols) protocols = HTList_new();
                    213:     HTList_addObject(protocols, protocol);
                    214:     return YES;
                    215: }
                    216: 
                    217: 
                    218: /*     Register all known protocols
                    219: **     ----------------------------
                    220: **
                    221: **     Add to or subtract from this list if you add or remove protocol modules.
                    222: **     This routine is called the first time the protocol list is needed,
1.52      frystyk   223: **     unless any protocols are already registered, in which case it is not
                    224: **     called. Therefore the application can override this list.
1.1       timbl     225: **
                    226: **     Compiling with NO_INIT prevents all known protocols from being forced
                    227: **     in at link time.
                    228: */
                    229: #ifndef NO_INIT
                    230: PRIVATE void HTAccessInit NOARGS                       /* Call me once */
                    231: {
1.14      duns      232: GLOBALREF HTProtocol HTTP, HTFile, HTTelnet, HTTn3270, HTRlogin;
1.1       timbl     233: #ifndef DECNET
1.54    ! frystyk   234: #ifdef NEW_CODE
        !           235: GLOBALREF  HTProtocol HTFTP, HTNews, HTNNTP, HTGopher;
        !           236: #endif
1.14      duns      237: GLOBALREF  HTProtocol HTFTP, HTNews, HTGopher;
1.42      frystyk   238: 
1.3       timbl     239: #ifdef DIRECT_WAIS
1.14      duns      240: GLOBALREF  HTProtocol HTWAIS;
1.3       timbl     241: #endif
1.2       timbl     242:     HTRegisterProtocol(&HTFTP);
                    243:     HTRegisterProtocol(&HTNews);
1.54    ! frystyk   244: #ifdef NEW_CODE
        !           245:     HTRegisterProtocol(&HTNNTP);
        !           246: #endif
1.2       timbl     247:     HTRegisterProtocol(&HTGopher);
1.42      frystyk   248: 
1.3       timbl     249: #ifdef DIRECT_WAIS
                    250:     HTRegisterProtocol(&HTWAIS);
                    251: #endif
1.1       timbl     252: 
1.54    ! frystyk   253: #endif /* DECNET */
1.2       timbl     254:     HTRegisterProtocol(&HTTP);
                    255:     HTRegisterProtocol(&HTFile);
                    256:     HTRegisterProtocol(&HTTelnet);
                    257:     HTRegisterProtocol(&HTTn3270);
                    258:     HTRegisterProtocol(&HTRlogin);
1.1       timbl     259: }
                    260: #endif
                    261: 
                    262: 
1.33      luotonen  263: 
                    264: /*                                                     override_proxy()
                    265: **
                    266: **     Check the no_proxy environment variable to get the list
                    267: **     of hosts for which proxy server is not consulted.
                    268: **
                    269: **     no_proxy is a comma- or space-separated list of machine
                    270: **     or domain names, with optional :port part.  If no :port
                    271: **     part is present, it applies to all ports on that domain.
                    272: **
                    273: **     Example:
                    274: **             no_proxy="cern.ch,some.domain:8001"
                    275: **
                    276: */
                    277: PRIVATE BOOL override_proxy ARGS1(CONST char *, addr)
                    278: {
                    279:     CONST char * no_proxy = getenv("no_proxy");
                    280:     char * p = NULL;
                    281:     char * host = NULL;
                    282:     int port = 0;
                    283:     int h_len = 0;
                    284: 
                    285:     if (!no_proxy || !addr || !(host = HTParse(addr, "", PARSE_HOST)))
                    286:        return NO;
                    287:     if (!*host) { free(host); return NO; }
                    288: 
1.34      frystyk   289:     if ((p = strchr(host, ':')) != NULL) {     /* Port specified */
1.33      luotonen  290:        *p++ = 0;                       /* Chop off port */
                    291:        port = atoi(p);
                    292:     }
                    293:     else {                             /* Use default port */
                    294:        char * access = HTParse(addr, "", PARSE_ACCESS);
                    295:        if (access) {
                    296:            if      (!strcmp(access,"http"))    port = 80;
                    297:            else if (!strcmp(access,"gopher"))  port = 70;
                    298:            else if (!strcmp(access,"ftp"))     port = 21;
                    299:            free(access);
                    300:        }
                    301:     }
                    302:     if (!port) port = 80;              /* Default */
                    303:     h_len = strlen(host);
                    304: 
                    305:     while (*no_proxy) {
                    306:        CONST char * end;
                    307:        CONST char * colon = NULL;
                    308:        int templ_port = 0;
                    309:        int t_len;
                    310: 
                    311:        while (*no_proxy && (WHITE(*no_proxy) || *no_proxy==','))
                    312:            no_proxy++;                 /* Skip whitespace and separators */
                    313: 
                    314:        end = no_proxy;
                    315:        while (*end && !WHITE(*end) && *end != ',') {   /* Find separator */
                    316:            if (*end==':') colon = end;                 /* Port number given */
                    317:            end++;
                    318:        }
                    319: 
                    320:        if (colon) {
                    321:            templ_port = atoi(colon+1);
                    322:            t_len = colon - no_proxy;
                    323:        }
                    324:        else {
                    325:            t_len = end - no_proxy;
                    326:        }
                    327: 
                    328:        if ((!templ_port || templ_port == port)  &&
                    329:            (t_len > 0  &&  t_len <= h_len  &&
                    330:             !strncmp(host + h_len - t_len, no_proxy, t_len))) {
                    331:            free(host);
                    332:            return YES;
                    333:        }
                    334:        if (*end) no_proxy = end+1;
                    335:        else break;
                    336:     }
                    337: 
                    338:     free(host);
                    339:     return NO;
                    340: }
                    341: 
                    342: 
                    343: 
1.2       timbl     344: /*             Find physical name and access protocol
                    345: **             --------------------------------------
1.1       timbl     346: **
                    347: **
                    348: ** On entry,
                    349: **     addr            must point to the fully qualified hypertext reference.
                    350: **     anchor          a pareent anchor with whose address is addr
                    351: **
                    352: ** On exit,
1.2       timbl     353: **     returns         HT_NO_ACCESS            Error has occured.
                    354: **                     HT_OK                   Success
1.1       timbl     355: **
                    356: */
1.21      luotonen  357: PRIVATE int get_physical ARGS1(HTRequest *, req)
                    358: {    
1.1       timbl     359:     char * access=0;   /* Name of access method */
1.21      luotonen  360:     char * addr = HTAnchor_address((HTAnchor*)req->anchor);    /* free me */
1.27      luotonen  361: 
1.35      luotonen  362:     /*
                    363:     ** This HACK is here until we have redirection implemented.
                    364:     ** This is used when we are recursively calling HTLoad().
                    365:     ** We then take the physical address, because currently the
                    366:     ** virtual address is kept in a hash table so it can't be
                    367:     ** changed -- otherwise it wouldn't be found anymore.
                    368:     */
1.36      luotonen  369:     if (HTAnchor_physical(req->anchor))
                    370:        StrAllocCopy(addr, HTAnchor_physical(req->anchor));
1.35      luotonen  371: 
1.2       timbl     372: #ifndef NO_RULES
1.47      luotonen  373:     if (HTImServer) {  /* cern_httpd has already done its own translations */
1.45      luotonen  374:        HTAnchor_setPhysical(req->anchor, HTImServer);
1.47      luotonen  375:        StrAllocCopy(addr, HTImServer); /* Oops, queries thru many proxies */
                    376:                                        /* didn't work without this -- AL  */
                    377:     }
1.21      luotonen  378:     else {
1.27      luotonen  379:        char * physical = HTTranslate(addr);
1.21      luotonen  380:        if (!physical) {
1.47      luotonen  381:            free(addr);
1.21      luotonen  382:            return HT_FORBIDDEN;
                    383:        }
                    384:        HTAnchor_setPhysical(req->anchor, physical);
                    385:        free(physical);                 /* free our copy */
1.2       timbl     386:     }
                    387: #else
1.21      luotonen  388:     HTAnchor_setPhysical(req->anchor, addr);
1.2       timbl     389: #endif
                    390: 
1.21      luotonen  391:     access =  HTParse(HTAnchor_physical(req->anchor),
1.27      luotonen  392:                      "file:", PARSE_ACCESS);
1.1       timbl     393: 
                    394: /*     Check whether gateway access has been set up for this
1.8       timbl     395: **
                    396: **     This function can be replaced by the rule system above.
1.1       timbl     397: */
1.8       timbl     398: #define USE_GATEWAYS
1.1       timbl     399: #ifdef USE_GATEWAYS
1.39      luotonen  400: 
                    401:     /* make sure the using_proxy variable is false */
                    402:     using_proxy = NO;
                    403: 
1.33      luotonen  404:     if (!override_proxy(addr)) {
1.27      luotonen  405:        char * gateway_parameter, *gateway, *proxy;
                    406: 
1.2       timbl     407:        gateway_parameter = (char *)malloc(strlen(access)+20);
                    408:        if (gateway_parameter == NULL) outofmem(__FILE__, "HTLoad");
1.27      luotonen  409: 
                    410:        /* search for proxy gateways */
1.2       timbl     411:        strcpy(gateway_parameter, "WWW_");
                    412:        strcat(gateway_parameter, access);
                    413:        strcat(gateway_parameter, "_GATEWAY");
                    414:        gateway = (char *)getenv(gateway_parameter); /* coerce for decstation */
1.27      luotonen  415: 
                    416:        /* search for proxy servers */
                    417:        strcpy(gateway_parameter, access);
                    418:        strcat(gateway_parameter, "_proxy");
                    419:        proxy = (char *)getenv(gateway_parameter);
                    420: 
1.2       timbl     421:        free(gateway_parameter);
1.27      luotonen  422: 
                    423:        if (TRACE && gateway)
                    424:            fprintf(stderr,"Gateway found: %s\n",gateway);
                    425:        if (TRACE && proxy)
                    426:            fprintf(stderr,"Proxy server found: %s\n",proxy);
                    427: 
1.8       timbl     428: #ifndef DIRECT_WAIS
1.9       timbl     429:        if (!gateway && 0==strcmp(access, "wais")) {
1.8       timbl     430:            gateway = DEFAULT_WAIS_GATEWAY;
                    431:        }
                    432: #endif
1.27      luotonen  433: 
                    434:        /* proxy servers have precedence over gateway servers */
                    435:        if (proxy) {
                    436:            char * gatewayed=0;
                    437: 
                    438:             StrAllocCopy(gatewayed,proxy);
                    439:            StrAllocCat(gatewayed,addr);
                    440:            using_proxy = YES;
                    441:            HTAnchor_setPhysical(req->anchor, gatewayed);
                    442:            free(gatewayed);
                    443:            free(access);
                    444: 
                    445:            access =  HTParse(HTAnchor_physical(req->anchor),
                    446:                              "http:", PARSE_ACCESS);
                    447:        } else if (gateway) {
1.9       timbl     448:            char * path = HTParse(addr, "",
                    449:                PARSE_HOST + PARSE_PATH + PARSE_PUNCTUATION);
                    450:                /* Chop leading / off to make host into part of path */
                    451:            char * gatewayed = HTParse(path+1, gateway, PARSE_ALL);
                    452:            free(path);
1.21      luotonen  453:             HTAnchor_setPhysical(req->anchor, gatewayed);
1.9       timbl     454:            free(gatewayed);
1.2       timbl     455:            free(access);
1.9       timbl     456:            
1.21      luotonen  457:            access =  HTParse(HTAnchor_physical(req->anchor),
1.8       timbl     458:                "http:", PARSE_ACCESS);
1.2       timbl     459:        }
                    460:     }
1.1       timbl     461: #endif
                    462: 
1.19      timbl     463:     free(addr);
1.1       timbl     464: 
                    465: 
                    466: /*     Search registered protocols to find suitable one
                    467: */
                    468:     {
1.20      luotonen  469:        HTList *cur;
                    470:        HTProtocol *p;
1.1       timbl     471: #ifndef NO_INIT
1.2       timbl     472:         if (!protocols) HTAccessInit();
1.1       timbl     473: #endif
1.20      luotonen  474:        cur = protocols;
                    475:        while ((p = (HTProtocol*)HTList_nextObject(cur))) {
1.2       timbl     476:            if (strcmp(p->name, access)==0) {
1.21      luotonen  477:                HTAnchor_setProtocol(req->anchor, p);
1.2       timbl     478:                free(access);
                    479:                return (HT_OK);
1.1       timbl     480:            }
                    481:        }
                    482:     }
                    483: 
                    484:     free(access);
1.2       timbl     485:     return HT_NO_ACCESS;
1.1       timbl     486: }
                    487: 
                    488: 
                    489: /*             Load a document
                    490: **             ---------------
                    491: **
1.2       timbl     492: **     This is an internal routine, which has an address AND a matching
                    493: **     anchor.  (The public routines are called with one OR the other.)
                    494: **
                    495: ** On entry,
1.15      timbl     496: **     request->
1.35      luotonen  497: **         anchor              a parent anchor with fully qualified
                    498: **                             hypertext reference as its address set
1.15      timbl     499: **         output_format       valid
                    500: **         output_stream       valid on NULL
1.2       timbl     501: **
                    502: ** On exit,
                    503: **     returns         <0              Error has occured.
                    504: **                     HT_LOADED       Success
                    505: **                     HT_NO_DATA      Success, but no document loaded.
1.8       timbl     506: **                                     (telnet sesssion started etc)
1.2       timbl     507: **
                    508: */
1.52      frystyk   509: PUBLIC int HTLoad ARGS2(HTRequest *, request, BOOL, keep_error_stack)
1.2       timbl     510: {
1.25      frystyk   511:     char       *arg = NULL;
                    512:     HTProtocol *p;
                    513:     int        status;
                    514: 
1.22      luotonen  515:     if (request->method == METHOD_INVALID)
                    516:        request->method = METHOD_GET;
1.52      frystyk   517:     if (!keep_error_stack) {
                    518:        HTErrorFree(request);
                    519:        request->error_block = NO;
                    520:     }
                    521: 
1.21      luotonen  522:     status = get_physical(request);
1.2       timbl     523:     if (status == HT_FORBIDDEN) {
1.49      frystyk   524:        char *url = HTAnchor_address((HTAnchor *) request->anchor);
                    525:        if (url) {
                    526:            HTUnEscape(url);
                    527:            HTErrorAdd(request, ERR_FATAL, NO, HTERR_FORBIDDEN,
                    528:                       (void *) url, (int) strlen(url), "HTLoad");
                    529:            free(url);
                    530:        } else {
                    531:            HTErrorAdd(request, ERR_FATAL, NO, HTERR_FORBIDDEN,
                    532:                       NULL, 0, "HTLoad");
                    533:        }
                    534:        return -1;
1.2       timbl     535:     }
                    536:     if (status < 0) return status;     /* Can't resolve or forbidden */
1.25      frystyk   537: 
                    538:     if(!(arg = HTAnchor_physical(request->anchor)) || !*arg) 
                    539:        return (-1);
1.27      luotonen  540: 
1.15      timbl     541:     p = HTAnchor_protocol(request->anchor);
1.17      timbl     542:     return (*(p->load))(request);
1.2       timbl     543: }
                    544: 
                    545: 
                    546: /*             Get a save stream for a document
                    547: **             --------------------------------
                    548: */
1.19      timbl     549: PUBLIC HTStream *HTSaveStream ARGS1(HTRequest *, request)
1.15      timbl     550: {
                    551:     HTProtocol * p;
1.19      timbl     552:     int status;
1.22      luotonen  553:     request->method = METHOD_PUT;
1.21      luotonen  554:     status = get_physical(request);
1.19      timbl     555:     if (status == HT_FORBIDDEN) {
1.49      frystyk   556:        char *url = HTAnchor_address((HTAnchor *) request->anchor);
                    557:        if (url) {
                    558:            HTUnEscape(url);
                    559:            HTErrorAdd(request, ERR_FATAL, NO, HTERR_FORBIDDEN,
                    560:                       (void *) url, (int) strlen(url), "HTLoad");
                    561:            free(url);
                    562:        } else {
                    563:            HTErrorAdd(request, ERR_FATAL, NO, HTERR_FORBIDDEN,
                    564:                       NULL, 0, "HTLoad");
                    565:        }
                    566:        return NULL;    /* should return error status? */
1.19      timbl     567:     }
                    568:     if (status < 0) return NULL; /* @@ error. Can't resolve or forbidden */
                    569:     
1.15      timbl     570:     p = HTAnchor_protocol(request->anchor);
1.2       timbl     571:     if (!p) return NULL;
                    572:     
1.15      timbl     573:     return (*p->saveStream)(request);
1.2       timbl     574:     
                    575: }
                    576: 
                    577: 
                    578: /*             Load a document - with logging etc
                    579: **             ----------------------------------
                    580: **
                    581: **     - Checks or documents already loaded
                    582: **     - Logs the access
                    583: **     - Allows stdin filter option
                    584: **     - Trace ouput and error messages
                    585: **
1.1       timbl     586: **    On Entry,
1.19      timbl     587: **        request->anchor      valid for of the document to be accessed.
                    588: **      request->childAnchor   optional anchor within doc to be selected
                    589: **
1.2       timbl     590: **        filter            if YES, treat stdin as HTML
1.1       timbl     591: **
1.15      timbl     592: **       request->anchor   is the node_anchor for the document
                    593: **       request->output_format is valid
                    594: **
1.1       timbl     595: **    On Exit,
                    596: **        returns    YES     Success in opening document
                    597: **                   NO      Failure 
                    598: **
                    599: */
                    600: 
1.52      frystyk   601: PRIVATE BOOL HTLoadDocument ARGS2(HTRequest *,         request,
                    602:                                  BOOL,                 keep_error_stack)
1.1       timbl     603: 
                    604: {
                    605:     int                status;
                    606:     HText *    text;
1.19      timbl     607:     char * full_address = HTAnchor_address((HTAnchor*)request->anchor);
1.54    ! frystyk   608: 
1.49      frystyk   609:     if (TRACE) fprintf (stderr, "HTAccess.... Loading document %s\n",
                    610:                        full_address);
1.1       timbl     611: 
1.18      timbl     612:     request->using_cache = NULL;
                    613:     
1.15      timbl     614:     if (!request->output_format) request->output_format = WWW_PRESENT;
1.25      frystyk   615: 
1.31      frystyk   616:     if (!HTForceReload && (text=(HText *)HTAnchor_document(request->anchor)))
1.15      timbl     617:     {  /* Already loaded */
1.1       timbl     618:         if (TRACE) fprintf(stderr, "HTAccess: Document already in memory.\n");
1.19      timbl     619:        if (request->childAnchor) {
                    620:            HText_selectAnchor(text, request->childAnchor);
                    621:        } else {
                    622:            HText_select(text); 
                    623:        }
                    624:        free(full_address);
1.1       timbl     625:        return YES;
                    626:     }
1.17      timbl     627:     
1.34      frystyk   628:     /* Check the Cache */
1.17      timbl     629:     /* Bug: for each format, we only check whether it is ok, we
                    630:        don't check them all and chose the best */
1.54    ! frystyk   631:     if (request->anchor->cacheItems) {
1.17      timbl     632:         HTList * list = request->anchor->cacheItems;
1.20      luotonen  633:        HTList * cur = list;
                    634:        HTCacheItem * item;
                    635: 
                    636:        while ((item = (HTCacheItem*)HTList_nextObject(cur))) {
1.18      timbl     637:            HTStream * s;
                    638:            
                    639:            request->using_cache = item;
                    640:            
1.37      luotonen  641:            s = HTStreamStack(item->format, request, NO);
1.17      timbl     642:            if (s) {            /* format was suitable */
                    643:                FILE * fp = fopen(item->filename, "r");
1.18      timbl     644:                if (TRACE) fprintf(stderr, "Cache: HIT file %s for %s\n",
1.20      luotonen  645:                                   item->filename, 
                    646:                                   full_address);
1.17      timbl     647:                if (fp) {
                    648:                    HTFileCopy(fp, s);
1.53      duns      649:                    (*s->isa->_free)(s);        /* close up pipeline */
1.17      timbl     650:                    fclose(fp);
1.19      timbl     651:                    free(full_address);
1.17      timbl     652:                    return YES;
                    653:                } else {
                    654:                    fprintf(stderr, "***** Can't read cache file %s !\n",
1.20      luotonen  655:                            item->filename);
1.17      timbl     656:                } /* file open ok */
                    657:            } /* stream ok */
                    658:        } /* next cache item */
                    659:     } /* if cache available for this anchor */
1.1       timbl     660:     
1.52      frystyk   661:     status = HTLoad(request, keep_error_stack);
1.2       timbl     662: 
1.1       timbl     663: /*     Log the access if necessary
                    664: */
1.42      frystyk   665:     if (HTlogfile) {
1.1       timbl     666:        time_t theTime;
                    667:        time(&theTime);
1.42      frystyk   668:        fprintf(HTlogfile, "%24.24s %s %s %s\n",
1.1       timbl     669:            ctime(&theTime),
                    670:            HTClientHost ? HTClientHost : "local",
                    671:            status<0 ? "FAIL" : "GET",
                    672:            full_address);
1.42      frystyk   673:        fflush(HTlogfile);      /* Actually update it on disk */
1.1       timbl     674:        if (TRACE) fprintf(stderr, "Log: %24.24s %s %s %s\n",
                    675:            ctime(&theTime),
                    676:            HTClientHost ? HTClientHost : "local",
                    677:            status<0 ? "FAIL" : "GET",
                    678:            full_address);
                    679:     }
                    680: 
1.52      frystyk   681:     /* The error stack might contain general information to the client
                    682:        about what has been going on in the library (not only errors) */
                    683:     if (request->error_stack)
                    684:        HTErrorMsg(request);
                    685: 
1.1       timbl     686:     if (status == HT_LOADED) {
                    687:        if (TRACE) {
1.54    ! frystyk   688:            fprintf(stderr, "HTAccess.... `%s' has been accessed.\n",
1.1       timbl     689:            full_address);
                    690:        }
1.19      timbl     691:        free(full_address);
1.1       timbl     692:        return YES;
                    693:     }
                    694:     
                    695:     if (status == HT_NO_DATA) {
                    696:        if (TRACE) {
                    697:            fprintf(stderr, 
1.54    ! frystyk   698:            "HTAccess.... `%s' has been accessed, No data left.\n",
1.1       timbl     699:            full_address);
                    700:        }
1.19      timbl     701:        free(full_address);
1.1       timbl     702:        return NO;
                    703:     }
                    704:     
1.34      frystyk   705:     /* Bug fix thanks to Lou Montulli. Henrik 10/03-94 */
                    706:     if (status<=0) {                 /* Failure in accessing a document */
1.1       timbl     707: #ifdef CURSES
                    708:         user_message("Can't access `%s'", full_address);
                    709: #else
1.5       timbl     710:        if (TRACE) fprintf(stderr, 
                    711:                "HTAccess: Can't access `%s'\n", full_address);
1.1       timbl     712: #endif
1.19      timbl     713:        free(full_address);
1.1       timbl     714:        return NO;
                    715:     }
1.9       timbl     716:  
                    717:     /* If you get this, then please find which routine is returning
                    718:        a positive unrecognised error code! */
1.1       timbl     719:     fprintf(stderr,
1.50      frystyk   720:     "**** HTAccess: Internal software error in CERN WWWLib version %s ****\n\nPlease mail www-bug@info.cern.ch quoting what software and what version you are using\nand the URL: %s that caused the problem, thanks!\n",
                    721:            HTLibraryVersion,
                    722:            full_address);
1.19      timbl     723:     free(full_address);
                    724:    
1.1       timbl     725:     exit(-6996);
1.20      luotonen  726:     return NO; /* For gcc :-( */
1.2       timbl     727: } /* HTLoadDocument */
1.1       timbl     728: 
                    729: 
                    730: 
                    731: /*             Load a document from absolute name
                    732: **             ---------------
                    733: **
                    734: **    On Entry,
                    735: **        addr     The absolute address of the document to be accessed.
                    736: **        filter   if YES, treat document as HTML
                    737: **
                    738: **    On Exit,
                    739: **        returns    YES     Success in opening document
                    740: **                   NO      Failure 
                    741: **
                    742: **
                    743: */
                    744: 
1.15      timbl     745: PUBLIC BOOL HTLoadAbsolute ARGS2(CONST char *,addr, HTRequest*, request)
1.2       timbl     746: {
1.19      timbl     747:    HTAnchor * anchor = HTAnchor_findAddress(addr);
                    748:    request->anchor = HTAnchor_parent(anchor);
                    749:    request->childAnchor = ((HTAnchor*)request->anchor == anchor) ?
                    750:                        NULL : (HTChildAnchor*) anchor;
1.52      frystyk   751:    return HTLoadDocument(request, NO);
1.2       timbl     752: }
                    753: 
                    754: 
                    755: /*             Load a document from absolute name to stream
                    756: **             --------------------------------------------
                    757: **
                    758: **    On Entry,
                    759: **        addr     The absolute address of the document to be accessed.
1.15      timbl     760: **        request->output_stream     if non-NULL, send data down this stream
1.2       timbl     761: **
                    762: **    On Exit,
                    763: **        returns    YES     Success in opening document
                    764: **                   NO      Failure 
                    765: **
                    766: **
                    767: */
                    768: 
                    769: PUBLIC BOOL HTLoadToStream ARGS3(
                    770:                CONST char *,   addr,
                    771:                BOOL,           filter,
1.15      timbl     772:                HTRequest*,     request)
1.1       timbl     773: {
1.19      timbl     774:    HTAnchor * anchor = HTAnchor_findAddress(addr);
                    775:    request->anchor = HTAnchor_parent(anchor);
                    776:    request->childAnchor = ((HTAnchor*)request->anchor == anchor) ? NULL :
                    777:        (HTChildAnchor*) anchor;
1.15      timbl     778:     request->output_stream = request->output_stream;
1.52      frystyk   779:     return HTLoadDocument(request, NO);
1.1       timbl     780: }
                    781: 
                    782: 
1.2       timbl     783: 
                    784: 
1.1       timbl     785: /*             Load a document from relative name
                    786: **             ---------------
                    787: **
                    788: **    On Entry,
1.2       timbl     789: **        relative_name     The relative address of the document
                    790: **                         to be accessed.
1.1       timbl     791: **
                    792: **    On Exit,
                    793: **        returns    YES     Success in opening document
                    794: **                   NO      Failure 
                    795: **
                    796: **
                    797: */
                    798: 
1.15      timbl     799: PUBLIC BOOL HTLoadRelative ARGS3(
1.2       timbl     800:                CONST char *,           relative_name,
1.15      timbl     801:                HTParentAnchor *,       here,
1.20      luotonen  802:                HTRequest *,            request)
1.1       timbl     803: {
                    804:     char *             full_address = 0;
                    805:     BOOL                       result;
                    806:     char *             mycopy = 0;
                    807:     char *             stripped = 0;
                    808:     char *             current_address =
1.2       timbl     809:                                HTAnchor_address((HTAnchor*)here);
1.1       timbl     810: 
                    811:     StrAllocCopy(mycopy, relative_name);
                    812: 
                    813:     stripped = HTStrip(mycopy);
                    814:     full_address = HTParse(stripped,
                    815:                   current_address,
                    816:                   PARSE_ACCESS|PARSE_HOST|PARSE_PATH|PARSE_PUNCTUATION);
1.15      timbl     817:     result = HTLoadAbsolute(full_address, request);
1.1       timbl     818:     free(full_address);
                    819:     free(current_address);
                    820:     free(mycopy);  /* Memory leak fixed 10/7/92 -- JFG */
                    821:     return result;
                    822: }
                    823: 
                    824: 
                    825: /*             Load if necessary, and select an anchor
                    826: **             --------------------------------------
                    827: **
                    828: **    On Entry,
                    829: **        destination              The child or parenet anchor to be loaded.
                    830: **
                    831: **    On Exit,
                    832: **        returns    YES     Success
                    833: **                   NO      Failure 
                    834: **
                    835: */
                    836: 
1.15      timbl     837: PUBLIC BOOL HTLoadAnchor ARGS2(HTAnchor*, anchor, HTRequest *, request)
1.1       timbl     838: {
1.15      timbl     839:     if (!anchor) return NO;    /* No link */
1.1       timbl     840:     
1.15      timbl     841:     request->anchor  = HTAnchor_parent(anchor);
1.19      timbl     842:     request->childAnchor = ((HTAnchor*)request->anchor == anchor) ? NULL
                    843:                                        : (HTChildAnchor*) anchor;
1.1       timbl     844:     
1.52      frystyk   845:     return HTLoadDocument(request, NO) ? YES : NO;
                    846:        
                    847: } /* HTLoadAnchor */
                    848: 
                    849: 
                    850: /*             Load if necessary, and select an anchor
                    851: **             --------------------------------------
                    852: **
                    853: **     This function is almost identical to HTLoadAnchor, but it doesn't
                    854: **     clear the error stack so that the information in there is kept.
                    855: **
                    856: **    On Entry,
                    857: **        destination              The child or parenet anchor to be loaded.
                    858: **
                    859: **    On Exit,
                    860: **        returns    YES     Success
                    861: **                   NO      Failure 
                    862: **
                    863: */
                    864: 
                    865: PUBLIC BOOL HTLoadAnchorRecursive ARGS2(HTAnchor*, anchor,
                    866:                                        HTRequest *, request)
                    867: {
                    868:     if (!anchor) return NO;    /* No link */
                    869:     
                    870:     request->anchor  = HTAnchor_parent(anchor);
                    871:     request->childAnchor = ((HTAnchor*)request->anchor == anchor) ? NULL
                    872:                                        : (HTChildAnchor*) anchor;
                    873:     
                    874:     return HTLoadDocument(request, YES) ? YES : NO;
1.1       timbl     875:        
                    876: } /* HTLoadAnchor */
                    877: 
                    878: 
                    879: /*             Search
                    880: **             ------
                    881: **  Performs a keyword search on word given by the user. Adds the keyword to 
                    882: **  the end of the current address and attempts to open the new address.
                    883: **
                    884: **  On Entry,
                    885: **       *keywords     space-separated keyword list or similar search list
1.2       timbl     886: **     here            is anchor search is to be done on.
1.1       timbl     887: */
                    888: 
1.2       timbl     889: PRIVATE char hex(i)
                    890:     int i;
                    891: {
1.13      timbl     892:     char * hexchars = "0123456789ABCDEF";
                    893:     return hexchars[i];
1.2       timbl     894: }
1.1       timbl     895: 
1.15      timbl     896: PUBLIC BOOL HTSearch ARGS3(
1.2       timbl     897:        CONST char *,           keywords,
1.15      timbl     898:        HTParentAnchor *,       here,
                    899:        HTRequest *,            request)
1.1       timbl     900: {
1.2       timbl     901: 
                    902: #define acceptable \
                    903: "1234567890abcdefghijlkmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-_"
                    904: 
                    905:     char *q, *u;
                    906:     CONST char * p, *s, *e;            /* Pointers into keywords */
                    907:     char * address = HTAnchor_address((HTAnchor*)here);
1.1       timbl     908:     BOOL result;
1.2       timbl     909:     char * escaped = malloc(strlen(keywords)*3+1);
                    910: 
1.29      frystyk   911:     /* static CONST BOOL isAcceptable[96] = */
                    912:     /* static AND const is not good for a gnu compiler! Frystyk 25/02-94 */
1.30      luotonen  913:     static BOOL isAcceptable[96] =
1.2       timbl     914:     /*   0 1 2 3 4 5 6 7 8 9 A B C D E F */
                    915:     {    0,0,0,0,0,0,0,0,0,0,1,0,0,1,1,0,      /* 2x   !"#$%&'()*+,-./  */
                    916:          1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,      /* 3x  0123456789:;<=>?  */
                    917:         1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,       /* 4x  @ABCDEFGHIJKLMNO  */
                    918:         1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,       /* 5X  PQRSTUVWXYZ[\]^_  */
                    919:         0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,       /* 6x  `abcdefghijklmno  */
                    920:         1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0 };     /* 7X  pqrstuvwxyz{\}~  DEL */
                    921: 
                    922:     if (escaped == NULL) outofmem(__FILE__, "HTSearch");
                    923:     
1.29      frystyk   924: /* Convert spaces to + and hex escape unacceptable characters */
1.2       timbl     925: 
1.29      frystyk   926:     for(s=keywords; *s && WHITE(*s); s++); /*scan */    /* Skip white space */
                    927:     for(e = s + strlen(s); e>s && WHITE(*(e-1)) ; e--);     /* Skip trailers */
                    928:     for(q=escaped, p=s; p<e; p++) {                  /* scan stripped field */
1.2       timbl     929:         int c = (int)TOASCII(*p);
                    930:         if (WHITE(*p)) {
                    931:            *q++ = '+';
1.29      frystyk   932:        } else if (c>=32 && c<=127 && isAcceptable[c-32] != 0) {
1.13      timbl     933:            *q++ = *p;                  /* 930706 TBL for MVS bug */
1.2       timbl     934:        } else {
                    935:            *q++ = '%';
                    936:            *q++ = hex(c / 16);
                    937:            *q++ = hex(c % 16);
                    938:        }
                    939:     } /* Loop over string */
1.1       timbl     940:     
1.2       timbl     941:     *q=0;
                    942:                                /* terminate escaped sctring */
                    943:     u=strchr(address, '?');            /* Find old search string */
                    944:     if (u) *u = 0;                             /* Chop old search off */
1.1       timbl     945: 
                    946:     StrAllocCat(address, "?");
1.2       timbl     947:     StrAllocCat(address, escaped);
                    948:     free(escaped);
1.15      timbl     949:     result = HTLoadRelative(address, here, request);
1.1       timbl     950:     free(address);
1.2       timbl     951:     
1.1       timbl     952:     return result;
1.2       timbl     953: }
                    954: 
                    955: 
                    956: /*             Search Given Indexname
                    957: **             ------
                    958: **  Performs a keyword search on word given by the user. Adds the keyword to 
                    959: **  the end of the current address and attempts to open the new address.
                    960: **
                    961: **  On Entry,
                    962: **       *keywords     space-separated keyword list or similar search list
                    963: **     *addres         is name of object search is to be done on.
                    964: */
                    965: 
1.15      timbl     966: PUBLIC BOOL HTSearchAbsolute ARGS3(
1.2       timbl     967:        CONST char *,   keywords,
1.15      timbl     968:        CONST char *,   indexname,
                    969:        HTRequest *,    request)
1.2       timbl     970: {
                    971:     HTParentAnchor * anchor =
                    972:        (HTParentAnchor*) HTAnchor_findAddress(indexname);
1.15      timbl     973:     return HTSearch(keywords, anchor, request);
1.2       timbl     974: }
                    975: 
                    976: 
                    977: /*             Generate the anchor for the home page
                    978: **             -------------------------------------
                    979: **
                    980: **     As it involves file access, this should only be done once
                    981: **     when the program first runs.
1.10      timbl     982: **     This is a default algorithm -- browser don't HAVE to use this.
                    983: **     But consistency betwen browsers is STRONGLY recommended!
1.2       timbl     984: **
1.10      timbl     985: **     Priority order is:
                    986: **
                    987: **             1       WWW_HOME environment variable (logical name, etc)
                    988: **             2       ~/WWW/default.html
                    989: **             3       /usr/local/bin/default.html
                    990: **             4       http://info.cern.ch/default.html
                    991: **
1.2       timbl     992: */
                    993: PUBLIC HTParentAnchor * HTHomeAnchor NOARGS
                    994: {
1.12      timbl     995:     char * my_home_document = NULL;
                    996:     char * home = (char *)getenv(LOGICAL_DEFAULT);
1.2       timbl     997:     char * ref;
                    998:     HTParentAnchor * anchor;
1.1       timbl     999:     
1.12      timbl    1000:     if (home) {
                   1001:         StrAllocCopy(my_home_document, home);
                   1002:     
                   1003: /*     Someone telnets in, they get a special home.
                   1004: */
                   1005: #define MAX_FILE_NAME 1024                                     /* @@@ */
                   1006:     } else  if (HTClientHost) {                        /* Telnet server */
                   1007:        FILE * fp = fopen(REMOTE_POINTER, "r");
                   1008:        char * status;
                   1009:        if (fp) {
                   1010:            my_home_document = (char*) malloc(MAX_FILE_NAME);
                   1011:            status = fgets(my_home_document, MAX_FILE_NAME, fp);
                   1012:            if (!status) {
                   1013:                free(my_home_document);
                   1014:                my_home_document = NULL;
                   1015:            }
                   1016:            fclose(fp);
                   1017:        }
                   1018:        if (!my_home_document) StrAllocCopy(my_home_document, REMOTE_ADDRESS);
                   1019:     }
                   1020: 
                   1021:     
                   1022: 
1.2       timbl    1023: #ifdef unix
1.12      timbl    1024: 
1.10      timbl    1025:     if (!my_home_document) {
                   1026:        FILE * fp = NULL;
                   1027:        CONST char * home =  (CONST char*)getenv("HOME");
                   1028:        if (home) { 
                   1029:            my_home_document = (char *)malloc(
                   1030:                strlen(home)+1+ strlen(PERSONAL_DEFAULT)+1);
                   1031:            if (my_home_document == NULL) outofmem(__FILE__, "HTLocalName");
                   1032:            sprintf(my_home_document, "%s/%s", home, PERSONAL_DEFAULT);
                   1033:            fp = fopen(my_home_document, "r");
                   1034:        }
                   1035:        
                   1036:        if (!fp) {
                   1037:            StrAllocCopy(my_home_document, LOCAL_DEFAULT_FILE);
                   1038:            fp = fopen(my_home_document, "r");
                   1039:        }
1.2       timbl    1040:        if (fp) {
                   1041:            fclose(fp);
                   1042:        } else {
                   1043:        if (TRACE) fprintf(stderr,
1.10      timbl    1044:            "HTBrowse: No local home document ~/%s or %s\n",
                   1045:            PERSONAL_DEFAULT, LOCAL_DEFAULT_FILE);
1.11      timbl    1046:            free(my_home_document);
                   1047:            my_home_document = NULL;
1.2       timbl    1048:        }
                   1049:     }
                   1050: #endif
1.10      timbl    1051:     ref = HTParse( my_home_document ?  my_home_document :
                   1052:                                HTClientHost ? REMOTE_ADDRESS
                   1053:                                : LAST_RESORT,
                   1054:                    "file:",
1.2       timbl    1055:                    PARSE_ACCESS|PARSE_HOST|PARSE_PATH|PARSE_PUNCTUATION);
1.10      timbl    1056:     if (my_home_document) {
1.2       timbl    1057:        if (TRACE) fprintf(stderr,
                   1058:            "HTAccess: Using custom home page %s i.e. address %s\n",
1.10      timbl    1059:            my_home_document, ref);
                   1060:        free(my_home_document);
1.2       timbl    1061:     }
                   1062:     anchor = (HTParentAnchor*) HTAnchor_findAddress(ref);
                   1063:     free(ref);
                   1064:     return anchor;
1.1       timbl    1065: }
1.26      frystyk  1066: 
                   1067: 
                   1068: /*             Bind an Anchor to the request structure
                   1069: **             ---------------------------------------
                   1070: **
                   1071: **    On Entry,
                   1072: **     anchor          The child or parenet anchor to be binded
                   1073: **     request         The request sturcture
                   1074: **    On Exit,
                   1075: **        returns    YES     Success
                   1076: **                   NO      Failure 
                   1077: **
                   1078: **  Note: Actually the same as HTLoadAnchor() but DOES NOT do the loading
                   1079: **                                             Henrik Frystyk 17/02-94
                   1080: */
                   1081: 
                   1082: PUBLIC BOOL HTBindAnchor ARGS2(HTAnchor*, anchor, HTRequest *, request)
                   1083: {
                   1084:     if (!anchor) return NO;    /* No link */
                   1085:     
                   1086:     request->anchor  = HTAnchor_parent(anchor);
                   1087:     request->childAnchor = ((HTAnchor*)request->anchor == anchor) ? NULL
                   1088:                                        : (HTChildAnchor*) anchor;
                   1089:        
1.29      frystyk  1090:     return YES;
1.26      frystyk  1091: } /* HTBindAnchor */
                   1092: 

Webmaster