1 /*        $NetBSD: l_stdlib.h,v 1.6 2022/10/09 21:41:03 christos Exp $          */
2 
3 /*
4  * Proto types for machines that are not ANSI and POSIX      compliant.
5  * This is optional
6  */
7 
8 #ifndef L_STDLIB_H
9 #define L_STDLIB_H
10 
11 #ifdef HAVE_STDLIB_H
12 # include <stdlib.h>
13 #endif
14 
15 #include <stdarg.h>
16 #include <sys/types.h>
17 
18 /* Needed for speed_t. */
19 #ifdef HAVE_TERMIOS_H
20 # include <termios.h>
21 #endif
22 
23 #ifdef HAVE_ERRNO_H
24 # include <errno.h>
25 #endif
26 
27 #include "ntp_types.h"
28 #include "ntp_proto.h"
29 
30 /* Let's try to keep this more or less alphabetized... */
31 
32 #ifdef DECL_ADJTIME_0
33 struct timeval;
34 extern    int       adjtime             (struct timeval *, struct timeval *);
35 #endif
36 
37 #ifdef DECL_BCOPY_0
38 #ifndef bcopy
39 extern    void      bcopy               (const char *, char *, int);
40 #endif
41 #endif
42 
43 #ifdef DECL_BZERO_0
44 #ifndef bzero
45 extern    void      bzero               (char *, int);
46 #endif
47 #endif
48 
49 #ifdef DECL_CFSETISPEED_0
50 struct termios;
51 extern    int       cfsetispeed         (struct termios *, speed_t);
52 extern    int       cfsetospeed         (struct termios *, speed_t);
53 #endif
54 
55 extern    char *    getpass             (const char *);
56 
57 #ifdef DECL_HSTRERROR_0
58 extern    const char * hstrerror        (int);
59 #endif
60 
61 #ifdef DECL_INET_NTOA_0
62 struct in_addr;
63 extern    char *    inet_ntoa (struct in_addr);
64 #endif
65 
66 #ifdef DECL_IOCTL_0
67 extern    int       ioctl               (int, u_long, char *);
68 #endif
69 
70 #ifdef DECL_IPC_0
71 struct sockaddr;
72 extern    int       bind                (int, struct sockaddr *, int);
73 extern    int       connect             (int, struct sockaddr *, int);
74 extern    int       recv                (int, char *, int, int);
75 extern    int       recvfrom  (int, char *, int, int, struct sockaddr *, int *);
76 extern    int       send                (int, char *, int, int);
77 extern    int       sendto              (int, char *, int, int, struct sockaddr *, int);
78 extern    int       setsockopt          (int, int, int, char *, int);
79 extern    int       socket              (int, int, int);
80 #endif
81 
82 #ifdef DECL_MEMMOVE_0
83 extern    void *    memmove             (void *, const void *, size_t);
84 #endif
85 
86 #ifdef DECL_MEMSET_0
87 extern    char *    memset              (char *, int, int);
88 #endif
89 
90 #ifdef DECL_MKSTEMP_0
91 extern    int       mkstemp             (char *);
92 #endif
93 
94 #ifdef DECL_MKTEMP_0
95 extern    char   *mktemp                (char *);
96 #endif
97 
98 #ifdef DECL_NLIST_0
99 struct nlist;
100 extern int          nlist               (const char *, struct nlist *);
101 #endif
102 
103 #ifdef DECL_PLOCK_0
104 extern    int       plock               (int);
105 #endif
106 
107 #ifdef DECL_RENAME_0
108 extern    int       rename              (const char *, const char *);
109 #endif
110 
111 #ifdef DECL_SELECT_0
112 #ifdef NTP_SELECT_H
113 extern    int       select              (int, fd_set *, fd_set *, fd_set *, struct timeval *);
114 #endif
115 #endif
116 
117 #ifdef DECL_SETITIMER_0
118 struct itimerval;
119 extern    int       setitimer (int , struct itimerval *, struct itimerval *);
120 #endif
121 
122 #ifdef PRIO_PROCESS
123 #ifdef DECL_SETPRIORITY_0
124 extern    int       setpriority         (int, int, int);
125 #endif
126 #ifdef DECL_SETPRIORITY_1
127 extern    int       setpriority         (int, id_t, int);
128 #endif
129 #endif
130 
131 #ifdef DECL_SIGVEC_0
132 struct sigvec;
133 extern    int       sigvec              (int, struct sigvec *, struct sigvec *);
134 #endif
135 
136 #ifdef DECL_STDIO_0
137 #if defined(FILE) || defined(BUFSIZ)
138 extern    int       _flsbuf             (int, FILE *);
139 extern    int       _filbuf             (FILE *);
140 extern    int       fclose              (FILE *);
141 extern    int       fflush              (FILE *);
142 extern    int       fprintf             (FILE *, const char *, ...);
143 extern    int       fscanf              (FILE *, const char *, ...);
144 extern    int       fputs               (const char *, FILE *);
145 extern    int       fputc               (int, FILE *);
146 extern    int       fread               (char *, int, int, FILE *);
147 extern    void      perror              (const char *);
148 extern    int       printf              (const char *, ...);
149 extern    int       setbuf              (FILE *, char *);
150 # ifdef HAVE_SETLINEBUF
151 extern    int       setlinebuf          (FILE *);
152 # endif
153 extern    int       setvbuf             (FILE *, char *, int, int);
154 extern    int       scanf               (const char *, ...);
155 extern    int       sscanf              (const char *, const char *, ...);
156 extern    int       vfprintf  (FILE *, const char *, ...);
157 extern    int       vsprintf  (char *, const char *, ...);
158 #endif
159 #endif
160 
161 #ifdef DECL_STIME_0
162 extern    int       stime               (const time_t *);
163 #endif
164 
165 #ifdef DECL_STIME_1
166 extern    int       stime               (long *);
167 #endif
168 
169 #ifdef DECL_STRERROR_0
170 extern    char *    strerror            (int errnum);
171 #endif
172 
173 #ifdef DECL_STRTOL_0
174 extern    long      strtol              (const char *, char **, int);
175 #endif
176 
177 #ifdef DECL_SYSCALL
178 extern    int       syscall             (int, ...);
179 #endif
180 
181 #ifdef DECL_SYSLOG_0
182 extern    void      closelog  (void);
183 #ifndef LOG_DAEMON
184 extern    void      openlog             (const char *, int);
185 #else
186 extern    void      openlog             (const char *, int, int);
187 #endif
188 extern    int       setlogmask          (int);
189 extern    void      syslog              (int, const char *, ...);
190 #endif
191 
192 #ifdef DECL_TIME_0
193 extern    time_t    time                (time_t *);
194 #endif
195 
196 #ifdef DECL_TIMEOFDAY_0
197 #ifdef SYSV_TIMEOFDAY
198 extern    int       gettimeofday        (struct timeval *);
199 extern    int       settimeofday        (struct timeval *);
200 #else /* not SYSV_TIMEOFDAY */
201 struct timezone;
202 extern    int       gettimeofday        (struct timeval *, struct timezone *);
203 extern    int       settimeofday        (struct timeval *, void *);
204 #endif /* not SYSV_TIMEOFDAY */
205 #endif
206 
207 #ifdef DECL_TOLOWER_0
208 extern    int       tolower             (int);
209 #endif
210 
211 #ifdef DECL_TOUPPER_0
212 extern    int       toupper             (int);
213 #endif
214 
215 /*
216  * Necessary variable declarations.
217  */
218 #ifdef DECL_ERRNO
219 extern    int       errno;
220 #endif
221 
222 #if defined(DECL_H_ERRNO) && !defined(h_errno)
223 extern    int       h_errno;
224 #endif
225 
226 #ifndef HAVE_MEMCHR
227 extern void *memchr(const void *s, int c, size_t n);
228 #endif
229 
230 #ifndef HAVE_STRNLEN
231 extern size_t strnlen(const char *s, size_t n);
232 #endif
233 
234 
235 #endif    /* L_STDLIB_H */
236