* GLOB_MAGCHAR:
* Set in gl_flags if pattern contained a globbing character.
*/
-#include <sys/param.h>
+#include <sys/types.h>
#include <sys/stat.h>
#include <glib.h>
#include <ctype.h>
-#include <dirent.h>
#include <errno.h>
-#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define M_MASK 0xffff
#define M_ASCII 0x00ff
-typedef u_short Char;
+typedef unsigned short Char;
#else
#define ismeta(c) (((c)&M_QUOTE) != 0)
-static int g_Ctoc(const gchar *, char *, u_int);
+static int g_Ctoc(const gchar *, char *, unsigned int);
static int glob0(GDir *dir, const gchar *, wapi_glob_t *, gboolean,
gboolean);
static int glob1(GDir *dir, gchar *, gchar *, wapi_glob_t *, size_t *,
gboolean, gboolean);
static int globextend(const gchar *, wapi_glob_t *, size_t *);
static int match(const gchar *, gchar *, gchar *, gboolean);
-#ifdef DEBUG
+#ifdef DEBUG_ENABLED
static void qprintf(const char *, Char *);
#endif
int
_wapi_glob(GDir *dir, const char *pattern, int flags, wapi_glob_t *pglob)
{
- const u_char *patnext;
+ const unsigned char *patnext;
int c;
- gchar *bufnext, *bufend, patbuf[MAXPATHLEN];
+ gchar *bufnext, *bufend, patbuf[PATH_MAX];
- patnext = (u_char *) pattern;
+ patnext = (unsigned char *) pattern;
if (!(flags & WAPI_GLOB_APPEND)) {
pglob->gl_pathc = 0;
pglob->gl_pathv = NULL;
pglob->gl_flags = flags & ~WAPI_GLOB_MAGCHAR;
bufnext = patbuf;
- bufend = bufnext + MAXPATHLEN - 1;
+ bufend = bufnext + PATH_MAX - 1;
/* Protect the quoted characters. */
while (bufnext < bufend && (c = *patnext++) != EOS)
{
const gchar *qpatnext;
int c, err, oldpathc;
- gchar *bufnext, patbuf[MAXPATHLEN];
+ gchar *bufnext, patbuf[PATH_MAX];
size_t limit = 0;
qpatnext = pattern;
}
}
*bufnext = EOS;
-#ifdef DEBUG
+#ifdef DEBUG_ENABLED
qprintf("glob0:", patbuf);
#endif
- if ((err = glob1(dir, patbuf, patbuf+MAXPATHLEN-1, pglob, &limit,
+ if ((err = glob1(dir, patbuf, patbuf+PATH_MAX-1, pglob, &limit,
ignorecase, unique)) != 0)
return(err);
{
char **pathv;
int i;
- u_int newsize, len;
+ unsigned int newsize, len;
char *copy;
const gchar *p;
newsize = sizeof(*pathv) * (2 + pglob->gl_pathc + pglob->gl_offs);
- pathv = pglob->gl_pathv ? realloc((char *)pglob->gl_pathv, newsize) :
- malloc(newsize);
+ /* FIXME: Can just use realloc(). */
+ pathv = (char **)(pglob->gl_pathv ? realloc((char *)pglob->gl_pathv, newsize) :
+ malloc(newsize));
if (pathv == NULL) {
if (pglob->gl_pathv) {
free(pglob->gl_pathv);
;
len = (size_t)(p - path);
*limitp += len;
- if ((copy = malloc(len)) != NULL) {
+ if ((copy = (char *)malloc(len)) != NULL) {
if (g_Ctoc(path, copy, len)) {
free(copy);
return(WAPI_GLOB_NOSPACE);
}
static int
-g_Ctoc(const gchar *str, char *buf, u_int len)
+g_Ctoc(const gchar *str, char *buf, unsigned int len)
{
while (len--) {
return (1);
}
-#ifdef DEBUG
+#ifdef DEBUG_ENABLED
static void
qprintf(const char *str, Char *s)
{