ESPTerm - ESP8266 terminal emulator. Branches: [master] patches, [work] next release
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
espterm-firmware/include/helpers.h

25 lines
805 B

//
// Created by MightyPork on 2017/07/23.
//
#ifndef ESP_VT100_FIRMWARE_HELPERS_H
#define ESP_VT100_FIRMWARE_HELPERS_H
// strcpy that adds 0 at the end of the buffer. Returns void.
#define strncpy_safe(dst, src, n) do { strncpy((char *)(dst), (char *)(src), (n)); (dst)[(n)-1]=0; } while (0)
/**
* Convert IP hex to arguments for printf.
* Library IP2STR(ip) does not work correctly due to unaligned memory access.
*/
#define GOOD_IP2STR(ip) ((ip)>>0)&0xff, ((ip)>>8)&0xff, ((ip)>>16)&0xff, ((ip)>>24)&0xff
/**
* Helper that retrieves an arg from `connData->getArgs` and stores it in `buff`. Returns 1 on success
*/
#define GET_ARG(key) (httpdFindArg(connData->getArgs, key, buff, sizeof(buff)) >= 0)
#define STR_HELPER(x) #x
#define STR(x) STR_HELPER(x)
#endif //ESP_VT100_FIRMWARE_HELPERS_H