xref: /dflybsd-src/lib/libssh/openbsd-compat/glob.h (revision 2c81fb9c483cc2c8f293c3c199fac04d266b4e1b)
1bc9cc675SDaniel Fojt /*	$OpenBSD: glob.h,v 1.14 2019/02/04 16:45:40 millert Exp $	*/
22c0338ffSzrj /*	$NetBSD: glob.h,v 1.5 1994/10/26 00:55:56 cgd Exp $	*/
32c0338ffSzrj 
42c0338ffSzrj /*
52c0338ffSzrj  * Copyright (c) 1989, 1993
62c0338ffSzrj  *	The Regents of the University of California.  All rights reserved.
72c0338ffSzrj  *
82c0338ffSzrj  * This code is derived from software contributed to Berkeley by
92c0338ffSzrj  * Guido van Rossum.
102c0338ffSzrj  *
112c0338ffSzrj  * Redistribution and use in source and binary forms, with or without
122c0338ffSzrj  * modification, are permitted provided that the following conditions
132c0338ffSzrj  * are met:
142c0338ffSzrj  * 1. Redistributions of source code must retain the above copyright
152c0338ffSzrj  *    notice, this list of conditions and the following disclaimer.
162c0338ffSzrj  * 2. Redistributions in binary form must reproduce the above copyright
172c0338ffSzrj  *    notice, this list of conditions and the following disclaimer in the
182c0338ffSzrj  *    documentation and/or other materials provided with the distribution.
192c0338ffSzrj  * 3. Neither the name of the University nor the names of its contributors
202c0338ffSzrj  *    may be used to endorse or promote products derived from this software
212c0338ffSzrj  *    without specific prior written permission.
222c0338ffSzrj  *
232c0338ffSzrj  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
242c0338ffSzrj  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
252c0338ffSzrj  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
262c0338ffSzrj  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
272c0338ffSzrj  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
282c0338ffSzrj  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
292c0338ffSzrj  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
302c0338ffSzrj  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
312c0338ffSzrj  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
322c0338ffSzrj  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
332c0338ffSzrj  * SUCH DAMAGE.
342c0338ffSzrj  *
352c0338ffSzrj  *	@(#)glob.h	8.1 (Berkeley) 6/2/93
362c0338ffSzrj  */
372c0338ffSzrj 
382c0338ffSzrj /* OPENBSD ORIGINAL: include/glob.h */
392c0338ffSzrj 
402c0338ffSzrj #if !defined(HAVE_GLOB_H) || !defined(GLOB_HAS_ALTDIRFUNC) || \
412c0338ffSzrj     !defined(GLOB_HAS_GL_MATCHC) || !defined(GLOB_HAS_GL_STATV) || \
422c0338ffSzrj     !defined(HAVE_DECL_GLOB_NOMATCH) || HAVE_DECL_GLOB_NOMATCH == 0 || \
432c0338ffSzrj     defined(BROKEN_GLOB)
442c0338ffSzrj 
452c0338ffSzrj #ifndef _COMPAT_GLOB_H_
462c0338ffSzrj #define	_COMPAT_GLOB_H_
472c0338ffSzrj 
482c0338ffSzrj #include <sys/stat.h>
49bc9cc675SDaniel Fojt #include <sys/types.h>
502c0338ffSzrj 
512c0338ffSzrj # define glob_t _ssh_compat_glob_t
522c0338ffSzrj # define glob(a, b, c, d)  _ssh__compat_glob(a, b, c, d)
532c0338ffSzrj # define globfree(a)  _ssh__compat_globfree(a)
542c0338ffSzrj 
552c0338ffSzrj struct stat;
562c0338ffSzrj typedef struct {
57bc9cc675SDaniel Fojt 	size_t gl_pathc;	/* Count of total paths so far. */
58bc9cc675SDaniel Fojt 	size_t gl_matchc;	/* Count of paths matching pattern. */
59bc9cc675SDaniel Fojt 	size_t gl_offs;		/* Reserved at beginning of gl_pathv. */
602c0338ffSzrj 	int gl_flags;		/* Copy of flags parameter to glob. */
612c0338ffSzrj 	char **gl_pathv;	/* List of paths matching pattern. */
622c0338ffSzrj 	struct stat **gl_statv;	/* Stat entries corresponding to gl_pathv */
632c0338ffSzrj 				/* Copy of errfunc parameter to glob. */
642c0338ffSzrj 	int (*gl_errfunc)(const char *, int);
652c0338ffSzrj 
662c0338ffSzrj 	/*
672c0338ffSzrj 	 * Alternate filesystem access methods for glob; replacement
682c0338ffSzrj 	 * versions of closedir(3), readdir(3), opendir(3), stat(2)
692c0338ffSzrj 	 * and lstat(2).
702c0338ffSzrj 	 */
712c0338ffSzrj 	void (*gl_closedir)(void *);
722c0338ffSzrj 	struct dirent *(*gl_readdir)(void *);
732c0338ffSzrj 	void *(*gl_opendir)(const char *);
742c0338ffSzrj 	int (*gl_lstat)(const char *, struct stat *);
752c0338ffSzrj 	int (*gl_stat)(const char *, struct stat *);
762c0338ffSzrj } glob_t;
772c0338ffSzrj 
782c0338ffSzrj #define	GLOB_APPEND	0x0001	/* Append to output from previous call. */
792c0338ffSzrj #define	GLOB_DOOFFS	0x0002	/* Use gl_offs. */
802c0338ffSzrj #define	GLOB_ERR	0x0004	/* Return on error. */
812c0338ffSzrj #define	GLOB_MARK	0x0008	/* Append / to matching directories. */
822c0338ffSzrj #define	GLOB_NOCHECK	0x0010	/* Return pattern itself if nothing matches. */
832c0338ffSzrj #define	GLOB_NOSORT	0x0020	/* Don't sort. */
842c0338ffSzrj #define	GLOB_NOESCAPE	0x1000	/* Disable backslash escaping. */
852c0338ffSzrj 
862c0338ffSzrj #define	GLOB_NOSPACE	(-1)	/* Malloc call failed. */
872c0338ffSzrj #define	GLOB_ABORTED	(-2)	/* Unignored error. */
882c0338ffSzrj #define	GLOB_NOMATCH	(-3)	/* No match and GLOB_NOCHECK not set. */
892c0338ffSzrj #define	GLOB_NOSYS	(-4)	/* Function not supported. */
902c0338ffSzrj 
912c0338ffSzrj #define	GLOB_ALTDIRFUNC	0x0040	/* Use alternately specified directory funcs. */
922c0338ffSzrj #define	GLOB_BRACE	0x0080	/* Expand braces ala csh. */
932c0338ffSzrj #define	GLOB_MAGCHAR	0x0100	/* Pattern had globbing characters. */
942c0338ffSzrj #define	GLOB_NOMAGIC	0x0200	/* GLOB_NOCHECK without magic chars (csh). */
952c0338ffSzrj #define	GLOB_QUOTE	0x0400	/* Quote special chars with \. */
962c0338ffSzrj #define	GLOB_TILDE	0x0800	/* Expand tilde names from the passwd file. */
972c0338ffSzrj #define GLOB_LIMIT	0x2000	/* Limit pattern match output to ARG_MAX */
982c0338ffSzrj #define	GLOB_KEEPSTAT	0x4000	/* Retain stat data for paths in gl_statv. */
992c0338ffSzrj #define GLOB_ABEND	GLOB_ABORTED /* backward compatibility */
1002c0338ffSzrj 
1012c0338ffSzrj int	glob(const char *, int, int (*)(const char *, int), glob_t *);
1022c0338ffSzrj void	globfree(glob_t *);
1032c0338ffSzrj 
1042c0338ffSzrj #endif /* !_GLOB_H_ */
1052c0338ffSzrj 
1062c0338ffSzrj #endif /* !defined(HAVE_GLOB_H) || !defined(GLOB_HAS_ALTDIRFUNC)  ||
1072c0338ffSzrj 	  !defined(GLOB_HAS_GL_MATCHC) || !defined(GLOH_HAS_GL_STATV) */
108*2c81fb9cSAntonio Huete Jimenez 
109