xref: /onnv-gate/usr/src/cmd/ssh/include/misc.h (revision 9139:84e06a454b4b)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * Author: Tatu Ylonen <ylo@cs.hut.fi>
30Sstevel@tonic-gate  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
40Sstevel@tonic-gate  *                    All rights reserved
50Sstevel@tonic-gate  *
60Sstevel@tonic-gate  * As far as I am concerned, the code I have written for this software
70Sstevel@tonic-gate  * can be used freely for any purpose.  Any derived versions of this
80Sstevel@tonic-gate  * software must be clearly marked as such, and if the derived work is
90Sstevel@tonic-gate  * incompatible with the protocol description in the RFC file, it must be
100Sstevel@tonic-gate  * called by a name other than "ssh" or "Secure Shell".
110Sstevel@tonic-gate  */
120Sstevel@tonic-gate /*
13*9139SJan.Pechanec@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
140Sstevel@tonic-gate  * Use is subject to license terms.
150Sstevel@tonic-gate  */
160Sstevel@tonic-gate 
175087Sjp161948 #ifndef	_MISC_H
185087Sjp161948 #define	_MISC_H
195087Sjp161948 
205087Sjp161948 /*	$OpenBSD: misc.h,v 1.12 2002/03/19 10:49:35 markus Exp $	*/
215087Sjp161948 
225087Sjp161948 #ifdef __cplusplus
235087Sjp161948 extern "C" {
245087Sjp161948 #endif
255087Sjp161948 
260Sstevel@tonic-gate char	*chop(char *);
270Sstevel@tonic-gate char	*strdelim(char **);
280Sstevel@tonic-gate void	 set_nonblock(int);
290Sstevel@tonic-gate void	 unset_nonblock(int);
300Sstevel@tonic-gate void	 set_nodelay(int);
310Sstevel@tonic-gate int	 a2port(const char *);
320Sstevel@tonic-gate char	*cleanhostname(char *);
335334Sjp161948 char	*hpdelim(char **);
340Sstevel@tonic-gate char	*colon(char *);
350Sstevel@tonic-gate long	 convtime(const char *);
36*9139SJan.Pechanec@Sun.COM char	*percent_expand(const char *, ...);
374907Sjp161948 char	*tohex(const void *, size_t);
385087Sjp161948 void	 sanitise_stdfd(void);
394958Sjp161948 int	 get_yes_no_flag(int *option, const char *arg, const char *filename,
404958Sjp161948 		    int linenum, int active);
415266Sjp161948 char    *tolowercase(const char *s);
420Sstevel@tonic-gate 
430Sstevel@tonic-gate struct passwd	*pwcopy(struct passwd *);
440Sstevel@tonic-gate void		 pwfree(struct passwd **);
450Sstevel@tonic-gate 
460Sstevel@tonic-gate typedef struct arglist arglist;
470Sstevel@tonic-gate struct arglist {
480Sstevel@tonic-gate 	char    **list;
490Sstevel@tonic-gate 	int     num;
500Sstevel@tonic-gate 	int     nalloc;
510Sstevel@tonic-gate };
520Sstevel@tonic-gate void	 addargs(arglist *, char *, ...) __attribute__((format(printf, 2, 3)));
535087Sjp161948 void	 replacearg(arglist *, u_int, char *, ...)
545087Sjp161948 	     __attribute__((format(printf, 3, 4)));
552780Sjp161948 void	 freeargs(arglist *);
560Sstevel@tonic-gate 
570Sstevel@tonic-gate /* wrapper for signal interface */
580Sstevel@tonic-gate typedef void (*mysig_t)(int);
590Sstevel@tonic-gate mysig_t mysignal(int sig, mysig_t act);
600Sstevel@tonic-gate 
615087Sjp161948 /* Functions to extract or store big-endian words of various sizes */
625087Sjp161948 u_int64_t	get_u64(const void *)
635087Sjp161948     __attribute__((__bounded__( __minbytes__, 1, 8)));
645087Sjp161948 u_int32_t	get_u32(const void *)
655087Sjp161948     __attribute__((__bounded__( __minbytes__, 1, 4)));
665087Sjp161948 u_int16_t	get_u16(const void *)
675087Sjp161948     __attribute__((__bounded__( __minbytes__, 1, 2)));
685087Sjp161948 void		put_u64(void *, u_int64_t)
695087Sjp161948     __attribute__((__bounded__( __minbytes__, 1, 8)));
705087Sjp161948 void		put_u32(void *, u_int32_t)
715087Sjp161948     __attribute__((__bounded__( __minbytes__, 1, 4)));
725087Sjp161948 void		put_u16(void *, u_int16_t)
735087Sjp161948     __attribute__((__bounded__( __minbytes__, 1, 2)));
745087Sjp161948 
750Sstevel@tonic-gate #ifdef __cplusplus
760Sstevel@tonic-gate }
770Sstevel@tonic-gate #endif
780Sstevel@tonic-gate 
790Sstevel@tonic-gate #endif /* _MISC_H */
80