From 6c650d1b8de5912b49764c80b52a638a64941f5d Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Thu, 27 May 2021 12:43:01 +0200 Subject: [PATCH] LibC: Add stubs for glob and globfree --- Userland/Libraries/LibC/CMakeLists.txt | 1 + Userland/Libraries/LibC/glob.cpp | 25 ++++++++++++++++++ Userland/Libraries/LibC/glob.h | 35 ++++++++++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 Userland/Libraries/LibC/glob.cpp create mode 100644 Userland/Libraries/LibC/glob.h diff --git a/Userland/Libraries/LibC/CMakeLists.txt b/Userland/Libraries/LibC/CMakeLists.txt index 0389a04c8bf4be..aa5c40d116aed5 100644 --- a/Userland/Libraries/LibC/CMakeLists.txt +++ b/Userland/Libraries/LibC/CMakeLists.txt @@ -12,6 +12,7 @@ set(LIBC_SOURCES ifaddrs.cpp getopt.cpp getsubopt.cpp + glob.cpp grp.cpp inttypes.cpp ioctl.cpp diff --git a/Userland/Libraries/LibC/glob.cpp b/Userland/Libraries/LibC/glob.cpp new file mode 100644 index 00000000000000..690f26fc7616a2 --- /dev/null +++ b/Userland/Libraries/LibC/glob.cpp @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2021, the SerenityOS developers. + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include +#include +#include + +extern "C" { + +// https://pubs.opengroup.org/onlinepubs/9699919799/functions/glob.html +int glob(char const*, int, int (*)(char const* epath, int eerrno), glob_t*) +{ + dbgln("FIXME: Implement glob()"); + TODO(); +} + +void globfree(glob_t*) +{ + dbgln("FIXME: Implement globfree()"); + TODO(); +} +} diff --git a/Userland/Libraries/LibC/glob.h b/Userland/Libraries/LibC/glob.h new file mode 100644 index 00000000000000..ed7a545fe4af0f --- /dev/null +++ b/Userland/Libraries/LibC/glob.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2021, the SerenityOS developers. + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include + +__BEGIN_DECLS + +typedef struct { + size_t gl_pathc; + char** gl_pathv; + size_t gl_offs; +} glob_t; + +#define GLOB_APPEND (1 << 0) +#define GLOB_DOOFS (1 << 1) +#define GLOB_ERR (1 << 2) +#define GLOB_MARK (1 << 3) +#define GLOB_NOCHECK (1 << 4) +#define GLOB_NOESCAPE (1 << 5) +#define GLOB_NOSORT (1 << 6) + +#define GLOB_ABORTED 1 +#define GLOB_NOMATCH 2 +#define GLOB_NOSPACE 3 + +int glob(char const* pattern, int flags, int (*errfunc)(char const* epath, int eerrno), glob_t* pglob); + +void globfree(glob_t* pglob); + +__END_DECLS