banned.h 953 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * Copyright (C) 2021 Kovid Goyal <kovid at kovidgoyal.net>
  3. *
  4. * Distributed under terms of the GPL3 license.
  5. */
  6. #pragma once
  7. #define BANNED(func) sorry_##func##_is_a_banned_function
  8. #undef strcpy
  9. #define strcpy(x,y) BANNED(strcpy)
  10. #undef strcat
  11. #define strcat(x,y) BANNED(strcat)
  12. #undef strncpy
  13. #define strncpy(x,y,n) BANNED(strncpy)
  14. #undef strncat
  15. #define strncat(x,y,n) BANNED(strncat)
  16. #undef sprintf
  17. #undef vsprintf
  18. #ifdef HAVE_VARIADIC_MACROS
  19. #define sprintf(...) BANNED(sprintf)
  20. #define vsprintf(...) BANNED(vsprintf)
  21. #else
  22. #define sprintf(buf,fmt,arg) BANNED(sprintf)
  23. #define vsprintf(buf,fmt,arg) BANNED(vsprintf)
  24. #endif
  25. #undef gmtime
  26. #define gmtime(t) BANNED(gmtime)
  27. #undef localtime
  28. #define localtime(t) BANNED(localtime)
  29. #undef ctime
  30. #define ctime(t) BANNED(ctime)
  31. #undef ctime_r
  32. #define ctime_r(t, buf) BANNED(ctime_r)
  33. #undef asctime
  34. #define asctime(t) BANNED(asctime)
  35. #undef asctime_r
  36. #define asctime_r(t, buf) BANNED(asctime_r)