compat.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * compat.h
  3. *
  4. * Compatibility functions for different OSes (prototypes)
  5. *
  6. * $Id: compat.h,v 1.5 2005/01/05 11:01:51 quozl Exp $
  7. */
  8. #ifndef _PPTPD_COMPAT_H
  9. #define _PPTPD_COMPAT_H
  10. #if HAVE_CONFIG_H
  11. #include "config.h"
  12. #endif
  13. #if HAVE_SETSID
  14. #define SETSIDPGRP setsid
  15. #else
  16. #define SETSIDPGRP setpgrp
  17. #endif
  18. #include <sys/types.h>
  19. #ifndef HAVE_STRLCPY
  20. /* void since to be fast and portable, we use strncpy, but this
  21. * means we don't know how many bytes were copied
  22. */
  23. extern void strlcpy(char *dst, const char *src, size_t size);
  24. #endif /* !HAVE_STRLCPY */
  25. #ifndef HAVE_MEMMOVE
  26. extern void *memmove(void *dst, const void *src, size_t size);
  27. #endif /* !HAVE_MEMMOVE */
  28. #ifndef HAVE_OPENPTY
  29. /* Originally from code by C. S. Ananian */
  30. /* These are the Linux values - and fairly sane defaults.
  31. * Since we search from the start and just skip errors, they'll do.
  32. * Note that Unix98 has an openpty() call so we don't need to worry
  33. * about the new pty names here.
  34. */
  35. #define PTYDEV "/dev/ptyxx"
  36. #define TTYDEV "/dev/ttyxx"
  37. #define PTYMAX 11
  38. #define TTYMAX 11
  39. #define PTYCHAR1 "pqrstuvwxyzabcde"
  40. #define PTYCHAR2 "0123456789abcdef"
  41. /* Dummy the last 2 args, so we don't have to find the right include
  42. * files on every OS to define the needed structures.
  43. */
  44. extern int openpty(int *, int *, char *, void *, void *);
  45. #endif /* !HAVE_OPENPTY */
  46. #ifndef HAVE_STRERROR
  47. extern char *strerror(int);
  48. #endif
  49. extern void my_setproctitle(int argc, char **argv, const char *format, ...)
  50. __attribute__ ((format (printf, 3, 4)));
  51. /* signal to pipe delivery implementation */
  52. /* create a signal pipe, returns 0 for success, -1 with errno for failure */
  53. int sigpipe_create();
  54. /* generic handler for signals, writes signal number to pipe */
  55. void sigpipe_handler(int signum);
  56. /* assign a signal number to the pipe */
  57. void sigpipe_assign(int signum);
  58. /* return the signal pipe read file descriptor for select(2) */
  59. int sigpipe_fd();
  60. /* read and return the pending signal from the pipe */
  61. int sigpipe_read();
  62. void sigpipe_close();
  63. #endif /* !_PPTPD_COMPAT_H */