lib/sw_apps/img_rcvry/src/xbir_http.c
static void Xbir_HttpExtractFileName(char *HttpReq, u16 HttpReqLen,
	char *FileName, u8 FileNameSize)
{
	char *Start, *End;
	u16 Offset;

	/* First locate the file name in the request.
	 * Requests are of the form GET /path/to/filename HTTP... OR
	 * POST /path/to/filename HTTP...
	 */
	if (strcmp(HttpReq, "GET ") == 0)
		Offset = strlen("GET ");
	else {
		Offset = strlen("POST ");
	}

	if (HttpReq[Offset] == '/')
		Offset++;

	Start = HttpReq + Offset;   /* Start marker */

	/* File name finally ends in a space */
	while (HttpReq[Offset] != ' ')
		Offset++;

	End = HttpReq + Offset - 1; /* End marker */

	if (End < Start) {
		strcpy(FileName, "index.htm");
		goto END;
	}

	/* If there is something wrong with the URL & we ran for for more than
	 * the HTTP buffer length (Offset > HttpReqLen) or the file name is too
	 * long, throw 404 error */
	if ((Offset > HttpReqLen) ||
		((End - Start) > FileNameSize)) {
		*End = 0;
		strcpy(FileName, "404.htm");
		Xbir_Printf("ERROR: Request filename is too long, length = %d,"
			"file = %s (truncated), max = %d\r\n",
			(int)(End - Start), Start, FileNameSize);
		goto END;
	}

	/* Copy over the filename */
	strncpy(FileName, Start, End - Start + 1U);
	FileName[End - Start + 1U] = 0U;

	/* If last character is a '/', append index.htm */
	if (*End == '/')
		strcat(FileName, "index.htm");

END:
	return;
}
/*****************************************************************************/
/**
 * @brief
 * This function extracts the file name from the HTTP request.
 *
 * @param	HttpReq		Pointer to HTTP payload
 * @param	HttpReqLen	HTTP payload length
 * @param	FileName	Pointer to memory for storing file name
 * @param	FileNameSize	Memory available for storing file name
 *
 * @return	None
 *
 *****************************************************************************/
@brief
This function extracts the file name from the HTTP request.

@param       HttpReq         Pointer to HTTP payload
@param       HttpReqLen      HTTP payload length
@param       FileName        Pointer to memory for storing file name
@param       FileNameSize    Memory available for storing file name

@return      None
@brief This function extracts the file name from the HTTP request . @param HttpReq Pointer to HTTP payload @param HttpReqLen HTTP payload length @param FileName Pointer to memory for storing file name @param FileNameSize Memory available for storing file name @return None
static void Xbir_HttpExtractFileName(char *HttpReq, u16 HttpReqLen,
	char *FileName, u8 FileNameSize)
{
	char *Start, *End;
	u16 Offset;
	if (strcmp(HttpReq, "GET ") == 0)
		Offset = strlen("GET ");
	else {
		Offset = strlen("POST ");
	}
	if (HttpReq[Offset] == '/')
		Offset++;
	Start = HttpReq + Offset;   
	while (HttpReq[Offset] != ' ')
		Offset++;
	End = HttpReq + Offset - 1; 
	if (End < Start) {
		strcpy(FileName, "index.htm");
		goto END;
	}
	if ((Offset > HttpReqLen) ||
		((End - Start) > FileNameSize)) {
		*End = 0;
		strcpy(FileName, "404.htm");
		Xbir_Printf("ERROR: Request filename is too long, length = %d,"
			"file = %s (truncated), max = %d\r\n",
			(int)(End - Start), Start, FileNameSize);
		goto END;
	}
	strncpy(FileName, Start, End - Start + 1U);
	FileName[End - Start + 1U] = 0U;
	if (*End == '/')
		strcat(FileName, "index.htm");
END:
	return;
}
static void Xbir_HttpExtractFileName ( char * HttpReq , u16 HttpReqLen , char * FileName , u8 FileNameSize ) { char * Start , * End ; u16 Offset ; if ( strcmp ( HttpReq , " " ) == 0 ) Offset = strlen ( " " ) ; else { Offset = strlen ( " " ) ; } if ( HttpReq [ Offset ] == ' ' ) Offset ++ ; Start = HttpReq + Offset ; while ( HttpReq [ Offset ] != ' ' ) Offset ++ ; End = HttpReq + Offset - 1 ; if ( End < Start ) { strcpy ( FileName , " " ) ; goto END ; } if ( ( Offset > HttpReqLen ) || ( ( End - Start ) > FileNameSize ) ) { * End = 0 ; strcpy ( FileName , " " ) ; Xbir_Printf ( " " " \r \n " , ( int ) ( End - Start ) , Start , FileNameSize ) ; goto END ; } strncpy ( FileName , Start , End - Start + 1U ) ; FileName [ End - Start + 1U ] = 0U ; if ( * End == ' ' ) strcat ( FileName , " " ) ; END : return ; }
@brief
 This function extracts the file name from the HTTP request.
@brief This function extracts the file name from the HTTP request .
/* First locate the file name in the request.
	 * Requests are of the form GET /path/to/filename HTTP... OR
	 * POST /path/to/filename HTTP...
	 */ /* Start marker */ /* File name finally ends in a space */ /* End marker */ /* If there is something wrong with the URL & we ran for for more than
	 * the HTTP buffer length (Offset > HttpReqLen) or the file name is too
	 * long, throw 404 error */ /* Copy over the filename */ /* If last character is a '/', append index.htm */