Debian Codegraph @

share/libc/glob.h

raw
1 /**************************************************************************/
2 /* */
3 /* This file is part of Frama-C. */
4 /* */
5 /* Copyright (C) 2007-2022 */
6 /* CEA (Commissariat à l'énergie atomique et aux énergies */
7 /* alternatives) */
8 /* */
9 /* you can redistribute it and/or modify it under the terms of the GNU */
10 /* Lesser General Public License as published by the Free Software */
11 /* Foundation, version 2.1. */
12 /* */
13 /* It is distributed in the hope that it will be useful, */
14 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
15 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
16 /* GNU Lesser General Public License for more details. */
17 /* */
18 /* See the GNU Lesser General Public License version 2.1 */
19 /* for more details (enclosed in the file licenses/LGPLv2.1). */
20 /* */
21 /**************************************************************************/
22
23 #ifndef __FC_GLOB_H
24 #define __FC_GLOB_H
25 #include "features.h"
26 __PUSH_FC_STDLIB
27
28 #include "__fc_machdep.h"
29
30 #define GLOB_ERR (1 << 0)/* Return on read errors. */
31 #define GLOB_MARK (1 << 1)/* Append a slash to each name. */
32 #define GLOB_NOSORT (1 << 2)/* Don't sort the names. */
33 #define GLOB_DOOFFS (1 << 3)/* Insert PGLOB->gl_offs NULLs. */
34 #define GLOB_NOCHECK (1 << 4)/* If nothing matches, return the pattern. */
35 #define GLOB_APPEND (1 << 5)/* Append to results of a previous call. */
36 #define GLOB_NOESCAPE (1 << 6)/* Backslashes don't quote metacharacters. */
37 #define GLOB_PERIOD (1 << 7)/* Leading `.' can be matched by metachars. */
38
39 #define GLOB_NOSPACE 1 /* Ran out of memory. */
40 #define GLOB_ABORTED 2 /* Read error. */
41 #define GLOB_NOMATCH 3 /* No matches found. */
42 #define GLOB_NOSYS 4 /* Not implemented. */
43
44 __BEGIN_DECLS
45
46 typedef struct __fc_glob_t {
47 __SIZE_T gl_pathc; /* Count of paths matched by the pattern. */
48 char **gl_pathv; /* List of matched pathnames. */
49 __SIZE_T gl_offs; /* Slots to reserve in `gl_pathv'. */
50 int gl_flags; /* Set to FLAGS, maybe | GLOB_MAGCHAR. */
51
52 /* If the GLOB_ALTDIRFUNC flag is set, the following functions
53 are used instead of the normal file access functions. */
54 void (*gl_closedir) (void *);
55 #ifdef __USE_GNU
56 struct dirent *(*gl_readdir) (void *);
57 #else
58 void *(*gl_readdir) (void *);
59 #endif
60 void *(*gl_opendir) (__const char *);
61 #ifdef __USE_GNU
62 int (*gl_lstat) (__const char *__restrict, struct stat *__restrict);
63 int (*gl_stat) (__const char *__restrict, struct stat *__restrict);
64 #else
65 int (*gl_lstat) (__const char *__restrict, void *__restrict);
66 int (*gl_stat) (__const char *__restrict, void *__restrict);
67 #endif
68 } glob_t;
69
70 extern int glob(const char *pattern, int flags,
71 int (*errfunc) (const char *epath, int eerrno),
72 glob_t *pglob);
73
74 extern void globfree(glob_t *pglob);
75
76 __END_DECLS
77
78 __POP_FC_STDLIB
79 #endif