xref: /titanic_44/usr/src/cmd/ssh/include/misc.h (revision 159d09a20817016f09b3ea28d1bdada4a336bb91)
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	*hpdelim(char **);
36 char	*colon(char *);
37 long	 convtime(const char *);
38 char	*tohex(const void *, size_t);
39 void	 sanitise_stdfd(void);
40 int	 get_yes_no_flag(int *option, const char *arg, const char *filename,
41 		    int linenum, int active);
42 char    *tolowercase(const char *s);
43 
44 struct passwd	*pwcopy(struct passwd *);
45 void		 pwfree(struct passwd **);
46 
47 typedef struct arglist arglist;
48 struct arglist {
49 	char    **list;
50 	int     num;
51 	int     nalloc;
52 };
53 void	 addargs(arglist *, char *, ...) __attribute__((format(printf, 2, 3)));
54 void	 replacearg(arglist *, u_int, char *, ...)
55 	     __attribute__((format(printf, 3, 4)));
56 void	 freeargs(arglist *);
57 
58 /* wrapper for signal interface */
59 typedef void (*mysig_t)(int);
60 mysig_t mysignal(int sig, mysig_t act);
61 
62 /* Functions to extract or store big-endian words of various sizes */
63 u_int64_t	get_u64(const void *)
64     __attribute__((__bounded__( __minbytes__, 1, 8)));
65 u_int32_t	get_u32(const void *)
66     __attribute__((__bounded__( __minbytes__, 1, 4)));
67 u_int16_t	get_u16(const void *)
68     __attribute__((__bounded__( __minbytes__, 1, 2)));
69 void		put_u64(void *, u_int64_t)
70     __attribute__((__bounded__( __minbytes__, 1, 8)));
71 void		put_u32(void *, u_int32_t)
72     __attribute__((__bounded__( __minbytes__, 1, 4)));
73 void		put_u16(void *, u_int16_t)
74     __attribute__((__bounded__( __minbytes__, 1, 2)));
75 
76 #ifdef __cplusplus
77 }
78 #endif
79 
80 #endif /* _MISC_H */
81