1
0

compat.h 2.0 KB

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