45 lines
1.1 KiB
C
45 lines
1.1 KiB
C
#ifndef _VESSEL_FORM_H
|
|
#define _VESSEL_FORM_H
|
|
|
|
#include "conf.h"
|
|
|
|
#include "hmap.h"
|
|
#include "request.h"
|
|
|
|
#include <wchar.h>
|
|
|
|
#define FORM_URL_ENCODED_HASH 12013814961915400361ULL /* application/x-www-form-urlencoded */
|
|
#define FORM_PLAIN_HASH 11804510956092696560ULL /* text/plain */
|
|
|
|
#define FORM_VALUE_MAX (1024 * 256) /* 256 KB */
|
|
#define FORM_FILE_VALUE_CHUNKS 4096 /* 1 GB (4096 * 256 KB) */
|
|
|
|
#define FORM_PLAIN_KEY "content"
|
|
|
|
typedef enum {
|
|
FormFieldType_plain = 0,
|
|
FormFieldType_file,
|
|
} FormFieldType;
|
|
|
|
typedef struct {
|
|
wchar_t *filename;
|
|
char *path;
|
|
File f;
|
|
} FormFile;
|
|
|
|
typedef struct {
|
|
FormFieldType type;
|
|
void *value;
|
|
HMap headers;
|
|
} FormField;
|
|
|
|
Bool Form_read(HTTPRequest *req, HMap *hmap);
|
|
Bool Form_destroy(HMap *hmap);
|
|
|
|
Bool FormFile_init(FormFile *ff, const void *filename, const Bool convert);
|
|
Bool FormFile_open(FormFile *ff);
|
|
Bool FormFile_close(FormFile *ff);
|
|
uint64_t FormFile_read(FormFile *ff, void *buf, uint64_t count);
|
|
Bool FormFile_destroy(FormFile *ff);
|
|
|
|
#endif /* _VESSEL_FORM_H */
|