summaryrefslogtreecommitdiff
path: root/src/glob
diff options
context:
space:
mode:
Diffstat (limited to 'src/glob')
-rw-r--r--src/glob/GLOB_ABORTED.h6
-rw-r--r--src/glob/GLOB_APPEND.h6
-rw-r--r--src/glob/GLOB_DOOFFS.h6
-rw-r--r--src/glob/GLOB_ERR.h6
-rw-r--r--src/glob/GLOB_MARK.h6
-rw-r--r--src/glob/GLOB_NOCHECK.h6
-rw-r--r--src/glob/GLOB_NOESCAPE.h6
-rw-r--r--src/glob/GLOB_NOMATCH.h6
-rw-r--r--src/glob/GLOB_NOSORT.h6
-rw-r--r--src/glob/GLOB_NOSPACE.h6
-rw-r--r--src/glob/GLOB_NOSYS.h6
-rw-r--r--src/glob/glob.c126
-rw-r--r--src/glob/glob_t.h11
-rw-r--r--src/glob/globfree.c30
14 files changed, 0 insertions, 233 deletions
diff --git a/src/glob/GLOB_ABORTED.h b/src/glob/GLOB_ABORTED.h
deleted file mode 100644
index 4fff433e..00000000
--- a/src/glob/GLOB_ABORTED.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <glob.h>
-#define GLOB_ABORTED 1
-/*
-POSIX(2)
-*/
-
diff --git a/src/glob/GLOB_APPEND.h b/src/glob/GLOB_APPEND.h
deleted file mode 100644
index e9cdddac..00000000
--- a/src/glob/GLOB_APPEND.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <glob.h>
-#define GLOB_APPEND (1<<0)
-/*
-POSIX(2)
-*/
-
diff --git a/src/glob/GLOB_DOOFFS.h b/src/glob/GLOB_DOOFFS.h
deleted file mode 100644
index 5c1615ec..00000000
--- a/src/glob/GLOB_DOOFFS.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <glob.h>
-#define GLOB_DOOFFS (1<<1)
-/*
-POSIX(2)
-*/
-
diff --git a/src/glob/GLOB_ERR.h b/src/glob/GLOB_ERR.h
deleted file mode 100644
index 1b28a495..00000000
--- a/src/glob/GLOB_ERR.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <glob.h>
-#define GLOB_ERR (1<<2)
-/*
-POSIX(2)
-*/
-
diff --git a/src/glob/GLOB_MARK.h b/src/glob/GLOB_MARK.h
deleted file mode 100644
index 628b1e0d..00000000
--- a/src/glob/GLOB_MARK.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <glob.h>
-#define GLOB_MARK (1<<3)
-/*
-POSIX(2)
-*/
-
diff --git a/src/glob/GLOB_NOCHECK.h b/src/glob/GLOB_NOCHECK.h
deleted file mode 100644
index 323fdf40..00000000
--- a/src/glob/GLOB_NOCHECK.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <glob.h>
-#define GLOB_NOCHECK (1<<4)
-/*
-POSIX(2)
-*/
-
diff --git a/src/glob/GLOB_NOESCAPE.h b/src/glob/GLOB_NOESCAPE.h
deleted file mode 100644
index befaaaef..00000000
--- a/src/glob/GLOB_NOESCAPE.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <glob.h>
-#define GLOB_NOESCAPE (1<<5)
-/*
-POSIX(2)
-*/
-
diff --git a/src/glob/GLOB_NOMATCH.h b/src/glob/GLOB_NOMATCH.h
deleted file mode 100644
index 1d404a00..00000000
--- a/src/glob/GLOB_NOMATCH.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <glob.h>
-#define GLOB_NOMATCH 2
-/*
-POSIX(2)
-*/
-
diff --git a/src/glob/GLOB_NOSORT.h b/src/glob/GLOB_NOSORT.h
deleted file mode 100644
index c17dcf28..00000000
--- a/src/glob/GLOB_NOSORT.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <glob.h>
-#define GLOB_NOSORT (1<<6)
-/*
-POSIX(2)
-*/
-
diff --git a/src/glob/GLOB_NOSPACE.h b/src/glob/GLOB_NOSPACE.h
deleted file mode 100644
index e57a197b..00000000
--- a/src/glob/GLOB_NOSPACE.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <glob.h>
-#define GLOB_NOSPACE 3
-/*
-POSIX(2)
-*/
-
diff --git a/src/glob/GLOB_NOSYS.h b/src/glob/GLOB_NOSYS.h
deleted file mode 100644
index 4c0682c4..00000000
--- a/src/glob/GLOB_NOSYS.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <glob.h>
-#define GLOB_NOSYS (-2)
-/*
-POSIX(2)
-*/
-
diff --git a/src/glob/glob.c b/src/glob/glob.c
deleted file mode 100644
index 8a45ed65..00000000
--- a/src/glob/glob.c
+++ /dev/null
@@ -1,126 +0,0 @@
-#if 0
-
-#include <sys/types.h>
-#include <glob.h>
-#include <stdlib.h>
-#include <string.h>
-#include <dirent.h>
-#include <fnmatch.h>
-#include <errno.h>
-#include <unistd.h>
-#include "_assert.h"
-
-int glob(const char * restrict pattern, int flags, int (*errfunc) (const char * epath, int eerrno), glob_t * restrict pglob)
-{
- ASSERT_NONNULL(pattern);
- ASSERT_NONNULL(pglob);
-
- int slashes = 0;
- size_t i;
-
- int fnmatch_flags = FNM_PATHNAME | FNM_PERIOD;
-
- if (flags & GLOB_NOESCAPE) {
- fnmatch_flags |= FNM_NOESCAPE;
- }
-
- if (flags & GLOB_APPEND) {
- if (pglob->gl_pathc == 0) {
- /* no good */
- }
-
- if (pglob->gl_offs > 0 && !(flags & GLOB_DOOFFS)) {
- /* nope */
- }
- } else {
- if (pglob->gl_pathc != 0) {
- /* also no */
- }
- }
-
- char *path = malloc(strlen(pattern) + 1);
- strcpy(path, pattern);
-
- for (i = 0; path[i]; i++) {
- if (path[i] == '/') {
- slashes++;
- path[i] = '\0';
- }
- }
-
- if (path[0] == '\0') {
- path[0] = '/';
- slashes--;
- }
-
- /* TODO: check for trailing slash to match only directories */
- /* TODO: compress adjacent slashes */
- /* TODO: DOOFFS */
-
- do {
- const char *p = path + strlen(path) + 1;
- struct dirent *de;
- DIR *d = opendir(slashes ? path : ".");
- if (d == NULL) {
- if (errfunc != NULL) {
- if (errfunc(path, errno) != 0) {
- return GLOB_ABORTED;
- }
- }
-
- if (flags & GLOB_ERR) {
- return GLOB_ABORTED;
- }
- }
-
- while ((de = readdir(d)) != NULL) {
- if (fnmatch(p, de->d_name, fnmatch_flags) == 0) {
- pglob->gl_pathc++;
- char **tmp = realloc(pglob->gl_pathv, sizeof(char*) * pglob->gl_pathc);
- if (tmp == NULL) {
- pglob->gl_pathc--;
- return GLOB_NOSPACE;
- }
-
- pglob->gl_pathv = tmp;
- /* FIXME: add path to front */
- pglob->gl_pathv[pglob->gl_pathc - 1] = malloc(strlen(de->d_name) + 1);
- strcat(pglob->gl_pathv[pglob->gl_pathc - 1], de->d_name);
- /* TODO: MARK */
- }
- }
-
- closedir(d);
-
- path[strlen(path)] = '/';
- slashes--;
- } while (slashes);
-
- if (pglob->gl_pathc == 0) {
- if (flags & GLOB_NOCHECK) {
- /* TODO: DOOFFS */
- pglob->gl_pathc = 1;
- pglob->gl_pathv = malloc(sizeof(char*));
- pglob->gl_pathv[0] = malloc(strlen(pattern) + 1);
- strcpy(pglob->gl_pathv[0], pattern);
- } else {
- return GLOB_NOMATCH;
- }
- }
-
- if (!(flags & GLOB_NOSORT)) {
- qsort(pglob->gl_pathv + pglob->gl_offs, pglob->gl_pathc,
- sizeof(char*),
- (int (*)(const void *, const void *))strcoll);
- }
-
- return 0;
-}
-
-/*
-POSIX(2)
-*/
-
-
-
-#endif
diff --git a/src/glob/glob_t.h b/src/glob/glob_t.h
deleted file mode 100644
index 21fcf4f6..00000000
--- a/src/glob/glob_t.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <glob.h>
-
-typedef struct {
- size_t gl_pathc;
- char ** gl_pathv;
- size_t gl_offs;
-} glob_t;
-/*
-POSIX(2)
-*/
-
diff --git a/src/glob/globfree.c b/src/glob/globfree.c
deleted file mode 100644
index c9e6dc1a..00000000
--- a/src/glob/globfree.c
+++ /dev/null
@@ -1,30 +0,0 @@
-#if 0
-
-#include <sys/types.h>
-#include <glob.h>
-#include <stdlib.h>
-
-void globfree(glob_t * pglob)
-{
- size_t i;
-
- if (pglob == NULL) {
- return;
- }
-
- for (i = 0; i < pglob->gl_pathc; i++) {
- if (pglob->gl_pathv[i] != NULL) {
- free(pglob->gl_pathv[i]);
- }
- }
-
- free(pglob);
-}
-
-/*
-POSIX(2)
-*/
-
-
-
-#endif