Skip to content

Commit

Permalink
LibC: Add stubs for glob and globfree
Browse files Browse the repository at this point in the history
  • Loading branch information
timschumi authored and bgianfo committed Jul 8, 2022
1 parent f672b4c commit 6c650d1
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
1 change: 1 addition & 0 deletions Userland/Libraries/LibC/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ set(LIBC_SOURCES
ifaddrs.cpp
getopt.cpp
getsubopt.cpp
glob.cpp
grp.cpp
inttypes.cpp
ioctl.cpp
Expand Down
25 changes: 25 additions & 0 deletions Userland/Libraries/LibC/glob.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright (c) 2021, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/

#include <AK/Format.h>
#include <assert.h>
#include <glob.h>

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();
}
}
35 changes: 35 additions & 0 deletions Userland/Libraries/LibC/glob.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright (c) 2021, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/

#pragma once

#include <sys/types.h>

__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

0 comments on commit 6c650d1

Please sign in to comment.