1 /* $OpenBSD: misc.h,v 1.12 2002/03/19 10:49:35 markus Exp $ */
4 * Author: Tatu Ylonen <ylo@cs.hut.fi>
5 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8 * As far as I am concerned, the code I have written for this software
9 * can be used freely for any purpose. Any derived versions of this
10 * software must be clearly marked as such, and if the derived work is
11 * incompatible with the protocol description in the RFC file, it must be
12 * called by a name other than "ssh" or "Secure Shell".
15 /* actually from atomicio, but is only used in scp code */
16 #define vwrite (ssize_t (*)(int, void *, size_t))write
19 char *strdelim(char **);
20 void set_nonblock(int);
21 void unset_nonblock(int);
22 void set_nodelay(int);
23 int a2port(const char *);
24 char *cleanhostname(char *);
26 long convtime(const char *);
28 struct passwd
*pwcopy(struct passwd
*);
30 typedef struct arglist arglist
;
36 void addargs(arglist
*, char *, ...);
37 void replacearg(arglist
*, u_int
, char *, ...);
38 void freeargs(arglist
*);
41 void *xmalloc(size_t);
42 void *xrealloc(void *, size_t);
44 char *xstrdup(const char *);
46 char *ssh_get_progname(char *);
47 void fatal(char* fmt
,...);
48 void sanitise_stdfd(void);
50 /* Required for non-BSD platforms, from OpenSSH's defines.h */
52 #define timersub(a, b, result) \
54 (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
55 (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
56 if ((result)->tv_usec < 0) { \
58 (result)->tv_usec += 1000000; \
63 #ifndef TIMEVAL_TO_TIMESPEC
64 #define TIMEVAL_TO_TIMESPEC(tv, ts) { \
65 (ts)->tv_sec = (tv)->tv_sec; \
66 (ts)->tv_nsec = (tv)->tv_usec * 1000; \