The Android Open Source Project | f7fc46c | 2009-03-03 19:29:23 -0800 | [diff] [blame] | 1 | /* $OpenBSD: misc.h,v 1.12 2002/03/19 10:49:35 markus Exp $ */ |
| 2 | |
| 3 | /* |
| 4 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
| 5 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
| 6 | * All rights reserved |
| 7 | * |
| 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". |
| 13 | */ |
| 14 | |
| 15 | /* actually from atomicio, but is only used in scp code */ |
| 16 | #define vwrite (ssize_t (*)(int, void *, size_t))write |
| 17 | |
| 18 | char *chop(char *); |
| 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 *); |
| 25 | char *colon(char *); |
| 26 | long convtime(const char *); |
| 27 | |
| 28 | struct passwd *pwcopy(struct passwd *); |
| 29 | |
| 30 | typedef struct arglist arglist; |
| 31 | struct arglist { |
| 32 | char **list; |
| 33 | int num; |
| 34 | int nalloc; |
| 35 | }; |
| 36 | void addargs(arglist *, char *, ...); |
| 37 | void replacearg(arglist *, u_int, char *, ...); |
| 38 | void freeargs(arglist *); |
| 39 | |
| 40 | /* from xmalloc.h */ |
| 41 | void *xmalloc(size_t); |
| 42 | void *xrealloc(void *, size_t); |
| 43 | void xfree(void *); |
| 44 | char *xstrdup(const char *); |
| 45 | |
| 46 | char *ssh_get_progname(char *); |
| 47 | void fatal(char* fmt,...); |
| 48 | void sanitise_stdfd(void); |
| 49 | |
| 50 | /* Required for non-BSD platforms, from OpenSSH's defines.h */ |
| 51 | #ifndef timersub |
| 52 | #define timersub(a, b, result) \ |
| 53 | do { \ |
| 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) { \ |
| 57 | --(result)->tv_sec; \ |
| 58 | (result)->tv_usec += 1000000; \ |
| 59 | } \ |
| 60 | } while (0) |
| 61 | #endif |
| 62 | |
| 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; \ |
| 67 | } |
| 68 | #endif |
| 69 | |