/*
 *            Copyright (c) 1998-2000 by NETsilicon Inc.
 *
 *  This software is copyrighted by and is the sole property of 
 *  NETsilicon.  All rights, title, ownership, or other interests
 *  in the software remain the property of NETsilicon.  This
 *  software may only be used in accordance with the corresponding
 *  license agreement.  Any unauthorized use, duplication, transmission,  
 *  distribution, or disclosure of this software is expressly forbidden.
 *
 *  This Copyright notice may not be removed or modified without prior
 *  written consent of NETsilicon.
 *
 *  NETsilicon, reserves the right to modify this software
 *  without notice.
 *
 *  NETsilicon
 *  411 Waverley Oaks Road                  USA 781.647.1234
 *  Suite 227                               http://www.netsilicon.com
 *  Waltham, MA 02452                       AmericaSales@netsilicon.com
 *
 *************************************************************************
 *
 *     Module Name: asExtern.h
 *         Version: 1.00
 *   Original Date: 27-Jul-2000 
 *          Author: 
 *        Language: Ansi C
 * Compile Options: 
 * Compile defines: 
 *       Libraries: 
 *    Link Options: 
 *
 *    Entry Points: 
 *
 * Description.
 * =======================================================================
 * This header contains definitions needed to compile the Rp Http
 * Web pages.
 *                                                                        
 *                                                                        
 * Edit Date/Ver   Edit Description
 * ==============  ===================================================
 *      03/26/01   SW changed RpFileInsertItem and RomPagerUrlState 
 *                 from 0 to 1.
 *      09/19/01   SW changed this file name to asExtern.h.
 *                    added more #defines in accordance
 *                    with upgrade of server from 3.05 to 4.01
 *      11/15/04  JZW   Vantive 14372  Added new error condition eRpFileAccessError
 */

#ifndef __ASEXTERN_H
#define __ASEXTERN_H

#include "RpExtern.h"

#if defined(AUTODOC_VERSION)
/**
 * defined types for asTextType
 *
 * @external
 * @category HTTP_Advanced_Server
 * @since 5.1
 *
 * @param eAsTextType_ASCII             ASCII NUL-terminated string
 * @param eAsTextType_Hex				Hexadecimal Number
 * @param eAsTextType_HexColonForm		Hexadecimal number display with colons between chars 
 * @param eAsTextType_DotForm           Dotted decimal - nnn.nnn.nnn.nnn
 * @param eAsTextType_Signed8			Signed 8-bit
 * @param eAsTextType_Signed16			Signed 16-bit
 * @param eAsTextType_Signed32			Signed 32-bit
 * @param eAsTextType_Unsigned8			Unsigned 8-bit
 * @param eAsTextType_Unsigned16		Unsigned 16-bit
 * @param eAsTextType_Unsigned32		Unsigned 32-bit
 * @param eAsTextType_BoolString		Extended String
 * @param eAsTextType_BoolValue			Extended value type 
 *
 */
typedef enum {
    eAsTextType_ASCII,              /* ASCII null-terminated string             */
    eAsTextType_Hex,
    eAsTextType_HexColonForm,       /* Hex display with colons between chars    */
    eAsTextType_DotForm,            /* Dotted decimal - nnn.nnn.nnn.nnn         */
    eAsTextType_Signed8,
    eAsTextType_Signed16,
    eAsTextType_Signed32,
    eAsTextType_Unsigned8,
    eAsTextType_Unsigned16,
    eAsTextType_Unsigned32,
    eAsTextType_BoolString,
    eAsTextType_BoolValue
} asTextType;
#endif /* AUTODOC VERSION */

typedef enum {
    eAsTextType_ASCII,              /* ASCII null-terminated string             */
    eAsTextType_Hex,
    eAsTextType_HexColonForm,       /* Hex display with colons between chars    */
    eAsTextType_DotForm,            /* Dotted decimal - nnn.nnn.nnn.nnn         */
    eAsTextType_Signed8,
    eAsTextType_Signed16,
    eAsTextType_Signed32,
#if AsUse64BitIntegers
    eAsTextType_Signed64,
    eAsTextType_Unsigned64,
#endif
    eAsTextType_Unsigned8,
    eAsTextType_Unsigned16,
    eAsTextType_Unsigned32,
#if 1
    eAsTextType_BoolString,
    eAsTextType_BoolValue
#else
    eAsTextType_ASCII_Extended,     /* ASCII null-terminated - no expansion     */
    eAsTextType_ASCII_Fixed         /* ASCII chars with length specified        */
#endif
} asTextType;

/* Error codes used by external interface routines */

#ifndef _AS_ERROR_
#define _AS_ERROR_


/**
 * AS error codes
 *
 * @external
 * @category HTTP_Advanced_Server
 * @since 5.1
 *
 * @param eRpNoError              No Error
 * @param eRpOutOfMemory          Out Of Memory
 * @param eRpTcpInitError         Unable to initialize TCP
 * @param eRpTcpReceiveError      TCP receive error
 * @param eRpTcpSendError         TCP send error
 * @param eRpTcpConnectError      TCP connection error
 * @param eRpTcpDeInitError       Unable to free TCP
 * @param eRpTcpInternalError     TCP internal error
 * @param eRpTcpAlreadyOpen       Connection is already opened
 * @param eRpTcpCannotOpenPassive Unable to open a connection
 * @param eRpTcpCloseError        Unable to close a connection
 * @param eRpTcpNoConnection      No connection
 * @param eRpTcpZeroLengthRead    No data is read
 * @param eRpTcpAbortError        Unable to abort
 * @param eRpTcpAlreadyClosed     Connection is already closed
 * @param eRpTcpCannotOpenActive  Unable to open an active connection
 * @param eRpFatalFileSystemError Fatal File System Error
 * @param eRpFileSystemNotOpen    Unable to initialize file system
 * @param eRpFileNotOpen          A file is not opened
 * @param eRpFileReadError        Error on reading a file
 * @param eRpFileWriteError       Error on writing a file
 * @param eRpFileOpenError        Unable to open a file
 * @param eRpFileCloseError       Unable to close a file
 * @param eRpFileCreateError      Unable to create a file
 * @param eRpFileNotFound         File is not found
 * @param eRpFileInvalidPosition  Invalid file offset
 * @param eRpFileZeroLengthRead   No data is read from a file
 * @param eRpFileAlreadyClosed    A file is already closed
 * @param eRpFileSystemNotClosed  File system is not closed
 * @param eRpFileAlreadyExists    File is already existed
 * @param eRpFileNoRoom           No space
 * @param eRpFileSystemError      File System Error
 * @param eRpFileAccessError      File permissions error
 * @param eRpSerialInitError      Serial interface is not initialize
 * @param eRpSerialDeInitError    Unable to terminate serial interface
 * @param eRpSerialReceiveError   Receive error on serial
 * @param eRpSerialSendError      Send error on serial
 * @param eRpPpServerError        Print server error
 * @param eRpPpInitError          Unable to initial printer interface
 * @param eRpPpCreateError        Unable to create 
 * @param eRpPpJobDoesNotExist    Job not found
 * @param eRpPpAttachError        Unable to attach
 * @param eRpPpDocFormatError     Document format error
 * @param eRpPpAttrValueError     Invalid attribute value
 * @param eRpPpAttrSubstitution   Attribute substitution
 * @param eRpPpSendDataError      Send data error
 * @param eRpPpCloseJobError      Unable to close a print job
 * @param eRpPpAbortJobError      Unable to abort a print job 
 * @param eRpPpCancelJobError     Unable to cancel a print job
 * @param eRpPpFreeJobError       Unable to free a print job
 * @param eRpPpGetSprtdAttrError  Attribute error
 * @param eRpPpGetAttrError       Unable to get attribute
 * @param eRpPpSetAttrError       Unable to set attribute
 * @param eRpPpValidateError      Validate error
 * @param eRpUdpInitError         Unable to initialize UDP
 * @param eRpUdpCannotOpenActive  Unable to open action UDP connection
 * @param eRpUdpReceiveError      Receive error on UDP
 * @param eRpUdpAlreadyClosed     UDP connection is alread already
 * @param eRpUdpCloseError        Unable to close UDP connection
 * @param eRpUdpNoConnection      No UDP connection
 * @param eRpUdpSendError         UDP send error 
 * @param eRpUdpAlreadyOpen       UDP connection is already opened
 * @param eRpUdpDeInitError       Unable to terminate UDP
 * @param eRpUdpCannotOpenMulti   Unable to open Multi
 * @param eRpTlsInitError         Unable to initialize TLS
 * @param eRpTlsHandshakeError    TLS handshake error
 * @param eRpTlsCloseError        Unable to close TLS
 * @param eRpTlsOutOfMemoryError  TLS out of memory
 * @param eRpTlsReadError         TLS read error
 * @param eRpSsisBusyError        Security information storage is busy
 * @param eRpSsisRetrievalError   Unable to retrieve from security information storage
 * @param eRpSsisStorageError     Unable to store to security information storage
 * @param eRpCertCreationBusy     Busy in certificate creation 
 * @param eRpCertCreateFailed     Unable to create certificate
 * @param eRpCliLinkError         Cross-linkage for Telnet/CLI Errors
 *
 */
typedef enum {
    eRpNoError              = 0,
    eRpOutOfMemory          = -1100, 
    eRpTcpInitError         = -1101,
    eRpTcpReceiveError      = -1102,
    eRpTcpSendError         = -1103,
    eRpTcpConnectError      = -1104,
    eRpTcpDeInitError       = -1105,
    eRpTcpInternalError     = -1106,
    eRpTcpAlreadyOpen       = -1107,
    eRpTcpCannotOpenPassive = -1108,
    eRpTcpCloseError        = -1109,
    eRpTcpNoConnection      = -1110,
    eRpTcpZeroLengthRead    = -1111,
    eRpTcpAbortError        = -1112,
    eRpTcpAlreadyClosed     = -1113,
    eRpTcpCannotOpenActive  = -1114,
    eRpFatalFileSystemError = -1200,
    eRpFileSystemNotOpen    = -1201,
    eRpFileNotOpen          = -1202,
    eRpFileReadError        = -1203,
    eRpFileWriteError       = -1204,
    eRpFileOpenError        = -1205,
    eRpFileCloseError       = -1206,
    eRpFileCreateError      = -1207,
    eRpFileNotFound         = -1208,
    eRpFileInvalidPosition  = -1209,
    eRpFileZeroLengthRead   = -1210,
    eRpFileAlreadyClosed    = -1211,
    eRpFileSystemNotClosed  = -1212,
    eRpFileAlreadyExists    = -1213,
    eRpFileNoRoom           = -1214,
    eRpFileSystemError      = -1215,
    eRpFileAccessError      = -1216,
    eRpSerialInitError      = -1301,
    eRpSerialDeInitError    = -1302,
    eRpSerialReceiveError   = -1303,
    eRpSerialSendError      = -1304,
    eRpPpServerError        = -1400,	
    eRpPpInitError          = -1401,
    eRpPpCreateError        = -1402,
    eRpPpJobDoesNotExist    = -1403,
    eRpPpAttachError        = -1404,
    eRpPpDocFormatError     = -1405,
    eRpPpAttrValueError     = -1406,
    eRpPpAttrSubstitution   = -1407,
    eRpPpSendDataError      = -1408,
    eRpPpCloseJobError      = -1409,
    eRpPpAbortJobError      = -1410,
    eRpPpCancelJobError     = -1411,
    eRpPpFreeJobError       = -1412,
    eRpPpGetSprtdAttrError  = -1413,
    eRpPpGetAttrError       = -1414,
    eRpPpSetAttrError       = -1415,
    eRpPpValidateError      = -1416,
    eRpUdpInitError         = -1500, 
    eRpUdpCannotOpenActive  = -1501, 
    eRpUdpReceiveError      = -1502,
    eRpUdpAlreadyClosed     = -1503,
    eRpUdpCloseError        = -1504,
    eRpUdpNoConnection      = -1505,
    eRpUdpSendError         = -1506,
    eRpUdpAlreadyOpen       = -1507,
    eRpUdpDeInitError       = -1508,
    eRpUdpCannotOpenMulti   = -1509,
    eRpTlsInitError         = -1600, 
    eRpTlsHandshakeError    = -1601,
    eRpTlsCloseError        = -1602,
    eRpTlsOutOfMemoryError  = -1603,
    eRpTlsReadError         = -1604,
    eRpSsisBusyError        = -1700, 
    eRpSsisRetrievalError   = -1701,
    eRpSsisStorageError     = -1702,
    eRpCertCreationBusy     = -1703,
    eRpCertCreateFailed     = -1704,
    eRpCliLinkError         = -1800 

} RpErrorCode;

#endif

/*********************************************************************
    eRpItemType_FormCheckbox,
    eRpItemType_FormCheckboxDyn,
    eRpItemType_FormFixedMultiSelect,
    eRpItemType_FormFixedMultiDyn

        GetType = Function
*/
typedef Boolean (*rpFetchBooleanFuncPtr)(void);

/*
        GetType = Complex
*/
typedef Boolean (*rpFetchBooleanComplexPtr)(void *theTaskDataPtr,
                            char *theNamePtr, Signed16Ptr theIndexValuesPtr);
/*
        SetType = Function
*/
typedef void    (*rpStoreBooleanFuncPtr)(Boolean theValue);

/*
        SetType = Complex
*/
typedef void    (*rpStoreBooleanComplexPtr)(void *theTaskDataPtr,
                            Boolean theValue, char *theNamePtr,
                            Signed16Ptr theIndexValuesPtr);
/*
        Dynamic reset function
*/

typedef void (*rpResetCheckboxArrayPtr) (void *theTaskDataPtr,
                    char *theNamePtr, Signed16Ptr theIndexValuesPtr);

/*********************************************************************
    eRpItemType_FormRadioButton,
    eRpItemType_FormRadioButtonDyn,
    eRpItemType_FormRadioGroupDyn,
    eRpItemType_FormFixedSingleSelect
    eRpItemType_FormFixedSingleDyn

        GetType = Function
*/

typedef rpOneOfSeveral  (*rpFetchRadioGroupFuncPtr)(void);
/*
        GetType = Complex
*/
typedef rpOneOfSeveral  (*rpFetchRadioGroupComplexPtr)(void *theTaskDataPtr,
                            char *theNamePtr, Signed16Ptr theIndexValuesPtr);
/*
        SetType = Function
*/
typedef void    (*rpStoreRadioGroupFuncPtr)(rpOneOfSeveral theValue);
/*
        SetType = Complex
*/
typedef void    (*rpStoreRadioGroupComplexPtr)(void *theTaskDataPtr,
                            rpOneOfSeveral theValue, char *theNamePtr,
                            Signed16Ptr theIndexValuesPtr);



#if RpHtmlBufferDisplay
/*********************************************************************
    eRpItemType_BufferDisplay
*/

typedef Boolean (*rpFetchBufferComplexPtr)(void *theTaskDataPtr,
                    char *theNamePtr, Signed16Ptr theIndexValuesPtr,
                    char **theBufferPtr, Unsigned16Ptr theLengthPtr);
#endif


/*********************************************************************
    eRpItemType_FormTextArea

        GetType = Function
*/

typedef char *  (*rpFetchTextFuncPtr)(Unsigned16 theItemNumber);
/*
        GetType = Complex
*/
typedef char *  (*rpFetchTextComplexPtr)(void *theTaskDataPtr,
                            char *theNamePtr, Signed16Ptr theIndexValuesPtr,
                            Unsigned16 theItemNumber);

/*********************************************************************
    eRpItemType_FormVariableSingleSelect,
    eRpItemType_FormVariableMultiSelect,
    eRpItemType_FormVariableSingleDyn,
    eRpItemType_FormVariableMultiDyn

        GetType = Function
*/
typedef void *  (*rpFetchOptionFuncPtr)(Unsigned8 theItemNumber,
                    Boolean *theOptionSelectedFlag);
/*
        GetType = Complex
*/
typedef void *  (*rpFetchOptionComplexPtr)(void *theTaskDataPtr,
                    char *theNamePtr, Signed16Ptr theIndexValuesPtr,
                    Unsigned8 theItemNumber,
                    Boolean *theOptionSelectedFlag);


/*********************************************************************
    eRpItemType_FormVarValueSingleSelect,
    eRpItemType_FormVarValueMultiSelect,
    eRpItemType_FormVarValueSingleDyn,
    eRpItemType_FormVarValueMultiDyn

        GetType = Function
*/
typedef void *  (*rpFetchOptionValueFuncPtr)(Unsigned8 theItemNumber,
                    Boolean *theOptionSelectedFlag,
                    Unsigned32Ptr theValuePtr);
/*
        GetType = Complex
*/
typedef void *  (*rpFetchOptionValueComplexPtr)(void *theTaskDataPtr,
                    char *theNamePtr, Signed16Ptr theIndexValuesPtr,
                    Unsigned8 theItemNumber,
                    Boolean *theOptionSelectedFlag,
                    Unsigned32Ptr theValuePtr);

/*********************************************************************
    eRpItemType_FormVariableMultiSelect,
    eRpItemType_FormVariableMultiDyn
    eRpItemType_FormVarValueMultiSelect,
    eRpItemType_FormVarValueMultiDyn

        Reset Function
*/
typedef void (*rpResetVarSelectPtr)(void *theTaskDataPtr);



/*********************************************************************
    Server-Side Image Map Processing
*/
typedef void    (*rpStoreLocationPtr)(rpMapLocation theValue);
typedef void    (*rpStoreLocationComplexPtr)(void *theTaskDataPtr,
                    rpMapLocation theValue, char *theNamePtr,
                    Signed16Ptr theIndexValuesPtr);


/*********************************************************************
    eRpItemType_DynamicDisplay

        GetType = Function
*/
typedef Unsigned8   (*rpFetchIndexFuncPtr)(void);
/*
        GetType = Complex
*/
typedef Unsigned8   (*rpFetchIndexComplexPtr)(void *theTaskDataPtr,
                            Signed16Ptr theIndexValuesPtr);


/*********************************************************************
    eRpItemType_RepeatGroupDynamic
*/
typedef void (*rpDynamicRepeatFuncPtr)
                    (void *theTaskDataPtr,
                    Signed16Ptr theStart,
                    Signed16Ptr theLimit,
                    Signed16Ptr theIncrement);


/*********************************************************************
    eRpItemType_RepeatGroupWhile
*/
typedef void    (*rpRepeatWhileFuncPtr)(void *theTaskDataPtr,
                            Signed16Ptr theIndexPtr,
                            void ** theRepeatGroupValuePtr);


/*********************************************************************
    Page object pre-processing,
    Form object post-processing
*/
/**
 * Rompager pre- and post process data function pointer type
 *
 * This function is used before and after HTTP server processes data for a request.
 *
 * @external
 * @category HTTP_Advanced_Server
 * @since 3.0
 * 
 * @param theTaskDataPtr    Pointer to information about the current Rompager task.
 * @param theIndexValuesPtr Pointer to index information.
 */
typedef void (* rpProcessDataFuncPtr)(void * theTaskDataPtr, Signed16Ptr theIndexValuesPtr);


/*********************************************************************
    Connection Close processing
*/
typedef void (*rpProcessCloseFuncPtr)(void *theTaskDataPtr);


/*********************************************************************
    External Password processing
*/
typedef void (*rpSessionCloseFuncPtr)
        (void *theTaskDataPtr, void *theUserCookie);




/*

    The PageBuilder parser looks for HTML Form elements and converts them
    into internal data structures.  Each form element (ie. radio button, check
    box, text element, etc.) has a different structure.  These structures are
    used both for page creation (using Get routines to access the variables)
    and form processing (using Set routines to access the variables).

    The form element structures all contain Set/Get elements as appropriate.
    These Set/Get elements are:

        void *          fGetPtr;
        void *          fSetPtr;
        rpVariableType  fGetPtrType;
        rpVariableType  fSetPtrType;


    The rpVariableType field is used to indicate whether the Set/Get pointers
    point directly to a variable address (eRpVarType_Direct), point to a
    simple function to store/retrieve the variable (eRpVarType_Function), or
    point to a complex function (eRpVarType_Complex).  Complex functions are
    passed the HTML name of the variable, and the current state of the repeat
    group indices, as well as a pointer to the variable to be stored/retrieved.

    The data typing of the Set/Get value can be implicit or explicit.  For
    checkbox form elements, for example, the data type of the value is
    implicitly Boolean, so if an address of the value is specified in fGetPtr
    or fSetPtr, the RomPager routines will assume they are setting or getting
    a Boolean.  If a function call is specified in fGetPtr, then the function
    is assumed to have the form:

        typedef Boolean (*rpFetchBooleanFuncPtr)(void);

    If a function call is specified in fSetPtr, the function is assumed to
    have the form:

        typedef void    (*rpStoreBooleanFuncPtr)(Boolean theValue);

    For HTML elements that use text for display or entry, the form element
    structure contains an additional element that specifies an explicit data
    type so that RomPager can perform conversions if necessary.

        rpTextType  fTextType;

    The types and their explanations are defined above.
*/


/*
    The text display item structure.
*/
typedef struct {
    void *          fGetPtr;        /*  Pointer to either the memory location
                                        that the Get value is stored in, or a
                                        function to retrieve the Get value. */
    rpVariableType  fGetPtrType;
    rpTextType      fTextType;      /*  Used to indicate what type of
                                        conversion is necessary to turn the
                                        Get variable into display text  */
    Unsigned8       fFieldSize;     /*  Length of text on the page for the
                                        variable.  Used by hex and dot-form
                                        variables.  */
} rpTextDisplayItem, *rpTextDisplayItemPtr;


/*
    The named text display item structure.
*/
typedef struct {
    char *          fNamePtr;       /*  The name of the display text item   */
    void *          fGetPtr;        /*  Pointer to either the memory location
                                        that the Get value is stored in, or a
                                        function to retrieve the Get value. */
    rpVariableType  fGetPtrType;
    rpTextType      fTextType;      /*  Used to indicate what type of
                                        conversion is necessary to turn the
                                        Get variable into display text  */
    Unsigned8       fFieldSize;     /*  Length of text on the page for the
                                        variable.  Used by hex and dot-form
                                        variables.  */
} rpNamedTextDisplayItem, *rpNamedTextDisplayItemPtr;


#if RpHtmlBufferDisplay
/*
    The named buffer display item structure.
*/
typedef struct {
    char *          fNamePtr;       /*  The name of the buffer display item */
    void *          fGetPtr;        /*  Pointer to the complex function for
                                        retrieving the display buffers.     */
} rpBufferDisplayItem, *rpBufferDisplayItemPtr;
#endif


/*
    Checkbox form item structure.

    When this structure is used for checkbox items, the get and set pointers
    point to the memory locations or routines used get and set the Boolean
    value associated with the named checkbox.  Forms submitted with a checkbox
    item are in the format of "nnnn=checked" where nnnn is the contents of
    fNamePtr and checked is a constant set by the browser.  Only checked
    checkbox items will be returned by the browser.

    This structure is also used define the HTML for <INPUT TYPE=SUBMIT>
    buttons that have both an HTML name and a value, and for <INPUT
    TYPE=BUTTON> buttons. The value which will be displayed in the button is
    retrieved using the fGetPtr. When these buttons are returned from the
    form they have an argument format of "nnnn=xxxxx" where nnnn is the
    contents of fNamePtr, and xxxxx is the value.  The fSetPtr points to
    the routine or memory location that will process the incoming value.
*/
typedef struct {
    char *          fNamePtr;           /*  The HTML name of the checkbox
                                            item                      */
    void *          fGetPtr;            /*  Pointer to either the memory
                                            location that the Get value is
                                            stored in, or a function to
                                            retrieve the Get value.   */
    void *          fSetPtr;            /*  Pointer to either the memory
                                            location that the Set value is
                                            stored in, or a function to
                                            store the Set value.      */
    rpVariableType  fGetPtrType;
    rpVariableType  fSetPtrType;
#if RomPagerJavaScript
    char *          fJavaScriptPtr;     /*  The pointer to the Java Script */
#endif
} rpCheckboxFormItem, *rpCheckboxFormItemPtr;


/*
    Dynamic Checkbox form item structure.
*/
typedef struct {
    char *          fNamePtr;           /*  The HTML name of the checkbox
                                            item                        */
    void *          fGetPtr;            /*  Pointer to either the memory
                                            location that the Get value is
                                            stored in, or a function to
                                            retrieve the Get value.     */
    void *          fSetPtr;            /*  Pointer to either the memory
                                            location that the Set value is
                                            stored in, or a function to
                                            store the Set value.        */
    rpVariableType  fGetPtrType;
    rpVariableType  fSetPtrType;
    void *          fResetPtr;          /*  Pointer to routine to reset
                                            the checkbox array          */
#if RomPagerJavaScript
    char *          fJavaScriptPtr;     /*  The pointer to the Java Script */
#endif
} rpDynCheckboxFormItem, *rpDynCheckboxFormItemPtr;

/*
    Radio buttons require a group structure with the hooks to the Get/Set
    routines and individual structures for each button that refer back to the
    group structure.  The HTML value that is displayed and selected
    corresponds to an actual value that is Get/Set in the parameter values.
*/

typedef struct {
    char *          fNamePtr;           /*  The HTML name of the radio box
                                            item                        */
    void *          fGetPtr;            /*  Pointer to either the memory
                                            location that the Get value is
                                            stored in, or a function to
                                            retrieve the Get value.     */
    void *          fSetPtr;            /*  Pointer to either the memory
                                            location that the Set value is
                                            stored in, or a function to
                                            store the Set value.        */
    rpVariableType  fGetPtrType;
    rpVariableType  fSetPtrType;
} rpRadioGroupInfo, *rpRadioGroupInfoPtr;

typedef struct {
    rpRadioGroupInfoPtr fRadioGroupPtr; /*  Pointer to radio button group
                                            structure                   */
    char *              fValue;         /*  The HTML Value string of the
                                            radio button                */
    rpOneOfSeveral      fButtonNumber;  /*  The actual value of the radio
                                            button                      */
#if RomPagerJavaScript
    char *          fJavaScriptPtr;     /*  The pointer to the Java Script */
#endif
} rpRadioButtonFormItem, *rpRadioButtonFormItemPtr;


/*
    The text form item is used to display and process text fields.  The same
    structure is used for plain text and for HTML password text fields.
*/
typedef struct {
    char *          fNamePtr;           /*  The HTML name of the text form
                                            item                        */
    void *          fGetPtr;            /*  Pointer to either the memory
                                            location that the Get value is
                                            stored in, or a function to
                                            retrieve the Get value.      */
    void *          fSetPtr;            /*  Pointer to either the memory
                                            location that the Set value is
                                            stored in, or a function to
                                            store the Set value.         */
    rpVariableType  fGetPtrType;
    rpVariableType  fSetPtrType;
    rpTextType      fTextType;          /*  Used to indicate what type of
                                            conversion is necessary to turn
                                            variable to and from text    */
    Unsigned8       fFieldSize;         /*  Length of text on the page for
                                            the variable.  Used by the
                                            conversion routines for
                                            ASCII-Fixed, hex, and dot-form
                                            variables. */
    Unsigned8       fFieldMaxLength;    /*  Equivalent to HTML maxsize.  Used
                                            to control browser field entry. */
#if RomPagerJavaScript
    char *          fJavaScriptPtr;     /*  The pointer to the Java Script */
#endif
} rpTextFormItem, *rpTextFormItemPtr;


/*
    The button structure is used define the HTML for Submit and Reset buttons.
    Reset buttons do not return any information to a form, but only trigger
    local browser actions.  Submit buttons are returned to the form with an
    argument format of "Submit=xxxxx"  where xxxxx is the contents of
    fLabelText.  This value is stored in the global gRpSubmitButtonValue
    during forms processing.  The global can be examined by optional forms
    post-processing routines to determine appropriate actions if multiple
    Submit buttons are present in a single form.  The post processing routine
    is triggered by the presence of a rpProcessDataFuncPtr in the form's
    rpObjectExtension structure.
*/
typedef struct {
    char *          fLabelText;         /*  The HTML value of the button item   */
#if RomPagerJavaScript
    char *          fJavaScriptPtr;     /*  The pointer to the Java Script      */
#endif
} rpButtonFormItem, *rpButtonFormItemPtr;


/*
    The rpFixedSingleSelectFormItem item is used to display and process
    <SELECT> menu text lists where a single element can be chosen from a
    fixed list of elements. The list behaves like a set of radio buttons,
    where each element in the list corresponds to a value to be set. When
    an element is chosen from the list, its fOptionNumber is the value Set.
*/
typedef struct rpOption_OneSelect {
    struct rpOption_OneSelect * fNextPtr;       /*  Pointer to the next item
                                                    in a fixed list              */
    char *                      fValuePtr;      /*  HTML value to display  */
    rpOneOfSeveral              fOptionNumber;  /*  Item value to Set if
                                                    selected               */
} rpOption_OneSelect, *rpOption_OneSelectPtr;

typedef struct {
    char *                  fNamePtr;           /*  The HTML name of the list
                                                    item                   */
    rpOption_OneSelectPtr   fFirstOptionPtr;    /*  Pointer to the first
                                                    element in the list    */
    void *                  fGetPtr;            /*  Pointer to either the
                                                    memory location that the
                                                    Get value is stored in, or
                                                    a function to retrieve the
                                                    Get value.             */
    void *                  fSetPtr;            /*  Pointer to either the
                                                    memory location that the
                                                    Set value is stored in, or
                                                    a function to store the
                                                    Set value.             */
    rpVariableType          fGetPtrType;
    rpVariableType          fSetPtrType;
    Unsigned8               fListLength;        /*  HTML length of the list
                                                    (controls display)     */
#if RomPagerJavaScript
    char *          fJavaScriptPtr;             /*  The pointer to the Java
                                                    Script  */
#endif
} rpFixedSingleSelectFormItem, *rpFixedSingleSelectFormItemPtr;


/*
    The rpVariableSelectFormItem item is used to display and process <SELECT>
    menu lists where an element can be chosen from a variable length list of
    elements. The elements can be of any text type. When a value is chosen
    from the list, it is converted to the specified type and stored as
    determined by the Set pointer.
*/

typedef struct {
    char *                  fNamePtr;           /*  The HTML name of the list
                                                    item                */
    rpResetVarSelectPtr     fResetOptionsPtr;   /*  Pointer to function to
                                                    reset all elements for
                                                    Variable Multiple Select */
    void *                  fGetPtr;            /*  Pointer to a function to
                                                    retrieve the Get value for
                                                    an element.         */
    void *                  fSetPtr;            /*  Pointer to either the
                                                    memory location that an
                                                    element's Set value is
                                                    stored in, or a function
                                                    to store the Set value. */
    rpVariableType          fGetPtrType;
    rpVariableType          fSetPtrType;
    rpTextType              fTextType;          /*  Used to indicate what type
                                                    of conversion is necessary
                                                    to turn an element to and
                                                    from text                 */
    Unsigned8               fFieldSize;         /*  Length of text on the page
                                                    for hex and dot-form
                                                    elements.                 */
    Unsigned8               fListLength;        /*  HTML length of the list
                                                    (controls display)        */
#if RomPagerJavaScript
    char *          fJavaScriptPtr;             /*  The pointer to the Java
                                                    Script  */
#endif
} rpVariableSelectFormItem, *rpVariableSelectFormItemPtr;


/*
    The rpFixedMultiSelectFormItem item is used to display and process
    <SELECT> menu text lists where multiple elements can be chosen from a
    fixed list of elements. This list behaves like a set of checkboxes, that
    is, each element in the list has its own Set/Get structure.
*/
typedef struct rpOption_MultiSelect {
    struct rpOption_MultiSelect *   fNextPtr;   /*  Pointer to the next item
                                                    in a fixed list              */
    char *                          fValuePtr;  /*  HTML value to display */
    void *                          fGetPtr;    /*  Pointer to either the
                                                    memory location that the
                                                    Get value is stored in,
                                                    or a function to retrieve
                                                    the Get value.        */
    void *                          fSetPtr;    /*  Pointer to either the
                                                    memory location that the
                                                    Set value is stored in,
                                                    or a function to store
                                                    the Set value.        */
    rpVariableType                  fGetPtrType;
    rpVariableType                  fSetPtrType;
} rpOption_MultiSelect, *rpOption_MultiSelectPtr;

typedef struct {
    char *                  fNamePtr;           /*  The HTML name of the list
                                                    item                    */
    rpOption_MultiSelectPtr fFirstOptionPtr;    /*  Pointer to the first item
                                                    in the list             */
    Unsigned8               fListLength;        /*  HTML length of the list
                                                    (controls display)      */
#if RomPagerJavaScript
    char *                  fJavaScriptPtr;     /*  The pointer to the
                                                    Java Script */
#endif
} rpFixedMultiSelectFormItem, *rpFixedMultiSelectFormItemPtr;


/*
    The rpFixedMultiDynSelectFormItem item is like a
    rpFixedMultiSelectFormItem, but it is used when the list is within
    a repeat group.
*/
typedef struct {
    char *                  fNamePtr;           /*  The HTML name of the list
                                                    item                    */
    rpOption_MultiSelectPtr fFirstOptionPtr;    /*  Pointer to the first item
                                                    in the list             */
    Unsigned8               fListLength;        /*  HTML length of the list
                                                    (controls display)      */
    void *                  fResetPtr;          /*  Pointer to routine to reset
                                                    the all option values   */
#if RomPagerJavaScript
    char *                  fJavaScriptPtr;     /*  The pointer to the
                                                    Java Script */
#endif
} rpFixedMultiDynSelectFormItem, *rpFixedMultiDynSelectFormItemPtr;


/*
    The text area form item is used to display and process text area fields.
    Although the Get and Set pointers are here, use of these items only makes
    sense for variable information displayed or gathered with a function call.
*/
typedef struct {
    char *              fNamePtr;           /*  The HTML name of the text area  */
    void *              fGetPtr;            /*  Pointer to either the memory
                                                location that the Get value is
                                                stored in, or a function to
                                                retrieve the Get value.         */
    void *              fSetPtr;            /*  Pointer to either the memory
                                                location that the Set value is
                                                stored in, or a function to
                                                store the Set value.    */
    rpVariableType      fGetPtrType;
    rpVariableType      fSetPtrType;
    Unsigned8           fRows;              /*  The HTML number of rows for
                                                the text area                   */
    Unsigned8           fColumns;           /*  The HTML number of columns for
                                                the text area                   */
#if RomPagerJavaScript
    char *          fJavaScriptPtr;         /*  The pointer to the Java Script  */
#endif
} rpTextAreaFormItem, *rpTextAreaFormItemPtr;


/*
    The file form item is used to display and process the file upload tag.
*/
typedef struct {
    char *          fNamePtr;           /*  The HTML name of the file form
                                            item                                */
    Unsigned8       fFieldSize;         /*  Length of filename to display */
    Unsigned8       fFieldMaxLength;    /*  Equivalent to HTML maxsize.  Used
                                            to control browser field entry.     */
#if RomPagerJavaScript
    char *          fJavaScriptPtr;     /*  The pointer to the Java Script      */
#endif
} rpFileFormItem, *rpFileFormItemPtr;

/*
    Image mapping works in a similar fashion to radio buttons and require a
    group structure with the hooks to the Set variable and individual
    structures for each location in the map that can trigger an action. The
    location to be selected is determined by coordinates, and selects an
    arbitrary value stored in the structure, as well as the next page to be
    served.

    The fTop, fBottom, fLeft, fRight values in rpImageMapLocation describe the
    attributes of the location depending on its type as follows:
        Circle    - fTop and fLeft is the center with fRight being the radius;
        Rectangle - fTop, fBottom, fLeft, fRight are the bounds; and
        Polygon   - fRight is the count of points that fPolyPointPtr points to
*/

typedef enum {
    eRpLocationType_Rectangle,
    eRpLocationType_Circle,
    eRpLocationType_Polygon
} rpLocationType;

typedef struct {
    Signed16                fX;
    Signed16                fY;
} rpPoint, *rpPointPtr;

typedef struct rpImageMapLocation {
    struct rpImageMapLocation * fNextPtr;       /*  Pointer to the next
                                                    location item         */
    struct rpObjectDescription * fPagePtr;       /*  Page to serve if this
                                                    location is selected. */
    rpLocationType              fType;          /*  Rectangle, Circle or
                                                    Polygon               */
    rpPointPtr                  fPolyPointPtr;  /*  Pointer to a polygon's
                                                    array of points       */
    Unsigned8                   fTop;
    Unsigned8                   fBottom;
    Unsigned8                   fLeft;
    Unsigned8                   fRight;
    rpMapLocation               fLocation;      /*  The value to be Set if
                                                    this location is selected        */
} rpImageMapLocation, *rpImageMapLocationPtr;

typedef struct {
    struct rpObjectDescription  *fDefaultPagePtr;   /*  Page to serve if image
                                                        map is clicked on, but
                                                        no specific location
                                                        item matches.  Value
                                                        will be set to 0 if no
                                                        location item matches   */
    rpImageMapLocationPtr       fFirstLocationPtr;  /*  Pointer to the first
                                                        location item           */
    void *                      fSetPtr;            /*  Pointer to either the
                                                        memory location that
                                                        the Set value is stored
                                                        in, or a function to
                                                        store the Set value.    */
    rpVariableType              fSetPtrType;
} rpImageMapFormItem, *rpImageMapFormItemPtr;


/*
    The page/form item structure.
*/
/**
 * RomPager item structure
 * 
 * Each RomPager object contains a list of these item structures 
 * to describe a html page.
 *
 * @external
 * @category HTTP_Advanced_Server
 * @since 3.0
 * 
 * @param  fType		Type of the item
 * @param  fAddress		Pointer to the item data
 */
typedef struct {
    rpItemType              fType;
    void *                  fAddress;
} rpItem;

typedef rpItem * rpItemPtr;

/*
    The dynamic display item structure.
*/
typedef struct {
    void *                  fGetPtr;
    rpVariableType          fGetPtrType;
    Unsigned8               fItemCount;
    rpItem                  *fItemsArrayPtr;        /*  Pointer to array of
                                                        object items          */
} rpDynamicDisplayItem, *rpDynamicDisplayItemPtr;


/*
    The repeat group item structure.
*/
typedef struct {
    Signed16                fIndexStart;
    Signed16                fIndexLimit;
    Signed16                fIndexIncrement;
    rpItem                  *fItemsArrayPtr;        /*  Pointer to array of
                                                        object items          */
} rpRepeatGroupItem, *rpRepeatGroupItemPtr;


/*
    The dynamic repeat group item structure.
    (also used for repeat group while)
*/

typedef struct {
    void *                  fFunctionPtr;
    rpItem                  *fItemsArrayPtr;        /*  Pointer to array of
                                                        object items          */
} rpRepeatGroupDynItem, *rpRepeatGroupDynItemPtr;


/*
    The named indirect structure
*/
typedef struct {
    char *                  fNamePtr;               /*  The name of the item  */
    rpItem                  fItem;                  /*  The Referred Item     */
} rpNamedIndirectItem, *rpNamedIndirectItemPtr;

#if RomPagerSecure

/*
    The Full URL item structure.
*/

typedef enum {
    eRpUrlScheme_Http,
    eRpUrlScheme_Https
} rpUrlScheme;

typedef struct {
    rpUrlScheme                 fUrlScheme; /*  Access scheme       */
    Unsigned16                  fPort;      /*  Host Port           */
    struct rpObjectDescription *fPagePtr;   /*  Object to link to   */
    char *                      fLinkPtr;   /*  Hypertext link      */
} rpFullUrlItem, *rpFullUrlItemPtr;

#endif

#if RpHtmlFormImage
/*
    The Form Image item structure.
*/

typedef struct {
    char *          fNamePtr;           /*  The item's HTML name            */
    void *          fSetPtr;            /*  Pointer to either the memory
                                                location that the Set value
                                                is stored in, or a function
                                                to store the Set value.     */
    rpVariableType  fSetPtrType;
    char *          fImagePtr;          /*  The image's URL and modifiers   */
} rpImageFormItem, *rpImageFormItemPtr;
#endif


#if defined (AUTODOC_VERSION)
/**
 * Rompager object extension structure
 *
 * This is additional information on an object that HTTP server need to perform
 * before or after servicing the object.
 *
 * @external
 * @category HTTP_Advanced_Server
 * @since 3.0
 *
 * @param fProcessDataFuncPtr       Pointer to optional routine called  after form items
 *                                  are processed or before page is served.
 * @param fPagePtr                  Pointer to results page that will be served
 *                                  after the form is processed.
 * @param fRefreshPagePtr           Pointer to page to serve for client-pull refresh.
 * @param fRefreshSeconds           Optional time to trigger client-pull page refreshing.
 * @param fFlags                    Object flags that tells how HTTP server handle this object.
 * @param fJavaScriptPtr            The pointer to the Java Script.
 */
typedef struct rpObjectExtension {
    rpProcessDataFuncPtr        fProcessDataFuncPtr;    
    struct rpObjectDescription  * fPagePtr;              
    struct rpObjectDescription  * fRefreshPagePtr;       
    Unsigned16                  fRefreshSeconds;        
    rpObjectFlags               fFlags;                 
    char const                  * fJavaScriptPtr;         
} rpObjectExtension;
#endif

typedef struct rpObjectExtension {
    rpProcessDataFuncPtr        fProcessDataFuncPtr;    /*  Pointer to optional
                                                            routine called
                                                            after form items
                                                            are processed or
                                                            before page is
                                                            served              */
    struct rpObjectDescription  *fPagePtr;              /*  Pointer to results
                                                            page that will be served
                                                            after the form is
                                                            processed           */
    struct rpObjectDescription  *fRefreshPagePtr;       /*  Pointer to page to
                                                            serve for
                                                            client-pull
                                                            refresh             */
    Unsigned16                  fRefreshSeconds;        /*  optional time to
                                                            trigger client-pull
                                                            page refreshing     */
    rpObjectFlags               fFlags;                 /*  Flags defined above.    */
#if RomPagerJavaScript
    char const *                fJavaScriptPtr;         /*  The pointer to the
                                                            Java Script         */
#endif
} rpObjectExtension;

/**
 * Pointer to Rompager object extension structure
 *
 * @external
 * @category HTTP_Advanced_Server
 * @since 3.0
 *
 */
typedef rpObjectExtension  * rpObjectExtensionPtr;


/**
 * Rompager object description structure
 *
 * @external
 * @category HTTP_Advanced_Server
 * @since 3.0
 *
 * @param fURL                  Path used to find object.
 * @param fItemsArrayPtr        Pointer to array of object items.
 * @param fExtensionPtr         Pointer to structure of optional info.
 * @param fLength				Length of the object
 * @param fObjectAccess			Object access values
 * @param fMimeDataType         Indicates page type used for MIME type checking.  
 * @param fCacheObjectType      Static, Dynamic and File types will trigger 
 *                              different HTTP headers to control  browser caching.
 */
typedef struct rpObjectDescription {
    char                    * fURL;                   
    rpItem                  * fItemsArrayPtr;        
    rpObjectExtensionPtr    fExtensionPtr;          
    Unsigned32              fLength;                
    rpAccess                fObjectAccess;          
    rpDataType              fMimeDataType;          
    rpObjectType            fCacheObjectType;       
} rpObjectDescription;


/**
 * Pointer to Rompager object description structure
 *
 * @external
 * @category HTTP_Advanced_Server
 * @since 3.0
 *
 *
 */
typedef rpObjectDescription * rpObjectDescriptionPtr;

typedef rpObjectDescription ** rpObjectDescPtrPtr;





/*
    miscellaneous definitions used in page/form definitions
*/

#define kRootPage           0

extern rpObjectDescriptionPtr		gRpObjectList[];
extern rpObjectDescPtrPtr			gRpMasterObjectList[];



extern char *       RpGetRealmName(void *theServerDataPtr,
                        unsigned char theIndex);
extern char *       RpGetUserName(void *theServerDataPtr,
                        unsigned char theIndex);
extern char *       RpGetPassword(void *theServerDataPtr,
                        unsigned char theIndex);
extern void         RpSetRealmName(void *theServerDataPtr,
                        unsigned char theIndex,
                        char *theRealmNamePtr);
extern void         RpSetUserName(void *theServerDataPtr,
                        unsigned char theIndex,
                        char *theUsernamePtr);
extern void         RpSetPassword(void *theServerDataPtr,
                        unsigned char theIndex,
                        char *thePasswordPtr);
extern void         RpSetSecurityLevel(void *theServerDataPtr,
                        unsigned char theIndex,
                        rpSecurityLevel theSecurityLevel);
extern void         RpSetSessionCloseFunction(void *theServerDataPtr,
                        unsigned char theIndex,
                        rpSessionCloseFuncPtr theFunctionPtr,
                        void *theUserCookie);
extern void         RpSetServerPasswordTimeout(void *theServerDataPtr,
                        Unsigned16 theTimeoutSeconds);
extern void         RpSetRealmPasswordTimeout(void *theServerDataPtr,
                        unsigned char theIndex,
                        Unsigned16 theTimeoutSeconds);
extern void         RpSetIppAccess(void *theServerDataPtr,
                        rpAccess theAccessCode);
extern void         RpSetPutAccess(void *theServerDataPtr,
                        rpAccess theAccessCode);
extern Boolean      RpCheckSession(void *theServerDataPtr,
                        rpAccess theAccessCode);
extern void         RpResetCurrentSession(void *theServerDataPtr,
                        Signed16Ptr theIndexValuesPtr);
extern void         RpResetSession(void *theServerDataPtr,
                        unsigned char theIndex);
extern char *       RpGetSubmitButtonValue(void *theServerDataPtr);
extern void         RpSetNextPage(void *theServerDataPtr,
                        rpObjectDescriptionPtr theNextPagePtr);
extern void         RpSetRedirect(void *theServerDataPtr);
extern char *       RpGetCurrentUrl(void *theServerDataPtr);

#if RomPagerFileSystem || RomPagerUserExit
extern void         RpSetNextFilePage(void *theServerDataPtr,
                        char *theNextPagePtr);
#endif

#if RomPagerClientPull
extern void         RpSetRefreshTime(void *theServerDataPtr,
                        Unsigned16 theRefreshSeconds);
extern void         RpSetRefreshPage(void *theServerDataPtr,
                        rpObjectDescriptionPtr theRefreshPagePtr);
#endif

#if RomPagerServerPush
extern void         RpSetServerPushTime(void *theServerDataPtr,
                        Unsigned16 theServerPushSeconds);
extern void         RpSetServerPushPage(void *theServerDataPtr,
                        rpObjectDescriptionPtr theServerPushPagePtr);
#endif

extern void         RpSetRequestCloseFunction(void *theServerDataPtr,
                        rpProcessCloseFuncPtr theFunctionPtr);

#if RomPagerKeepAlive || RomPagerHttpOneDotOne
extern void         RpSetConnectionClose(void *theServerDataPtr);
#endif
extern Signed16     RpPopQueryIndex(void *theServerDataPtr);
extern void         RpPushQueryIndex(void *theServerDataPtr,
                        Signed16 theQueryValue);
extern Signed8      RpGetQueryIndexLevel(void *theServerDataPtr);

extern unsigned char    RpInitiateDelayedFunction(void *theServerDataPtr);
extern void             RpCompleteDelayedFunction(void *theServerDataPtr,
                            unsigned char theConnection);
extern unsigned char    RpGetCurrentConnection(void *theServerDataPtr);
extern unsigned char    RpSetCurrentConnection(void *theServerDataPtr,
                            unsigned char theConnection);

#if RomPagerDynamicGlobals
extern void     RpInitUserData(void *theServerDataPtr);
#endif
#if RpUserCookies
extern void     RpSetCookie(void *theServerDataPtr, void *theCookie);
extern void *   RpGetCookie(void *theServerDataPtr);
extern void     RpSetRequestCookie(void *theServerDataPtr, void *theCookie);
extern void *   RpGetRequestCookie(void *theServerDataPtr);
#endif
extern void     RpSetUserPhraseDictionary(void *theServerDataPtr,
                    char **theUserDictionaryPtr,
                    Boolean theCompressionFlag);
extern void     RpSetRequestUserPhraseDictionary(void *theServerDataPtr,
                    char **theUserDictionaryPtr,
                    Boolean theCompressionFlag);
extern void *   RpGetRepeatWhileValue(void *theServerDataPtr);
extern Unsigned16   RpConvertSigned32ToAscii(Signed32 theNumber,
                        char *theBufferPtr);
extern Unsigned16   RpConvertUnsigned32ToAscii(Unsigned32 theNumber,
                        char *theBufferPtr);
extern void         RpConvertHexString(void *theServerDataPtr, char *theHexPtr,
                        char *theValuePtr, Unsigned8 theOutputCharCount,
                        char theSeparator);
extern void         RpConvertDotFormString(void *theServerDataPtr,
                        char *theDotFormPtr, char *theValuePtr,
                        Unsigned8 theOutputCharCount);
extern Signed8      RpConvertStringToSigned8(void *theServerDataPtr,
                        char *theValuePtr);
extern Signed16     RpConvertStringToSigned16(void *theServerDataPtr,
                        char *theValuePtr);
extern Signed32     RpConvertStringToSigned32(void *theServerDataPtr,
                        char *theValuePtr);
extern Unsigned8    RpConvertStringToUnsigned8(void *theServerDataPtr,
                        char *theValuePtr);
extern Unsigned16   RpConvertStringToUnsigned16(void *theServerDataPtr,
                        char *theValuePtr);
extern Unsigned32   RpConvertStringToUnsigned32(void *theServerDataPtr,
                        char *theValuePtr);
extern rpItemError  RpGetConversionErrorCode(void *theServerDataPtr);
extern void         RpSetUserErrorMessage(void *theServerDataPtr,
                        char *theMessagePtr);
extern Unsigned32   RpGetMonthDayYearInSeconds(Unsigned32 theMonth,
                                                Unsigned32 theDay,
                                                Unsigned32 theYear);
extern Unsigned32   RpGetSysTimeInSeconds(void);

#if RomPagerCaptureUserAgent
extern char *       RpGetUserAgent(void *theServerDataPtr);
#endif
#if RomPagerCaptureLanguage
extern char *       RpGetAcceptLanguage(void *theServerDataPtr);
#endif
extern char *       RpGetHostName(void *theServerDataPtr);
extern char *   RpGetFormBufferPtr(void *theServerDataPtr);
extern void     RpGetFormItem(char ** theBufferPtr,
                            char * theNamePtr,
                            char * theValuePtr);
extern void     RpSetFormObject(void *theServerDataPtr,
                            rpObjectDescriptionPtr theObjectPtr);
extern void     RpReceiveItem(void *theServerDataPtr,
                            char *theNamePtr,
                            char *theValuePtr);
#if RomPagerUrlState
extern char *       RpGetUrlState(void *theServerDataPtr);
extern void         RpSetUrlState(void *theServerDataPtr, char * theNewState);
#endif

#if RomPagerHttpCookies
extern char *       RpGetHttpCookie(void *theServerDataPtr,
                                        Unsigned8 theIndex);
extern void         RpSetHttpCookie(void *theServerDataPtr,
                                        Unsigned8 theIndex,
                                        char * theCookie);
#endif
#if RomPagerRemoteHost
#if RpRemoteHostMulti
extern void         RpSetRemoteHostIpAddress(void * theServerDataPtr,
                                                Unsigned32 theIpAddress,
                                                Unsigned8 theHostIndex);
#else
extern void         RpSetRemoteHostIpAddress(void * theServerDataPtr,
                                                Unsigned32 theIpAddress);
#endif
#endif
#if RomPagerSlaveIdentity
extern void         RpSetSlaveIdentity(void *theServerDataPtr,
                                                char * theSlaveId);
#endif
#if RomPagerLogging
extern Signed16     RpGetHttpLogItemCount(void * theServerDataPtr);
extern void         RpBuildHttpEventStrings(void * theServerDataPtr,
                                            Signed16 theIndex,
                                            char * theEventTimeString,
                                            char * theEventTypeString,
                                            char * theEventObjectString);
#endif
#if RpPhraseDictPatching
extern void         RpSetDictionaryPatches(void * theServerDataPtr,
                                            char * thePatchFileNamePtr);
extern void         RpClearDictionaryPatches(void * theServerDataPtr);
#endif
#if RomPagerIpp
extern void         RpSetIppPrinterName(void *theServerDataPtr,
                                                char *thePrinterName);
#endif
#if RomPagerFileUpload

extern Boolean      RpGetFileUploadStatus(void * theServerDataPtr);
#endif
extern void     RpSetRomObjectList(void *theServerDataPtr,
                    rpObjectDescPtrPtr *theMasterObjectListPtr);

#define C_oP_NBSP_xP            "\200"  /* "<P>&nbsp;</P>\n" */
#define C_xTD_oP_xTR_xTABLE     "\201"  /* "</TD><P></TR></TABLE>\n" */
#define C_xTD_oP_xTR            "\202"  /* "</TD><P></TR>\n" */
#define C_oTR_ALIGN_LEFT        "\203"  /* "<TR ALIGN=left" */
#define C_oTR_ALIGN_CENTER      "\204"  /* "<TR ALIGN=center" */
#define C_oTR_ALIGN_RIGHT       "\205"  /* "<TR ALIGN=right" */
#define C_oTH_ALIGN_LEFT        "\206"  /* "<TH ALIGN=left" */
#define C_oTH_ALIGN_CENTER      "\207"  /* "<TH ALIGN=center" */
#define C_oTH_ALIGN_RIGHT       "\210"  /* "<TH ALIGN=right" */
#define C_oTD_ALIGN_LEFT        "\211"  /* "<TD ALIGN=left" */
#define C_oTD_ALIGN_CENTER      "\212"  /* "<TD ALIGN=center" */
#define C_oTD_ALIGN_RIGHT       "\213"  /* "<TD ALIGN=right" */
#define C_oTD_oBR_xTD           "\214"  /* "<TD><BR></TD>" */
#define C_oTABLE_CELLPADDING    "\215"  /* "<TABLE CELLPADDING=" */
#define C_oTABLE_CELLSPACING    "\216"  /* "<TABLE CELLSPACING=" */
#define C_oTABLE_BORDER         "\217"  /* "<TABLE BORDER=" */
#define C_oTD_oANCHOR_HREF      "\220"  /* "<TD><A HREF=\"" */
#define C_xANCHOR_xTD           "\221"  /* "</A></TD>\n" */
#define C_oHTML_oHEAD_oTITLE    "\222"  /* "<HTML>\n<HEAD>\n<TITLE>" */
#define C_xTITLE_xHEAD_oBODY    "\223"  /* "</TITLE>\n</HEAD>\n<BODY>\n" */
#define C_xBODY_xHTML           "\224"  /* "\n</BODY>\n</HTML>\n" */
#define C_xFORM                 "\225"  /* "\n</FORM>" */
#define C_oCENTER               "\226"  /* "<CENTER>" */
#define C_xCENTER               "\227"  /* "</CENTER>\n" */
#define C_oBLOCKQUOTE           "\230"  /* "<BLOCKQUOTE>\n" */
#define C_xBLOCKQUOTE           "\231"  /* "\n</BLOCKQUOTE>\n" */
#define C_oANCHOR_HREF          "\232"  /* "<A HREF=\"" */
#define C_xANCHOR               "\233"  /* "</A>" */
#define C_oIMG_SRC              "\234"  /* "<IMG SRC=\"" */
#define C_oH1                   "\235"  /* "<H1>" */
#define C_xH1                   "\236"  /* "</H1>\n" */
#define C_oH2                   "\237"  /* "<H2>" */
#define C_xH2                   "\240"  /* "</H2>\n" */
#define C_oH3                   "\241"  /* "<H3>" */
#define C_xH3                   "\242"  /* "</H3>\n" */
#define C_oH4                   "\243"  /* "<H4>" */
#define C_xH4                   "\244"  /* "</H4>\n" */
#define C_oP                    "\245"  /* "<P>\n" */
#define C_xP                    "\246"  /* "</P>" */
#define C_oHR                   "\247"  /* "<HR>\n" */
#define C_NBSP                  "\250"  /* "&nbsp;" */
#define C_oBR                   "\251"  /* "<BR>\n" */
#define C_oTABLE                "\252"  /* "<TABLE>" */
#define C_xTABLE                "\253"  /* "</TABLE>\n" */
#define C_oTR                   "\254"  /* "<TR>" */
#define C_xTR                   "\255"  /* "</TR>\n" */
#define C_oTH                   "\256"  /* "<TH>" */
#define C_xTH                   "\257"  /* "</TH>\n" */
#define C_oTD                   "\260"  /* "<TD>" */
#define C_xTD                   "\261"  /* "</TD>\n" */
#define C_oCODE                 "\262"  /* "<CODE>\n" */
#define C_xCODE                 "\263"  /* "\n</CODE>\n" */
#define C_oFONT_SIZE            "\264"  /* "<FONT SIZE=" */
#define C_oB                    "\265"  /* "<B>" */
#define C_xB                    "\266"  /* "</B>" */
#define C_oI                    "\267"  /* "<I>" */
#define C_xI                    "\270"  /* "</I>" */
#define C_oHTML                 "\271"  /* "<HTML>" */
#define C_xHTML                 "\272"  /* "</HTML>\n" */
#define C_oHEAD                 "\273"  /* "<HEAD>" */
#define C_xHEAD                 "\274"  /* "</HEAD>\n" */
#define C_oMETA                 "\275"  /* "<META" */
#define C_oBODY                 "\276"  /* "<BODY" */
#define C_xBODY                 "\277"  /* "</BODY>\n" */
#define C_oTITLE                "\300"  /* "<TITLE>" */
#define C_xTITLE                "\301"  /* "</TITLE>\n" */
#define C_WIDTH                 "\302"  /* " WIDTH=" */
#define C_HEIGHT                "\303"  /* " HEIGHT=" */
#define C_ALIGN_TOP             "\304"  /* " ALIGN=top" */
#define C_ALIGN_MIDDLE          "\305"  /* " ALIGN=middle" */
#define C_ALIGN_BOTTOM          "\306"  /* " ALIGN=bottom" */
#define C_ALIGN_LEFT            "\307"  /* " ALIGN=left" */
#define C_ALIGN_CENTER          "\310"  /* " ALIGN=center" */
#define C_ALIGN_RIGHT           "\311"  /* " ALIGN=right" */
#define C_VALIGN_TOP            "\312"  /* " VALIGN=top" */
#define C_VALIGN_MIDDLE         "\313"  /* " VALIGN=middle" */
#define C_VALIGN_BOTTOM         "\314"  /* " VALIGN=bottom" */
#define C_CELLPADDING           "\315"  /* " CELLPADDING=" */
#define C_BORDER                "\316"  /* " BORDER=" */
#define C_CELLSPACING           "\317"  /* " CELLSPACING=" */
#define C_COLSPAN               "\320"  /* " COLSPAN=" */
#define C_ROWSPAN               "\321"  /* " ROWSPAN=" */
#define C_NAME                  "\322"  /* " NAME=" */
#define C_CONTENT               "\323"  /* " CONTENT=" */
#define C_ALT                   "\324"  /* " ALT=\"" */
#define C_oTD_COLSPAN           "\325"  /* "<TD COLSPAN=" */
#define C_xFONT                 "\326"  /* "</FONT>" */
#define C_oFRAMESET             "\327"  /* "<FRAMESET>" */
#define C_xFRAMESET             "\330"  /* "</FRAMESET>\n" */
#define C_oFRAME_SCROLLING      "\331"  /* "<FRAME SCROLLING=" */
#define C_ALIGN                 "\332"  /* " ALIGN=" */
#define C_QUOTE                 "\333"  /* "&quot;" */
#define C_oDIV                  "\334"  /* "<DIV>" */
#define C_oDIV_                 "\335"  /* "<DIV" */
#define C_xDIV                  "\336"  /* "</DIV>\n" */
#define C_BGCOLOR               "\337"  /* " BGCOLOR=\"#" */

#include "RpUsrDct.h"
 	
/**
 * File info structure
 *	
 * @external
 * @since 5.1
 * @category HTTP_Advanced_Server:File_System_Interface
 *
 * @param FileSize	The size of the file in bytes
 * @param FileDate	The date of the file in seconds since January 1, 1900.
 * @param FileType	The mime type
 * @param FileAccess Access code for accessing the file.
 * @param UserData  Not used
 */
typedef struct {
    Unsigned32  FileSize;          
    Unsigned32  FileDate;          
    rpDataType  FileType;          
    Unsigned8   FileAccess;                                           
	void        * UserData;
} FILEINFO;

/**
 * Pointer to file info structure
 *	
 * @external
 * @since 5.1
 * @category HTTP_Advanced_Server:File_System_Interface
 */
typedef FILEINFO * FILEINFOPTR;

/**
 * Http file system action status
 *	
 * @external
 * @since 5.1
 * @category HTTP_Advanced_Server:File_System_Interface
 * @name HttpFileAction		"File System Action Status For HTTP server"
 *
 * @param ACTIONCOMPLETED   Action has been completed
 * @param ACTIONPENDING     Pending action
 */
#define ACTIONCOMPLETED 1
#define ACTIONPENDING   0


/**
 * File completion status
 *	
 * @external
 * @since 5.1
 * @category HTTP_Advanced_Server:File_System_Interface
 * @name HttpFileCompletion	"File Completion Status For HTTP Server"
 *
 * @param ENDOFFILE       End of file
 * @param READCOMPLETE    Finish reading
 * @param READPENDING     Pending to read
 */
#define ENDOFFILE       2
#define READCOMPLETE    1
#define READPENDING     0

#define FILENOTFOUND    -1208
#define FILENOTOPEN     -1202


#define REALM1     0
#define REALM2     1
#define REALM3     2
#define REALM4     3
#define REALM5     4
#define REALM6     5
#define REALM7     6
#define REALM8     7

#define PASSWORDNOTAUTHORIZED   0
#define PASSWORDAUTHORIZED      1
#define PASSWORDPENDING         2
#define PASSWORDDONE            3 /* only if Digest is used */

extern int HSReadFile(int theFileNumber, char *theReadPtr, unsigned long theByteCount);
extern int HSReadFileStatus(int theFileNumber,int *theCompletionStatusPtr, unsigned long *theBytesReadPtr);
extern int HSOpenFile(int theFileNumber, char *theFullNamePtr);
extern int HSOpenFileStatus(int theFileNumber, int *theCompletionStatusPtr,FILEINFOPTR theFileInfoPtr);
extern int HSWriteFile(int theFileNumber,char *theWritePtr, unsigned long theByteCount);
extern int HSCloseFileStatus(int theFileNumber,int *theCompletionStatusPtr) ;
extern int HSCloseFile(int theFileNumber, int theCompleteFlag);
extern int HSCreateFileStatus(int theFileNumber, int *theCompletionStatusPtr);
extern int HSCreateFile(int theFileNumber, char *theFullNamePtr, FILEINFOPTR theFileInfoPtr);
extern int HSWriteFileStatus(int theFileNumber, int *theCompletionStatusPtr,unsigned long *theBytesWrittenPtr);
extern int HSCloseFileSystem(void); 
extern int HSOpenFileSystem(int theOpenFilesCount); 

/*
    The following are function prototypes that were missing in the AsExtern.h
    header file supplied by NetSilicon.
*/

extern rpSecurityLevel RpGetSecurityLevel(void *theTaskDataPtr,
                                          unsigned char theIndex);
extern void RpRealmLocking(void *theTaskDataPtr, Boolean theLockState);

extern Boolean RpSetUserAttributes(void *theTaskDataPtr, char *theUsernamePtr,
                                   char *thePasswordPtr, rpAccess theAccessCode,
                                   Unsigned32 theIpAddress,
                                   Unsigned16 theTimeoutSeconds);
extern Boolean RpGetUserAttributes(void *theTaskDataPtr, Unsigned16 theUserIndex,
                                   char ** theUsernamePtr, char **thePasswordPtr,
                                   rpAccess *theAccessCode,
                                   Unsigned32 *theIpAddressPtr,
                                   Unsigned16 *theTimeoutSecondsPtr);
extern void RpDeleteUser(void *theTaskDataPtr, char *theUsernamePtr);
extern char * RpGetCurrentUserName(void *theTaskDataPtr);
extern void RpSetPasswordCookie(void *theTaskDataPtr, char *theUsernamePtr,
                                void *theCookie);
extern void * RpGetPasswordCookie(void *theTaskDataPtr, char *theUsernamePtr);

extern void RpSetCurrentSessionCloseFunction(void *theTaskDataPtr,
                                             rpSessionCloseFuncPtr theFunctionPtr,
                                             void *theUserCookie);
extern void RpResetUserSession(void *theTaskDataPtr, char *theUsernamePtr);

typedef spwdPasswordState (* spwdPasswordFunction)(void * theTaskDataPtr, int connection, char * path, char * username, char * password);
extern void SpwdSetExternalUser(rpAccess accessCode, spwdPasswordFunction externalHandler);

#endif  /* _ASEXTERN_ */
