GNU Octave  6.2.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
glob-wrappers.c
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 2016-2021 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 // These functions may be provided by gnulib. We don't include gnulib
27 // headers directly in Octave's C++ source files to avoid problems that
28 // may be caused by the way that gnulib overrides standard library
29 // functions.
30 
31 #if defined (HAVE_CONFIG_H)
32 # include "config.h"
33 #endif
34 
35 #include <stdlib.h>
36 
37 #include <fnmatch.h>
38 #include <glob.h>
39 
40 #include "glob-wrappers.h"
41 
42 void *
44 {
45  return malloc (sizeof (glob_t));
46 }
47 
48 // Does not call globfree.
49 void
51 {
52  free (glob_info);
53 }
54 
55 int
56 octave_glob_wrapper (const char *pattern, int flags, void *glob_info)
57 {
58  return glob (pattern, flags, 0, glob_info);
59 }
60 
61 int
62 octave_glob_num_matches (void *glob_info)
63 {
64  return glob_info ? ((glob_t *) glob_info)->gl_pathc : 0;
65 }
66 
67 char **
68 octave_glob_match_list (void *glob_info)
69 {
70  return glob_info ? ((glob_t *) glob_info)->gl_pathv : 0;
71 }
72 
73 void
74 octave_globfree_wrapper (void *glob_info)
75 {
76  globfree ((glob_t *) glob_info);
77 }
78 
79 int
81 {
82  return GLOB_NOSORT;
83 }
84 
85 int
86 octave_fnmatch_wrapper (const char *pattern, const char *name, int flags)
87 {
88  return fnmatch (pattern, name, flags);
89 }
90 
91 int
93 {
94  return FNM_NOMATCH;
95 }
96 
97 int
99 {
100  return FNM_PATHNAME;
101 }
102 
103 int
105 {
106  return FNM_NOESCAPE;
107 }
108 
109 int
111 {
112  return FNM_PERIOD;
113 }
int octave_fnm_nomatch_wrapper(void)
Definition: glob-wrappers.c:92
int octave_glob_nosort_wrapper(void)
Definition: glob-wrappers.c:80
void octave_destroy_glob_info_struct(void *glob_info)
Definition: glob-wrappers.c:50
void octave_globfree_wrapper(void *glob_info)
Definition: glob-wrappers.c:74
void * octave_create_glob_info_struct(void)
Definition: glob-wrappers.c:43
int octave_glob_num_matches(void *glob_info)
Definition: glob-wrappers.c:62
int octave_fnm_period_wrapper(void)
int octave_fnm_pathname_wrapper(void)
Definition: glob-wrappers.c:98
int octave_fnm_noescape_wrapper(void)
int octave_glob_wrapper(const char *pattern, int flags, void *glob_info)
Definition: glob-wrappers.c:56
int octave_fnmatch_wrapper(const char *pattern, const char *name, int flags)
Definition: glob-wrappers.c:86
char ** octave_glob_match_list(void *glob_info)
Definition: glob-wrappers.c:68
QString name
bool fnmatch(const string_vector &pat, const std::string &str, int fnm_flags)
Definition: oct-glob.cc:58
string_vector glob(const string_vector &pat)
Definition: oct-glob.cc:73
void * malloc(unsigned)
void free(void *)