MCPcopy Create free account
hub / github.com/RsyncProject/rsync / poptGlob

Function poptGlob

popt/poptconfig.c:72–108  ·  view source on GitHub ↗

* Return path(s) from a glob pattern. * @param con context * @param pattern glob pattern * @retval *acp no. of paths * @retval *avp array of paths * @return 0 on success */

Source from the content-addressed store, hash-verified

70 * @return 0 on success
71 */
72static int poptGlob(UNUSED(poptContext con), const char * pattern,
73 int * acp, const char *** avp)
74{
75 const char * pat = pattern;
76 int rc = 0; /* assume success */
77
78#if defined(HAVE_GLOB_H)
79 if (glob_pattern_p(pat, 0)) {
80 glob_t _g, *pglob = &_g;
81
82 if (!(rc = glob(pat, poptGlobFlags, poptGlob_error, pglob))) {
83 if (acp) {
84 *acp = (int) pglob->gl_pathc;
85 pglob->gl_pathc = 0;
86 }
87 if (avp) {
88 *avp = (const char **) pglob->gl_pathv;
89 pglob->gl_pathv = NULL;
90 }
91 globfree(pglob);
92 } else if (rc == GLOB_NOMATCH) {
93 *avp = NULL;
94 *acp = 0;
95 rc = 0;
96 } else
97 rc = POPT_ERROR_ERRNO;
98 } else
99#endif /* HAVE_GLOB_H */
100 {
101 if (acp)
102 *acp = 1;
103 if (avp && (*avp = calloc((size_t)(1 + 1), sizeof (**avp))) != NULL)
104 (*avp)[0] = xstrdup(pat);
105 }
106
107 return rc;
108}
109
110
111int poptSaneFile(const char * fn)

Callers 2

poptReadConfigFilesFunction · 0.85
poptReadDefaultConfigFunction · 0.85

Calls 1

glob_pattern_pFunction · 0.85

Tested by

no test coverage detected