1 /*
   2  * Author: Tatu Ylonen <ylo@cs.hut.fi>
   3  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
   4  *                    All rights reserved
   5  *
   6  * As far as I am concerned, the code I have written for this software
   7  * can be used freely for any purpose.  Any derived versions of this
   8  * software must be clearly marked as such, and if the derived work is
   9  * incompatible with the protocol description in the RFC file, it must be
  10  * called by a name other than "ssh" or "Secure Shell".
  11  */
  12 /*
  13  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  14  * Use is subject to license terms.
  15  */
  16 
  17 #ifndef _MISC_H
  18 #define _MISC_H
  19 
  20 /*      $OpenBSD: misc.h,v 1.12 2002/03/19 10:49:35 markus Exp $        */
  21 
  22 #ifdef __cplusplus
  23 extern "C" {
  24 #endif
  25 
  26 char    *chop(char *);
  27 char    *strdelim(char **);
  28 void     set_nonblock(int);
  29 void     unset_nonblock(int);
  30 void     set_nodelay(int);
  31 int      a2port(const char *);
  32 char    *cleanhostname(char *);
  33 char    *hpdelim(char **);
  34 char    *colon(char *);
  35 long     convtime(const char *);
  36 char    *percent_expand(const char *, ...);
  37 char    *tohex(const void *, size_t);
  38 void     sanitise_stdfd(void);
  39 int      get_yes_no_flag(int *option, const char *arg, const char *filename,
  40                     int linenum, int active);
  41 char    *tolowercase(const char *s);
  42 
  43 struct passwd   *pwcopy(struct passwd *);
  44 void             pwfree(struct passwd **);
  45 
  46 typedef struct arglist arglist;
  47 struct arglist {
  48         char    **list;
  49         int     num;
  50         int     nalloc;
  51 };
  52 void     addargs(arglist *, char *, ...) __attribute__((format(printf, 2, 3)));
  53 void     replacearg(arglist *, u_int, char *, ...)
  54              __attribute__((format(printf, 3, 4)));
  55 void     freeargs(arglist *);
  56 
  57 /* wrapper for signal interface */
  58 typedef void (*mysig_t)(int);
  59 mysig_t mysignal(int sig, mysig_t act);
  60 
  61 /* Functions to extract or store big-endian words of various sizes */
  62 u_int64_t       get_u64(const void *)
  63     __attribute__((__bounded__( __minbytes__, 1, 8)));
  64 u_int32_t       get_u32(const void *)
  65     __attribute__((__bounded__( __minbytes__, 1, 4)));
  66 u_int16_t       get_u16(const void *)
  67     __attribute__((__bounded__( __minbytes__, 1, 2)));
  68 void            put_u64(void *, u_int64_t)
  69     __attribute__((__bounded__( __minbytes__, 1, 8)));
  70 void            put_u32(void *, u_int32_t)
  71     __attribute__((__bounded__( __minbytes__, 1, 4)));
  72 void            put_u16(void *, u_int16_t)
  73     __attribute__((__bounded__( __minbytes__, 1, 2)));
  74 
  75 #ifdef __cplusplus
  76 }
  77 #endif
  78 
  79 #endif /* _MISC_H */