1221420Sdes/*	$OpenBSD: glob.h,v 1.11 2010/09/24 13:32:55 djm Exp $	*/
298937Sdes/*	$NetBSD: glob.h,v 1.5 1994/10/26 00:55:56 cgd Exp $	*/
398937Sdes
498937Sdes/*
598937Sdes * Copyright (c) 1989, 1993
698937Sdes *	The Regents of the University of California.  All rights reserved.
798937Sdes *
898937Sdes * This code is derived from software contributed to Berkeley by
998937Sdes * Guido van Rossum.
1098937Sdes *
1198937Sdes * Redistribution and use in source and binary forms, with or without
1298937Sdes * modification, are permitted provided that the following conditions
1398937Sdes * are met:
1498937Sdes * 1. Redistributions of source code must retain the above copyright
1598937Sdes *    notice, this list of conditions and the following disclaimer.
1698937Sdes * 2. Redistributions in binary form must reproduce the above copyright
1798937Sdes *    notice, this list of conditions and the following disclaimer in the
1898937Sdes *    documentation and/or other materials provided with the distribution.
19124208Sdes * 3. Neither the name of the University nor the names of its contributors
2098937Sdes *    may be used to endorse or promote products derived from this software
2198937Sdes *    without specific prior written permission.
2298937Sdes *
2398937Sdes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2498937Sdes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2598937Sdes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2698937Sdes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2798937Sdes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2898937Sdes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2998937Sdes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3098937Sdes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3198937Sdes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3298937Sdes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3398937Sdes * SUCH DAMAGE.
3498937Sdes *
3598937Sdes *	@(#)glob.h	8.1 (Berkeley) 6/2/93
3698937Sdes */
3798937Sdes
38157016Sdes/* OPENBSD ORIGINAL: include/glob.h */
39157016Sdes
4098937Sdes#if !defined(HAVE_GLOB_H) || !defined(GLOB_HAS_ALTDIRFUNC) || \
41221420Sdes    !defined(GLOB_HAS_GL_MATCHC) || !defined(GLOB_HAS_GL_STATV) || \
42181111Sdes    !defined(HAVE_DECL_GLOB_NOMATCH) || HAVE_DECL_GLOB_NOMATCH == 0 || \
43181111Sdes    defined(BROKEN_GLOB)
4498937Sdes
45296781Sdes#ifndef _COMPAT_GLOB_H_
46296781Sdes#define	_COMPAT_GLOB_H_
4798937Sdes
48221420Sdes#include <sys/stat.h>
49221420Sdes
50296781Sdes# define glob_t _ssh_compat_glob_t
51296781Sdes# define glob(a, b, c, d)  _ssh__compat_glob(a, b, c, d)
52296781Sdes# define globfree(a)  _ssh__compat_globfree(a)
53296781Sdes
5498937Sdesstruct stat;
5598937Sdestypedef struct {
5698937Sdes	int gl_pathc;		/* Count of total paths so far. */
5798937Sdes	int gl_matchc;		/* Count of paths matching pattern. */
5898937Sdes	int gl_offs;		/* Reserved at beginning of gl_pathv. */
5998937Sdes	int gl_flags;		/* Copy of flags parameter to glob. */
6098937Sdes	char **gl_pathv;	/* List of paths matching pattern. */
61221420Sdes	struct stat **gl_statv;	/* Stat entries corresponding to gl_pathv */
6298937Sdes				/* Copy of errfunc parameter to glob. */
63106121Sdes	int (*gl_errfunc)(const char *, int);
6498937Sdes
6598937Sdes	/*
6698937Sdes	 * Alternate filesystem access methods for glob; replacement
6798937Sdes	 * versions of closedir(3), readdir(3), opendir(3), stat(2)
6898937Sdes	 * and lstat(2).
6998937Sdes	 */
70106121Sdes	void (*gl_closedir)(void *);
71106121Sdes	struct dirent *(*gl_readdir)(void *);
72106121Sdes	void *(*gl_opendir)(const char *);
73106121Sdes	int (*gl_lstat)(const char *, struct stat *);
74106121Sdes	int (*gl_stat)(const char *, struct stat *);
7598937Sdes} glob_t;
7698937Sdes
7798937Sdes#define	GLOB_APPEND	0x0001	/* Append to output from previous call. */
7898937Sdes#define	GLOB_DOOFFS	0x0002	/* Use gl_offs. */
7998937Sdes#define	GLOB_ERR	0x0004	/* Return on error. */
8098937Sdes#define	GLOB_MARK	0x0008	/* Append / to matching directories. */
8198937Sdes#define	GLOB_NOCHECK	0x0010	/* Return pattern itself if nothing matches. */
8298937Sdes#define	GLOB_NOSORT	0x0020	/* Don't sort. */
83157016Sdes#define	GLOB_NOESCAPE	0x1000	/* Disable backslash escaping. */
8498937Sdes
85181111Sdes#define	GLOB_NOSPACE	(-1)	/* Malloc call failed. */
86181111Sdes#define	GLOB_ABORTED	(-2)	/* Unignored error. */
87181111Sdes#define	GLOB_NOMATCH	(-3)	/* No match and GLOB_NOCHECK not set. */
88181111Sdes#define	GLOB_NOSYS	(-4)	/* Function not supported. */
89181111Sdes
9098937Sdes#define	GLOB_ALTDIRFUNC	0x0040	/* Use alternately specified directory funcs. */
9198937Sdes#define	GLOB_BRACE	0x0080	/* Expand braces ala csh. */
9298937Sdes#define	GLOB_MAGCHAR	0x0100	/* Pattern had globbing characters. */
9398937Sdes#define	GLOB_NOMAGIC	0x0200	/* GLOB_NOCHECK without magic chars (csh). */
9498937Sdes#define	GLOB_QUOTE	0x0400	/* Quote special chars with \. */
9598937Sdes#define	GLOB_TILDE	0x0800	/* Expand tilde names from the passwd file. */
9698937Sdes#define GLOB_LIMIT	0x2000	/* Limit pattern match output to ARG_MAX */
97221420Sdes#define	GLOB_KEEPSTAT	0x4000	/* Retain stat data for paths in gl_statv. */
98221420Sdes#define GLOB_ABEND	GLOB_ABORTED /* backward compatibility */
9998937Sdes
100106121Sdesint	glob(const char *, int, int (*)(const char *, int), glob_t *);
101106121Sdesvoid	globfree(glob_t *);
10298937Sdes
10398937Sdes#endif /* !_GLOB_H_ */
10498937Sdes
10598937Sdes#endif /* !defined(HAVE_GLOB_H) || !defined(GLOB_HAS_ALTDIRFUNC)  ||
106221420Sdes	  !defined(GLOB_HAS_GL_MATCHC) || !defined(GLOH_HAS_GL_STATV) */
10798937Sdes
108