xref: /titanic_44/usr/src/cmd/ssh/include/misc.h (revision 6f8d59d8fcaf391990ca04c7bdcf65ab23320fe0)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * Author: Tatu Ylonen <ylo@cs.hut.fi>
37c478bd9Sstevel@tonic-gate  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
47c478bd9Sstevel@tonic-gate  *                    All rights reserved
57c478bd9Sstevel@tonic-gate  *
67c478bd9Sstevel@tonic-gate  * As far as I am concerned, the code I have written for this software
77c478bd9Sstevel@tonic-gate  * can be used freely for any purpose.  Any derived versions of this
87c478bd9Sstevel@tonic-gate  * software must be clearly marked as such, and if the derived work is
97c478bd9Sstevel@tonic-gate  * incompatible with the protocol description in the RFC file, it must be
107c478bd9Sstevel@tonic-gate  * called by a name other than "ssh" or "Secure Shell".
117c478bd9Sstevel@tonic-gate  */
127c478bd9Sstevel@tonic-gate /*
13*6f8d59d8SJan Pechanec  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
147c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
157c478bd9Sstevel@tonic-gate  */
167c478bd9Sstevel@tonic-gate 
1790685d2cSjp161948 #ifndef	_MISC_H
1890685d2cSjp161948 #define	_MISC_H
1990685d2cSjp161948 
2090685d2cSjp161948 /*	$OpenBSD: misc.h,v 1.12 2002/03/19 10:49:35 markus Exp $	*/
2190685d2cSjp161948 
2290685d2cSjp161948 #ifdef __cplusplus
2390685d2cSjp161948 extern "C" {
2490685d2cSjp161948 #endif
2590685d2cSjp161948 
267c478bd9Sstevel@tonic-gate char	*chop(char *);
277c478bd9Sstevel@tonic-gate char	*strdelim(char **);
287c478bd9Sstevel@tonic-gate void	 set_nonblock(int);
297c478bd9Sstevel@tonic-gate void	 unset_nonblock(int);
307c478bd9Sstevel@tonic-gate void	 set_nodelay(int);
317c478bd9Sstevel@tonic-gate int	 a2port(const char *);
327c478bd9Sstevel@tonic-gate char	*cleanhostname(char *);
339b03ea0fSjp161948 char	*hpdelim(char **);
347c478bd9Sstevel@tonic-gate char	*colon(char *);
357c478bd9Sstevel@tonic-gate long	 convtime(const char *);
36*6f8d59d8SJan Pechanec char	*percent_expand(const char *, ...);
37383a1232Sjp161948 char	*tohex(const void *, size_t);
3890685d2cSjp161948 void	 sanitise_stdfd(void);
39e5e9dedaSjp161948 int	 get_yes_no_flag(int *option, const char *arg, const char *filename,
40e5e9dedaSjp161948 		    int linenum, int active);
415d7f3ec0Sjp161948 char    *tolowercase(const char *s);
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate struct passwd	*pwcopy(struct passwd *);
447c478bd9Sstevel@tonic-gate void		 pwfree(struct passwd **);
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate typedef struct arglist arglist;
477c478bd9Sstevel@tonic-gate struct arglist {
487c478bd9Sstevel@tonic-gate 	char    **list;
497c478bd9Sstevel@tonic-gate 	int     num;
507c478bd9Sstevel@tonic-gate 	int     nalloc;
517c478bd9Sstevel@tonic-gate };
527c478bd9Sstevel@tonic-gate void	 addargs(arglist *, char *, ...) __attribute__((format(printf, 2, 3)));
5390685d2cSjp161948 void	 replacearg(arglist *, u_int, char *, ...)
5490685d2cSjp161948 	     __attribute__((format(printf, 3, 4)));
55a7e50fb1Sjp161948 void	 freeargs(arglist *);
567c478bd9Sstevel@tonic-gate 
577c478bd9Sstevel@tonic-gate /* wrapper for signal interface */
587c478bd9Sstevel@tonic-gate typedef void (*mysig_t)(int);
597c478bd9Sstevel@tonic-gate mysig_t mysignal(int sig, mysig_t act);
607c478bd9Sstevel@tonic-gate 
6190685d2cSjp161948 /* Functions to extract or store big-endian words of various sizes */
6290685d2cSjp161948 u_int64_t	get_u64(const void *)
6390685d2cSjp161948     __attribute__((__bounded__( __minbytes__, 1, 8)));
6490685d2cSjp161948 u_int32_t	get_u32(const void *)
6590685d2cSjp161948     __attribute__((__bounded__( __minbytes__, 1, 4)));
6690685d2cSjp161948 u_int16_t	get_u16(const void *)
6790685d2cSjp161948     __attribute__((__bounded__( __minbytes__, 1, 2)));
6890685d2cSjp161948 void		put_u64(void *, u_int64_t)
6990685d2cSjp161948     __attribute__((__bounded__( __minbytes__, 1, 8)));
7090685d2cSjp161948 void		put_u32(void *, u_int32_t)
7190685d2cSjp161948     __attribute__((__bounded__( __minbytes__, 1, 4)));
7290685d2cSjp161948 void		put_u16(void *, u_int16_t)
7390685d2cSjp161948     __attribute__((__bounded__( __minbytes__, 1, 2)));
7490685d2cSjp161948 
757c478bd9Sstevel@tonic-gate #ifdef __cplusplus
767c478bd9Sstevel@tonic-gate }
777c478bd9Sstevel@tonic-gate #endif
787c478bd9Sstevel@tonic-gate 
797c478bd9Sstevel@tonic-gate #endif /* _MISC_H */
80