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.

27 lines
754 B

  1. #ifndef _UTILS_H
  2. #define _UTILS_H
  3. #define STR(x) #x
  4. #define TOSTR(x) STR(x)
  5. #define TIME_FORMAT "%F %T"
  6. #define LOGD(format, ...) do {\
  7. time_t now = time(NULL);\
  8. char timestr[20];\
  9. strftime(timestr, 20, TIME_FORMAT, localtime(&now));\
  10. fprintf(stderr, "\e[01;32m %s INFO: \e[0m" format "\n", timestr, ##__VA_ARGS__);}\
  11. while(0)
  12. #define LOGE(format, ...) do {\
  13. time_t now = time(NULL);\
  14. char timestr[20];\
  15. strftime(timestr, 20, TIME_FORMAT, localtime(&now));\
  16. fprintf(stderr, "\e[01;35m %s ERROR: \e[0m" format " on File: %s Line: %s\n", timestr, ##__VA_ARGS__, __FILE__, TOSTR(__LINE__));}\
  17. while(0)
  18. void FATAL(const char *msg);
  19. void usage(void);
  20. void demonize(const char* path);
  21. char *itoa(int i);
  22. #endif // _UTILS_H