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