touched up glob.c and glob.h
This commit is contained in:
parent
ac61c3044a
commit
1ef7fc2569
45
qse/bld/watcom.txt
Normal file
45
qse/bld/watcom.txt
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
Here are sample commands and linker files to use sample programs
|
||||||
|
using the watcom compiler and linker.
|
||||||
|
|
||||||
|
------------------------------------------------------------------------
|
||||||
|
|
||||||
|
wcc386 -bt=os2 -zq -i=..\..\include -DNDEBUG -DQSE_CHAR_IS_WCHAR=1 -wx -d0 -bm -ot -ox ..\..\samples\cmn\dir01.c
|
||||||
|
|
||||||
|
>>> dir01.lbc
|
||||||
|
option quiet
|
||||||
|
name dir01.exe
|
||||||
|
option caseexact
|
||||||
|
system os2v2
|
||||||
|
file dir01.obj
|
||||||
|
library release-wchar-shared\qsecmn.lib
|
||||||
|
|
||||||
|
|
||||||
|
wlink @dir01.lbc
|
||||||
|
|
||||||
|
------------------------------------------------------------------------
|
||||||
|
|
||||||
|
wcc386 -bt=dos -dDOS4GW -zq -i=..\..\include -DNDEBUG -DQSE_CHAR_IS_WCHAR=1 -wx -d0 -bm -ot -ox ..\..\samples\cmn\dir01.c
|
||||||
|
|
||||||
|
>>> dir01.lbc
|
||||||
|
option quiet
|
||||||
|
name dir01.exe
|
||||||
|
option caseexact
|
||||||
|
system DOS4G
|
||||||
|
file dir01.obj
|
||||||
|
library release-wchar-static\qsecmn.lib
|
||||||
|
option stack=256k
|
||||||
|
|
||||||
|
wlink @dir01.lbc
|
||||||
|
------------------------------------------------------------------------
|
||||||
|
|
||||||
|
wcc386 -bt=nt -zq -i=..\..\include -DNDEBUG -DQSE_CHAR_IS_WCHAR=1 -wx -d0 -bm -ot -ox ..\..\samples\cmn\dir01.c
|
||||||
|
|
||||||
|
>>> dir01.lbc
|
||||||
|
option quiet
|
||||||
|
name dir01.exe
|
||||||
|
option caseexact
|
||||||
|
system nt ref 'main_'
|
||||||
|
file dir01.obj
|
||||||
|
library release-wchar-shared\qsecmn.lib
|
||||||
|
|
||||||
|
wlink @dir01.lbc
|
@ -115,7 +115,7 @@ typedef enum segment_type_t segment_type_t;
|
|||||||
#define get_next_segment mbs_get_next_segment
|
#define get_next_segment mbs_get_next_segment
|
||||||
#define handle_non_wild_segments mbs_handle_non_wild_segments
|
#define handle_non_wild_segments mbs_handle_non_wild_segments
|
||||||
#define CHAR_IS_MCHAR
|
#define CHAR_IS_MCHAR
|
||||||
#undef DECLARE_MBUF
|
#undef INCLUDE_MBUF
|
||||||
#include "glob.h"
|
#include "glob.h"
|
||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
@ -156,7 +156,7 @@ typedef enum segment_type_t segment_type_t;
|
|||||||
#undef get_next_segment
|
#undef get_next_segment
|
||||||
#undef handle_non_wild_segments
|
#undef handle_non_wild_segments
|
||||||
#undef CHAR_IS_MCHAR
|
#undef CHAR_IS_MCHAR
|
||||||
#undef DECLARE_MBUF
|
#undef INCLUDE_MBUF
|
||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
|
|
||||||
@ -198,6 +198,6 @@ typedef enum segment_type_t segment_type_t;
|
|||||||
#define handle_non_wild_segments wcs_handle_non_wild_segments
|
#define handle_non_wild_segments wcs_handle_non_wild_segments
|
||||||
#undef CHAR_IS_MCHAR
|
#undef CHAR_IS_MCHAR
|
||||||
#if !defined(_WIN32)
|
#if !defined(_WIN32)
|
||||||
# define DECLARE_MBUF 1
|
# define INCLUDE_MBUF 1
|
||||||
#endif
|
#endif
|
||||||
#include "glob.h"
|
#include "glob.h"
|
||||||
|
@ -41,7 +41,7 @@ struct glob_t
|
|||||||
str_t path;
|
str_t path;
|
||||||
str_t tbuf; /* temporary buffer */
|
str_t tbuf; /* temporary buffer */
|
||||||
|
|
||||||
#if defined(DECLARE_MBUF)
|
#if defined(INCLUDE_MBUF)
|
||||||
qse_mbs_t mbuf;
|
qse_mbs_t mbuf;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ struct stack_node_t
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(DECLARE_MBUF)
|
#if defined(INCLUDE_MBUF)
|
||||||
static qse_mchar_t* wcs_to_mbuf (glob_t* g, const qse_wchar_t* wcs, qse_mbs_t* mbs)
|
static qse_mchar_t* wcs_to_mbuf (glob_t* g, const qse_wchar_t* wcs, qse_mbs_t* mbs)
|
||||||
{
|
{
|
||||||
qse_size_t ml, wl;
|
qse_size_t ml, wl;
|
||||||
@ -104,6 +104,7 @@ static int path_exists (glob_t* g, const char_t* name)
|
|||||||
#if !defined(INVALID_FILE_ATTRIBUTES)
|
#if !defined(INVALID_FILE_ATTRIBUTES)
|
||||||
#define INVALID_FILE_ATTRIBUTES ((DWORD)-1)
|
#define INVALID_FILE_ATTRIBUTES ((DWORD)-1)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CHAR_IS_MCHAR)
|
#if defined(CHAR_IS_MCHAR)
|
||||||
return (GetFileAttributesA(name) != INVALID_FILE_ATTRIBUTES)? 1: 0;
|
return (GetFileAttributesA(name) != INVALID_FILE_ATTRIBUTES)? 1: 0;
|
||||||
#else
|
#else
|
||||||
@ -563,7 +564,7 @@ int glob (const char_t* pattern, cbimpl_t cbimpl, void* cbctx, int flags, qse_mm
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(DECLARE_MBUF)
|
#if defined(INCLUDE_MBUF)
|
||||||
if (qse_mbs_init (&g.mbuf, mmgr, 512) <= -1)
|
if (qse_mbs_init (&g.mbuf, mmgr, 512) <= -1)
|
||||||
{
|
{
|
||||||
str_fini (&g.path);
|
str_fini (&g.path);
|
||||||
@ -579,7 +580,7 @@ int glob (const char_t* pattern, cbimpl_t cbimpl, void* cbctx, int flags, qse_mm
|
|||||||
|
|
||||||
x = search (&g, &seg);
|
x = search (&g, &seg);
|
||||||
|
|
||||||
#if defined(DECLARE_MBUF)
|
#if defined(INCLUDE_MBUF)
|
||||||
qse_mbs_fini (&g.mbuf);
|
qse_mbs_fini (&g.mbuf);
|
||||||
#endif
|
#endif
|
||||||
str_fini (&g.tbuf);
|
str_fini (&g.tbuf);
|
||||||
|
@ -48,7 +48,6 @@ static qse_cmgr_t builtin_cmgr[] =
|
|||||||
{ qse_cp949touc, qse_uctocp949 },
|
{ qse_cp949touc, qse_uctocp949 },
|
||||||
{ qse_cp950touc, qse_uctocp950 }
|
{ qse_cp950touc, qse_uctocp950 }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static qse_cmgr_t* dfl_cmgr = &builtin_cmgr[QSE_CMGR_SLMB];
|
static qse_cmgr_t* dfl_cmgr = &builtin_cmgr[QSE_CMGR_SLMB];
|
||||||
|
@ -148,7 +148,6 @@ static qse_size_t format_dirent (
|
|||||||
const qse_httpd_dirent_t* dirent,
|
const qse_httpd_dirent_t* dirent,
|
||||||
qse_mchar_t* buf, int bufsz)
|
qse_mchar_t* buf, int bufsz)
|
||||||
{
|
{
|
||||||
/* TODO: page encoding?? utf-8??? or derive name from cmgr or current locale??? */
|
|
||||||
qse_size_t x;
|
qse_size_t x;
|
||||||
|
|
||||||
qse_mchar_t* encname;
|
qse_mchar_t* encname;
|
||||||
@ -332,8 +331,11 @@ static int task_main_dseg (
|
|||||||
qpath_esc = qse_httpd_escapehtml (httpd, ctx->qpath.ptr);
|
qpath_esc = qse_httpd_escapehtml (httpd, ctx->qpath.ptr);
|
||||||
if (qpath_esc == QSE_NULL) return -1;
|
if (qpath_esc == QSE_NULL) return -1;
|
||||||
|
|
||||||
|
/* TODO: page encoding?? utf-8??? or derive name from cmgr or current locale??? */
|
||||||
|
/* TODO: SUPPORT character set. DON't HARD_CODE it to UTF8 */
|
||||||
x = qse_mbsxfmts (&ctx->buf[ctx->buflen], ctx->bufrem,
|
x = qse_mbsxfmts (&ctx->buf[ctx->buflen], ctx->bufrem,
|
||||||
QSE_MT("<html><head>%s</head>\n<body>\n<div class='header'>%s</div>\n<div class='body'><table>%s"), ctx->head.ptr, qpath_esc,
|
QSE_MT("<html><meta http-equiv=\"Content-Type\" content=\"text/html; charset='UTF-8'\">\n<head>%s</head>\n<body>\n<div class='header'>%s</div>\n<div class='body'><table>%s"),
|
||||||
|
ctx->head.ptr, qpath_esc,
|
||||||
(is_root? QSE_MT(""): QSE_MT("<tr><td class='name'><a href='../' class='dir'>..</a></td><td class='time'></td><td class='size'></td></tr>\n"))
|
(is_root? QSE_MT(""): QSE_MT("<tr><td class='name'><a href='../' class='dir'>..</a></td><td class='time'></td><td class='size'></td></tr>\n"))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -22,7 +22,6 @@ static void print_usage (const qse_char_t* argv0)
|
|||||||
qse_fprintf (QSE_STDERR, QSE_T(" -p preserve\n"));
|
qse_fprintf (QSE_STDERR, QSE_T(" -p preserve\n"));
|
||||||
qse_fprintf (QSE_STDERR, QSE_T(" -r recursive\n"));
|
qse_fprintf (QSE_STDERR, QSE_T(" -r recursive\n"));
|
||||||
qse_fprintf (QSE_STDERR, QSE_T(" -s symlink\n"));
|
qse_fprintf (QSE_STDERR, QSE_T(" -s symlink\n"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int fs_main (int argc, qse_char_t* argv[])
|
static int fs_main (int argc, qse_char_t* argv[])
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
#include <qse/cmn/glob.h>
|
#include <qse/cmn/glob.h>
|
||||||
#include <qse/cmn/stdio.h>
|
#include <qse/cmn/sio.h>
|
||||||
#include <qse/cmn/main.h>
|
#include <qse/cmn/main.h>
|
||||||
#include <qse/cmn/mbwc.h>
|
#include <qse/cmn/mbwc.h>
|
||||||
#include <qse/cmn/str.h>
|
#include <qse/cmn/str.h>
|
||||||
#include <qse/cmn/mem.h>
|
#include <qse/cmn/mem.h>
|
||||||
|
#include <qse/cmn/fmt.h>
|
||||||
#include <qse/cmn/path.h>
|
#include <qse/cmn/path.h>
|
||||||
|
|
||||||
|
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
# include <windows.h>
|
# include <windows.h>
|
||||||
@ -30,7 +30,8 @@ static int glob_main (int argc, qse_char_t* argv[])
|
|||||||
|
|
||||||
for (i = 1; i < argc; i++)
|
for (i = 1; i < argc; i++)
|
||||||
{
|
{
|
||||||
if (qse_glob (argv[i], print, QSE_NULL, QSE_GLOB_PERIOD, QSE_MMGR_GETDFL()) <= -1) return -1;
|
if (qse_glob (argv[i], print, QSE_NULL, QSE_GLOB_PERIOD,
|
||||||
|
qse_getdflmmgr(), qse_getdflcmgr()) <= -1) return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -38,6 +39,7 @@ static int glob_main (int argc, qse_char_t* argv[])
|
|||||||
|
|
||||||
int qse_main (int argc, qse_achar_t* argv[])
|
int qse_main (int argc, qse_achar_t* argv[])
|
||||||
{
|
{
|
||||||
|
int x;
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
char locale[100];
|
char locale[100];
|
||||||
UINT codepage = GetConsoleOutputCP();
|
UINT codepage = GetConsoleOutputCP();
|
||||||
@ -48,7 +50,9 @@ int qse_main (int argc, qse_achar_t* argv[])
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sprintf (locale, ".%u", (unsigned int)codepage);
|
/* .codepage */
|
||||||
|
qse_fmtuintmaxtombs (locale, QSE_COUNTOF(locale),
|
||||||
|
codepage, 10, -1, QSE_MT('\0'), QSE_MT("."));
|
||||||
setlocale (LC_ALL, locale);
|
setlocale (LC_ALL, locale);
|
||||||
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
|
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
|
||||||
}
|
}
|
||||||
@ -56,6 +60,13 @@ int qse_main (int argc, qse_achar_t* argv[])
|
|||||||
setlocale (LC_ALL, "");
|
setlocale (LC_ALL, "");
|
||||||
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
|
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
|
||||||
#endif
|
#endif
|
||||||
return qse_runmain (argc, argv, glob_main);
|
|
||||||
|
qse_openstdsios ();
|
||||||
|
|
||||||
|
x = qse_runmain (argc, argv, glob_main);
|
||||||
|
|
||||||
|
qse_closestdsios ();
|
||||||
|
|
||||||
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user