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@109:bca6ebe63e32, 2019-01-18 (annotated)
- Committer:
- andrewboyson
- Date:
- Fri Jan 18 14:24:17 2019 +0000
- Revision:
- 109:bca6ebe63e32
- Child:
- 118:067cb5bce7e3
Added HttpSame module to provide NULL safe comparison routines
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
andrewboyson | 109:bca6ebe63e32 | 1 | #include <stdbool.h> |
andrewboyson | 109:bca6ebe63e32 | 2 | #include "http.h" |
andrewboyson | 109:bca6ebe63e32 | 3 | |
andrewboyson | 109:bca6ebe63e32 | 4 | bool HttpSameStr(const char* pa, const char* pb) |
andrewboyson | 109:bca6ebe63e32 | 5 | { |
andrewboyson | 109:bca6ebe63e32 | 6 | if (!pa || !pb) return false; //Handle NULL references |
andrewboyson | 109:bca6ebe63e32 | 7 | |
andrewboyson | 109:bca6ebe63e32 | 8 | while(true) |
andrewboyson | 109:bca6ebe63e32 | 9 | { |
andrewboyson | 109:bca6ebe63e32 | 10 | if ( *pa != *pb) return false; //If they are not the same return false |
andrewboyson | 109:bca6ebe63e32 | 11 | if (!*pa) return true; //If finished return true; |
andrewboyson | 109:bca6ebe63e32 | 12 | pa++; |
andrewboyson | 109:bca6ebe63e32 | 13 | pb++; |
andrewboyson | 109:bca6ebe63e32 | 14 | } |
andrewboyson | 109:bca6ebe63e32 | 15 | } |
andrewboyson | 109:bca6ebe63e32 | 16 | bool HttpSameDate(const char* date, const char* time, const char* pOtherDate) |
andrewboyson | 109:bca6ebe63e32 | 17 | { |
andrewboyson | 109:bca6ebe63e32 | 18 | if (!pOtherDate) return false; //Not the same if no lastModified |
andrewboyson | 109:bca6ebe63e32 | 19 | |
andrewboyson | 109:bca6ebe63e32 | 20 | char pFileDate[HTTP_DATE_LENGTH]; |
andrewboyson | 109:bca6ebe63e32 | 21 | HttpDateFromDateTime(date, time, pFileDate); |
andrewboyson | 109:bca6ebe63e32 | 22 | |
andrewboyson | 109:bca6ebe63e32 | 23 | return HttpSameStr(pFileDate, pOtherDate); |
andrewboyson | 109:bca6ebe63e32 | 24 | } |