Annotation of libwww/Library/src/HTParse.c, revision 2.19

1.1       timbl       1: /*             Parse HyperText Document Address                HTParse.c
                      2: **             ================================
                      3: */
                      4: 
                      5: #include "HTUtils.h"
                      6: #include "HTParse.h"
                      7: #include "tcp.h"
                      8: 
2.6       timbl       9: #define HEX_ESCAPE '%'
                     10: 
1.1       timbl      11: struct struct_parts {
                     12:        char * access;
                     13:        char * host;
                     14:        char * absolute;
                     15:        char * relative;
                     16: /*     char * search;          no - treated as part of path */
                     17:        char * anchor;
                     18: };
                     19: 
                     20: 
                     21: /*     Strip white space off a string
                     22: **     ------------------------------
                     23: **
                     24: ** On exit,
                     25: **     Return value points to first non-white character, or to 0 if none.
                     26: **     All trailing white space is OVERWRITTEN with zero.
                     27: */
                     28: 
2.13      luotonen   29: PUBLIC char * HTStrip ARGS1(char *, s)
1.1       timbl      30: {
                     31: #define SPACE(c) ((c==' ')||(c=='\t')||(c=='\n')) 
                     32:     char * p=s;
2.13      luotonen   33:     if (!s) return NULL;       /* Doesn't dump core if NULL */
                     34:     for(p=s;*p;p++);           /* Find end of string */
1.1       timbl      35:     for(p--;p>=s;p--) {
                     36:        if(SPACE(*p)) *p=0;     /* Zap trailing blanks */
                     37:        else break;
                     38:     }
                     39:     while(SPACE(*s))s++;       /* Strip leading blanks */
                     40:     return s;
                     41: }
                     42: 
                     43: 
                     44: /*     Scan a filename for its consituents
                     45: **     -----------------------------------
                     46: **
                     47: ** On entry,
                     48: **     name    points to a document name which may be incomplete.
                     49: ** On exit,
                     50: **      absolute or relative may be nonzero (but not both).
                     51: **     host, anchor and access may be nonzero if they were specified.
                     52: **     Any which are nonzero point to zero terminated strings.
                     53: */
                     54: #ifdef __STDC__
                     55: PRIVATE void scan(char * name, struct struct_parts *parts)
                     56: #else
                     57: PRIVATE void scan(name, parts)
                     58:     char * name;
                     59:     struct struct_parts *parts;
                     60: #endif
                     61: {
                     62:     char * after_access;
                     63:     char * p;
                     64:     int length = strlen(name);
                     65:     
                     66:     parts->access = 0;
                     67:     parts->host = 0;
                     68:     parts->absolute = 0;
                     69:     parts->relative = 0;
                     70:     parts->anchor = 0;
                     71:     
                     72:     after_access = name;
                     73:     for(p=name; *p; p++) {
                     74:        if (*p==':') {
                     75:                *p = 0;
                     76:                parts->access = name;   /* Access name has been specified */
                     77:                after_access = p+1;
                     78:        }
                     79:        if (*p=='/') break;
                     80:        if (*p=='#') break;
                     81:     }
                     82:     
                     83:     for(p=name+length-1; p>=name; p--) {
                     84:        if (*p =='#') {
                     85:            parts->anchor=p+1;
                     86:            *p=0;                               /* terminate the rest */
                     87:        }
                     88:     }
                     89:     p = after_access;
                     90:     if (*p=='/'){
                     91:        if (p[1]=='/') {
                     92:            parts->host = p+2;          /* host has been specified      */
                     93:            *p=0;                       /* Terminate access             */
                     94:            p=strchr(parts->host,'/');  /* look for end of host name if any */
                     95:            if(p) {
                     96:                *p=0;                   /* Terminate host */
                     97:                parts->absolute = p+1;          /* Root has been found */
                     98:            }
                     99:        } else {
                    100:            parts->absolute = p+1;              /* Root found but no host */
                    101:        }           
                    102:     } else {
                    103:         parts->relative = (*after_access) ? after_access : 0;  /* zero for "" */
                    104:     }
                    105: 
2.16      timbl     106: #ifdef OLD_CODE
1.1       timbl     107:     /* Access specified but no host: the anchor was not really one
2.16      timbl     108:        e.g. news:j462#36487@foo.bar -- JFG 10/jul/92, from bug report */
                    109:     /* This kludge doesn't work for example when coming across
                    110:        file:/usr/local/www/fred#123
                    111:        which loses its anchor. Correct approach in news is to
                    112:        escape weird characters not allowed in URL.  TBL 21/dec/93
                    113:     */
1.1       timbl     114:     if (parts->access && ! parts->host && parts->anchor) {
                    115:       *(parts->anchor - 1) = '#';  /* Restore the '#' in the address */
                    116:       parts->anchor = 0;
                    117:     }
2.16      timbl     118: #endif
1.1       timbl     119: 
                    120: #ifdef NOT_DEFINED     /* search is just treated as part of path */
                    121:     {
                    122:         char *p = relative ? relative : absolute;
                    123:        if (p) {
                    124:            char * q = strchr(p, '?');  /* Any search string? */
                    125:            if (q) {
                    126:                *q = 0;                 /* If so, chop that off. */
                    127:                parts->search = q+1;
                    128:            }
                    129:        }
                    130:     }
                    131: #endif
                    132: } /*scan */    
                    133: 
                    134: 
                    135: /*     Parse a Name relative to another name
                    136: **     -------------------------------------
                    137: **
                    138: **     This returns those parts of a name which are given (and requested)
                    139: **     substituting bits from the related name where necessary.
                    140: **
                    141: ** On entry,
                    142: **     aName           A filename given
                    143: **      relatedName     A name relative to which aName is to be parsed
                    144: **      wanted          A mask for the bits which are wanted.
                    145: **
                    146: ** On exit,
                    147: **     returns         A pointer to a malloc'd string which MUST BE FREED
                    148: */
                    149: #ifdef __STDC__
                    150: char * HTParse(const char * aName, const char * relatedName, int wanted)
                    151: #else
                    152: char * HTParse(aName, relatedName, wanted)
                    153:     char * aName;
                    154:     char * relatedName;
                    155:     int wanted;
                    156: #endif
                    157: 
                    158: {
                    159:     char * result = 0;
                    160:     char * return_value = 0;
                    161:     int len;
                    162:     char * name = 0;
                    163:     char * rel = 0;
                    164:     char * p;
2.12      timbl     165:     char * access;
1.1       timbl     166:     struct struct_parts given, related;
                    167:     
                    168:     /* Make working copies of input strings to cut up:
                    169:     */
                    170:     len = strlen(aName)+strlen(relatedName)+10;
                    171:     result=(char *)malloc(len);                /* Lots of space: more than enough */
                    172:     if (result == NULL) outofmem(__FILE__, "HTParse");
                    173:     
                    174:     StrAllocCopy(name, aName);
                    175:     StrAllocCopy(rel, relatedName);
                    176:     
                    177:     scan(name, &given);
                    178:     scan(rel,  &related); 
                    179:     result[0]=0;               /* Clear string  */
2.12      timbl     180:     access = given.access ? given.access : related.access;
1.1       timbl     181:     if (wanted & PARSE_ACCESS)
2.12      timbl     182:         if (access) {
                    183:            strcat(result, access);
1.1       timbl     184:            if(wanted & PARSE_PUNCTUATION) strcat(result, ":");
                    185:        }
                    186:        
                    187:     if (given.access && related.access)        /* If different, inherit nothing. */
                    188:         if (strcmp(given.access, related.access)!=0) {
                    189:            related.host=0;
                    190:            related.absolute=0;
                    191:            related.relative=0;
                    192:            related.anchor=0;
                    193:        }
                    194:        
                    195:     if (wanted & PARSE_HOST)
                    196:         if(given.host || related.host) {
2.12      timbl     197:            char * tail = result + strlen(result);
1.1       timbl     198:            if(wanted & PARSE_PUNCTUATION) strcat(result, "//");
                    199:            strcat(result, given.host ? given.host : related.host);
2.12      timbl     200: #define CLEAN_URLS
                    201: #ifdef CLEAN_URLS
                    202:            /* Ignore default port numbers, and trailing dots on FQDNs
                    203:               which will only cause identical adreesses to look different */
                    204:            {
                    205:                char * p;
                    206:                p = strchr(tail, ':');
                    207:                if (p && access) {              /* Port specified */
                    208:                    if (  (   strcmp(access, "http") == 0
                    209:                           && strcmp(p, ":80") == 0 )
                    210:                        ||
                    211:                          (   strcmp(access, "gopher") == 0
                    212:                           && strcmp(p, ":70") == 0 )
                    213:                        )
                    214:                    *p = (char)0;       /* It is the default: ignore it */
                    215:                }
                    216:                if (!p) p = tail + strlen(tail); /* After hostname */
                    217:                p--;                            /* End of hostname */
                    218:                if (*p == '.') *p = (char)0; /* chop final . */
                    219:            }
                    220: #endif
1.1       timbl     221:        }
                    222:        
                    223:     if (given.host && related.host)  /* If different hosts, inherit no path. */
                    224:         if (strcmp(given.host, related.host)!=0) {
                    225:            related.absolute=0;
                    226:            related.relative=0;
                    227:            related.anchor=0;
                    228:        }
                    229:        
                    230:     if (wanted & PARSE_PATH) {
                    231:         if(given.absolute) {                           /* All is given */
                    232:            if(wanted & PARSE_PUNCTUATION) strcat(result, "/");
                    233:            strcat(result, given.absolute);
                    234:        } else if(related.absolute) {   /* Adopt path not name */
                    235:            strcat(result, "/");
                    236:            strcat(result, related.absolute);
                    237:            if (given.relative) {
                    238:                p = strchr(result, '?');        /* Search part? */
                    239:                if (!p) p=result+strlen(result)-1;
                    240:                for (; *p!='/'; p--);   /* last / */
                    241:                p[1]=0;                                 /* Remove filename */
                    242:                strcat(result, given.relative);         /* Add given one */
                    243:                HTSimplify (result);
                    244:            }
                    245:        } else if(given.relative) {
                    246:            strcat(result, given.relative);             /* what we've got */
                    247:        } else if(related.relative) {
                    248:            strcat(result, related.relative);
                    249:        } else {  /* No inheritance */
                    250:            strcat(result, "/");
                    251:        }
                    252:     }
                    253:                
                    254:     if (wanted & PARSE_ANCHOR)
                    255:         if(given.anchor || related.anchor) {
                    256:            if(wanted & PARSE_PUNCTUATION) strcat(result, "#");
                    257:            strcat(result, given.anchor ? given.anchor : related.anchor);
                    258:        }
                    259:     free(rel);
                    260:     free(name);
                    261:     
                    262:     StrAllocCopy(return_value, result);
                    263:     free(result);
                    264:     return return_value;               /* exactly the right length */
                    265: }
                    266: 
2.11      timbl     267: 
2.15      luotonen  268: /*
                    269: **     As strcpy() but guaranteed to work correctly
                    270: **     with overlapping parameters.    AL 7 Feb 1994
                    271: */
                    272: PRIVATE void ari_strcpy ARGS2(char *, to,
                    273:                              char *, from)
                    274: {
                    275:     char * tmp;
                    276: 
                    277:     if (!to || !from) return;
                    278: 
                    279:     tmp = (char*)malloc(strlen(from)+1);
                    280:     if (!tmp) outofmem(__FILE__, "my_strcpy");
                    281: 
                    282:     strcpy(tmp, from);
                    283:     strcpy(to, tmp);
                    284:     free(tmp);
                    285: }
1.1       timbl     286: /*             Simplify a filename
                    287: //             -------------------
                    288: //
                    289: // A unix-style file is allowed to contain the seqeunce xxx/../ which may be
                    290: // replaced by "" , and the seqeunce "/./" which may be replaced by "/".
                    291: // Simplification helps us recognize duplicate filenames.
                    292: //
                    293: //     Thus,   /etc/junk/../fred       becomes /etc/fred
                    294: //             /etc/junk/./fred        becomes /etc/junk/fred
2.11      timbl     295: //
                    296: //      but we should NOT change
                    297: //             http://fred.xxx.edu/../..
                    298: //
                    299: //     or      ../../albert.html
1.1       timbl     300: */
2.14      luotonen  301: PUBLIC void HTSimplify ARGS1(char *, filename)
1.1       timbl     302: {
2.19    ! frystyk   303:     int tokcnt = 0;
        !           304:     char *strptr;
        !           305:     char *urlptr;
        !           306:     if (!filename || !*filename)                         /* Just to be sure! */
        !           307:        return;
        !           308: 
        !           309:     /* Skip prefix, starting ./ and starting ///<etc> */
        !           310:     urlptr = strstr(filename, "://");                         /* Find prefix */
        !           311:     urlptr = urlptr ? urlptr+3 : filename;
        !           312:     if (*urlptr == '.' && *(urlptr+1) == '/')            /* Starting ./<etc> */
        !           313:        urlptr += 2;
        !           314:     else if (*urlptr == '/') {                  /* Some URLs start //<file> */
        !           315:        while (*++urlptr == '/');
        !           316:     }
        !           317:     if (!*urlptr)
        !           318:        return;
        !           319: 
        !           320:     /* Now we have the string we want to work with */
        !           321:     strptr = urlptr;
        !           322:     while (*strptr++) {                        /* Count number of delimiters */
        !           323:        if (*strptr == '/')
        !           324:            tokcnt++;
        !           325:     }
        !           326:     {
        !           327:        BOOL slashtail = NO;
        !           328:        char *empty = "";
        !           329:        char *url = NULL;
        !           330:        char **tokptr;
        !           331:        char **tokstart;
        !           332:        StrAllocCopy(url, urlptr);
        !           333: 
        !           334:        /* Does the URL end with a slash? */
        !           335:        if(*(filename+strlen(filename)-1) == '/')
        !           336:            slashtail = YES;
        !           337:        
        !           338:        /* I allocate cnt+2 as I don't know if the url is terminated by '/' */
        !           339:        if ((tokstart = (char **) calloc(tokcnt+2, sizeof(char *))) == NULL)
        !           340:            outofmem(__FILE__, "HTSimplify");
        !           341: 
        !           342:        /* Read the tokens forwards */
        !           343:        tokptr = tokstart;
        !           344:        *tokptr++ = strtok(url, "/");
        !           345:        while ((strptr = strtok(NULL, "/")) != NULL)
        !           346:            *tokptr++ = strptr;
        !           347:        
        !           348:        /* Scan backwards for '.' and '..' */
        !           349:        tokptr--;
        !           350:        while(tokptr >= tokstart) {
        !           351:            if (!strcmp(*tokptr, ".")) {
        !           352:                *tokptr = empty;
        !           353:            } else if (!strcmp(*tokptr, "..")) {
        !           354:                char **pptr = tokptr-1;
        !           355:                while (pptr >= tokstart) {
        !           356:                    if (**pptr && strcmp(*pptr, "..") && strcmp(*pptr, ".")) {
        !           357:                        *pptr = empty;
        !           358:                        *tokptr = empty;
        !           359:                        break;
        !           360:                    }
        !           361:                    pptr--;
        !           362:                }
        !           363:            }
        !           364:            tokptr--;
        !           365:        }
        !           366: 
        !           367:        /* Write the rest out forwards */
        !           368:        *urlptr = '\0';
        !           369:        strcat(urlptr, *++tokptr);
        !           370:        while (*++tokptr) {
        !           371:            if (**tokptr) {
        !           372:                strcat(urlptr, "/");
        !           373:                strcat(urlptr, *tokptr);
        !           374:            }
        !           375:        }
        !           376:        if (slashtail == YES)
        !           377:            strcat(urlptr, "/");
        !           378:        free(url);
        !           379:        free(tokstart);
        !           380:     }
        !           381:     if (TRACE)
        !           382:        fprintf(stderr, "HTSimplify: %s\n", filename);
        !           383: }
        !           384: #ifdef OLD_CODE
2.17      frystyk   385:     char * p = filename;
1.1       timbl     386:     char * q;
2.17      frystyk   387:     
                    388:     if (p) {
                    389:        while (*p && (*p == '/' || *p == '.'))     /* Pass starting / or .'s */
                    390:            p++;
                    391:        while(*p) {
                    392:            if (*p=='/') {
1.1       timbl     393:            if ((p[1]=='.') && (p[2]=='.') && (p[3]=='/' || !p[3] )) {
2.11      timbl     394:                for (q=p-1; (q>=filename) && (*q!='/'); q--); /* prev slash */
                    395:                if (q[0]=='/' && 0!=strncmp(q, "/../", 4)
                    396:                        &&!(q-1>filename && q[-1]=='/')) {
2.15      luotonen  397:                    ari_strcpy(q, p+3);         /* Remove  /xxx/..      */
1.1       timbl     398:                    if (!*filename) strcpy(filename, "/");
                    399:                    p = q-1;            /* Start again with prev slash  */
2.11      timbl     400:                } else {                        /*   xxx/.. leave it!   */
2.9       timbl     401: #ifdef BUG_CODE
2.15      luotonen  402:                    ari_strcpy(filename, p[3] ? p+4 : p+3); /* rm  xxx/../ */
1.1       timbl     403:                    p = filename;               /* Start again */
2.9       timbl     404: #endif
1.1       timbl     405:                }
                    406:            } else if ((p[1]=='.') && (p[2]=='/' || !p[2])) {
2.15      luotonen  407:                ari_strcpy(p, p+2);             /* Remove a slash and a dot */
2.13      luotonen  408:            } else if (p[-1] != ':') {
                    409:                while (p[1] == '/') {
2.15      luotonen  410:                    ari_strcpy(p, p+1); /* Remove multiple slashes */
2.13      luotonen  411:                }
1.1       timbl     412:            }
2.17      frystyk   413:            }
                    414:            p++;
                    415:        }  /* end while (*p) */
                    416:     } /* end if (p) */
1.1       timbl     417: }
2.19    ! frystyk   418: #endif /* OLD_CODE */
1.1       timbl     419: 
                    420: 
                    421: /*             Make Relative Name
                    422: **             ------------------
                    423: **
                    424: ** This function creates and returns a string which gives an expression of
                    425: ** one address as related to another. Where there is no relation, an absolute
                    426: ** address is retured.
                    427: **
                    428: **  On entry,
                    429: **     Both names must be absolute, fully qualified names of nodes
                    430: **     (no anchor bits)
                    431: **
                    432: **  On exit,
                    433: **     The return result points to a newly allocated name which, if
                    434: **     parsed by HTParse relative to relatedName, will yield aName.
                    435: **     The caller is responsible for freeing the resulting name later.
                    436: **
                    437: */
                    438: #ifdef __STDC__
                    439: char * HTRelative(const char * aName, const char *relatedName)
                    440: #else
                    441: char * HTRelative(aName, relatedName)
                    442:    char * aName;
                    443:    char * relatedName;
                    444: #endif
                    445: {
                    446:     char * result = 0;
                    447:     CONST char *p = aName;
                    448:     CONST char *q = relatedName;
                    449:     CONST char * after_access = 0;
                    450:     CONST char * path = 0;
                    451:     CONST char * last_slash = 0;
                    452:     int slashes = 0;
                    453:     
                    454:     for(;*p; p++, q++) {       /* Find extent of match */
                    455:        if (*p!=*q) break;
                    456:        if (*p==':') after_access = p+1;
                    457:        if (*p=='/') {
                    458:            last_slash = p;
                    459:            slashes++;
                    460:            if (slashes==3) path=p;
                    461:        }
                    462:     }
                    463:     
                    464:     /* q, p point to the first non-matching character or zero */
                    465:     
                    466:     if (!after_access) {                       /* Different access */
                    467:         StrAllocCopy(result, aName);
                    468:     } else if (slashes<3){                     /* Different nodes */
                    469:        StrAllocCopy(result, after_access);
                    470:     } else if (slashes==3){                    /* Same node, different path */
                    471:         StrAllocCopy(result, path);
                    472:     } else {                                   /* Some path in common */
                    473:         int levels= 0;
                    474:         for(; *q && (*q!='#'); q++)  if (*q=='/') levels++;
                    475:        result = (char *)malloc(3*levels + strlen(last_slash) + 1);
                    476:       if (result == NULL) outofmem(__FILE__, "HTRelative");
                    477:        result[0]=0;
                    478:        for(;levels; levels--)strcat(result, "../");
                    479:        strcat(result, last_slash+1);
                    480:     }
                    481:     if (TRACE) fprintf(stderr, "HT: `%s' expressed relative to\n    `%s' is\n   `%s'.",
                    482:                aName, relatedName, result);
                    483:     return result;
                    484: }
2.1       timbl     485: 
                    486: 
2.6       timbl     487: /*             Escape undesirable characters using %           HTEscape()
                    488: **             -------------------------------------
                    489: **
                    490: **     This function takes a pointer to a string in which
                    491: **     some characters may be unacceptable unescaped.
                    492: **     It returns a string which has these characters
                    493: **     represented by a '%' character followed by two hex digits.
                    494: **
                    495: **     Unlike HTUnEscape(), this routine returns a malloced string.
                    496: */
                    497: 
2.19    ! frystyk   498: /* Not BOTH static AND const at the same time in gcc :-(, Henrik 18/03-94 */
        !           499: /* PRIVATE CONST unsigned char isAcceptable[96] = */
        !           500: PRIVATE unsigned char isAcceptable[96] =
2.6       timbl     501: 
                    502: /*     Bit 0           xalpha          -- see HTFile.h
                    503: **     Bit 1           xpalpha         -- as xalpha but with plus.
2.18      luotonen  504: **     Bit 2 ...       path            -- as xpalphas but with /
2.6       timbl     505: */
                    506:     /*   0 1 2 3 4 5 6 7 8 9 A B C D E F */
                    507:     {    0,0,0,0,0,0,0,0,0,0,7,6,0,7,7,4,      /* 2x   !"#$%&'()*+,-./  */
                    508:          7,7,7,7,7,7,7,7,7,7,0,0,0,0,0,0,      /* 3x  0123456789:;<=>?  */
                    509:         7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,       /* 4x  @ABCDEFGHIJKLMNO  */
                    510:         7,7,7,7,7,7,7,7,7,7,7,0,0,0,0,7,       /* 5X  PQRSTUVWXYZ[\]^_  */
                    511:         0,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,       /* 6x  `abcdefghijklmno  */
                    512:         7,7,7,7,7,7,7,7,7,7,7,0,0,0,0,0 };     /* 7X  pqrstuvwxyz{\}~  DEL */
                    513: 
                    514: PRIVATE char *hex = "0123456789ABCDEF";
                    515: 
2.8       timbl     516: PUBLIC char * HTEscape ARGS2 (CONST char *, str,
2.6       timbl     517:        unsigned char, mask)
                    518: {
                    519: #define ACCEPTABLE(a)  ( a>=32 && a<128 && ((isAcceptable[a-32]) & mask))
                    520:     CONST char * p;
                    521:     char * q;
                    522:     char * result;
                    523:     int unacceptable = 0;
                    524:     for(p=str; *p; p++)
                    525:         if (!ACCEPTABLE((unsigned char)TOASCII(*p)))
                    526:                unacceptable++;
                    527:     result = (char *) malloc(p-str + unacceptable+ unacceptable + 1);
                    528:     if (result == NULL) outofmem(__FILE__, "HTEscape");
                    529:     for(q=result, p=str; *p; p++) {
                    530:        unsigned char a = TOASCII(*p);
                    531:        if (!ACCEPTABLE(a)) {
                    532:            *q++ = HEX_ESCAPE;  /* Means hex commming */
                    533:            *q++ = hex[a >> 4];
                    534:            *q++ = hex[a & 15];
                    535:        }
                    536:        else *q++ = *p;
                    537:     }
                    538:     *q++ = 0;                  /* Terminate */
                    539:     return result;
                    540: }
                    541: 
                    542: 
2.1       timbl     543: /*             Decode %xx escaped characters                   HTUnEscape()
                    544: **             -----------------------------
                    545: **
                    546: **     This function takes a pointer to a string in which some
                    547: **     characters may have been encoded in %xy form, where xy is
                    548: **     the acsii hex code for character 16x+y.
                    549: **     The string is converted in place, as it will never grow.
                    550: */
                    551: 
                    552: PRIVATE char from_hex ARGS1(char, c)
                    553: {
2.6       timbl     554:     return  c >= '0' && c <= '9' ?  c - '0' 
                    555:            : c >= 'A' && c <= 'F'? c - 'A' + 10
                    556:            : c - 'a' + 10;     /* accept small letters just in case */
2.1       timbl     557: }
                    558: 
                    559: PUBLIC char * HTUnEscape ARGS1( char *, str)
                    560: {
                    561:     char * p = str;
                    562:     char * q = str;
                    563:     while(*p) {
2.6       timbl     564:         if (*p == HEX_ESCAPE) {
2.1       timbl     565:            p++;
                    566:            if (*p) *q = from_hex(*p++) * 16;
                    567:            if (*p) *q = FROMASCII(*q + from_hex(*p++));
                    568:            q++;
                    569:        } else {
                    570:            *q++ = *p++; 
                    571:        }
                    572:     }
                    573:     
                    574:     *q++ = 0;
                    575:     return str;
                    576:     
                    577: } /* HTUnEscape */
                    578: 
                    579: 

Webmaster