99 lines
1.8 KiB
C++
Executable File
99 lines
1.8 KiB
C++
Executable File
/*
|
|
* This file is a part of Winix
|
|
* and is not publicly distributed
|
|
*
|
|
* Copyright (c) 2008-2010, Tomasz Sowa
|
|
* All rights reserved.
|
|
*
|
|
*/
|
|
|
|
#ifndef headerfilecmslucorepostmultiparser
|
|
#define headerfilecmslucorepostmultiparser
|
|
|
|
#include <string>
|
|
#include <fcgiapp.h>
|
|
#include <fstream>
|
|
#include "error.h"
|
|
#include "requesttypes.h"
|
|
#include "config.h"
|
|
|
|
|
|
// 2 MB
|
|
#define WINIX_POSTMULTI_INPUT_BUFFER 2097152
|
|
#define WINIX_POSTMULTI_OUTPUT_BUFFER 2097152
|
|
|
|
|
|
class PostMultiParser
|
|
{
|
|
|
|
public:
|
|
|
|
PostMultiParser();
|
|
PostMultiParser(const PostMultiParser &);
|
|
PostMultiParser & operator=(const PostMultiParser &);
|
|
~PostMultiParser();
|
|
|
|
void SetConfig(Config * pconfig);
|
|
Error Parse(FCGX_Stream * in_, PostTab & post_tab_, PostFileTab & post_file_tab_);
|
|
|
|
private:
|
|
|
|
Config * config;
|
|
|
|
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;
|
|
|
|
PostTab * post_tab;
|
|
PostFileTab * post_file_tab;
|
|
|
|
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
|