[0001]
[0002]
[0003]
[0004]
[0005]
[0006]
[0007]
[0008]
[0009]
[0010]
[0011]
[0012]
[0013]
[0014]
[0015]
[0016]
[0017]
[0018]
[0019]
[0020]
[0021]
[0022]
[0023]
[0024]
[0025]
[0026]
[0027]
[0028]
[0029]
[0030]
[0031]
[0032]
[0033]
[0034]
[0035]
[0036]
[0037]
[0038]
[0039]
[0040]
[0041]
[0042]
[0043]
[0044]
[0045]
[0046]
[0047]
[0048]
[0049]
[0050]
[0051]
[0052]
[0053]
[0054]
[0055]
[0056]
[0057]
[0058]
[0059]
[0060]
[0061]
[0062]
[0063]
[0064]
[0065]
[0066]
[0067]
[0068]
[0069]
[0070]
[0071]
[0072]
[0073]
[0074]
[0075]
[0076]
[0077]
[0078]
[0079]
[0080]
[0081]
[0082]
[0083]
[0084]
[0085]
[0086]
[0087]
[0088]
[0089]
[0090]
[0091]
[0092]
[0093]
[0094]
[0095]
[0096]
[0097]
[0098]
[0099]
[0100]
[0101]
[0102]
[0103]
[0104]
[0105]
[0106]
[0107]
[0108]
[0109]
[0110]
[0111]
[0112]
[0113]
[0114]
[0115]
[0116]
[0117]
[0118]
[0119]
[0120]
[0121]
[0122]
[0123]
[0124]
[0125]
[0126]
[0127]
[0128]
[0129]
[0130]
[0131]
[0132]
[0133]
[0134]
[0135]
[0136]
[0137]
[0138]
[0139]
[0140]
[0141]
[0142]
[0143]
[0144]
[0145]
[0146]
[0147]
[0148]
[0149]
[0150]
[0151]
[0152]
[0153]
[0154]
[0155]
[0156]
[0157]
[0158]
/*****************************************************************************/
/*
                                   body.h
*/
/*****************************************************************************/

#ifndef BODY_H_LOADED
#define BODY_H_LOADED 1

#include "wasd.h"

/**********/
/* macros */
/**********/

#define BODY_PROCESSED_AS_NONE                0
#define BODY_PROCESSED_AS_TEXT                1
#define BODY_PROCESSED_AS_OTHER               2
#define BODY_PROCESSED_AS_VIRTUALBLOCK        3
#define BODY_PROCESSED_AS_URLENCODED          4
#define BODY_PROCESSED_AS_MULTIPART_FORMDATA  5
#define BODY_PROCESSED_AS_CHUNKED             6

#define CHUNK_STATE_BEGIN   0   /* uninitialized */
#define CHUNK_STATE_SIZE    1   /* getting the chunk size from hex string */
#define CHUNK_STATE_EOL     2   /* finding the CR-LF trailing hex string */
#define CHUNK_STATE_DATA    3   /* processing the chunk data */
#define CHUNK_STATE_EOD     4   /* finding the CR-LF trailing the data */
#define CHUNK_STATE_TRAILER 5   /* end of chunks, processing the trailer */
#define CHUNK_STATE_END     6   /* end of chunks and trailer */

/**************/
/* structures */
/**************/

typedef struct BodyProcessStruct BODY_PROCESS;

struct  BodyProcessStruct
{
   BOOL  /* document posted is URL-encoded */
         ContentTypeUrlEncoded,
         /* form field CDATA contains '^' substituted for LFs */
         UrlEncodedHiddenLF,
         /* delete file after it's been transfered */
         PreviewOnly,
         /* currently processing a hex-encoded field value */
         UrlEncodedFieldHexEncoded,
         /* the current field name has reserved usage */
         UrlEncodedFieldNameReserved;

   int  /* count of bytes in buffer used for block I/O */
        BlockBufferCount,
        /* size in bytes of buffer used for block I/O */
        BlockBufferSize,
        /* contains the VMS status of the contents of the block buffer */
        BlockBufferStatus,
        /* number of the leading 512 byte block */
        BlockBufferVBN,
        /* bytes of data beyond the last whole virtual block */
        BlockLeftOverCount,
        /* position in 'BoundaryBuffer' */
        BoundaryIdx,
        /* final count of characters in buffered MIME header */
        MimeHeaderCount,
        /* when buffering the MIME header */
        MimeHeaderIdx,
        /* RMS multiblock count value */
        MultiBlockCount,
        /* length of MIME boundary used to delimit mixed subparts in buffer */
        MultipartBoundaryLength,
        /* current number of bytes in multipart field being buffered to */
        MultipartFormDataCount,
        /* keep track of 'form-data; name="name" filename=\"..\"' */
        MultipartFormDataFileNameCount,
        /* size of current multipart field being buffered to */
        MultipartFormDataSize,
        /* position in 'HexDecode' */
        UrlDecodeIdx,
        /* position in 'UrlDecode' */
        HexDecodeIdx,
        /* progressive number of bytes processed and passed on */
        ProcessedByteCount,
        /* FAB record attributes supplied with file body */
        UrlEncodedFabRat,
        /* FAB record format supplied with file body */
        UrlEncodedFabRfm,
        /* current length of field name while processing URL-encoded file */
        UrlEncodedFieldNameCount,
        /* size of field name while processing URL-encoded file */
        UrlEncodedFieldNameSize,
        /* current length of field value while processing URL-encoded file */
        UrlEncodedFieldValueCount,
        /* size of field value while processing URL-encoded file */
        UrlEncodedFieldValueSize;

   char  /* points to the start of buffer used for block I/O */
         *BlockBufferPtr,
         /* points to data beyond the last whole virtual block */
         *BlockLeftOverPtr,
         /* multipart content-type */
         *MultipartContentTypePtr,
         /* pointer to start of multipart field being buffered to */
         *MultipartFormDataPtr,
         /* pointer to next character of multipart field being buffered to */
         *MultipartFormDataCurrentPtr;

   char  /* multipart boundary string */
         BoundaryBuffer [96],
         /* should be "ascii" or "binary" */
         FtpFileType [8],
         /* buffers when hex-encode decoding between reads */
         HexDecode [2],
         /* buffer the MIME part header */
         MimeHeaderBuffer [1024],
         /* multipart boundary string (from content-type) */
         MultipartBoundary [96],
         /* buffer the 'form-data; name="uploadfilename"' data */
         MultipartUploadFileName [96],
         /* buffer the 'form-data; filename=".."' data */
         MultipartFileName [96],
         /* used to buffer the 'form-data; name="success"' data */
         MultipartSuccessUrl [256],
         /* buffer a string providing file protection */
         ProtectionHexString [8],
         /* buffer URL-encoded character */
         UrlDecode [4],
         /* store field name while processing URL-encoded file */
         UrlEncodedFieldName [256],
         /* store field value while processing URL-encoded file */
         UrlEncodedFieldValue [256];
};

/***********************/
/* function prototypes */
/***********************/

void BodyBufferAllocate (REQUEST_STRUCT*);
void BodyBufferEndOfFile (REQUEST_STRUCT*);
void BodyBufferWrite (REQUEST_STRUCT*);
BOOL BodyContentGzip (REQUEST_STRUCT*);
int BodyGetMimeBoundary (REQUEST_STRUCT*);
void BodyProcessByVirtualBlock (REQUEST_STRUCT*);
void BodyProcessMultipartFormData (REQUEST_STRUCT*);
int BodyProcessMultipartMimeHeader (REQUEST_STRUCT*);
void BodyProcessReadAll (REQUEST_STRUCT*);
void BodyProcessUrlEncoded (REQUEST_STRUCT*);
void BodyRead (REQUEST_STRUCT*);
void BodyReadAst (REQUEST_STRUCT*);
void BodyReadBegin (REQUEST_STRUCT*, REQUEST_AST, REQUEST_AST);
void BodyReadProcess (REQUEST_STRUCT*);
BOOL BodyReadUnEncode (REQUEST_STRUCT*);
void BodyTransferChunked (REQUEST_STRUCT*);
int BodyTransferChunkedTrailer (REQUEST_STRUCT*, char*, int);

#endif /* BODY_H_LOADED */

/*****************************************************************************/