_syslog_build.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. from cffi import FFI
  2. ffi = FFI()
  3. ffi.set_source("_syslog_cffi", """
  4. #include <syslog.h>
  5. #ifndef LOG_NOWAIT
  6. #define LOG_NOWAIT -919919
  7. #endif
  8. #ifndef LOG_PERROR
  9. #define LOG_PERROR -919919
  10. #endif
  11. #ifndef LOG_SYSLOG
  12. #define LOG_SYSLOG LOG_DAEMON
  13. #endif
  14. #ifndef LOG_CRON
  15. #define LOG_CRON LOG_DAEMON
  16. #endif
  17. #ifndef LOG_UUCP
  18. #define LOG_UUCP LOG_MAIL
  19. #endif
  20. #ifndef LOG_NEWS
  21. #define LOG_NEWS LOG_MAIL
  22. #endif
  23. """)
  24. ffi.cdef("""
  25. /* mandatory constants */
  26. #define LOG_EMERG ...
  27. #define LOG_ALERT ...
  28. #define LOG_CRIT ...
  29. #define LOG_ERR ...
  30. #define LOG_WARNING ...
  31. #define LOG_NOTICE ...
  32. #define LOG_INFO ...
  33. #define LOG_DEBUG ...
  34. #define LOG_PID ...
  35. #define LOG_CONS ...
  36. #define LOG_NDELAY ...
  37. #define LOG_KERN ...
  38. #define LOG_USER ...
  39. #define LOG_MAIL ...
  40. #define LOG_DAEMON ...
  41. #define LOG_AUTH ...
  42. #define LOG_LPR ...
  43. #define LOG_LOCAL0 ...
  44. #define LOG_LOCAL1 ...
  45. #define LOG_LOCAL2 ...
  46. #define LOG_LOCAL3 ...
  47. #define LOG_LOCAL4 ...
  48. #define LOG_LOCAL5 ...
  49. #define LOG_LOCAL6 ...
  50. #define LOG_LOCAL7 ...
  51. /* optional constants, gets defined to -919919 if missing */
  52. #define LOG_NOWAIT ...
  53. #define LOG_PERROR ...
  54. /* aliased constants, gets defined as some other constant if missing */
  55. #define LOG_SYSLOG ...
  56. #define LOG_CRON ...
  57. #define LOG_UUCP ...
  58. #define LOG_NEWS ...
  59. /* functions */
  60. void openlog(const char *ident, int option, int facility);
  61. void syslog(int priority, const char *format, const char *string);
  62. // NB. the signature of syslog() is specialized to the only case we use
  63. void closelog(void);
  64. int setlogmask(int mask);
  65. """)
  66. if __name__ == "__main__":
  67. ffi.compile()