소스 검색

mg_form_data_handler.md improved

Added documentation for the field_get method and fixed formatting issues.
daveelton 6 년 전
부모
커밋
18e3c0c737
1개의 변경된 파일13개의 추가작업 그리고 5개의 파일을 삭제
  1. 13 5
      docs/api/mg_form_data_handler.md

+ 13 - 5
docs/api/mg_form_data_handler.md

@@ -19,12 +19,20 @@
 ||**`FORM_FIELD_STORAGE_STORE`** - Store a file as `path` and overwrite that file if it already exists|
 ||**`FORM_FIELD_STORAGE_STORE`** - Store a file as `path` and overwrite that file if it already exists|
 ||**`FORM_FIELD_STORAGE_ABORT`** - Stop parsing the request and ignore all remaining form fields|
 ||**`FORM_FIELD_STORAGE_ABORT`** - Stop parsing the request and ignore all remaining form fields|
 |**`field_get`**|**`int field_get( const char *key, const char *value, size_t valuelen, void *user_data );`**|
 |**`field_get`**|**`int field_get( const char *key, const char *value, size_t valuelen, void *user_data );`**|
+||If the callback function `field_found()` returned `FORM_FIELD_STORAGE_GET`, Civetweb will call `field_get()` one or more times to pass back the data for this field.|
+||**`key`** - the name of the field being decoded, note this is only passed on the first call for file parameters (bug?)|
+||**`value`** - a pointer to the data read so far from the field's value|
+||**`valuelen`** - the size of the data in the value for this call to `field_get()`|
+||**`user_data`** - A pointer to the value of the field `user_data` of the structure `struct mg_form_data_handler`.|
+||**`return` `MG_FORM_FIELD_HANDLE_GET`** - to continue calling get until all data has been received. |
+||**`return` `MG_FORM_FIELD_HANDLE_NEXT`** - to skip further calls to get for this field and move on to the next field. |
+||**`return` `MG_FORM_FIELD_HANDLE_ABORT`** - to stop parsing this form and abandon the search for further fields. |
 |**`field_store`**|**`int field_store( const char *path, long long file_size, void *user_data );`**|
 |**`field_store`**|**`int field_store( const char *path, long long file_size, void *user_data );`**|
-||If the callback function `field_found()` returned `FORM_FIELD_STORAGE_STORE`, Civetweb will try to store the received data in a file. If writing the file is successful, the callback function `field_store()` is called. This function is only called after completion of a full upload, not if a file has only partly been uploaded. When only part of a file is received, Civetweb will delete that partly upload in the background and not inform the main application through this callback. The following parameters are provided in the function call:|
-||**`path`** -|
-||**`file_size`** - The path on the server where the file was stored|
-||**`user_data`** - The size of the stored file in bytes|
-|**`user_data`**|**`void *`** The value of the field `user_data` when the callback functions were registered with a call to `mg_handle_form_request();`|
+||If the callback function `field_found()` returned `FORM_FIELD_STORAGE_STORE`, Civetweb will try to store the received data in a file. If writing the file is successful, the callback function `field_store()` is called. This function is only called after completion of a full upload, not if a file has only partly been uploaded. When only part of a file is received, Civetweb will delete that partly upload in the background and not inform the main application through this callback. The following parameters are provided in the function call|
+||**`path`** - The path on the server where the file was stored|
+||**`file_size`** - The size of the stored file in bytes|
+||**`user_data`** - The value of the field `user_data` when the callback functions were registered with a call to `mg_handle_form_request();`|
+|**`user_data`**|**`void *`** |
 ||The `user_data` field is a user supplied argument that will be passed as parameter to each of callback functions|
 ||The `user_data` field is a user supplied argument that will be passed as parameter to each of callback functions|
 
 
 ### Description
 ### Description