mirror of
https://github.com/apache/nuttx.git
synced 2026-05-21 13:13:08 +08:00
libc/misc: add lib_glob.
Signed-off-by: FASTSHIFT <vifextech@foxmail.com>
This commit is contained in:
committed by
Gustavo Henrique Nihei
parent
44268bac1f
commit
649f99ce30
+111
@@ -0,0 +1,111 @@
|
||||
/****************************************************************************
|
||||
* include/glob.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_GLOB_H
|
||||
#define __INCLUDE_GLOB_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/compiler.h>
|
||||
#include <stddef.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* The following constants shall be provided as values
|
||||
* for the flags argument:
|
||||
*/
|
||||
|
||||
#define GLOB_APPEND 0x01 /* Append generated pathnames to
|
||||
* those previously obtained. */
|
||||
#define GLOB_DOOFFS 0x02 /* Specify how many null pointers
|
||||
* to add to the beginning of gl_pathv. */
|
||||
#define GLOB_ERR 0x04 /* Cause glob() to return on error. */
|
||||
#define GLOB_MARK 0x08 /* Each pathname that is a directory that
|
||||
* matches pattern has a slash appended. */
|
||||
#define GLOB_NOCHECK 0x10 /* If pattern does not match any pathname, then
|
||||
* return a list consisting of only pattern. */
|
||||
#define GLOB_NOESCAPE 0x20 /* Disable backslash escaping. */
|
||||
#define GLOB_NOSORT 0x40 /* Do not sort the pathnames returned. */
|
||||
|
||||
/* The following constants shall be defined as error return values:
|
||||
*/
|
||||
|
||||
#define GLOB_ABORTED 1 /* The scan was stopped because GLOB_ERR
|
||||
* was set or (*errfunc)() returned non-zero. */
|
||||
#define GLOB_NOMATCH 2 /* The pattern does not match any existing pathname,
|
||||
* and GLOB_NOCHECK was not set in flags. */
|
||||
#define GLOB_NOSPACE 3 /* An attempt to allocate memory failed. */
|
||||
#define GLOB_NOSYS 4 /* Reserved */
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
size_t gl_pathc; /* Count of paths matched by pattern. */
|
||||
FAR char **gl_pathv; /* Pointer to a list of matched pathnames. */
|
||||
size_t gl_offs; /* Slots to reserve at the beginning of gl_pathv. */
|
||||
} glob_t;
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: glob
|
||||
*
|
||||
* Description:
|
||||
* find pathnames matching a pattern.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int glob(FAR const char *pat, int flags,
|
||||
CODE int (*errfunc)(FAR const char *path, int err),
|
||||
FAR glob_t *g);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: globfree
|
||||
*
|
||||
* Description:
|
||||
* Free memory from glob().
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void globfree(FAR glob_t *g);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __INCLUDE_GLOB_H */
|
||||
@@ -46,7 +46,7 @@ endif
|
||||
|
||||
CSRCS += lib_dumpbuffer.c lib_dumpvbuffer.c lib_fnmatch.c lib_debug.c
|
||||
CSRCS += lib_crc64.c lib_crc32.c lib_crc16.c lib_crc8.c lib_crc8ccitt.c
|
||||
CSRCS += lib_crc8table.c
|
||||
CSRCS += lib_crc8table.c lib_glob.c
|
||||
|
||||
# Keyboard driver encoder/decoder
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user