diff options
author | Aleksey Veresov <aleksey@veresov.pro> | 2020-03-20 23:06:46 +0300 |
---|---|---|
committer | Aleksey Veresov <aleksey@veresov.pro> | 2020-03-20 23:06:46 +0300 |
commit | 8acbd33a82d2c13e70eb17447bc6abfd86cf9512 (patch) | |
tree | f89d1c6ec04e3ba418b63c37202d6abc4f08138e /include/magi/loadfiles.h | |
parent | fcffb003f36a4357b6ba88e6b5e2239d7d111a6a (diff) | |
download | magi-8acbd33a82d2c13e70eb17447bc6abfd86cf9512.tar magi-8acbd33a82d2c13e70eb17447bc6abfd86cf9512.tar.xz magi-8acbd33a82d2c13e70eb17447bc6abfd86cf9512.zip |
[magi]
Diffstat (limited to 'include/magi/loadfiles.h')
-rw-r--r-- | include/magi/loadfiles.h | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/include/magi/loadfiles.h b/include/magi/loadfiles.h new file mode 100644 index 0000000..bf3421c --- /dev/null +++ b/include/magi/loadfiles.h @@ -0,0 +1,48 @@ +#ifndef MAGI_INCLUDED_LOADFILE +#define MAGI_INCLUDED_LOADFILE +/* Simple callback to load files. + * + * Generally satisfies task of receiving files. Fill magi_loadfiles table + * via magi_loadfiles_add, specifying which file-parameter to load into which + * path, and what are size limitations for it. When table is complete, setup + * your request to use this callback with magi_loadfiles_set. + * + * This module is optional. + */ +#include "request.h" + + +/* Rule of loading single file. + * There is no need to form or edit it directly. */ +typedef struct magi_loadfile { + const char *name; /* Form field to load file from. */ + const char *path; /* Path to load file in. */ + int max; /* Limit in bytes. Null means unlimited. */ +} magi_loadfile; + +/* Table of rules for loading files. + * Set count and files as null to initialize. */ +typedef struct magi_loadfiles { + int count; /* Size of files array.*/ + magi_loadfile *files; /* Dynamic array of rules to load files. */ +} magi_loadfiles; + + +/* Free memory used by table. Request using table will become invalid. */ +void magi_loadfiles_free(magi_loadfiles *table); + +/* Add entity into table. + * Specify form field to load file from with name, + * wnated loaction to load file with path, + * and file size limit in bytes with max (pass null to unlimit). */ +void magi_loadfiles_add(magi_loadfiles *table, + const char *name, + const char *path, + int max); + + +/* Setup request to use loadfiles callback with table. */ +void magi_loadfiles_set(magi_request *request, magi_loadfiles *table); + + +#endif |