diff options
Diffstat (limited to 'src/lib/action_process_upload.c')
-rw-r--r-- | src/lib/action_process_upload.c | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/src/lib/action_process_upload.c b/src/lib/action_process_upload.c new file mode 100644 index 00000000..d67b60a1 --- /dev/null +++ b/src/lib/action_process_upload.c | |||
@@ -0,0 +1,92 @@ | |||
1 | /* | ||
2 | This file is part of libmicrohttpd | ||
3 | Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 2.1 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General Public | ||
16 | License along with this library; if not, write to the Free Software | ||
17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
18 | */ | ||
19 | |||
20 | /** | ||
21 | * @file lib/action_process_upload.c | ||
22 | * @brief implementation of MHD_action_process_upload() | ||
23 | * @author Christian Grothoff | ||
24 | */ | ||
25 | #include "internal.h" | ||
26 | |||
27 | |||
28 | /** | ||
29 | * Internal details about an upload action. | ||
30 | */ | ||
31 | struct UploadAction | ||
32 | { | ||
33 | /** | ||
34 | * An upload action is an action. This field | ||
35 | * must come first! | ||
36 | */ | ||
37 | struct MHD_Action action; | ||
38 | |||
39 | MHD_UploadCallback uc; | ||
40 | |||
41 | void *uc_cls; | ||
42 | |||
43 | }; | ||
44 | |||
45 | |||
46 | /** | ||
47 | * The application wants to process uploaded data for | ||
48 | * the given request. Do it! | ||
49 | * | ||
50 | * @param cls the `struct UploadAction` with the | ||
51 | * function we are to call for upload data | ||
52 | * @param request the request for which we are to process | ||
53 | * upload data | ||
54 | */ | ||
55 | static void | ||
56 | upload_action (void *cls, | ||
57 | struct MHD_Request *request) | ||
58 | { | ||
59 | struct UploadAction *ua = cls; | ||
60 | |||
61 | (void) ua; | ||
62 | // FIXME: implement! | ||
63 | } | ||
64 | |||
65 | |||
66 | /** | ||
67 | * Create an action that handles an upload. | ||
68 | * | ||
69 | * @param uc function to call with uploaded data | ||
70 | * @param uc_cls closure for @a uc | ||
71 | * @return NULL on error (out of memory) | ||
72 | * @ingroup action | ||
73 | */ | ||
74 | struct MHD_Action * | ||
75 | MHD_action_process_upload (MHD_UploadCallback uc, | ||
76 | void *uc_cls) | ||
77 | { | ||
78 | struct UploadAction *ua; | ||
79 | |||
80 | if (NULL == (ua = malloc (sizeof (struct UploadAction)))) | ||
81 | return NULL; | ||
82 | ua->action = &upload_action; | ||
83 | ua->action_cls = ua; | ||
84 | ua->uc = uc; | ||
85 | ua->uc_cls = uc_cls; | ||
86 | return ua; | ||
87 | } | ||
88 | |||
89 | |||
90 | /* end of action_process_upload.c */ | ||
91 | |||
92 | |||