Annotation of libwww/Library/src/HTAAUtil.html, revision 2.5

2.2       timbl       1: <HTML>
2.1       luotonen    2: <HEAD>
2.2       timbl       3: <TITLE>Utilities for the Authorization parts of libwww</TITLE></HEAD>
2.1       luotonen    4: <BODY>
2.2       timbl       5: <H1>Common Parts of Authorization Module
                      6: to Both Server And Browser</H1>This module is the interface to the
                      7: common parts of Access Authorization
                      8: (AA) package for both server and
                      9: browser. Important to know about
                     10: memory allocation:<P>
                     11: Routines in this module use dynamic
                     12: allocation, but free automatically
                     13: all the memory reserved by them.<P>
                     14: Therefore the caller never has to
                     15: (and never should) free() any object
                     16: returned by these functions.<P>
                     17: Therefore also all the strings returned
                     18: by this package are only valid until
                     19: the next call to the same function
                     20: is made. This approach is selected,
                     21: because of the nature of access authorization:
                     22: no string returned by the package
                     23: needs to be valid longer than until
                     24: the next call.<P>
                     25: This also makes it easy to plug the
                     26: AA package in: you don't have to
                     27: ponder whether to free() something
                     28: here or is it done somewhere else
                     29: (because it is always done somewhere
                     30: else).<P>
                     31: The strings that the package needs
                     32: to store are copied so the original
                     33: strings given as parameters to AA
                     34: functions may be freed or modified
                     35: with no side effects.<P>
                     36: Also note: The AA package does not
                     37: free() anything else than what it
                     38: has itself allocated.
2.1       luotonen   39: <PRE>
                     40: #ifndef HTAAUTIL_H
                     41: #define HTAAUTIL_H
                     42: 
                     43: #include "HTUtils.h"           /* BOOL, PARAMS, ARGS */
                     44: #include "HTList.h"
2.5     ! luotonen   45: #include "HTAtom.h"
2.2       timbl      46: #include "tcp.h"
2.1       luotonen   47: 
                     48: #ifdef SHORT_NAMES
                     49: #define HTAASenu       HTAAScheme_enum
                     50: #define HTAASnam       HTAAScheme_name
2.5     ! luotonen   51: #define        HTMeInLi        HTMethod_inList
2.1       luotonen   52: #define HTAAteMa       HTAA_templateMatch
                     53: #define HTAAmaPT       HTAA_makeProtectionTemplate
                     54: #define HTAApALi       HTAA_parseArgList
                     55: #endif /*SHORT_NAMES*/
                     56: 
                     57: 
2.2       timbl      58: </PRE>
                     59: <H2>Default filenames</H2>
                     60: <PRE>#ifndef PASSWD_FILE
2.1       luotonen   61: #define PASSWD_FILE    "/home2/luotonen/passwd"
                     62: #endif
                     63: 
                     64: #ifndef GROUP_FILE
                     65: #define GROUP_FILE     "/home2/luotonen/group"
                     66: #endif
                     67: 
                     68: #define ACL_FILE_NAME  ".www_acl"
                     69: 
                     70: 
                     71: /*
                     72: ** Numeric constants
                     73: */
                     74: #define MAX_USERNAME_LEN       16      /* @@ Longest allowed username    */
2.5     ! luotonen   75: #define MAX_PASSWORD_LEN       4*13    /* @@ Longest allowed password    */
        !            76:                                        /* (encrypted, so really only 4*8)*/
2.1       luotonen   77: #define MAX_METHODNAME_LEN     12      /* @@ Longest allowed method name */
                     78: #define MAX_FIELDNAME_LEN      16      /* @@ Longest field name in       */
                     79:                                        /* protection setup file          */
                     80: #define MAX_PATHNAME_LEN       80      /* @@ Longest passwd/group file   */
                     81:                                        /* patname to allow               */
                     82: 
                     83: /*
                     84: ** Helpful macros
                     85: */
                     86: #define FREE(x)        if (x) {free(x); x=NULL;}
                     87: 
                     88: </PRE>
                     89: <H2>Datatype definitions</H2>
2.2       timbl      90: <H3>HTAAScheme</H3>The enumeration HTAAScheme represents
                     91: the possible authentication schemes
                     92: used by the WWW Access Authorization.
2.1       luotonen   93: <PRE>
                     94: typedef enum {
                     95:     HTAA_UNKNOWN,
                     96:     HTAA_NONE,
                     97:     HTAA_BASIC,
                     98:     HTAA_PUBKEY,
                     99:     HTAA_KERBEROS_V4,
                    100:     HTAA_KERBEROS_V5,
                    101:     HTAA_MAX_SCHEMES /* THIS MUST ALWAYS BE LAST! Number of schemes */
                    102: } HTAAScheme;
                    103: 
2.2       timbl     104: </PRE>
2.1       luotonen  105: 
                    106: <H2>Authentication Schemes</H2>
                    107: <PRE>
                    108: /* PUBLIC                                              HTAAScheme_enum()
                    109: **             TRANSLATE SCHEME NAME TO A SCHEME ENUMERATION
                    110: ** ON ENTRY:
                    111: **     name            is a string representing the scheme name.
                    112: **
                    113: ** ON EXIT:
                    114: **     returns         the enumerated constant for that scheme.
                    115: */
                    116: PUBLIC HTAAScheme HTAAScheme_enum PARAMS((CONST char* name));
                    117: 
                    118: 
                    119: /* PUBLIC                                              HTAAScheme_name()
                    120: **                     GET THE NAME OF A GIVEN SCHEME
                    121: ** ON ENTRY:
                    122: **     scheme          is one of the scheme enum values:
                    123: **                     HTAA_NONE, HTAA_BASIC, HTAA_PUBKEY, ...
                    124: **
                    125: ** ON EXIT:
                    126: **     returns         the name of the scheme, i.e.
                    127: **                     "none", "basic", "pubkey", ...
                    128: */
                    129: PUBLIC char *HTAAScheme_name PARAMS((HTAAScheme scheme));
2.2       timbl     130: 
2.1       luotonen  131: </PRE>
                    132: <H2>Methods</H2>
2.5     ! luotonen  133: Methods are now represented as HTAtoms.
2.1       luotonen  134: <PRE>
2.5     ! luotonen  135: /* PUBLIC                                              HTMethod_inList()
2.1       luotonen  136: **             IS A METHOD IN A LIST OF METHOD NAMES
                    137: ** ON ENTRY:
                    138: **     method          is the method to look for.
                    139: **     list            is a list of method names.
                    140: **
                    141: ** ON EXIT:
                    142: **     returns         YES, if method was found.
                    143: **                     NO, if not found.
                    144: */
2.5     ! luotonen  145: PUBLIC BOOL HTMethod_inList PARAMS((HTAtom *   method,
        !           146:                                    HTList *    list));
2.1       luotonen  147: </PRE>
                    148: <H2>Match Template Against Filename</H2>
                    149: <PRE>
                    150: /* PUBLIC                                              HTAA_templateMatch()
                    151: **             STRING COMPARISON FUNCTION FOR FILE NAMES
                    152: **                WITH ONE WILDCARD * IN THE TEMPLATE
                    153: ** NOTE:
                    154: **     This is essentially the same code as in HTRules.c, but it
                    155: **     cannot be used because it is embedded in between other code.
                    156: **     (In fact, HTRules.c should use this routine, but then this
                    157: **      routine would have to be more sophisticated... why is life
                    158: **      sometimes so hard...)
                    159: **
                    160: ** ON ENTRY:
                    161: **     template        is a template string to match the file name
                    162: **                     agaist, may contain a single wildcard
                    163: **                     character * which matches zero or more
                    164: **                     arbitrary characters.
                    165: **     filename        is the filename (or pathname) to be matched
                    166: **                     agaist the template.
                    167: **
                    168: ** ON EXIT:
                    169: **     returns         YES, if filename matches the template.
                    170: **                     NO, otherwise.
                    171: */
                    172: PUBLIC BOOL HTAA_templateMatch PARAMS((CONST char * template, 
                    173:                                       CONST char * filename));
                    174: 
                    175: 
2.4       duns      176: /* PUBLIC                                              HTAA_templateCaseMatch()
                    177: **             STRING COMPARISON FUNCTION FOR FILE NAMES
                    178: **                WITH ONE WILDCARD * IN THE TEMPLATE (Case Insensitive)
                    179: ** NOTE:
                    180: **     This is essentially the same code as in HTAA_templateMatch, but
                    181: **     it compares case insensitive (for VMS). Reason for this routine
                    182: **     is that HTAA_templateMatch gets called from several places, also 
                    183: **     there where a case sensitive match is needed, so one cannot just
                    184: **     change the HTAA_templateMatch routine for VMS.
                    185: **
                    186: ** ON ENTRY:
                    187: **     template        is a template string to match the file name
                    188: **                     agaist, may contain a single wildcard
                    189: **                     character * which matches zero or more
                    190: **                     arbitrary characters.
                    191: **     filename        is the filename (or pathname) to be matched
                    192: **                     agaist the template.
                    193: **
                    194: ** ON EXIT:
                    195: **     returns         YES, if filename matches the template.
                    196: **                     NO, otherwise.
                    197: */
                    198: PUBLIC BOOL HTAA_templateCaseMatch PARAMS((CONST char * template, 
                    199:                                         CONST char * filename));
                    200: 
                    201: 
2.1       luotonen  202: /* PUBLIC                                      HTAA_makeProtectionTemplate()
                    203: **             CREATE A PROTECTION TEMPLATE FOR THE FILES
                    204: **             IN THE SAME DIRECTORY AS THE GIVEN FILE
                    205: **             (Used by server if there is no fancier way for
                    206: **             it to tell the client, and by browser if server
                    207: **             didn't send WWW-ProtectionTemplate: field)
                    208: ** ON ENTRY:
                    209: **     docname is the document pathname (from URL).
                    210: **
                    211: ** ON EXIT:
                    212: **     returns a template matching docname, and other files
                    213: **             files in that directory.
                    214: **
                    215: **             E.g.  /foo/bar/x.html  =>  /foo/bar/ *
                    216: **                                                 ^
                    217: **                             Space only to prevent it from
                    218: **                             being a comment marker here,
                    219: **                             there really isn't any space.
                    220: */
                    221: PUBLIC char *HTAA_makeProtectionTemplate PARAMS((CONST char * docname));
                    222: </PRE>
                    223: <H2>MIME Argument List Parser</H2>
                    224: <PRE>
                    225: 
                    226: /* PUBLIC                                              HTAA_parseArgList()
                    227: **             PARSE AN ARGUMENT LIST GIVEN IN A HEADER FIELD
                    228: ** ON ENTRY:
                    229: **     str     is a comma-separated list:
                    230: **
                    231: **                     item, item, item
                    232: **             where
                    233: **                     item ::= value
                    234: **                            | name=value
                    235: **                            | name="value"
                    236: **
                    237: **             Leading and trailing whitespace is ignored
                    238: **             everywhere except inside quotes, so the following
                    239: **             examples are equal:
                    240: **
                    241: **                     name=value,foo=bar
                    242: **                      name="value",foo="bar"
                    243: **                       name = value ,  foo = bar
                    244: **                        name = "value" ,  foo = "bar"
                    245: **
                    246: ** ON EXIT:
                    247: **     returns a list of name-value pairs (actually HTAssocList*).
                    248: **             For items with no name, just value, the name is
                    249: **             the number of order number of that item. E.g.
                    250: **             "1" for the first, etc.
                    251: */
                    252: PUBLIC HTList *HTAA_parseArgList PARAMS((char * str));
                    253: 
                    254: </PRE>
2.5     ! luotonen  255: 
2.1       luotonen  256: <PRE>
                    257: #endif /* NOT HTAAUTIL_H */
2.2       timbl     258: </PRE>End of file HTAAUtil.h.</BODY>
                    259: </HTML>

Webmaster