scpmisc.h 2.0 KB

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