]> git.proxmox.com Git - ceph.git/blob - ceph/src/civetweb/docs/api/mg_get_var2.md
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / civetweb / docs / api / mg_get_var2.md
1 # Civetweb API Reference
2
3 ### `mg_get_var2( data, data_len, var_name, dst, dst_len, occurrence );`
4
5 ### Parameters
6
7 | Parameter | Type | Description |
8 | :--- | :--- | :--- |
9 |**`data`**|`const char *`|Encoded data buffer from either POST data or a GET URI|
10 |**`data_len`**|`size_t`|The size of the encoded data buffer|
11 |**`var_name`**|`const char *`|The name of the variable to search for|
12 |**`dst`**|`char *`|Destination buffer to store the variable content|
13 |**`dst_len`**|`size_t`|The size of the destination buffer including the terminating NUL|
14 |**`occurrence`**|`size_t`|The instance index of the wanted variable|
15
16 ### Return Value
17
18 | Type | Description |
19 | :--- | :--- |
20 |`int`|Length of the variable contents, or an error code|
21
22 ### Description
23
24 The function `mg_get_var2()` can be used to return the contents of a variable passed to the server as either POST data, or in the URI in a GET call. The function is somilar to [`mg_get_var()`](mg_get_var.md) but the difference is that `mg_get_var2()` can be used if the same variable is present multiple times in the data. The `occurence` parameter is used to identify which instance of the variable must be returned where **`0`** is used for the first variable with the specified name, **`1`** for the second and so on.
25
26 The function returns the length of the variable content in the return buffer, **`-1`** if a variable with the specified name could not be found and **`-2`** if the pointer to the result buffer is NULL, the size of the result buffer is zero or when the result buffer is too small to contain the variable content and terminating NUL.
27
28 ### See Also
29
30 * [`mg_get_cookie();`](mg_get_cookie.md)
31 * [`mg_get_var();`](mg_get_var.md)