48 lines
1.4 KiB
C
48 lines
1.4 KiB
C
#ifndef VESSEL_WEB_FORM_H_
|
|
#define VESSEL_WEB_FORM_H_
|
|
|
|
#include "conf.h"
|
|
|
|
#include "request.h"
|
|
|
|
#include <vessel/def.h>
|
|
#include <vessel/file.h>
|
|
#include <vessel/hmap.h>
|
|
|
|
typedef enum {
|
|
vw_FormFieldType_plain = 0,
|
|
vw_FormFieldType_file,
|
|
} vw_FormFieldType;
|
|
|
|
typedef struct {
|
|
char *filename;
|
|
vs_File file;
|
|
} vw_FormFile;
|
|
|
|
typedef struct {
|
|
vw_FormFieldType type;
|
|
void *value;
|
|
vs_HMap headers;
|
|
} vw_FormField;
|
|
|
|
#define VW_FORM_URL_ENCODED_HASH \
|
|
12013814961915400361ULL /* application/x-www-form-urlencoded \
|
|
*/
|
|
#define VW_FORM_PLAIN_HASH 11804510956092696560ULL /* text/plain */
|
|
|
|
#define VW_FORM_VALUE_MAX ((size_t)(1024 * 256)) /* 256 KB */
|
|
#define VW_FORM_FILE_VALUE_CHUNKS 4096 /* 1 GB (4096 * 256 KB) */
|
|
|
|
#define VW_FORM_PLAIN_KEY "content"
|
|
|
|
bool vw_Form_read(vw_HTTPRequest *req, vs_HMap *hmap);
|
|
bool vw_Form_print(vs_HMap *hmap);
|
|
bool vw_Form_destroy(vs_HMap *hmap);
|
|
|
|
bool vw_FormFile_init(vw_FormFile *file, const char *filename);
|
|
bool vw_FormFile_open(vw_FormFile *file);
|
|
bool vw_FormFile_close(vw_FormFile *file);
|
|
size_t vw_FormFile_read(vw_FormFile *file, void *buf, size_t count);
|
|
bool vw_FormFile_destroy(vw_FormFile *file);
|
|
|
|
#endif /* VESSEL_WEB_FORM_H_ */
|