A stack which works with or without an Mbed os library. Provides IPv4 or IPv6 with a full 1500 byte buffer.

Dependents:   oldheating gps motorhome heating

tcp/http/httpsame.c

Committer:
andrewboyson
Date:
2019-02-22
Revision:
125:8c84daac38ab
Parent:
118:067cb5bce7e3

File content as of revision 125:8c84daac38ab:

#include <stdbool.h>
#include <ctype.h>
#include "http.h"

bool HttpSameStr(const char* pa, const char* pb)
{
    if (!pa || !pb) return false; //Handle NULL references
    
    while(true)
    {
        if ( *pa != *pb) return false; //If they are not the same return false
        if (!*pa)        return true;  //If finished return true;
        pa++;
        pb++;
    }
}
bool HttpSameStrCaseInsensitive(const char* pa, const char* pb)
{
    if (!pa || !pb) return false; //Handle NULL references
    
    while(true)
    {
        if ( toupper(*pa) != toupper(*pb)) return false; //If they are not the same return false
        if (!*pa)        return true;  //If finished return true;
        pa++;
        pb++;
    }
}
bool HttpSameDate(const char* date, const char* time, const char* pOtherDate)
{
    if (!pOtherDate) return false; //Not the same if no lastModified
    
    char pFileDate[HTTP_DATE_LENGTH];
    HttpDateFromDateTime(date, time, pFileDate);
    
    return HttpSameStr(pFileDate, pOtherDate);
}