libwebsockets
Lightweight C library for HTML5 websockets
lws-spa.h
1 /*
2  * libwebsockets - small server side websockets and web server implementation
3  *
4  * Copyright (C) 2010 - 2019 Andy Green <andy@warmcat.com>
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to
8  * deal in the Software without restriction, including without limitation the
9  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10  * sell copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22  * IN THE SOFTWARE.
23  */
24 
44 
55 };
56 
70 typedef int (*lws_spa_fileupload_cb)(void *data, const char *name,
71  const char *filename, char *buf, int len,
72  enum lws_spa_fileupload_states state);
73 
76 struct lws_spa;
77 
99 LWS_VISIBLE LWS_EXTERN struct lws_spa *
100 lws_spa_create(struct lws *wsi, const char * const *param_names,
101  int count_params, int max_storage, lws_spa_fileupload_cb opt_cb,
102  void *opt_data);
103 
104 typedef struct lws_spa_create_info {
105  const char * const *param_names; /* array of form parameter names, like "username" */
106  int count_params; /* count of param_names */
107  int max_storage; /* total amount of form parameter values we can store */
108  lws_spa_fileupload_cb opt_cb; /* NULL, or callback to receive file upload data. */
109  void *opt_data; /* NULL, or user pointer provided to opt_cb. */
110  size_t param_names_stride; /* 0 if param_names is an array of char *.
111  Else stride to next char * */
112  struct lwsac **ac; /* NULL, or pointer to lwsac * to contain all
113  related heap allocations */
114  size_t ac_chunk_size; /* 0 for default, or ac chunk size */
116 
131 LWS_VISIBLE LWS_EXTERN struct lws_spa *
132 lws_spa_create_via_info(struct lws *wsi, const lws_spa_create_info_t *info);
133 
141 LWS_VISIBLE LWS_EXTERN int
142 lws_spa_process(struct lws_spa *spa, const char *in, int len);
143 
149 LWS_VISIBLE LWS_EXTERN int
150 lws_spa_finalize(struct lws_spa *spa);
151 
158 LWS_VISIBLE LWS_EXTERN int
159 lws_spa_get_length(struct lws_spa *spa, int n);
160 
166 LWS_VISIBLE LWS_EXTERN const char *
167 lws_spa_get_string(struct lws_spa *spa, int n);
168 
174 LWS_VISIBLE LWS_EXTERN int
175 lws_spa_destroy(struct lws_spa *spa);
LWS_VISIBLE LWS_EXTERN struct lws_spa * lws_spa_create(struct lws *wsi, const char *const *param_names, int count_params, int max_storage, lws_spa_fileupload_cb opt_cb, void *opt_data)
LWS_VISIBLE LWS_EXTERN const char * lws_spa_get_string(struct lws_spa *spa, int n)
LWS_VISIBLE LWS_EXTERN int lws_spa_get_length(struct lws_spa *spa, int n)
lws_spa_fileupload_states
Definition: lws-spa.h:46
int(* lws_spa_fileupload_cb)(void *data, const char *name, const char *filename, char *buf, int len, enum lws_spa_fileupload_states state)
Definition: lws-spa.h:70
LWS_VISIBLE LWS_EXTERN int lws_spa_finalize(struct lws_spa *spa)
LWS_VISIBLE LWS_EXTERN struct lws_spa * lws_spa_create_via_info(struct lws *wsi, const lws_spa_create_info_t *info)
LWS_VISIBLE LWS_EXTERN int lws_spa_process(struct lws_spa *spa, const char *in, int len)
LWS_VISIBLE LWS_EXTERN int lws_spa_destroy(struct lws_spa *spa)
@ LWS_UFS_CLOSE
Definition: lws-spa.h:53
@ LWS_UFS_OPEN
Definition: lws-spa.h:51
@ LWS_UFS_FINAL_CONTENT
Definition: lws-spa.h:49
@ LWS_UFS_CONTENT
Definition: lws-spa.h:47
Definition: lws-spa.h:104