added: parser for multipart forms, files: postmultiparser.h postmultiparser.cpp
added: function: upload git-svn-id: svn://ttmath.org/publicrep/cmslu/trunk@543 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
93
core/postmultiparser.h
Executable file
93
core/postmultiparser.h
Executable file
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* 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 <string>
|
||||
#include <fcgiapp.h>
|
||||
#include <fstream>
|
||||
#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
|
Reference in New Issue
Block a user