scpmisc.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. char *chop(char *);
  14. char *strdelim(char **);
  15. void set_nonblock(int);
  16. void unset_nonblock(int);
  17. void set_nodelay(int);
  18. int a2port(const char *);
  19. char *cleanhostname(char *);
  20. char *colon(char *);
  21. long convtime(const char *);
  22. struct passwd *pwcopy(struct passwd *);
  23. typedef struct arglist arglist;
  24. struct arglist {
  25. char **list;
  26. u_int num;
  27. u_int nalloc;
  28. };
  29. void addargs(arglist *, char *, ...);
  30. void replacearg(arglist *, u_int, char *, ...);
  31. void freeargs(arglist *);
  32. /* from xmalloc.h */
  33. void *xmalloc(size_t);
  34. void *xrealloc(void *, size_t);
  35. void xfree(void *);
  36. char *xstrdup(const char *);
  37. char *ssh_get_progname(char *);
  38. void fatal(char* fmt,...);
  39. void sanitise_stdfd(void);
  40. /* Required for non-BSD platforms, from OpenSSH's defines.h */
  41. #ifndef timersub
  42. #define timersub(a, b, result) \
  43. do { \
  44. (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
  45. (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
  46. if ((result)->tv_usec < 0) { \
  47. --(result)->tv_sec; \
  48. (result)->tv_usec += 1000000; \
  49. } \
  50. } while (0)
  51. #endif
  52. #ifndef TIMEVAL_TO_TIMESPEC
  53. #define TIMEVAL_TO_TIMESPEC(tv, ts) { \
  54. (ts)->tv_sec = (tv)->tv_sec; \
  55. (ts)->tv_nsec = (tv)->tv_usec * 1000; \
  56. }
  57. #endif