1.2.1.12.8 TCPIP_HTTP_ArgGet Function

C

const uint8_t* TCPIP_HTTP_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 numner of null-terminated strings, followed by an additional null terminator.

Preconditions

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

Parameters

ParametersDescription
cDataThe buffer to search.
cArgThe name of the argument to find.

Returns

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

Remarks

None.

Example

void TCPIP_HTTP_Print_cookiename(HTTP_CONN_HANDLE connHandle) { const uint8_t *ptr; TCP_SOCKET sktHTTP;

  ptr = TCPIP_HTTP_ArgGet(TCPIP_HTTP_CurrentConnectionDataBufferGet(connHandle), (const uint8_t*)"name");
  sktHTTP = TCPIP_HTTP_CurrentConnectionSocketGet(connHandle);
  if(ptr)
      TCPIP_TCP_StringPut(sktHTTP, ptr);
  else
      TCPIP_TCP_StringPut(sktHTTP, (const uint8_t*)"not set");

}