Jump to main content

##

# TCPIP_HTTP_NET_ArgGet Function

## C

    const uint8_t* TCPIP_HTTP_NET_ArgGet(
        const uint8_t* cData,
        const uint8_t* cArg
    );

## Description

This function searches through a data array to find the value associated with a given argument. It can be used to find form field values in data received over GET or POST.

The end of data is assumed to be reached when a null name parameter is encountered. This requires the string to have an even number of null-terminated strings, followed by an additional null terminator.

## Preconditions

The data array has a valid series of null terminated name/value pairs.

## Parameters

Parameters | Description
--- | ---
cData | The buffer to search.
cArg | The name of the argument to find.

## Returns

- A pointer to the argument value, or NULL if not found.

## Remarks

None.

## Example

    template_DynPrint(TCPIP_HTTP_NET_CONN_HANDLE connHandle, const TCPIP_HTTP_DYN_VAR_DCPT*
                            varDcpt, const TCPIP_HTTP_NET_USER_CALLBACK* pCBack)
    {
        const uint8_t *ptr;

        ptr = TCPIP_HTTP_NET_ArgGet(TCPIP_HTTP_NET_ConnectionDataBufferGet(connHandle),
                                    (const uint8_t*)"name");
        if(ptr == 0)
        {
            ptr = "not set";
        }
        else
        {
            strncpy(myBuffer, ptr, sizeof(myBuffer));
            ptr = myBuffer;
        }

        TCPIP_HTTP_NET_DynamicWrite(varDcpt, ptr, strlen(ptr), false);

    }