AceTime  1.1
Date and time classes for Arduino that support timezones from the TZ Database, and a system clock that can synchronize from an NTP server or an RTC chip.
compat.cpp
1 #include "compat.h"
2 
3 // There are many different boards which identify themselves as
4 // ARDUINO_SAMD_ZERO. The original Arduino Zero using Native USB Port
5 // does not set SERIAL_PORT_MONITOR correctly, so warn the user.
6 #if defined(ARDUINO_SAMD_ZERO)
7  #warning Arduino Zero may need SERIAL_PORT_MONITOR fixed (see USER_GUIDE.md)
8 #endif
9 
10 #if defined(ESP8266) || defined(ESP32)
11 
12 const char* strchr_P(const char* s, int c) {
13  char cc = c;
14  while (true) {
15  char d = pgm_read_byte(s);
16  if (cc == d) return s;
17  if (!d) return nullptr;
18  s++;
19  }
20 }
21 
22 const char* strrchr_P(const char* s, int c) {
23  char cc = c;
24  const char* found = nullptr;
25  while (true) {
26  char d = pgm_read_byte(s);
27  if (cc == d) found = s;
28  if (!d) break;
29  s++;
30  }
31  return found;
32 }
33 
34 #endif
35 
36 int acetime_strcmp_PP(const char* a, const char* b) {
37  if (a == b) { return 0; }
38  if (a == nullptr) { return -1; }
39  if (b == nullptr) { return 1; }
40 
41  while (true) {
42  uint8_t ca = pgm_read_byte(a);
43  uint8_t cb = pgm_read_byte(b);
44  if (ca != cb) return (int) ca - (int) cb;
45  if (ca == '\0') return 0;
46  a++;
47  b++;
48  }
49 }
int acetime_strcmp_PP(const char *a, const char *b)
Compare 2 strings in flash memory.
Definition: compat.cpp:36
Macros and definitions that provide a consistency layer among the various Arduino boards for compatib...