/* * This file is a part of CMSLU -- Content Management System like Unix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa * All rights reserved. * */ #ifndef headerfilecmslucorepostmultiparser #define headerfilecmslucorepostmultiparser #include #include #include #include "error.h" #include "requesttypes.h" // 2 MB #define CMSLU_POSTMULTI_INPUT_BUFFER 2097152 #define CMSLU_POSTMULTI_OUTPUT_BUFFER 2097152 class PostMultiParser { public: PostMultiParser(); PostMultiParser(const PostMultiParser &); PostMultiParser & operator=(const PostMultiParser &); ~PostMultiParser(); Error Parse(FCGX_Stream * in_, PostTable & post_table_, PostFileTable & post_file_table_); private: FCGX_Stream * in; unsigned char * in_buffer; std::ofstream tmp_file; std::string tmp_filename; int tmp_filename_postfix; size_t in_buffer_ind; size_t in_buffer_len; PostTable * post_table; PostFileTable * post_file_table; int last; // last read character bool line_end_dos; std::string boundary; std::string content; size_t content_len; std::string header_name, header_value; Error err; std::string name, filename; PostFile post_file_temp; void LogFirst(const std::string & to_log, size_t len); bool IsWhite(int c); void SkipWhite(); void AddNormalPostVar(); void AddFilePostVar(); void AddPostVar(); void ReadBoundary(); bool IsHeader(); void ReadHeaderName(); void ReadHeaderValue(); void ReadPartHeader(); void CreateTmpFile(); bool HasBoundary(); void ReadContentSkipBoundary(bool has_boundary); void ReadContentToFileLoop(); void ReadContentToFile(); void ReadContentLoop(); void ReadContent(); void CheckBoundaryEnd(); void ReadPart(); void ReadChar(); }; #endif