xref: /titanic_44/usr/src/cmd/ssh/include/misc.h (revision 1d03c31e0733adea0edef54f0d5d2ea9639ecd2a)
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 2007 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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 char	*chop(char *);
29 char	*strdelim(char **);
30 void	 set_nonblock(int);
31 void	 unset_nonblock(int);
32 void	 set_nodelay(int);
33 int	 a2port(const char *);
34 char	*cleanhostname(char *);
35 char	*colon(char *);
36 long	 convtime(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 
42 struct passwd	*pwcopy(struct passwd *);
43 void		 pwfree(struct passwd **);
44 
45 typedef struct arglist arglist;
46 struct arglist {
47 	char    **list;
48 	int     num;
49 	int     nalloc;
50 };
51 void	 addargs(arglist *, char *, ...) __attribute__((format(printf, 2, 3)));
52 void	 replacearg(arglist *, u_int, char *, ...)
53 	     __attribute__((format(printf, 3, 4)));
54 void	 freeargs(arglist *);
55 
56 /* wrapper for signal interface */
57 typedef void (*mysig_t)(int);
58 mysig_t mysignal(int sig, mysig_t act);
59 
60 /* Functions to extract or store big-endian words of various sizes */
61 u_int64_t	get_u64(const void *)
62     __attribute__((__bounded__( __minbytes__, 1, 8)));
63 u_int32_t	get_u32(const void *)
64     __attribute__((__bounded__( __minbytes__, 1, 4)));
65 u_int16_t	get_u16(const void *)
66     __attribute__((__bounded__( __minbytes__, 1, 2)));
67 void		put_u64(void *, u_int64_t)
68     __attribute__((__bounded__( __minbytes__, 1, 8)));
69 void		put_u32(void *, u_int32_t)
70     __attribute__((__bounded__( __minbytes__, 1, 4)));
71 void		put_u16(void *, u_int16_t)
72     __attribute__((__bounded__( __minbytes__, 1, 2)));
73 
74 #ifdef __cplusplus
75 }
76 #endif
77 
78 #endif /* _MISC_H */
79