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