Compare commits
2 Commits
c15ba6aa15
...
d36d1a8675
| Author | SHA1 | Date | |
|---|---|---|---|
| d36d1a8675 | |||
| edea38a631 |
+9
-9
@@ -7,7 +7,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: hawk 1.0.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2026-05-14 23:00+0900\n"
|
||||
"POT-Creation-Date: 2026-05-23 12:01+0900\n"
|
||||
"PO-Revision-Date: 2026-03-28 16:29+0800\n"
|
||||
"Last-Translator: <author@hawk>\n"
|
||||
"Language-Team: Korean <translation-team-ko@hawk>\n"
|
||||
@@ -101,7 +101,7 @@ msgstr "오류 허용성을 높임"
|
||||
msgid "enable the extended call syntax"
|
||||
msgstr "확장 호출 문법을 활성화"
|
||||
|
||||
#: ../../bin/hawk.c:409 ../../bin/main.c:414
|
||||
#: ../../bin/hawk.c:409 ../../bin/main.c:416
|
||||
msgid "USAGE"
|
||||
msgstr "사용법"
|
||||
|
||||
@@ -117,7 +117,7 @@ msgstr " "
|
||||
msgid "[options] [ -- ] sourcestring [datafile]*"
|
||||
msgstr "[옵션] [ -- ] 소스문자열 [자료파일]*"
|
||||
|
||||
#: ../../bin/hawk.c:411 ../../bin/main.c:415
|
||||
#: ../../bin/hawk.c:411 ../../bin/main.c:417
|
||||
msgid "Options as follows:"
|
||||
msgstr "옵션은 다음과 같습니다:"
|
||||
|
||||
@@ -214,15 +214,15 @@ msgstr " --classic 고전 모드로 실행"
|
||||
msgid "Special mode switching options(must be specified first to take effect):"
|
||||
msgstr "모드 전환 옵션(처음에 지정해야 적용됨):"
|
||||
|
||||
#: ../../bin/hawk.c:446 ../../bin/main.c:418
|
||||
#: ../../bin/hawk.c:446 ../../bin/main.c:420
|
||||
msgid " --awk/--hawk switch to the awk mode(default)"
|
||||
msgstr " --awk/--hawk awk 모드로 전환(기본값)"
|
||||
|
||||
#: ../../bin/hawk.c:447 ../../bin/main.c:419
|
||||
#: ../../bin/hawk.c:447 ../../bin/main.c:421
|
||||
msgid " --cut switch to the cut mode"
|
||||
msgstr " --cut cut 모드로 전환"
|
||||
|
||||
#: ../../bin/hawk.c:448 ../../bin/main.c:420
|
||||
#: ../../bin/hawk.c:448 ../../bin/main.c:422
|
||||
msgid " --sed switch to the sed mode"
|
||||
msgstr " --sed sed 모드로 전환"
|
||||
|
||||
@@ -246,15 +246,15 @@ msgstr "코드"
|
||||
msgid "File "
|
||||
msgstr "파일 "
|
||||
|
||||
#: ../../bin/main.c:414
|
||||
#: ../../bin/main.c:416
|
||||
msgid "[options] [mode specific options and parameters]"
|
||||
msgstr "[옵션] [모드별 옵션과 인자]"
|
||||
|
||||
#: ../../bin/main.c:416
|
||||
#: ../../bin/main.c:418
|
||||
msgid " --usage print this message"
|
||||
msgstr " --usage 이 메시지를 출력"
|
||||
|
||||
#: ../../bin/main.c:417
|
||||
#: ../../bin/main.c:419
|
||||
msgid " --version print version"
|
||||
msgstr " --version 버전을 출력"
|
||||
|
||||
|
||||
+9
-9
@@ -7,7 +7,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: hawk 1.0.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2026-05-14 23:00+0900\n"
|
||||
"POT-Creation-Date: 2026-05-23 12:01+0900\n"
|
||||
"PO-Revision-Date: 2026-03-28 17:00+0800\n"
|
||||
"Last-Translator: <author@hawk>\n"
|
||||
"Language-Team: Chinese (Simplified) <translation-team-zh_CN@hawk>\n"
|
||||
@@ -101,7 +101,7 @@ msgstr "提高容错性"
|
||||
msgid "enable the extended call syntax"
|
||||
msgstr "启用扩展调用语法"
|
||||
|
||||
#: ../../bin/hawk.c:409 ../../bin/main.c:414
|
||||
#: ../../bin/hawk.c:409 ../../bin/main.c:416
|
||||
msgid "USAGE"
|
||||
msgstr "用法"
|
||||
|
||||
@@ -117,7 +117,7 @@ msgstr " "
|
||||
msgid "[options] [ -- ] sourcestring [datafile]*"
|
||||
msgstr "[选项] [ -- ] 源字符串 [数据文件]*"
|
||||
|
||||
#: ../../bin/hawk.c:411 ../../bin/main.c:415
|
||||
#: ../../bin/hawk.c:411 ../../bin/main.c:417
|
||||
msgid "Options as follows:"
|
||||
msgstr "选项如下:"
|
||||
|
||||
@@ -213,15 +213,15 @@ msgstr " --classic 以经典模式运行"
|
||||
msgid "Special mode switching options(must be specified first to take effect):"
|
||||
msgstr "特殊模式切换选项(必须先指定才能生效):"
|
||||
|
||||
#: ../../bin/hawk.c:446 ../../bin/main.c:418
|
||||
#: ../../bin/hawk.c:446 ../../bin/main.c:420
|
||||
msgid " --awk/--hawk switch to the awk mode(default)"
|
||||
msgstr " --awk/--hawk 切换到 awk 模式(默认)"
|
||||
|
||||
#: ../../bin/hawk.c:447 ../../bin/main.c:419
|
||||
#: ../../bin/hawk.c:447 ../../bin/main.c:421
|
||||
msgid " --cut switch to the cut mode"
|
||||
msgstr " --cut 切换到 cut 模式"
|
||||
|
||||
#: ../../bin/hawk.c:448 ../../bin/main.c:420
|
||||
#: ../../bin/hawk.c:448 ../../bin/main.c:422
|
||||
msgid " --sed switch to the sed mode"
|
||||
msgstr " --sed 切换到 sed 模式"
|
||||
|
||||
@@ -245,15 +245,15 @@ msgstr "代码"
|
||||
msgid "File "
|
||||
msgstr "文件 "
|
||||
|
||||
#: ../../bin/main.c:414
|
||||
#: ../../bin/main.c:416
|
||||
msgid "[options] [mode specific options and parameters]"
|
||||
msgstr "[选项] [模式特定选项与参数]"
|
||||
|
||||
#: ../../bin/main.c:416
|
||||
#: ../../bin/main.c:418
|
||||
msgid " --usage print this message"
|
||||
msgstr " --usage 显示此信息"
|
||||
|
||||
#: ../../bin/main.c:417
|
||||
#: ../../bin/main.c:419
|
||||
msgid " --version print version"
|
||||
msgstr " --version 显示版本"
|
||||
|
||||
|
||||
+9
-9
@@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2026-05-14 23:00+0900\n"
|
||||
"POT-Creation-Date: 2026-05-23 12:01+0900\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@@ -101,7 +101,7 @@ msgstr ""
|
||||
msgid "enable the extended call syntax"
|
||||
msgstr ""
|
||||
|
||||
#: ../../bin/hawk.c:409 ../../bin/main.c:414
|
||||
#: ../../bin/hawk.c:409 ../../bin/main.c:416
|
||||
msgid "USAGE"
|
||||
msgstr ""
|
||||
|
||||
@@ -117,7 +117,7 @@ msgstr ""
|
||||
msgid "[options] [ -- ] sourcestring [datafile]*"
|
||||
msgstr ""
|
||||
|
||||
#: ../../bin/hawk.c:411 ../../bin/main.c:415
|
||||
#: ../../bin/hawk.c:411 ../../bin/main.c:417
|
||||
msgid "Options as follows:"
|
||||
msgstr ""
|
||||
|
||||
@@ -211,15 +211,15 @@ msgstr ""
|
||||
msgid "Special mode switching options(must be specified first to take effect):"
|
||||
msgstr ""
|
||||
|
||||
#: ../../bin/hawk.c:446 ../../bin/main.c:418
|
||||
#: ../../bin/hawk.c:446 ../../bin/main.c:420
|
||||
msgid " --awk/--hawk switch to the awk mode(default)"
|
||||
msgstr ""
|
||||
|
||||
#: ../../bin/hawk.c:447 ../../bin/main.c:419
|
||||
#: ../../bin/hawk.c:447 ../../bin/main.c:421
|
||||
msgid " --cut switch to the cut mode"
|
||||
msgstr ""
|
||||
|
||||
#: ../../bin/hawk.c:448 ../../bin/main.c:420
|
||||
#: ../../bin/hawk.c:448 ../../bin/main.c:422
|
||||
msgid " --sed switch to the sed mode"
|
||||
msgstr ""
|
||||
|
||||
@@ -243,15 +243,15 @@ msgstr ""
|
||||
msgid "File "
|
||||
msgstr ""
|
||||
|
||||
#: ../../bin/main.c:414
|
||||
#: ../../bin/main.c:416
|
||||
msgid "[options] [mode specific options and parameters]"
|
||||
msgstr ""
|
||||
|
||||
#: ../../bin/main.c:416
|
||||
#: ../../bin/main.c:418
|
||||
msgid " --usage print this message"
|
||||
msgstr ""
|
||||
|
||||
#: ../../bin/main.c:417
|
||||
#: ../../bin/main.c:419
|
||||
msgid " --version print version"
|
||||
msgstr ""
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
#include "main.h"
|
||||
#include <hawk.h>
|
||||
#include <hawk-fmt.h>
|
||||
#include <hawk-glob.h>
|
||||
#include <hawk-po.h>
|
||||
#include <hawk-xma.h>
|
||||
@@ -36,6 +37,7 @@
|
||||
|
||||
#if defined(_WIN32)
|
||||
# include <windows.h>
|
||||
# include <signal.h>
|
||||
#elif defined(__OS2__)
|
||||
# define INCL_ERRORS
|
||||
# include <os2.h>
|
||||
|
||||
+3
-2
@@ -1456,11 +1456,11 @@ Hawk::Value::IndexIterator Hawk::Value::getNextIndex (Index* idx, const IndexIte
|
||||
// Hawk::Run
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
Hawk::Run::Run (Hawk* hawk): hawk(hawk), rtx(HAWK_NULL), envp(HAWK_NULL), env_map(HAWK_NULL), env_map_rev(0)
|
||||
Hawk::Run::Run (Hawk* hawk): hawk(hawk), rtx(HAWK_NULL), envp(HAWK_NULL), env_map(HAWK_NULL), env_map_rev(0), env_type(HAWK_RTX_ENV_MK_BPP)
|
||||
{
|
||||
}
|
||||
|
||||
Hawk::Run::Run (Hawk* hawk, hawk_rtx_t* rtx): hawk(hawk), rtx(rtx), envp(HAWK_NULL), env_map(HAWK_NULL), env_map_rev(0)
|
||||
Hawk::Run::Run (Hawk* hawk, hawk_rtx_t* rtx): hawk(hawk), rtx(rtx), envp(HAWK_NULL), env_map(HAWK_NULL), env_map_rev(0), env_type(HAWK_RTX_ENV_MK_BPP)
|
||||
{
|
||||
HAWK_ASSERT(this->rtx != HAWK_NULL);
|
||||
}
|
||||
@@ -2159,6 +2159,7 @@ void Hawk::fini_runctx ()
|
||||
this->runctx.envp = HAWK_NULL;
|
||||
this->runctx.env_map = HAWK_NULL;
|
||||
this->runctx.env_map_rev = 0;
|
||||
this->runctx.env_type = HAWK_RTX_ENV_MK_BPP;
|
||||
}
|
||||
|
||||
hawk_rtx_close(this->runctx.rtx);
|
||||
|
||||
+8
-1
@@ -1342,11 +1342,17 @@ public:
|
||||
return this->env_map_rev;
|
||||
}
|
||||
|
||||
void setEnvCache (void* envp, hawk_map_t* env_map, hawk_oow_t env_map_rev)
|
||||
hawk_rtx_env_mk_type_t getEnvType () const
|
||||
{
|
||||
return this->env_type;
|
||||
}
|
||||
|
||||
void setEnvCache (void* envp, hawk_map_t* env_map, hawk_oow_t env_map_rev, hawk_rtx_env_mk_type_t env_type)
|
||||
{
|
||||
this->envp = envp;
|
||||
this->env_map = env_map;
|
||||
this->env_map_rev = env_map_rev;
|
||||
this->env_type = env_type;
|
||||
}
|
||||
|
||||
protected:
|
||||
@@ -1356,6 +1362,7 @@ public:
|
||||
void* envp;
|
||||
hawk_map_t* env_map;
|
||||
hawk_oow_t env_map_rev;
|
||||
hawk_rtx_env_mk_type_t env_type;
|
||||
};
|
||||
|
||||
///
|
||||
|
||||
+34
-14
@@ -34,21 +34,42 @@
|
||||
#define IO_UFLAG_PIPE_IS_NWIO (((hawk_uint16_t)1) << 0)
|
||||
#define IO_UFLAG_CONSOLE_PENDING_NEXT (((hawk_uint16_t)1) << 1)
|
||||
|
||||
// TODO: remove the following definitions and find a way to share the similar definitions in std.c
|
||||
#if defined(HAWK_ENABLE_LIBLTDL)
|
||||
# define USE_LTDL
|
||||
#elif defined(HAVE_DLFCN_H)
|
||||
# define USE_DLFCN
|
||||
#if defined(_WIN32)
|
||||
# include <windows.h>
|
||||
# include <tchar.h>
|
||||
# if defined(HAWK_HAVE_CFG_H) && defined(HAWK_ENABLE_LIBLTDL)
|
||||
# include <ltdl.h>
|
||||
# define USE_LTDL
|
||||
# endif
|
||||
# include <io.h>
|
||||
#elif defined(__OS2__)
|
||||
# define INCL_DOSMODULEMGR
|
||||
# define INCL_DOSPROCESS
|
||||
# define INCL_DOSERRORS
|
||||
# include <os2.h>
|
||||
#elif defined(__DOS__)
|
||||
/* nothing to include */
|
||||
#else
|
||||
# error UNSUPPORTED DYNAMIC LINKER
|
||||
# include "syscall.h"
|
||||
# if defined(HAWK_ENABLE_LIBLTDL)
|
||||
# include <ltdl.h>
|
||||
# define USE_LTDL
|
||||
# elif defined(HAVE_DLFCN_H)
|
||||
# include <dlfcn.h>
|
||||
# define USE_DLFCN
|
||||
# else
|
||||
# error UNSUPPORTED DYNAMIC LINKER
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_CRT_EXTERNS_H)
|
||||
#if defined(_WIN32)
|
||||
# define SYSTEM_ENVIRON _environ
|
||||
#elif defined(HAVE_CRT_EXTERNS_H)
|
||||
# include <crt_externs.h> /* MacOSX/darwin. _NSGetEnviron() */
|
||||
# define SYSTEM_ENVIRON (*(_NSGetEnviron()))
|
||||
#else
|
||||
extern char** environ;
|
||||
# define SYSTEM_ENVIRON ::environ
|
||||
# define SYSTEM_ENVIRON environ
|
||||
#endif
|
||||
|
||||
/////////////////////////////////
|
||||
@@ -78,8 +99,6 @@ static void* rtx_env_maker (hawk_rtx_t* rtx, hawk_rtx_env_mk_type_t env_mk_type)
|
||||
hawk_oow_t env_map_rev;
|
||||
int gbl_id;
|
||||
|
||||
if (env_mk_type != HAWK_RTX_ENV_MK_BPP) return HAWK_NULL;
|
||||
|
||||
run = GET_STD_RXTN(rtx)->run;
|
||||
if (HAWK_UNLIKELY(run == HAWK_NULL)) return HAWK_NULL;
|
||||
hawk = (HawkStd*)(Hawk*)*run;
|
||||
@@ -103,16 +122,17 @@ static void* rtx_env_maker (hawk_rtx_t* rtx, hawk_rtx_env_mk_type_t env_mk_type)
|
||||
env_map_rev = 0;
|
||||
}
|
||||
|
||||
if (!run->getEnvp() || run->getEnvMap() != env_map ||
|
||||
if (!run->getEnvp() || run->getEnvType() != env_mk_type ||
|
||||
run->getEnvMap() != env_map ||
|
||||
(env_map && run->getEnvMapRev() != env_map_rev))
|
||||
{
|
||||
hawk_bch_t** envp;
|
||||
void* envp;
|
||||
|
||||
envp = hawk_rtx_commit_environ(rtx, gbl_id);
|
||||
envp = hawk_rtx_commit_environ(rtx, gbl_id, env_mk_type);
|
||||
if (HAWK_UNLIKELY(!envp)) return HAWK_NULL;
|
||||
|
||||
if (run->getEnvp()) hawk_rtx_freemem(rtx, run->getEnvp());
|
||||
run->setEnvCache(envp, env_map, env_map_rev);
|
||||
run->setEnvCache(envp, env_map, env_map_rev, env_mk_type);
|
||||
}
|
||||
|
||||
return run->getEnvp();
|
||||
|
||||
@@ -255,9 +255,9 @@ static hawk_bch_t* mbs_to_mbuf (hawk_dir_t* dir, const hawk_bch_t* mbs, hawk_bec
|
||||
}
|
||||
|
||||
#if defined(_WIN32) || defined(__OS2__) || defined(__DOS__)
|
||||
static hawk_bch_t* make_mbsdos_path (hawk_dir_t* dir, const hawk_bch_t* mpath)
|
||||
static hawk_bch_t* make_bcstr_path (hawk_dir_t* dir, const hawk_bch_t* mpath)
|
||||
{
|
||||
if (mpath[0] == '\0')
|
||||
if (mpath[0] == '\0') /* blank */
|
||||
{
|
||||
if (hawk_becs_cpy(&dir->mbuf, "*.*") == (hawk_oow_t)-1) return HAWK_NULL;
|
||||
}
|
||||
@@ -265,29 +265,29 @@ static hawk_bch_t* make_mbsdos_path (hawk_dir_t* dir, const hawk_bch_t* mpath)
|
||||
{
|
||||
hawk_oow_t len;
|
||||
if ((len = hawk_becs_cpy(&dir->mbuf, mpath)) == (hawk_oow_t)-1 ||
|
||||
(!HAWK_ISPATHMBSEP(mpath[len - 1]) &&
|
||||
!hawk_ismbsdrivecurpath(mpath) &&
|
||||
hawk_becs_ccat(&dir->mbuf, '\\') == (hawk_oow_t)-1) ||
|
||||
(!HAWK_IS_PATH_SEP(mpath[len - 1]) && /* last letter is not a path sepearator */
|
||||
!(len == 2 && HAWK_IS_PATH_DRIVE(mpath)) && /* isn't just a driver letter and colon (e.g. A:) */
|
||||
hawk_becs_ccat(&dir->mbuf, '\\') == (hawk_oow_t)-1 /* append a path separator */ ) ||
|
||||
hawk_becs_cat(&dir->mbuf, "*.*") == (hawk_oow_t)-1) return HAWK_NULL;
|
||||
}
|
||||
|
||||
return HAWK_BECS_PTR(&dir->mbuf);
|
||||
}
|
||||
|
||||
static hawk_uch_t* make_wcsdos_path (hawk_dir_t* dir, const hawk_uch_t* wpath)
|
||||
static hawk_uch_t* make_ucstr_path (hawk_dir_t* dir, const hawk_uch_t* wpath)
|
||||
{
|
||||
if (wpath[0] == HAWK_UT('\0'))
|
||||
if (wpath[0] == '\0')
|
||||
{
|
||||
if (hawk_uecs_cpy (&dir->wbuf, HAWK_UT("*.*")) == (hawk_oow_t)-1) return HAWK_NULL;
|
||||
if (hawk_uecs_cpy(&dir->wbuf, HAWK_UT("*.*")) == (hawk_oow_t)-1) return HAWK_NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
hawk_oow_t len;
|
||||
if ((len = hawk_uecs_cpy (&dir->wbuf, wpath)) == (hawk_oow_t)-1 ||
|
||||
(!HAWK_ISPATHWCSEP(wpath[len - 1]) &&
|
||||
!hawk_iswcsdrivecurpath(wpath) &&
|
||||
hawk_uecs_ccat (&dir->wbuf, HAWK_UT('\\')) == (hawk_oow_t)-1) ||
|
||||
hawk_uecs_cat (&dir->wbuf, HAWK_UT("*.*")) == (hawk_oow_t)-1) return HAWK_NULL;
|
||||
if ((len = hawk_uecs_cpy(&dir->wbuf, wpath)) == (hawk_oow_t)-1 ||
|
||||
(!HAWK_IS_PATH_SEP(wpath[len - 1]) && /* last letter is not a path sepearator */
|
||||
!(len == 2 && HAWK_IS_PATH_DRIVE(wpath)) && /* isn't just a driver letter and colon (e.g. A:) */
|
||||
hawk_uecs_ccat(&dir->wbuf, HAWK_UT('\\')) == (hawk_oow_t)-1 /* append a path separator */ ) ||
|
||||
hawk_uecs_cat(&dir->wbuf, HAWK_UT("*.*")) == (hawk_oow_t)-1) return HAWK_NULL;
|
||||
}
|
||||
|
||||
return HAWK_UECS_PTR(&dir->wbuf);
|
||||
@@ -309,7 +309,7 @@ static int reset_to_path (hawk_dir_t* dir, const hawk_ooch_t* path)
|
||||
{
|
||||
hawk_bch_t* mptr;
|
||||
|
||||
mptr = make_mbsdos_path(dir, (const hawk_bch_t*)path);
|
||||
mptr = make_bcstr_path(dir, (const hawk_bch_t*)path);
|
||||
if (mptr == HAWK_NULL) return -1;
|
||||
|
||||
#if defined(HAWK_OOCH_IS_BCH)
|
||||
@@ -323,7 +323,7 @@ static int reset_to_path (hawk_dir_t* dir, const hawk_ooch_t* path)
|
||||
hawk_uch_t* wptr;
|
||||
HAWK_ASSERT (dir->flags & HAWK_DIR_UPATH);
|
||||
|
||||
wptr = make_wcsdos_path(dir, (const hawk_uch_t*)path);
|
||||
wptr = make_ucstr_path(dir, (const hawk_uch_t*)path);
|
||||
if (wptr == HAWK_NULL) return -1;
|
||||
|
||||
#if defined(HAWK_OOCH_IS_BCH)
|
||||
@@ -363,14 +363,14 @@ static int reset_to_path (hawk_dir_t* dir, const hawk_ooch_t* path)
|
||||
|
||||
if (dir->flags & HAWK_DIR_BPATH)
|
||||
{
|
||||
mptr = make_mbsdos_path (dir, (const hawk_bch_t*)path);
|
||||
mptr = make_bcstr_path (dir, (const hawk_bch_t*)path);
|
||||
}
|
||||
else
|
||||
{
|
||||
hawk_uch_t* wptr;
|
||||
HAWK_ASSERT (dir->flags & HAWK_DIR_UPATH);
|
||||
|
||||
wptr = make_wcsdos_path(dir, (const hawk_uch_t*)path);
|
||||
wptr = make_ucstr_path(dir, (const hawk_uch_t*)path);
|
||||
if (wptr == HAWK_NULL) return -1;
|
||||
mptr = wcs_to_mbuf(dir, wptr, &dir->mbuf);
|
||||
}
|
||||
@@ -417,15 +417,15 @@ static int reset_to_path (hawk_dir_t* dir, const hawk_ooch_t* path)
|
||||
|
||||
if (dir->flags & HAWK_DIR_BPATH)
|
||||
{
|
||||
mptr = make_mbsdos_path(dir, (const hawk_bch_t*)path);
|
||||
mptr = make_bcstr_path(dir, (const hawk_bch_t*)path);
|
||||
}
|
||||
else
|
||||
{
|
||||
hawk_uch_t* wptr;
|
||||
|
||||
HAWK_ASSERT (dir->flags & HAWK_DIR_UPATH);
|
||||
HAWK_ASSERT(dir->flags & HAWK_DIR_UPATH);
|
||||
|
||||
wptr = make_wcsdos_path(dir, (const hawk_uch_t*)path);
|
||||
wptr = make_ucstr_path(dir, (const hawk_uch_t*)path);
|
||||
if (wptr == HAWK_NULL) return -1;
|
||||
mptr = wcs_to_mbuf(dir, wptr, &dir->mbuf);
|
||||
}
|
||||
@@ -456,7 +456,7 @@ static int reset_to_path (hawk_dir_t* dir, const hawk_ooch_t* path)
|
||||
else
|
||||
{
|
||||
const hawk_uch_t* wpath;
|
||||
/*HAWK_ASSERT (dir->flags & HAWK_DIR_UPATH);*/
|
||||
/*HAWK_ASSERT(dir->flags & HAWK_DIR_UPATH);*/
|
||||
|
||||
wpath = (const hawk_uch_t*)path;
|
||||
if (wpath[0] == '\0')
|
||||
@@ -550,7 +550,7 @@ static int read_dir_to_buf (hawk_dir_t* dir, void** name)
|
||||
}
|
||||
else
|
||||
{
|
||||
HAWK_ASSERT (dir->flags & HAWK_DIR_UPATH);
|
||||
HAWK_ASSERT(dir->flags & HAWK_DIR_UPATH);
|
||||
#if defined(HAWK_OOCH_IS_BCH)
|
||||
if (mbs_to_wbuf(dir, dir->wfd.cFileName, &dir->wbuf) == HAWK_NULL) return -1;
|
||||
#else
|
||||
@@ -607,7 +607,7 @@ static int read_dir_to_buf (hawk_dir_t* dir, void** name)
|
||||
}
|
||||
else
|
||||
{
|
||||
HAWK_ASSERT (dir->flags & HAWK_DIR_UPATH);
|
||||
HAWK_ASSERT(dir->flags & HAWK_DIR_UPATH);
|
||||
if (mbs_to_wbuf (dir, dir->ffb.achName, &dir->wbuf) == HAWK_NULL) return -1;
|
||||
*name = HAWK_UECS_PTR(&dir->wbuf);
|
||||
}
|
||||
@@ -660,7 +660,7 @@ static int read_dir_to_buf (hawk_dir_t* dir, void** name)
|
||||
}
|
||||
else
|
||||
{
|
||||
HAWK_ASSERT (dir->flags & HAWK_DIR_UPATH);
|
||||
HAWK_ASSERT(dir->flags & HAWK_DIR_UPATH);
|
||||
|
||||
if (mbs_to_wbuf (dir, dir->f.name, &dir->wbuf) == HAWK_NULL) return -1;
|
||||
*name = HAWK_UECS_PTR(&dir->wbuf);
|
||||
@@ -708,7 +708,7 @@ read:
|
||||
}
|
||||
else
|
||||
{
|
||||
/*HAWK_ASSERT (dir->flags & HAWK_DIR_UPATH);*/
|
||||
/*HAWK_ASSERT(dir->flags & HAWK_DIR_UPATH);*/
|
||||
if (mbs_to_wbuf(dir, de->d_name, &dir->wbuf) == HAWK_NULL) return -1;
|
||||
*name = HAWK_UECS_PTR(&dir->wbuf);
|
||||
}
|
||||
|
||||
+13
-1
@@ -35,7 +35,18 @@
|
||||
#include <hawk-dir.h>
|
||||
#include <hawk-glob.h>
|
||||
|
||||
#include "syscall.h"
|
||||
#if defined(_WIN32)
|
||||
# include <windows.h>
|
||||
#elif defined(__OS2__)
|
||||
# define INCL_DOSERRORS
|
||||
# define INCL_DOSFILEMGR
|
||||
# include <os2.h>
|
||||
#elif defined(__DOS__)
|
||||
# include <errno.h>
|
||||
# include <io.h>
|
||||
#else
|
||||
# include "syscall.h"
|
||||
#endif
|
||||
|
||||
#define NO_RECURSION 1
|
||||
|
||||
@@ -52,6 +63,7 @@ typedef enum segment_type_t segment_type_t;
|
||||
#define IS_SEP(c) HAWK_FNMAT_IS_SEP(c)
|
||||
#define IS_NIL(c) ((c) == '\0')
|
||||
#define IS_SEP_OR_NIL(c) (IS_SEP(c) || IS_NIL(c))
|
||||
#define IS_DRIVE(c) HAWK_IS_PATH_DRIVE(c)
|
||||
|
||||
/* this macro only checks for top-level wild-cards among these.
|
||||
* *, ?, [], !, -
|
||||
|
||||
+13
-1
@@ -35,7 +35,18 @@
|
||||
#include <hawk-dir.h>
|
||||
#include <hawk-glob.h>
|
||||
|
||||
#include "syscall.h"
|
||||
#if defined(_WIN32)
|
||||
# include <windows.h>
|
||||
#elif defined(__OS2__)
|
||||
# define INCL_DOSERRORS
|
||||
# define INCL_DOSFILEMGR
|
||||
# include <os2.h>
|
||||
#elif defined(__DOS__)
|
||||
# include <errno.h>
|
||||
# include <io.h>
|
||||
#else
|
||||
# include "syscall.h"
|
||||
#endif
|
||||
|
||||
#define NO_RECURSION 1
|
||||
|
||||
@@ -52,6 +63,7 @@ typedef enum segment_type_t segment_type_t;
|
||||
#define IS_SEP(c) HAWK_FNMAT_IS_SEP(c)
|
||||
#define IS_NIL(c) ((c) == '\0')
|
||||
#define IS_SEP_OR_NIL(c) (IS_SEP(c) || IS_NIL(c))
|
||||
#define IS_DRIVE(c) HAWK_IS_PATH_DRIVE(c)
|
||||
|
||||
/* this macro only checks for top-level wild-cards among these.
|
||||
* *, ?, [], !, -
|
||||
|
||||
+1
-1
@@ -124,7 +124,7 @@ enum hawk_pio_env_mk_type_t
|
||||
{
|
||||
HAWK_PIO_ENV_MK_BPP, /* P1 ... PN HAWK_NUL where P1 .. PN points to K=V */
|
||||
HAWK_PIO_ENV_MK_BPN, /* K1=V\0K2=V\0\0 */
|
||||
HAWK_PIO_ENV_MK_UPP,
|
||||
HAWK_PIO_ENV_MK_UPN, /* K1=V\0K2=V\0\0 using hawk_uch_t */
|
||||
};
|
||||
|
||||
typedef enum hawk_pio_env_mk_type_t hawk_pio_env_mk_type_t;
|
||||
|
||||
+4
-3
@@ -724,9 +724,10 @@ void hawk_fini (hawk_t* hawk);
|
||||
hawk_rbt_walk_t hawk_modtab_unload_module (hawk_rbt_t* rbt, hawk_rbt_pair_t* pair, void* ctx);
|
||||
int hawk_rtx_setnamedval (hawk_rtx_t* rtx, hawk_oow_t id, hawk_val_t* val);
|
||||
|
||||
hawk_bch_t** hawk_rtx_commit_environ (
|
||||
hawk_rtx_t* rtx,
|
||||
int gbl_id
|
||||
void* hawk_rtx_commit_environ (
|
||||
hawk_rtx_t* rtx,
|
||||
int gbl_id,
|
||||
hawk_rtx_env_mk_type_t env_mk_type
|
||||
);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
@@ -320,6 +320,23 @@ typedef hawk_bch_t* (*hawk_subst_for_bcs_t) (
|
||||
# define hawk_subst_for_oocs_t hawk_subst_for_bcs_t
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(_WIN32) || defined(__OS2__) || defined(__DOS__)
|
||||
# define HAWK_IS_PATH_SEP(c) ((c) == '/' || (c) == '\\')
|
||||
#else
|
||||
# define HAWK_IS_PATH_SEP(c) ((c) == '/')
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(_WIN32) || defined(__OS2__) || defined(__DOS__)
|
||||
/* check if the first two letter is a drive specifier.
|
||||
* useful on DOS/WIN/OS2 like system */
|
||||
#define HAWK_IS_PATH_DRIVE(s) \
|
||||
(((s[0] >= 'A' && s[0] <= 'Z') || \
|
||||
(s[0] >= 'a' && s[0] <= 'z')) && \
|
||||
s[1] == ':')
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
+1
-1
@@ -912,7 +912,7 @@ enum hawk_rtx_env_mk_type_t
|
||||
{
|
||||
HAWK_RTX_ENV_MK_BPP = HAWK_PIO_ENV_MK_BPP,
|
||||
HAWK_RTX_ENV_MK_BPN = HAWK_PIO_ENV_MK_BPN,
|
||||
HAWK_RTX_ENV_MK_UPP = HAWK_PIO_ENV_MK_UPP,
|
||||
HAWK_RTX_ENV_MK_UPN = HAWK_PIO_ENV_MK_UPN,
|
||||
};
|
||||
typedef enum hawk_rtx_env_mk_type_t hawk_rtx_env_mk_type_t;
|
||||
|
||||
|
||||
+275
-25
@@ -29,7 +29,10 @@
|
||||
|
||||
#if defined(_WIN32)
|
||||
# include <windows.h>
|
||||
# include <io.h>
|
||||
# include <fcntl.h>
|
||||
# include <process.h>
|
||||
# include <tlhelp32.h>
|
||||
# include <tchar.h>
|
||||
#elif defined(__OS2__)
|
||||
# define INCL_DOSPROCESS
|
||||
@@ -51,10 +54,12 @@
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# include <termios.h>
|
||||
# include <sys/socket.h>
|
||||
|
||||
# define ENABLE_SYSLOG
|
||||
# define ENABLE_TERMIOS
|
||||
# include <termios.h>
|
||||
|
||||
# define ENABLE_SYSLOG /* enable libc's openlog, closelog, syslog */
|
||||
# include <syslog.h>
|
||||
|
||||
#endif
|
||||
@@ -1027,6 +1032,7 @@ static int fnc_fcntl (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
sys_node = get_sys_list_node_with_arg(rtx, sys_list, hawk_rtx_getarg(rtx, 0), SYS_NODE_DATA_TYPE_FILE | SYS_NODE_DATA_TYPE_SCK, &rx);
|
||||
if (sys_node)
|
||||
{
|
||||
#if defined(F_GETFD) && defined(F_GETFL) && defined(F_SETFD) && defined(F_SETFL)
|
||||
hawk_int_t cmd;
|
||||
|
||||
if (hawk_rtx_valtoint_inline(rtx, hawk_rtx_getarg(rtx, 1), &cmd) <= -1)
|
||||
@@ -1068,6 +1074,9 @@ static int fnc_fcntl (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
rx = set_error_on_sys_list(rtx, sys_list, HAWK_EINVAL, HAWK_NULL);
|
||||
break;
|
||||
}
|
||||
#else
|
||||
rx = set_error_on_sys_list(rtx, sys_list, HAWK_ENOSUP, HAWK_NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
done:
|
||||
@@ -1096,6 +1105,7 @@ static int fnc_flock (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
hawk_int_t rx;
|
||||
hawk_val_t* retv;
|
||||
|
||||
#if defined(F_RDLCK) && defined(F_WRLCK) && defined(F_UNLCK) && defined(F_GETLK) && defined(F_SETLKW) && defined(F_SETLK)
|
||||
HAWK_STATIC_ASSERT(FLOCK_GET != F_RDLCK);
|
||||
HAWK_STATIC_ASSERT(FLOCK_GET != F_WRLCK);
|
||||
HAWK_STATIC_ASSERT(FLOCK_GET != F_UNLCK);
|
||||
@@ -1154,6 +1164,10 @@ static int fnc_flock (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
rx = fl.l_type; /* for get, it returns the lock type */
|
||||
}
|
||||
}
|
||||
#else
|
||||
sys_list = rtx_to_sys_list(rtx, fi);
|
||||
rx = set_error_on_sys_list(rtx, sys_list, HAWK_ENOSUP, HAWK_NULL);
|
||||
#endif
|
||||
|
||||
done:
|
||||
retv = hawk_rtx_makeintval_inline(rtx, rx);
|
||||
@@ -1217,6 +1231,7 @@ static int fnc_tcgetattr (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) /* this is
|
||||
sys_node = get_sys_list_node_with_arg(rtx, sys_list, hawk_rtx_getarg(rtx, 0), SYS_NODE_DATA_TYPE_FILE, &rx);
|
||||
if (sys_node)
|
||||
{
|
||||
#if defined(ENABLE_TERMIOS)
|
||||
struct termios t;
|
||||
hawk_val_map_data_t md[5];
|
||||
hawk_bcs_t c_cc;
|
||||
@@ -1275,6 +1290,9 @@ static int fnc_tcgetattr (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) /* this is
|
||||
fail:
|
||||
rx = copy_error_to_sys_list(rtx, sys_list);
|
||||
}
|
||||
#else
|
||||
rx = set_error_on_sys_list(rtx, sys_list, HAWK_ENOSUP, HAWK_NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
done:
|
||||
@@ -1311,6 +1329,7 @@ static int fnc_tcsetattr (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) /* this is
|
||||
sys_node = get_sys_list_node_with_arg(rtx, sys_list, hawk_rtx_getarg(rtx, 0), SYS_NODE_DATA_TYPE_FILE, &rx);
|
||||
if (sys_node)
|
||||
{
|
||||
#if defined(ENABLE_TERMIOS)
|
||||
struct termios t;
|
||||
hawk_map_itr_t itr;
|
||||
hawk_map_pair_t* pair;
|
||||
@@ -1391,6 +1410,9 @@ static int fnc_tcsetattr (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) /* this is
|
||||
set_error_on_sys_list_with_errno(rtx, sys_list, HAWK_NULL);
|
||||
goto done;
|
||||
}
|
||||
#else
|
||||
rx = set_error_on_sys_list(rtx, sys_list, HAWK_ENOSUP, HAWK_NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
done:
|
||||
@@ -1423,6 +1445,7 @@ static int fnc_tcsetraw (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
sys_node = get_sys_list_node_with_arg(rtx, sys_list, hawk_rtx_getarg(rtx, 0), SYS_NODE_DATA_TYPE_FILE, &rx);
|
||||
if (sys_node)
|
||||
{
|
||||
#if defined(ENABLE_TERMIOS)
|
||||
struct termios t;
|
||||
|
||||
rx = tcgetattr(sys_node->ctx.u.file.fd, &t);
|
||||
@@ -1441,6 +1464,9 @@ static int fnc_tcsetraw (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
set_error_on_sys_list_with_errno(rtx, sys_list, HAWK_NULL);
|
||||
goto done;
|
||||
}
|
||||
#else
|
||||
rx = set_error_on_sys_list(rtx, sys_list, HAWK_ENOSUP, HAWK_NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
done:
|
||||
@@ -1462,6 +1488,7 @@ static int fnc_tcflush (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
sys_node = get_sys_list_node_with_arg(rtx, sys_list, hawk_rtx_getarg(rtx, 0), SYS_NODE_DATA_TYPE_FILE, &rx);
|
||||
if (sys_node)
|
||||
{
|
||||
#if defined(ENABLE_TERMIOS)
|
||||
hawk_int_t qs;
|
||||
|
||||
if (hawk_rtx_valtoint_inline(rtx, hawk_rtx_getarg(rtx, 1), &qs) <= -1) qs = TCIOFLUSH;
|
||||
@@ -1472,6 +1499,9 @@ static int fnc_tcflush (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
set_error_on_sys_list_with_errno(rtx, sys_list, HAWK_NULL);
|
||||
goto done;
|
||||
}
|
||||
#else
|
||||
rx = set_error_on_sys_list(rtx, sys_list, HAWK_ENOSUP, HAWK_NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
done:
|
||||
@@ -1580,6 +1610,9 @@ static int fnc_pipe (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
|
||||
if (hawk_rtx_getnargs(rtx) >= 3 && (hawk_rtx_valtoint_inline(rtx, hawk_rtx_getarg(rtx, 2), &flags) <= -1 || flags < 0)) flags = 0;
|
||||
|
||||
#if defined(_WIN32)
|
||||
rx = set_error_on_sys_list(rtx, sys_list, HAWK_ENOSUP, HAWK_NULL);
|
||||
#else
|
||||
#if defined(HAVE_PIPE2)
|
||||
if (pipe2(fds, flags) >= 0)
|
||||
#else
|
||||
@@ -1655,6 +1688,7 @@ static int fnc_pipe (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
{
|
||||
rx = set_error_on_sys_list_with_errno(rtx, sys_list, HAWK_NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
hawk_rtx_setretval(rtx, hawk_rtx_makeintval_inline(rtx, rx));
|
||||
return 0;
|
||||
@@ -1681,9 +1715,13 @@ static int fnc_fchown (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
rx = set_error_on_sys_list(rtx, sys_list, HAWK_ENOSUP, HAWK_NULL);
|
||||
#else
|
||||
rx = fchown(sys_node->ctx.u.file.fd, uid, gid) <= -1?
|
||||
set_error_on_sys_list_with_errno(rtx, sys_list, HAWK_NULL):
|
||||
ERRNUM_TO_RC(HAWK_ENOERR);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1709,9 +1747,13 @@ static int fnc_fchmod (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
rx = set_error_on_sys_list(rtx, sys_list, HAWK_ENOSUP, HAWK_NULL);
|
||||
#else
|
||||
rx = fchmod(sys_node->ctx.u.file.fd, mode) <= -1?
|
||||
set_error_on_sys_list_with_errno(rtx, sys_list, HAWK_NULL):
|
||||
ERRNUM_TO_RC(HAWK_ENOERR);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1922,8 +1964,8 @@ static int fnc_wait (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
sys_list_t* sys_list = rtx_to_sys_list(rtx, fi);
|
||||
|
||||
nargs = hawk_rtx_getnargs(rtx);
|
||||
if (nargs >= 3 && hawk_rtx_valtoint_inline(rtx, hawk_rtx_getarg(rtx, 2), &opts) <= -1) goto fail;
|
||||
if (hawk_rtx_valtoint_inline(rtx, hawk_rtx_getarg(rtx, 0), &pid) <= -1) goto fail;
|
||||
if (nargs >= 3 && hawk_rtx_valtoint_inline(rtx, hawk_rtx_getarg(rtx, 2), &opts) <= -1) goto oops;
|
||||
if (hawk_rtx_valtoint_inline(rtx, hawk_rtx_getarg(rtx, 0), &pid) <= -1) goto oops;
|
||||
|
||||
#if defined(_WIN32)
|
||||
/* TOOD: implement this*/
|
||||
@@ -1951,16 +1993,12 @@ static int fnc_wait (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
int x;
|
||||
|
||||
sv = hawk_rtx_makeintval_inline(rtx, status);
|
||||
if (!sv) goto fail;
|
||||
if (!sv) goto oops;
|
||||
|
||||
hawk_rtx_refupval_inline(rtx, sv);
|
||||
x = hawk_rtx_setrefval(rtx, (hawk_val_ref_t*)hawk_rtx_getarg(rtx, 1), sv);
|
||||
hawk_rtx_refdownval_inline(rtx, sv);
|
||||
if (x <= -1)
|
||||
{
|
||||
fail:
|
||||
rx = copy_error_to_sys_list(rtx, sys_list);
|
||||
}
|
||||
if (x <= -1) goto oops;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1970,13 +2008,24 @@ static int fnc_wait (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
|
||||
hawk_rtx_setretval(rtx, retv);
|
||||
return 0;
|
||||
|
||||
oops:
|
||||
rx = copy_error_to_sys_list(rtx, sys_list);
|
||||
retv = hawk_rtx_makeintval_inline(rtx, rx);
|
||||
if (!retv) return -1;
|
||||
hawk_rtx_setretval(rtx, retv);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int fnc_wifexited (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
{
|
||||
hawk_int_t wstatus;
|
||||
int rv;
|
||||
#if defined(WIFEXITED)
|
||||
rv = (hawk_rtx_valtoint_inline(rtx, hawk_rtx_getarg(rtx, 0), &wstatus) <= -1)? 0: !!WIFEXITED(wstatus);
|
||||
#else
|
||||
rv = 0;
|
||||
#endif
|
||||
hawk_rtx_setretval(rtx, hawk_rtx_makeintval_inline(rtx, rv));
|
||||
return 0;
|
||||
}
|
||||
@@ -1987,7 +2036,11 @@ static int fnc_wexitstatus (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
int rv;
|
||||
|
||||
hawk_val_t* retv;
|
||||
#if defined(WEXITSTATUS)
|
||||
rv = (hawk_rtx_valtoint_inline(rtx, hawk_rtx_getarg(rtx, 0), &wstatus) <= -1)? -1: WEXITSTATUS(wstatus);
|
||||
#else
|
||||
rv = -1;
|
||||
#endif
|
||||
|
||||
retv = hawk_rtx_makeintval_inline(rtx, rv);
|
||||
if (!retv) return -1;
|
||||
@@ -2000,7 +2053,11 @@ static int fnc_wifsignaled (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
{
|
||||
hawk_int_t wstatus;
|
||||
int rv;
|
||||
#if defined(WIFSIGNALED)
|
||||
rv = (hawk_rtx_valtoint_inline(rtx, hawk_rtx_getarg(rtx, 0), &wstatus) <= -1)? 0: !!WIFSIGNALED(wstatus);
|
||||
#else
|
||||
rv = 0;
|
||||
#endif
|
||||
hawk_rtx_setretval(rtx, hawk_rtx_makeintval_inline(rtx, rv));
|
||||
return 0;
|
||||
}
|
||||
@@ -2011,7 +2068,11 @@ static int fnc_wtermsig (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
int rv;
|
||||
|
||||
hawk_val_t* retv;
|
||||
#if defined(WTERMSIG)
|
||||
rv = (hawk_rtx_valtoint_inline(rtx, hawk_rtx_getarg(rtx, 0), &wstatus) <= -1)? -1: WTERMSIG(wstatus);
|
||||
#else
|
||||
rv = -1;
|
||||
#endif
|
||||
|
||||
retv = hawk_rtx_makeintval_inline(rtx, rv);
|
||||
if (!retv) return -1;
|
||||
@@ -2282,7 +2343,7 @@ static int fnc_getppid (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
HANDLE ps;
|
||||
PROCESSENTRY32 p;
|
||||
|
||||
pid = GetCurrentPorcessId();
|
||||
pid = GetCurrentProcessId();
|
||||
ps = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
|
||||
if (ps == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
@@ -2292,7 +2353,7 @@ static int fnc_getppid (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
{
|
||||
rx = set_error_on_sys_list(rtx, sys_list, HAWK_ENOENT, HAWK_NULL);
|
||||
|
||||
p.dwSize = HAWK_SZIEOF(p);
|
||||
p.dwSize = HAWK_SIZEOF(p);
|
||||
if (Process32First(ps, &p))
|
||||
{
|
||||
do
|
||||
@@ -2705,7 +2766,7 @@ static int fnc_strftime (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
#if defined(HAVE_GMTIME_R)
|
||||
tmx = gmtime_r(&t, &tm);
|
||||
#else
|
||||
tmx = gmtime(&t.sec);
|
||||
tmx = gmtime(&t);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
@@ -2714,7 +2775,7 @@ static int fnc_strftime (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
#if defined(HAVE_LOCALTIME_R)
|
||||
tmx = localtime_r(&t, &tm);
|
||||
#else
|
||||
tmx = localtime(&t.sec);
|
||||
tmx = localtime(&t);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -4412,17 +4473,25 @@ static int fnc_accept (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
#if defined(HAVE_ACCEPT4)
|
||||
/* nothing to do */
|
||||
#else
|
||||
#if defined(F_GETFD)
|
||||
fd_flags = fcntl(fd, F_GETFD, 0);
|
||||
if (fd_flags >= 0)
|
||||
{
|
||||
#if defined(FD_CLOEXEC) && defined(SOCK_CLOEXEC)
|
||||
if (flags & SOCK_CLOEXEC) fd_flags |= FD_CLOEXEC;
|
||||
#endif
|
||||
#if defined(O_NONBLOCK) && defined(SOCK_NONBLOCK)
|
||||
if (flags & SOCK_NONBLOCK) fd_flags |= O_NONBLOCK;
|
||||
#endif
|
||||
#if defined(F_SETFD)
|
||||
fcntl(fd, F_SETFD, fd_flags);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#if defined(F_GETFL) && defined(F_SETFL) && defined(O_NONBLOCK) && defined(SOCK_NONBLOCK)
|
||||
if (flags & SOCK_NONBLOCK)
|
||||
{
|
||||
fd_flags = fcntl(fd, F_GETFL, 0);
|
||||
if (fd_flags >= 0) fcntl(fd, F_SETFL, fd_flags | O_NONBLOCK);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (hawk_rtx_getnargs(rtx) >= 3)
|
||||
@@ -4556,7 +4625,7 @@ you can specify the remote:// with /dev/log or @/dev/log.
|
||||
*/
|
||||
static void open_remote_log_socket (hawk_rtx_t* rtx, rtx_data_t* rdp)
|
||||
{
|
||||
int sck, flags;
|
||||
int sck;
|
||||
int domain = hawk_skad_get_family(&rdp->log.skad);
|
||||
int type = SOCK_DGRAM;
|
||||
|
||||
@@ -4586,15 +4655,32 @@ open_socket:
|
||||
#endif
|
||||
}
|
||||
|
||||
flags = fcntl(sck, F_GETFD, 0);
|
||||
if (flags <= -1) return;
|
||||
#if defined(F_GETFD)
|
||||
{
|
||||
int flags;
|
||||
|
||||
flags = fcntl(sck, F_GETFD, 0);
|
||||
if (flags <= -1) return;
|
||||
#if defined(FD_CLOEXEC)
|
||||
flags |= FD_CLOEXEC;
|
||||
flags |= FD_CLOEXEC;
|
||||
#endif
|
||||
#if defined(F_SETFD)
|
||||
if (fcntl(sck, F_SETFD, flags) <= -1) return;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#if defined(F_GETFL) && defined(F_SETFL) && defined(O_NONBLOCK)
|
||||
{
|
||||
int flags;
|
||||
|
||||
flags = fcntl(sck, F_GETFL, 0);
|
||||
if (flags <= -1) return;
|
||||
#if defined(O_NONBLOCK)
|
||||
flags |= O_NONBLOCK;
|
||||
flags |= O_NONBLOCK;
|
||||
#endif
|
||||
if (fcntl(sck, F_SETFL, flags) <= -1) return;
|
||||
}
|
||||
#endif
|
||||
if (fcntl(sck, F_SETFD, flags) <= -1) return;
|
||||
|
||||
done:
|
||||
rdp->log.sck = sck;
|
||||
@@ -4682,7 +4768,7 @@ static int fnc_openlog (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
#if defined(ENABLE_SYSLOG)
|
||||
if (rdp->log.syslog_opened)
|
||||
{
|
||||
closelog ();
|
||||
closelog();
|
||||
rdp->log.syslog_opened = 0;
|
||||
}
|
||||
#endif
|
||||
@@ -4709,7 +4795,9 @@ static int fnc_openlog (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
else if (rdp->log.type == SYSLOG_REMOTE)
|
||||
{
|
||||
rdp->log.skad = skad;
|
||||
#if defined(LOG_NDELAY)
|
||||
if ((opt & LOG_NDELAY) && rdp->log.sck <= -1) open_remote_log_socket(rtx, rdp);
|
||||
#endif
|
||||
}
|
||||
|
||||
rx = ERRNUM_TO_RC(HAWK_ENOERR);
|
||||
@@ -4730,7 +4818,7 @@ static int fnc_closelog (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
{
|
||||
case SYSLOG_LOCAL:
|
||||
#if defined(ENABLE_SYSLOG)
|
||||
closelog ();
|
||||
closelog();
|
||||
/* closelog() might be called without openlog(). so there is no
|
||||
* check if syslog_opened is true.
|
||||
* it is just used as an indicator to decide wheter closelog()
|
||||
@@ -6082,18 +6170,30 @@ static hawk_mod_int_tab_t inttab[] =
|
||||
|
||||
{ HAWK_T("DIR_SORT"), { HAWK_DIR_SORT } },
|
||||
|
||||
#if defined(FD_CLOEXEC)
|
||||
{ HAWK_T("FD_CLOEXEC"), { FD_CLOEXEC } },
|
||||
#endif
|
||||
|
||||
#if defined(F_RDLCK) && defined(F_UNLCK) && defined(F_WRLCK)
|
||||
{ HAWK_T("FLOCK_GET"), { FLOCK_GET } }, /* bitwise-OR with another FLOCK_READ/WRITE/WAIT value */
|
||||
{ HAWK_T("FLOCK_READ"), { F_RDLCK } },
|
||||
{ HAWK_T("FLOCK_UNLOCK"), { F_UNLCK } },
|
||||
{ HAWK_T("FLOCK_WAIT"), { FLOCK_WAIT } }, /* bitwise-OR with another FLOCK_READ/WRITE/WAIT value */
|
||||
{ HAWK_T("FLOCK_WRITE"), { F_WRLCK } },
|
||||
#endif
|
||||
|
||||
#if defined(F_GETFD)
|
||||
{ HAWK_T("F_GETFD"), { F_GETFD } },
|
||||
#endif
|
||||
#if defined(F_GETFL)
|
||||
{ HAWK_T("F_GETFL"), { F_GETFL } },
|
||||
#endif
|
||||
#if defined(F_SETFD)
|
||||
{ HAWK_T("F_SETFD"), { F_SETFD } },
|
||||
#endif
|
||||
#if defined(F_SETFL)
|
||||
{ HAWK_T("F_SETFL"), { F_SETFL } },
|
||||
#endif
|
||||
|
||||
{ HAWK_T("IFCFG_IN4"), { HAWK_IFCFG_IN4 } },
|
||||
{ HAWK_T("IFCFG_IN6"), { HAWK_IFCFG_IN6 } },
|
||||
@@ -6125,7 +6225,9 @@ static hawk_mod_int_tab_t inttab[] =
|
||||
{ HAWK_T("LOG_FAC_UUCP"), { LOG_UUCP } },
|
||||
|
||||
{ HAWK_T("LOG_OPT_CONS"), { LOG_CONS } },
|
||||
#if defined(LOG_NDELAY)
|
||||
{ HAWK_T("LOG_OPT_NDELAY"), { LOG_NDELAY } },
|
||||
#endif
|
||||
{ HAWK_T("LOG_OPT_NOWAIT"), { LOG_NOWAIT } },
|
||||
{ HAWK_T("LOG_OPT_PID"), { LOG_PID } },
|
||||
|
||||
@@ -6281,116 +6383,264 @@ static hawk_mod_int_tab_t inttab[] =
|
||||
#if defined(VDISCARD)
|
||||
{ HAWK_T("TC_CC_VDISCARD"), { VDISCARD } },
|
||||
#endif
|
||||
#if defined(VEOF)
|
||||
{ HAWK_T("TC_CC_VEOF"), { VEOF } },
|
||||
#endif
|
||||
#if defined(VEOL)
|
||||
{ HAWK_T("TC_CC_VEOL"), { VEOL } },
|
||||
#endif
|
||||
#if defined(VEOL2)
|
||||
{ HAWK_T("TC_CC_VEOL2"), { VEOL2 } },
|
||||
#endif
|
||||
#if defined(VERASE)
|
||||
{ HAWK_T("TC_CC_VERASE"), { VERASE } },
|
||||
#endif
|
||||
#if defined(VINTR)
|
||||
{ HAWK_T("TC_CC_VINTR"), { VINTR } },
|
||||
#endif
|
||||
#if defined(VKILL)
|
||||
{ HAWK_T("TC_CC_VKILL"), { VKILL } },
|
||||
#endif
|
||||
#if defined(VLNEXT)
|
||||
{ HAWK_T("TC_CC_VLNEXT"), { VLNEXT } },
|
||||
#endif
|
||||
#if defined(VMIN)
|
||||
{ HAWK_T("TC_CC_VMIN"), { VMIN } },
|
||||
#endif
|
||||
#if defined(VQUIT)
|
||||
{ HAWK_T("TC_CC_VQUIT"), { VQUIT } },
|
||||
#endif
|
||||
#if defined(VREPRINT)
|
||||
{ HAWK_T("TC_CC_VREPRINT"), { VREPRINT } },
|
||||
#endif
|
||||
#if defined(VSTART)
|
||||
{ HAWK_T("TC_CC_VSTART"), { VSTART } },
|
||||
#endif
|
||||
#if defined(VSTOP)
|
||||
{ HAWK_T("TC_CC_VSTOP"), { VSTOP } },
|
||||
#endif
|
||||
#if defined(VSUSP)
|
||||
{ HAWK_T("TC_CC_VSUSP"), { VSUSP } },
|
||||
#endif
|
||||
#if defined(VSWTC)
|
||||
{ HAWK_T("TC_CC_VSWTC"), { VSWTC } }, /* hard to define with an alternative value when it's not available */
|
||||
#endif
|
||||
#if defined(VTIME)
|
||||
{ HAWK_T("TC_CC_VTIME"), { VTIME } },
|
||||
#endif
|
||||
#if defined(VWERASE)
|
||||
{ HAWK_T("TC_CC_VWERASE"), { VWERASE } },
|
||||
#endif
|
||||
|
||||
#if defined(B0)
|
||||
{ HAWK_T("TC_CFLAG_B0"), { B0 } },
|
||||
#endif
|
||||
#if defined(B110)
|
||||
{ HAWK_T("TC_CFLAG_B110"), { B110 } },
|
||||
#endif
|
||||
#if defined(B115200)
|
||||
{ HAWK_T("TC_CFLAG_B115200"), { B115200 } },
|
||||
#endif
|
||||
#if defined(B1200)
|
||||
{ HAWK_T("TC_CFLAG_B1200"), { B1200 } },
|
||||
#endif
|
||||
#if defined(B134)
|
||||
{ HAWK_T("TC_CFLAG_B134"), { B134 } },
|
||||
#endif
|
||||
#if defined(B150)
|
||||
{ HAWK_T("TC_CFLAG_B150"), { B150 } },
|
||||
#endif
|
||||
#if defined(B1800)
|
||||
{ HAWK_T("TC_CFLAG_B1800"), { B1800 } },
|
||||
#endif
|
||||
#if defined(B19200)
|
||||
{ HAWK_T("TC_CFLAG_B19200"), { B19200 } },
|
||||
#endif
|
||||
#if defined(B200)
|
||||
{ HAWK_T("TC_CFLAG_B200"), { B200 } },
|
||||
#endif
|
||||
#if defined(B230400)
|
||||
{ HAWK_T("TC_CFLAG_B230400"), { B230400 } },
|
||||
#endif
|
||||
#if defined(B2400)
|
||||
{ HAWK_T("TC_CFLAG_B2400"), { B2400 } },
|
||||
#endif
|
||||
#if defined(B300)
|
||||
{ HAWK_T("TC_CFLAG_B300"), { B300 } },
|
||||
#endif
|
||||
#if defined(B38400)
|
||||
{ HAWK_T("TC_CFLAG_B38400"), { B38400 } },
|
||||
#endif
|
||||
#if defined(B460800)
|
||||
{ HAWK_T("TC_CFLAG_B460800"), { B460800 } },
|
||||
#endif
|
||||
#if defined(B4800)
|
||||
{ HAWK_T("TC_CFLAG_B4800"), { B4800 } },
|
||||
#endif
|
||||
#if defined(B50)
|
||||
{ HAWK_T("TC_CFLAG_B50"), { B50 } },
|
||||
#endif
|
||||
#if defined(B57600)
|
||||
{ HAWK_T("TC_CFLAG_B57600"), { B57600 } },
|
||||
#endif
|
||||
#if defined(B600)
|
||||
{ HAWK_T("TC_CFLAG_B600"), { B600 } },
|
||||
#endif
|
||||
#if defined(B75)
|
||||
{ HAWK_T("TC_CFLAG_B75"), { B75 } },
|
||||
#endif
|
||||
#if defined(B921600)
|
||||
{ HAWK_T("TC_CFLAG_B921600"), { B921600 } },
|
||||
#endif
|
||||
#if defined(B9600)
|
||||
{ HAWK_T("TC_CFLAG_B9600"), { B9600 } },
|
||||
#endif
|
||||
|
||||
#if defined(CLOCAL)
|
||||
{ HAWK_T("TC_CFLAG_CLOCAL"), { CLOCAL } },
|
||||
#endif
|
||||
#if defined(CREAD)
|
||||
{ HAWK_T("TC_CFLAG_CREAD"), { CREAD } },
|
||||
#endif
|
||||
#if defined(CRTSCTS)
|
||||
{ HAWK_T("TC_CFLAG_CRTSCTS"), { CRTSCTS } },
|
||||
#endif
|
||||
#if defined(CS5)
|
||||
{ HAWK_T("TC_CFLAG_CS5"), { CS5 } },
|
||||
#endif
|
||||
#if defined(CS6)
|
||||
{ HAWK_T("TC_CFLAG_CS6"), { CS6 } },
|
||||
#endif
|
||||
#if defined(CS7)
|
||||
{ HAWK_T("TC_CFLAG_CS7"), { CS7 } },
|
||||
#endif
|
||||
#if defined(CS8)
|
||||
{ HAWK_T("TC_CFLAG_CS8"), { CS8 } },
|
||||
#endif
|
||||
#if defined(CSIZE)
|
||||
{ HAWK_T("TC_CFLAG_CSIZE"), { CSIZE } },
|
||||
#endif
|
||||
#if defined(CSTOPB)
|
||||
{ HAWK_T("TC_CFLAG_CSTOPB"), { CSTOPB } },
|
||||
#endif
|
||||
#if defined(HUPCL)
|
||||
{ HAWK_T("TC_CFLAG_HUPCL"), { HUPCL } },
|
||||
#endif
|
||||
#if defined(PARENB)
|
||||
{ HAWK_T("TC_CFLAG_PARENB"), { PARENB } },
|
||||
#endif
|
||||
#if defined(PARODD)
|
||||
{ HAWK_T("TC_CFLAG_PARODD"), { PARODD } },
|
||||
#endif
|
||||
|
||||
#if defined(BRKINT)
|
||||
{ HAWK_T("TC_IFLAG_BRKINT"), { BRKINT } },
|
||||
#endif
|
||||
#if defined(ICRNL)
|
||||
{ HAWK_T("TC_IFLAG_ICRNL"), { ICRNL } },
|
||||
#endif
|
||||
#if defined(IGNBRK)
|
||||
{ HAWK_T("TC_IFLAG_IGNBRK"), { IGNBRK } },
|
||||
#endif
|
||||
#if defined(IGNCR)
|
||||
{ HAWK_T("TC_IFLAG_IGNCR"), { IGNCR } },
|
||||
#endif
|
||||
#if defined(IGNPAR)
|
||||
{ HAWK_T("TC_IFLAG_IGNPAR"), { IGNPAR } },
|
||||
#endif
|
||||
#if defined(IMAXBEL)
|
||||
{ HAWK_T("TC_IFLAG_IMAXBEL"),{ IMAXBEL } },
|
||||
#endif
|
||||
#if defined(INLCR)
|
||||
{ HAWK_T("TC_IFLAG_INLCR"), { INLCR } },
|
||||
#endif
|
||||
#if defined(INPCK)
|
||||
{ HAWK_T("TC_IFLAG_INPCK"), { INPCK } },
|
||||
#endif
|
||||
#if defined(ISTRIP)
|
||||
{ HAWK_T("TC_IFLAG_ISTRIP"), { ISTRIP } },
|
||||
#endif
|
||||
{ HAWK_T("TC_IFLAG_IUCLC"), { X_IUCLC } },
|
||||
{ HAWK_T("TC_IFLAG_IUTF8"), { X_IUTF8 } },
|
||||
#if defined(IXANY)
|
||||
{ HAWK_T("TC_IFLAG_IXANY"), { IXANY } },
|
||||
#endif
|
||||
#if defined(IXOFF)
|
||||
{ HAWK_T("TC_IFLAG_IXOFF"), { IXOFF } },
|
||||
#endif
|
||||
#if defined(IXON)
|
||||
{ HAWK_T("TC_IFLAG_IXON"), { IXON } },
|
||||
#endif
|
||||
#if defined(PARMRK)
|
||||
{ HAWK_T("TC_IFLAG_PARMRK"), { PARMRK } },
|
||||
#endif
|
||||
|
||||
#if defined(TCIFLUSH)
|
||||
{ HAWK_T("TC_IFLUSH"), { TCIFLUSH } },
|
||||
#endif
|
||||
#if defined(TCIOFLUSH)
|
||||
{ HAWK_T("TC_IOFLUSH"), { TCIOFLUSH } },
|
||||
#endif
|
||||
#if defined(TCOFLUSH)
|
||||
{ HAWK_T("TC_OFLUSH"), { TCOFLUSH } },
|
||||
#endif
|
||||
|
||||
#if defined(ECHO)
|
||||
{ HAWK_T("TC_LFLAG_ECHO"), { ECHO } },
|
||||
#endif
|
||||
#if defined(ECHOE)
|
||||
{ HAWK_T("TC_LFLAG_ECHOE"), { ECHOE } },
|
||||
#endif
|
||||
#if defined(ECHOK)
|
||||
{ HAWK_T("TC_LFLAG_ECHOK"), { ECHOK } },
|
||||
#endif
|
||||
#if defined(ECHONL)
|
||||
{ HAWK_T("TC_LFLAG_ECHONL"), { ECHONL } },
|
||||
#endif
|
||||
#if defined(ICANON)
|
||||
{ HAWK_T("TC_LFLAG_ICANON"), { ICANON } },
|
||||
#endif
|
||||
#if defined(ISIG)
|
||||
{ HAWK_T("TC_LFLAG_ISIG"), { ISIG } },
|
||||
#endif
|
||||
#if defined(NOFLSH)
|
||||
{ HAWK_T("TC_LFLAG_NOFLSH"), { NOFLSH } },
|
||||
#endif
|
||||
#if defined(TOSTOP)
|
||||
{ HAWK_T("TC_LFLAG_TOSTOP"), { TOSTOP } },
|
||||
#endif
|
||||
|
||||
#if defined(OCRNL)
|
||||
{ HAWK_T("TC_OFLAG_OCRNL"), { OCRNL } },
|
||||
#endif
|
||||
#if defined(ONLCR)
|
||||
{ HAWK_T("TC_OFLAG_ONLCR"), { ONLCR } },
|
||||
#endif
|
||||
#if defined(ONLRET)
|
||||
{ HAWK_T("TC_OFLAG_ONLRET"), { ONLRET } },
|
||||
#endif
|
||||
#if defined(ONOCR)
|
||||
{ HAWK_T("TC_OFLAG_ONOCR"), { ONOCR } },
|
||||
#endif
|
||||
{ HAWK_T("TC_OFLAG_ONOEOT"), { X_ONOEOT } },
|
||||
#if defined(OPOST)
|
||||
{ HAWK_T("TC_OFLAG_OPOST"), { OPOST } },
|
||||
#endif
|
||||
{ HAWK_T("TC_OFLAG_OXTABS"), { X_OXTABS } },
|
||||
|
||||
#if defined(TCSADRAIN)
|
||||
{ HAWK_T("TC_SADRAIN"), { TCSADRAIN } },
|
||||
#endif
|
||||
#if defined(TCSAFLUSH)
|
||||
{ HAWK_T("TC_SAFLUSH"), { TCSAFLUSH } },
|
||||
#endif
|
||||
#if defined(TCSANOW)
|
||||
{ HAWK_T("TC_SANOW"), { TCSANOW } },
|
||||
#endif
|
||||
|
||||
#if defined(WNOHANG)
|
||||
{ HAWK_T("WNOHANG"), { WNOHANG } }
|
||||
#endif
|
||||
};
|
||||
|
||||
static int query (hawk_mod_t* mod, hawk_t* hawk, const hawk_ooch_t* name, hawk_mod_sym_t* sym)
|
||||
|
||||
@@ -643,6 +643,8 @@ int hawk_pio_init (hawk_pio_t* pio, hawk_gem_t* gem, const hawk_ooch_t* cmd, int
|
||||
HANDLE windevnul = INVALID_HANDLE_VALUE;
|
||||
BOOL apiret;
|
||||
hawk_ooch_t* dupcmd;
|
||||
void* envblk = HAWK_NULL;
|
||||
DWORD create_flags;
|
||||
int create_retried;
|
||||
|
||||
#elif defined(__OS2__)
|
||||
@@ -904,18 +906,30 @@ create_process:
|
||||
|
||||
if (HAWK_UNLIKELY(!dupcmd)) goto oops;
|
||||
|
||||
if (env_mk)
|
||||
{
|
||||
#if defined(HAWK_OOCH_IS_BCH)
|
||||
envblk = env_mk(HAWK_PIO_ENV_MK_BPN, env_ctx);
|
||||
#else
|
||||
envblk = env_mk(HAWK_PIO_ENV_MK_UPN, env_ctx);
|
||||
#endif
|
||||
if (HAWK_UNLIKELY(!envblk)) goto oops;
|
||||
}
|
||||
|
||||
#if defined(HAWK_OOCH_IS_BCH)
|
||||
create_flags = 0;
|
||||
#else
|
||||
create_flags = CREATE_UNICODE_ENVIRONMENT;
|
||||
#endif
|
||||
|
||||
apiret = CreateProcess(
|
||||
HAWK_NULL, /* LPCTSTR lpApplicationName */
|
||||
dupcmd, /* LPTSTR lpCommandLine */
|
||||
HAWK_NULL, /* LPSECURITY_ATTRIBUTES lpProcessAttributes */
|
||||
HAWK_NULL, /* LPSECURITY_ATTRIBUTES lpThreadAttributes */
|
||||
TRUE, /* BOOL bInheritHandles */
|
||||
#if defined(HAWK_OOCH_IS_BCH)
|
||||
0, /* DWORD dwCreationFlags */
|
||||
#else
|
||||
CREATE_UNICODE_ENVIRONMENT, /* DWORD dwCreationFlags */
|
||||
#endif
|
||||
HAWK_NULL, /* LPVOID lpEnvironment */
|
||||
create_flags, /* DWORD dwCreationFlags */
|
||||
envblk, /* LPVOID lpEnvironment */
|
||||
HAWK_NULL, /* LPCTSTR lpCurrentDirectory */
|
||||
&startup, /* LPSTARTUPINFO lpStartupInfo */
|
||||
&procinfo /* LPPROCESS_INFORMATION lpProcessInformation */
|
||||
|
||||
+36
-12
@@ -25,19 +25,43 @@
|
||||
#ifndef _HAWK_SKAD_PRV_H_
|
||||
#define _HAWK_SKAD_PRV_H_
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#if defined(HAVE_NETINET_IN_H)
|
||||
#if defined(_WIN32)
|
||||
# include <winsock2.h>
|
||||
# include <ws2tcpip.h>
|
||||
/*# include <iphlpapi.h> */
|
||||
#elif defined(__OS2__)
|
||||
# if defined(TCPV40HDRS)
|
||||
# define BSD_SELECT
|
||||
# endif
|
||||
# include <types.h>
|
||||
# include <sys/socket.h>
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
#if defined(HAVE_SYS_UN_H)
|
||||
# include <sys/un.h>
|
||||
#endif
|
||||
#if defined(HAVE_NETPACKET_PACKET_H)
|
||||
# include <netpacket/packet.h>
|
||||
#endif
|
||||
#if defined(HAVE_NET_IF_DL_H)
|
||||
# include <net/if_dl.h>
|
||||
# include <sys/ioctl.h>
|
||||
# include <nerrno.h>
|
||||
# if defined(TCPV40HDRS)
|
||||
# define USE_SELECT
|
||||
# include <sys/select.h>
|
||||
# else
|
||||
# include <unistd.h>
|
||||
# endif
|
||||
#elif defined(__DOS__)
|
||||
|
||||
/* TODO: */
|
||||
#else
|
||||
# include <sys/types.h>
|
||||
# include <sys/socket.h>
|
||||
# if defined(HAVE_NETINET_IN_H)
|
||||
# include <netinet/in.h>
|
||||
# endif
|
||||
# if defined(HAVE_SYS_UN_H)
|
||||
# include <sys/un.h>
|
||||
# endif
|
||||
# if defined(HAVE_NETPACKET_PACKET_H)
|
||||
# include <netpacket/packet.h>
|
||||
# endif
|
||||
# if defined(HAVE_NET_IF_DL_H)
|
||||
# include <net/if_dl.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
union hawk_skad_alt_t
|
||||
|
||||
+24
-20
@@ -902,7 +902,7 @@ static hawk_oow_t ip6ad_to_ucstr (const struct in6_addr* ipad, hawk_uch_t* buf,
|
||||
if (i == 6 && best.base == 0 && (best.len == 6 || (best.len == 5 && words[5] == 0xffff)))
|
||||
{
|
||||
struct in_addr ip4ad;
|
||||
HAWK_MEMCPY (&ip4ad.s_addr, ipad->s6_addr + 12, HAWK_SIZEOF(ip4ad.s_addr));
|
||||
HAWK_MEMCPY(&ip4ad.s_addr, ipad->s6_addr + 12, HAWK_SIZEOF(ip4ad.s_addr));
|
||||
tp += ip4ad_to_ucstr(&ip4ad, tp, HAWK_COUNTOF(tmp) - (tp - tmp));
|
||||
break;
|
||||
}
|
||||
@@ -1011,6 +1011,7 @@ hawk_oow_t hawk_gem_skadtoucstr (hawk_gem_t* gem, const hawk_skad_t* _skad, hawk
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if (HAWK_SIZEOF_STRUCT_SOCKADDR_UN > 0)
|
||||
case HAWK_AF_UNIX:
|
||||
if (flags & HAWK_SKAD_TO_BCSTR_ADDR)
|
||||
{
|
||||
@@ -1021,13 +1022,14 @@ hawk_oow_t hawk_gem_skadtoucstr (hawk_gem_t* gem, const hawk_skad_t* _skad, hawk
|
||||
else
|
||||
{
|
||||
hawk_oow_t mbslen, wcslen = len - xlen;
|
||||
hawk_gem_convbtoucstr (gem, skad->un.sun_path, &mbslen, &buf[xlen], &wcslen, 1);
|
||||
hawk_gem_convbtoucstr(gem, skad->un.sun_path, &mbslen, &buf[xlen], &wcslen, 1);
|
||||
/* i don't care about conversion errors */
|
||||
xlen += wcslen;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
done:
|
||||
@@ -1151,7 +1153,7 @@ static hawk_oow_t ip6ad_to_bcstr (const struct in6_addr* ipad, hawk_bch_t* buf,
|
||||
if (i == 6 && best.base == 0 && (best.len == 6 || (best.len == 5 && words[5] == 0xffff)))
|
||||
{
|
||||
struct in_addr ip4ad;
|
||||
HAWK_MEMCPY (&ip4ad.s_addr, ipad->s6_addr + 12, HAWK_SIZEOF(ip4ad.s_addr));
|
||||
HAWK_MEMCPY(&ip4ad.s_addr, ipad->s6_addr + 12, HAWK_SIZEOF(ip4ad.s_addr));
|
||||
tp += ip4ad_to_bcstr(&ip4ad, tp, HAWK_COUNTOF(tmp) - (tp - tmp));
|
||||
break;
|
||||
}
|
||||
@@ -1261,6 +1263,7 @@ hawk_oow_t hawk_gem_skadtobcstr (hawk_gem_t* gem, const hawk_skad_t* _skad, hawk
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if (HAWK_SIZEOF_STRUCT_SOCKADDR_UN > 0)
|
||||
case HAWK_AF_UNIX:
|
||||
if (flags & HAWK_SKAD_TO_BCSTR_ADDR)
|
||||
{
|
||||
@@ -1282,6 +1285,7 @@ hawk_oow_t hawk_gem_skadtobcstr (hawk_gem_t* gem, const hawk_skad_t* _skad, hawk
|
||||
}
|
||||
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
done:
|
||||
@@ -1387,13 +1391,13 @@ hawk_oow_t hawk_skad_get_ipad_bytes (hawk_skad_t* _skad, void* buf, hawk_oow_t l
|
||||
#if defined(AF_INET) && (HAWK_SIZEOF_STRUCT_SOCKADDR_IN > 0)
|
||||
case AF_INET:
|
||||
outlen = len < HAWK_SIZEOF(skad->in4.sin_addr)? len: HAWK_SIZEOF(skad->in4.sin_addr);
|
||||
HAWK_MEMCPY (buf, &skad->in4.sin_addr, outlen);
|
||||
HAWK_MEMCPY(buf, &skad->in4.sin_addr, outlen);
|
||||
break;
|
||||
#endif
|
||||
#if defined(AF_INET6) && (HAWK_SIZEOF_STRUCT_SOCKADDR_IN6 > 0)
|
||||
case AF_INET6:
|
||||
outlen = len < HAWK_SIZEOF(skad->in6.sin6_addr)? len: HAWK_SIZEOF(skad->in6.sin6_addr);
|
||||
HAWK_MEMCPY (buf, &skad->in6.sin6_addr, outlen);
|
||||
HAWK_MEMCPY(buf, &skad->in6.sin6_addr, outlen);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
@@ -1408,7 +1412,7 @@ void hawk_skad_init_for_ip4 (hawk_skad_t* skad, hawk_uint16_t port, hawk_ip4ad_t
|
||||
HAWK_MEMSET (sin, 0, HAWK_SIZEOF(*sin));
|
||||
sin->sin_family = AF_INET;
|
||||
sin->sin_port = hawk_hton16(port);
|
||||
if (ip4ad) HAWK_MEMCPY (&sin->sin_addr, ip4ad->v, HAWK_IP4AD_LEN);
|
||||
if (ip4ad) HAWK_MEMCPY(&sin->sin_addr, ip4ad->v, HAWK_IP4AD_LEN);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1420,7 +1424,7 @@ void hawk_skad_init_for_ip6 (hawk_skad_t* skad, hawk_uint16_t port, hawk_ip6ad_t
|
||||
sin->sin6_family = AF_INET6;
|
||||
sin->sin6_port = hawk_hton16(port);
|
||||
sin->sin6_scope_id = scope_id;
|
||||
if (ip6ad) HAWK_MEMCPY (&sin->sin6_addr, ip6ad->v, HAWK_IP6AD_LEN);
|
||||
if (ip6ad) HAWK_MEMCPY(&sin->sin6_addr, ip6ad->v, HAWK_IP6AD_LEN);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1435,7 +1439,7 @@ void hawk_skad_init_for_ip_with_bytes (hawk_skad_t* skad, hawk_uint16_t port, co
|
||||
HAWK_MEMSET (sin, 0, HAWK_SIZEOF(*sin));
|
||||
sin->sin_family = AF_INET;
|
||||
sin->sin_port = hawk_hton16(port);
|
||||
HAWK_MEMCPY (&sin->sin_addr, bytes, len);
|
||||
HAWK_MEMCPY(&sin->sin_addr, bytes, len);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
@@ -1446,7 +1450,7 @@ void hawk_skad_init_for_ip_with_bytes (hawk_skad_t* skad, hawk_uint16_t port, co
|
||||
HAWK_MEMSET (sin, 0, HAWK_SIZEOF(*sin));
|
||||
sin->sin6_family = AF_INET6;
|
||||
sin->sin6_port = hawk_hton16(port);
|
||||
HAWK_MEMCPY (&sin->sin6_addr, bytes, len);
|
||||
HAWK_MEMCPY(&sin->sin6_addr, bytes, len);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
@@ -1466,7 +1470,7 @@ void hawk_skad_init_for_eth (hawk_skad_t* skad, int ifindex, hawk_ethad_t* ethad
|
||||
if (ethad)
|
||||
{
|
||||
sll->sll_halen = HAWK_ETHAD_LEN;
|
||||
HAWK_MEMCPY (sll->sll_addr, ethad, HAWK_ETHAD_LEN);
|
||||
HAWK_MEMCPY(sll->sll_addr, ethad, HAWK_ETHAD_LEN);
|
||||
}
|
||||
|
||||
#elif defined(AF_LINK) && (HAWK_SIZEOF_STRUCT_SOCKADDR_DL > 0)
|
||||
@@ -1477,10 +1481,10 @@ void hawk_skad_init_for_eth (hawk_skad_t* skad, int ifindex, hawk_ethad_t* ethad
|
||||
if (ethad)
|
||||
{
|
||||
sll->sdl_alen = HAWK_ETHAD_LEN;
|
||||
HAWK_MEMCPY (sll->sdl_data, ethad, HAWK_ETHAD_LEN);
|
||||
HAWK_MEMCPY(sll->sdl_data, ethad, HAWK_ETHAD_LEN);
|
||||
}
|
||||
#else
|
||||
# error UNSUPPORTED DATALINK SOCKET ADDRESS
|
||||
/* UNSUPPORTED, do nothing */
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1542,7 +1546,7 @@ hawk_oow_t hawk_ipad_bytes_to_ucstr (const hawk_uint8_t* iptr, hawk_oow_t ilen,
|
||||
case HAWK_IP4AD_LEN:
|
||||
{
|
||||
struct in_addr ip4ad;
|
||||
HAWK_MEMCPY (&ip4ad.s_addr, iptr, ilen);
|
||||
HAWK_MEMCPY(&ip4ad.s_addr, iptr, ilen);
|
||||
return ip4ad_to_ucstr(&ip4ad, buf, blen);
|
||||
}
|
||||
|
||||
@@ -1550,7 +1554,7 @@ hawk_oow_t hawk_ipad_bytes_to_ucstr (const hawk_uint8_t* iptr, hawk_oow_t ilen,
|
||||
case HAWK_IP6AD_LEN:
|
||||
{
|
||||
struct in6_addr ip6ad;
|
||||
HAWK_MEMCPY (&ip6ad.s6_addr, iptr, ilen);
|
||||
HAWK_MEMCPY(&ip6ad.s6_addr, iptr, ilen);
|
||||
return ip6ad_to_ucstr(&ip6ad, buf, blen);
|
||||
}
|
||||
#endif
|
||||
@@ -1568,7 +1572,7 @@ hawk_oow_t hawk_ipad_bytes_to_bcstr (const hawk_uint8_t* iptr, hawk_oow_t ilen,
|
||||
case HAWK_IP4AD_LEN:
|
||||
{
|
||||
struct in_addr ip4ad;
|
||||
HAWK_MEMCPY (&ip4ad.s_addr, iptr, ilen);
|
||||
HAWK_MEMCPY(&ip4ad.s_addr, iptr, ilen);
|
||||
return ip4ad_to_bcstr(&ip4ad, buf, blen);
|
||||
}
|
||||
|
||||
@@ -1576,7 +1580,7 @@ hawk_oow_t hawk_ipad_bytes_to_bcstr (const hawk_uint8_t* iptr, hawk_oow_t ilen,
|
||||
case HAWK_IP6AD_LEN:
|
||||
{
|
||||
struct in6_addr ip6ad;
|
||||
HAWK_MEMCPY (&ip6ad.s6_addr, iptr, ilen);
|
||||
HAWK_MEMCPY(&ip6ad.s6_addr, iptr, ilen);
|
||||
return ip6ad_to_bcstr(&ip6ad, buf, blen);
|
||||
}
|
||||
#endif
|
||||
@@ -1594,7 +1598,7 @@ int hawk_uchars_to_ipad_bytes (const hawk_uch_t* str, hawk_oow_t slen, hawk_uint
|
||||
#if (HAWK_SIZEOF_STRUCT_SOCKADDR_IN6 > 0)
|
||||
struct in6_addr i6;
|
||||
if (uchars_to_ipv6(str, slen, &i6) <= -1) goto ipv4;
|
||||
HAWK_MEMCPY (buf, i6.s6_addr, 16);
|
||||
HAWK_MEMCPY(buf, i6.s6_addr, 16);
|
||||
return HAWK_IP6AD_LEN;
|
||||
#endif
|
||||
}
|
||||
@@ -1603,7 +1607,7 @@ int hawk_uchars_to_ipad_bytes (const hawk_uch_t* str, hawk_oow_t slen, hawk_uint
|
||||
struct in_addr i4;
|
||||
ipv4:
|
||||
if (uchars_to_ipv4(str, slen, &i4) <= -1) return -1;
|
||||
HAWK_MEMCPY (buf, &i4.s_addr, 4);
|
||||
HAWK_MEMCPY(buf, &i4.s_addr, 4);
|
||||
return HAWK_IP4AD_LEN;
|
||||
}
|
||||
|
||||
@@ -1617,7 +1621,7 @@ int hawk_bchars_to_ipad_bytes (const hawk_bch_t* str, hawk_oow_t slen, hawk_uint
|
||||
#if (HAWK_SIZEOF_STRUCT_SOCKADDR_IN6 > 0)
|
||||
struct in6_addr i6;
|
||||
if (bchars_to_ipv6(str, slen, &i6) <= -1) goto ipv4;
|
||||
HAWK_MEMCPY (buf, i6.s6_addr, 16);
|
||||
HAWK_MEMCPY(buf, i6.s6_addr, 16);
|
||||
return HAWK_IP6AD_LEN;
|
||||
#endif
|
||||
}
|
||||
@@ -1626,7 +1630,7 @@ int hawk_bchars_to_ipad_bytes (const hawk_bch_t* str, hawk_oow_t slen, hawk_uint
|
||||
struct in_addr i4;
|
||||
ipv4:
|
||||
if (bchars_to_ipv4(str, slen, &i4) <= -1) return -1;
|
||||
HAWK_MEMCPY (buf, &i4.s_addr, 4);
|
||||
HAWK_MEMCPY(buf, &i4.s_addr, 4);
|
||||
return HAWK_IP4AD_LEN;
|
||||
}
|
||||
|
||||
|
||||
@@ -193,6 +193,7 @@ typedef struct rxtn_t
|
||||
void* envp; /* cached environment value */
|
||||
hawk_map_t* env_map;
|
||||
hawk_oow_t env_map_rev;
|
||||
hawk_rtx_env_mk_type_t env_type;
|
||||
} rxtn_t;
|
||||
|
||||
typedef struct ioattr_t
|
||||
@@ -446,7 +447,7 @@ void* hawk_stdmodopen (hawk_t* hawk, const hawk_mod_spec_t* spec)
|
||||
if (!modpath) return HAWK_NULL;
|
||||
|
||||
h = LoadLibrary(modpath);
|
||||
if (!h) hawk_seterrnum(hawk, HAWK_NULL, hawk_syserr_to_errnum(GetLastError());
|
||||
if (!h) hawk_seterrnum(hawk, HAWK_NULL, hawk_syserr_to_errnum(GetLastError()));
|
||||
|
||||
hawk_freemem(hawk, modpath);
|
||||
|
||||
@@ -457,7 +458,7 @@ void* hawk_stdmodopen (hawk_t* hawk, const hawk_mod_spec_t* spec)
|
||||
{
|
||||
HMODULE h;
|
||||
h = GetModuleHandle(HAWK_NULL);
|
||||
if (!h) hawk_seterrnum(hawk, HAWK_NULL, hawk_syserr_to_errnum(GetLastError());
|
||||
if (!h) hawk_seterrnum(hawk, HAWK_NULL, hawk_syserr_to_errnum(GetLastError()));
|
||||
return h;
|
||||
}
|
||||
|
||||
@@ -649,7 +650,7 @@ void* hawk_stdmodgetsym (hawk_t* hawk, void* handle, const hawk_ooch_t* name)
|
||||
|
||||
#elif defined(_WIN32)
|
||||
s = GetProcAddress((HMODULE)handle, mname);
|
||||
if (!s) hawk_seterrnum(hawk, HAWK_NULL, hawk_syserr_to_errnum(GetLastError());
|
||||
if (!s) hawk_seterrnum(hawk, HAWK_NULL, hawk_syserr_to_errnum(GetLastError()));
|
||||
|
||||
#elif defined(__OS2__)
|
||||
{
|
||||
@@ -2043,51 +2044,45 @@ static int parse_rwpipe_uri (const hawk_ooch_t* uri, int* flags, hawk_nwad_t* nw
|
||||
static void* rtx_env_maker (hawk_rtx_t* rtx, hawk_rtx_env_mk_type_t env_mk_type)
|
||||
{
|
||||
hawk_t* hawk = hawk_rtx_gethawk(rtx);
|
||||
hawk_val_t* v_env;
|
||||
hawk_map_t* env_map;
|
||||
hawk_oow_t env_map_rev;
|
||||
void* envp;
|
||||
xtn_t* xtn;
|
||||
rxtn_t* rxtn;
|
||||
|
||||
if (env_mk_type == HAWK_RTX_ENV_MK_BPP)
|
||||
xtn = GET_XTN(hawk);
|
||||
rxtn = GET_RXTN(rtx);
|
||||
v_env = hawk_rtx_getgbl(rtx, xtn->gbl_environ);
|
||||
HAWK_ASSERT(v_env != HAWK_NULL);
|
||||
|
||||
if (HAWK_RTX_GETVALTYPE(rtx, v_env) == HAWK_VAL_MAP)
|
||||
{
|
||||
hawk_val_t* v_env;
|
||||
hawk_map_t* env_map;
|
||||
hawk_oow_t env_map_rev;
|
||||
hawk_env_char_t** envp;
|
||||
xtn_t* xtn;
|
||||
rxtn_t* rxtn;
|
||||
|
||||
xtn = GET_XTN(hawk);
|
||||
rxtn = GET_RXTN(rtx);
|
||||
v_env = hawk_rtx_getgbl(rtx, xtn->gbl_environ);
|
||||
HAWK_ASSERT(v_env != HAWK_NULL);
|
||||
|
||||
if (HAWK_RTX_GETVALTYPE(rtx, v_env) == HAWK_VAL_MAP)
|
||||
{
|
||||
env_map = ((hawk_val_map_t*)v_env)->map;
|
||||
HAWK_ASSERT(env_map != HAWK_NULL);
|
||||
env_map_rev = HAWK_MAP_REV(env_map);
|
||||
}
|
||||
else
|
||||
{
|
||||
env_map = HAWK_NULL;
|
||||
env_map_rev = 0;
|
||||
}
|
||||
|
||||
if (!rxtn->envp || rxtn->env_map != env_map ||
|
||||
(env_map && rxtn->env_map_rev != env_map_rev))
|
||||
{
|
||||
envp = hawk_rtx_commit_environ(rtx, xtn->gbl_environ);
|
||||
if (HAWK_UNLIKELY(!envp)) return HAWK_NULL;
|
||||
|
||||
if (rxtn->envp) hawk_rtx_freemem(rtx, rxtn->envp);
|
||||
rxtn->envp = envp;
|
||||
rxtn->env_map = env_map;
|
||||
rxtn->env_map_rev = env_map_rev;
|
||||
}
|
||||
|
||||
return rxtn->envp;
|
||||
env_map = ((hawk_val_map_t*)v_env)->map;
|
||||
HAWK_ASSERT(env_map != HAWK_NULL);
|
||||
env_map_rev = HAWK_MAP_REV(env_map);
|
||||
}
|
||||
else
|
||||
{
|
||||
env_map = HAWK_NULL;
|
||||
env_map_rev = 0;
|
||||
}
|
||||
|
||||
/* TODO: support more types */
|
||||
/* unsupported env_mk_type */
|
||||
return HAWK_NULL;
|
||||
if (!rxtn->envp || rxtn->env_type != env_mk_type ||
|
||||
rxtn->env_map != env_map ||
|
||||
(env_map && rxtn->env_map_rev != env_map_rev))
|
||||
{
|
||||
envp = hawk_rtx_commit_environ(rtx, xtn->gbl_environ, env_mk_type);
|
||||
if (HAWK_UNLIKELY(!envp)) return HAWK_NULL;
|
||||
|
||||
if (rxtn->envp) hawk_rtx_freemem(rtx, rxtn->envp);
|
||||
rxtn->envp = envp;
|
||||
rxtn->env_map = env_map;
|
||||
rxtn->env_map_rev = env_map_rev;
|
||||
rxtn->env_type = env_mk_type;
|
||||
}
|
||||
|
||||
return rxtn->envp;
|
||||
}
|
||||
|
||||
static void* pio_env_maker (hawk_pio_env_mk_type_t env_mk_type, void* ctx)
|
||||
@@ -2849,6 +2844,7 @@ static void fini_rxtn (hawk_rtx_t* rtx, void* ctx)
|
||||
}
|
||||
rxtn->env_map = HAWK_NULL;
|
||||
rxtn->env_map_rev = 0;
|
||||
rxtn->env_type = HAWK_RTX_ENV_MK_BPP;
|
||||
}
|
||||
|
||||
static int build_argcv (hawk_rtx_t* rtx, int argc_id, int argv_id, const hawk_ooch_t* id, hawk_ooch_t* icf[])
|
||||
@@ -3078,14 +3074,12 @@ static int build_environ (hawk_rtx_t* rtx, int gbl_id, hawk_env_char_t* envarr[]
|
||||
return 0;
|
||||
}
|
||||
|
||||
hawk_bch_t** hawk_rtx_commit_environ (hawk_rtx_t* rtx, int gbl_id)
|
||||
void* hawk_rtx_commit_environ (hawk_rtx_t* rtx, int gbl_id, hawk_rtx_env_mk_type_t env_mk_type)
|
||||
{
|
||||
hawk_val_t* v_env;
|
||||
hawk_map_t* map;
|
||||
hawk_map_itr_t itr;
|
||||
hawk_map_pair_t* pair;
|
||||
hawk_env_char_t** envp;
|
||||
hawk_env_char_t* ptr;
|
||||
hawk_oow_t count, ptr_bytes, str_bytes;
|
||||
|
||||
v_env = hawk_rtx_getgbl(rtx, gbl_id);
|
||||
@@ -3095,10 +3089,42 @@ hawk_bch_t** hawk_rtx_commit_environ (hawk_rtx_t* rtx, int gbl_id)
|
||||
{
|
||||
/* it may be nil. but we can't prevent ENVIRON from being set to
|
||||
* other scalar types, we should handle this case gracefully */
|
||||
envp = (hawk_env_char_t**)hawk_rtx_allocmem(rtx, HAWK_SIZEOF(*envp) * 1);
|
||||
if (HAWK_UNLIKELY(!envp)) return HAWK_NULL;
|
||||
envp[0] = HAWK_NULL;
|
||||
return envp;
|
||||
switch (env_mk_type)
|
||||
{
|
||||
case HAWK_RTX_ENV_MK_BPP:
|
||||
{
|
||||
hawk_bch_t** envp;
|
||||
|
||||
envp = (hawk_bch_t**)hawk_rtx_allocmem(rtx, HAWK_SIZEOF(*envp) * 1);
|
||||
if (HAWK_UNLIKELY(!envp)) return HAWK_NULL;
|
||||
envp[0] = HAWK_NULL;
|
||||
return envp;
|
||||
}
|
||||
|
||||
case HAWK_RTX_ENV_MK_BPN:
|
||||
{
|
||||
hawk_bch_t* envp;
|
||||
|
||||
envp = (hawk_bch_t*)hawk_rtx_allocmem(rtx, HAWK_SIZEOF(*envp) * 2);
|
||||
if (HAWK_UNLIKELY(!envp)) return HAWK_NULL;
|
||||
envp[0] = '\0';
|
||||
envp[1] = '\0';
|
||||
return envp;
|
||||
}
|
||||
|
||||
case HAWK_RTX_ENV_MK_UPN:
|
||||
{
|
||||
hawk_uch_t* envp;
|
||||
|
||||
envp = (hawk_uch_t*)hawk_rtx_allocmem(rtx, HAWK_SIZEOF(*envp) * 2);
|
||||
if (HAWK_UNLIKELY(!envp)) return HAWK_NULL;
|
||||
envp[0] = '\0';
|
||||
envp[1] = '\0';
|
||||
return envp;
|
||||
}
|
||||
}
|
||||
|
||||
return HAWK_NULL;
|
||||
}
|
||||
|
||||
map = ((hawk_val_map_t*)v_env)->map;
|
||||
@@ -3130,128 +3156,226 @@ hawk_bch_t** hawk_rtx_commit_environ (hawk_rtx_t* rtx, int gbl_id)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(HAWK_ENV_CHAR_IS_BCH)
|
||||
if (env_mk_type == HAWK_RTX_ENV_MK_UPN)
|
||||
{
|
||||
{
|
||||
hawk_uch_t* vptr;
|
||||
vptr = hawk_rtx_valtoucstrdup(rtx, HAWK_MAP_VPTR(pair), &vlen);
|
||||
if (HAWK_UNLIKELY(!vptr)) return HAWK_NULL;
|
||||
hawk_rtx_freemem(rtx, vptr);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
hawk_bch_t* vptr;
|
||||
vptr = hawk_rtx_getvalbcstr(rtx, HAWK_MAP_VPTR(pair), &vlen);
|
||||
if (HAWK_UNLIKELY(!vptr)) return HAWK_NULL;
|
||||
hawk_rtx_freevalbcstr(rtx, HAWK_MAP_VPTR(pair), vptr);
|
||||
}
|
||||
#else
|
||||
{
|
||||
hawk_uch_t* vptr;
|
||||
vptr = hawk_rtx_getvalucstr(rtx, HAWK_MAP_VPTR(pair), &vlen);
|
||||
if (HAWK_UNLIKELY(!vptr)) return HAWK_NULL;
|
||||
hawk_rtx_freevalucstr(rtx, HAWK_MAP_VPTR(pair), vptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
str_bytes += klen + 1 + vlen + 1;
|
||||
count++;
|
||||
pair = hawk_map_getnextpair(map, &itr);
|
||||
}
|
||||
|
||||
ptr_bytes = HAWK_SIZEOF(*envp) * (count + 1);
|
||||
envp = (hawk_env_char_t**)hawk_rtx_allocmem(rtx, ptr_bytes + (str_bytes * HAWK_SIZEOF(*ptr)));
|
||||
if (HAWK_UNLIKELY(!envp)) return HAWK_NULL;
|
||||
|
||||
ptr = (hawk_env_char_t*)((hawk_uint8_t*)envp + ptr_bytes);
|
||||
count = 0;
|
||||
|
||||
hawk_init_map_itr(&itr, 0);
|
||||
pair = hawk_map_getfirstpair(map, &itr);
|
||||
while (pair)
|
||||
if (env_mk_type == HAWK_RTX_ENV_MK_BPP)
|
||||
{
|
||||
hawk_oow_t klen, vlen;
|
||||
hawk_bch_t** envp;
|
||||
hawk_bch_t* ptr;
|
||||
|
||||
envp[count++] = ptr;
|
||||
klen = HAWK_MAP_KLEN(pair);
|
||||
ptr_bytes = HAWK_SIZEOF(*envp) * (count + 1);
|
||||
envp = (hawk_bch_t**)hawk_rtx_allocmem(rtx, ptr_bytes + (str_bytes * HAWK_SIZEOF(*ptr)));
|
||||
if (HAWK_UNLIKELY(!envp)) return HAWK_NULL;
|
||||
|
||||
#if ((defined(HAWK_ENV_CHAR_IS_BCH) && defined(HAWK_OOCH_IS_BCH)) || \
|
||||
(defined(HAWK_ENV_CHAR_IS_UCH) && defined(HAWK_OOCH_IS_UCH)))
|
||||
HAWK_MEMCPY(ptr, HAWK_MAP_KPTR(pair), klen);
|
||||
ptr += klen;
|
||||
#elif defined(HAWK_ENV_CHAR_IS_BCH)
|
||||
ptr = (hawk_bch_t*)((hawk_uint8_t*)envp + ptr_bytes);
|
||||
count = 0;
|
||||
|
||||
hawk_init_map_itr(&itr, 0);
|
||||
pair = hawk_map_getfirstpair(map, &itr);
|
||||
while (pair)
|
||||
{
|
||||
hawk_oow_t tmp_ulen, tmp_blen;
|
||||
hawk_oow_t klen, vlen;
|
||||
|
||||
tmp_ulen = klen;
|
||||
tmp_blen = str_bytes;
|
||||
if (hawk_rtx_convutobchars(rtx, HAWK_MAP_KPTR(pair), &tmp_ulen, ptr, &tmp_blen) <= -1)
|
||||
{
|
||||
hawk_rtx_freemem(rtx, envp);
|
||||
return HAWK_NULL;
|
||||
}
|
||||
ptr += tmp_blen;
|
||||
klen = tmp_blen;
|
||||
}
|
||||
envp[count++] = ptr;
|
||||
klen = HAWK_MAP_KLEN(pair);
|
||||
|
||||
#if defined(HAWK_OOCH_IS_BCH)
|
||||
HAWK_MEMCPY(ptr, HAWK_MAP_KPTR(pair), klen);
|
||||
ptr += klen;
|
||||
#else
|
||||
{
|
||||
hawk_oow_t tmp_blen, tmp_ulen;
|
||||
|
||||
tmp_blen = klen;
|
||||
tmp_ulen = str_bytes;
|
||||
if (hawk_rtx_convbtouchars(rtx, HAWK_MAP_KPTR(pair), &tmp_blen, ptr, &tmp_ulen, 1) <= -1)
|
||||
{
|
||||
hawk_rtx_freemem(rtx, envp);
|
||||
return HAWK_NULL;
|
||||
hawk_oow_t tmp_ulen, tmp_blen;
|
||||
|
||||
tmp_ulen = klen;
|
||||
tmp_blen = str_bytes;
|
||||
if (hawk_rtx_convutobchars(rtx, HAWK_MAP_KPTR(pair), &tmp_ulen, ptr, &tmp_blen) <= -1)
|
||||
{
|
||||
hawk_rtx_freemem(rtx, envp);
|
||||
return HAWK_NULL;
|
||||
}
|
||||
ptr += tmp_blen;
|
||||
}
|
||||
ptr += tmp_ulen;
|
||||
klen = tmp_ulen;
|
||||
}
|
||||
#endif
|
||||
|
||||
*ptr++ = '=';
|
||||
*ptr++ = '=';
|
||||
|
||||
#if defined(HAWK_ENV_CHAR_IS_BCH)
|
||||
{
|
||||
hawk_bch_t* vptr;
|
||||
|
||||
vptr = hawk_rtx_getvalbcstr(rtx, HAWK_MAP_VPTR(pair), &vlen);
|
||||
if (HAWK_UNLIKELY(!vptr))
|
||||
{
|
||||
hawk_rtx_freemem(rtx, envp);
|
||||
return HAWK_NULL;
|
||||
hawk_bch_t* vptr;
|
||||
|
||||
vptr = hawk_rtx_getvalbcstr(rtx, HAWK_MAP_VPTR(pair), &vlen);
|
||||
if (HAWK_UNLIKELY(!vptr))
|
||||
{
|
||||
hawk_rtx_freemem(rtx, envp);
|
||||
return HAWK_NULL;
|
||||
}
|
||||
|
||||
HAWK_MEMCPY(ptr, vptr, vlen);
|
||||
ptr += vlen;
|
||||
hawk_rtx_freevalbcstr(rtx, HAWK_MAP_VPTR(pair), vptr);
|
||||
}
|
||||
|
||||
HAWK_MEMCPY(ptr, vptr, vlen);
|
||||
ptr += vlen;
|
||||
hawk_rtx_freevalbcstr(rtx, HAWK_MAP_VPTR(pair), vptr);
|
||||
*ptr++ = '\0';
|
||||
pair = hawk_map_getnextpair(map, &itr);
|
||||
}
|
||||
|
||||
envp[count] = HAWK_NULL;
|
||||
return envp;
|
||||
}
|
||||
else if (env_mk_type == HAWK_RTX_ENV_MK_BPN)
|
||||
{
|
||||
hawk_bch_t* envp;
|
||||
hawk_bch_t* ptr;
|
||||
|
||||
envp = (hawk_bch_t*)hawk_rtx_allocmem(rtx, (str_bytes + 1) * HAWK_SIZEOF(*envp));
|
||||
if (HAWK_UNLIKELY(!envp)) return HAWK_NULL;
|
||||
|
||||
ptr = envp;
|
||||
hawk_init_map_itr(&itr, 0);
|
||||
pair = hawk_map_getfirstpair(map, &itr);
|
||||
while (pair)
|
||||
{
|
||||
hawk_oow_t klen, vlen;
|
||||
|
||||
klen = HAWK_MAP_KLEN(pair);
|
||||
|
||||
#if defined(HAWK_OOCH_IS_BCH)
|
||||
HAWK_MEMCPY(ptr, HAWK_MAP_KPTR(pair), klen);
|
||||
ptr += klen;
|
||||
#else
|
||||
{
|
||||
hawk_uch_t* vptr;
|
||||
|
||||
vptr = hawk_rtx_getvalucstr(rtx, HAWK_MAP_VPTR(pair), &vlen);
|
||||
if (HAWK_UNLIKELY(!vptr))
|
||||
{
|
||||
hawk_rtx_freemem(rtx, envp);
|
||||
return HAWK_NULL;
|
||||
hawk_oow_t tmp_ulen, tmp_blen;
|
||||
|
||||
tmp_ulen = klen;
|
||||
tmp_blen = str_bytes;
|
||||
if (hawk_rtx_convutobchars(rtx, HAWK_MAP_KPTR(pair), &tmp_ulen, ptr, &tmp_blen) <= -1)
|
||||
{
|
||||
hawk_rtx_freemem(rtx, envp);
|
||||
return HAWK_NULL;
|
||||
}
|
||||
ptr += tmp_blen;
|
||||
}
|
||||
#endif
|
||||
|
||||
*ptr++ = '=';
|
||||
|
||||
{
|
||||
hawk_bch_t* vptr;
|
||||
|
||||
vptr = hawk_rtx_getvalbcstr(rtx, HAWK_MAP_VPTR(pair), &vlen);
|
||||
if (HAWK_UNLIKELY(!vptr))
|
||||
{
|
||||
hawk_rtx_freemem(rtx, envp);
|
||||
return HAWK_NULL;
|
||||
}
|
||||
|
||||
HAWK_MEMCPY(ptr, vptr, vlen);
|
||||
ptr += vlen;
|
||||
hawk_rtx_freevalbcstr(rtx, HAWK_MAP_VPTR(pair), vptr);
|
||||
}
|
||||
|
||||
HAWK_MEMCPY(ptr, vptr, vlen);
|
||||
ptr += vlen;
|
||||
hawk_rtx_freevalucstr(rtx, HAWK_MAP_VPTR(pair), vptr);
|
||||
*ptr++ = '\0';
|
||||
pair = hawk_map_getnextpair(map, &itr);
|
||||
}
|
||||
#endif
|
||||
|
||||
*ptr++ = '\0';
|
||||
pair = hawk_map_getnextpair(map, &itr);
|
||||
return envp;
|
||||
}
|
||||
else if (env_mk_type == HAWK_RTX_ENV_MK_UPN)
|
||||
{
|
||||
hawk_uch_t* envp;
|
||||
hawk_uch_t* ptr;
|
||||
|
||||
envp = (hawk_uch_t*)hawk_rtx_allocmem(rtx, (str_bytes + 1) * HAWK_SIZEOF(*envp));
|
||||
if (HAWK_UNLIKELY(!envp)) return HAWK_NULL;
|
||||
|
||||
ptr = envp;
|
||||
hawk_init_map_itr(&itr, 0);
|
||||
pair = hawk_map_getfirstpair(map, &itr);
|
||||
while (pair)
|
||||
{
|
||||
hawk_oow_t klen, vlen;
|
||||
|
||||
klen = HAWK_MAP_KLEN(pair);
|
||||
|
||||
#if defined(HAWK_OOCH_IS_UCH)
|
||||
HAWK_MEMCPY(ptr, HAWK_MAP_KPTR(pair), klen);
|
||||
ptr += klen;
|
||||
#else
|
||||
{
|
||||
hawk_oow_t tmp_blen, tmp_ulen;
|
||||
|
||||
tmp_blen = klen;
|
||||
tmp_ulen = str_bytes;
|
||||
if (hawk_rtx_convbtouchars(rtx, HAWK_MAP_KPTR(pair), &tmp_blen, ptr, &tmp_ulen, 1) <= -1)
|
||||
{
|
||||
hawk_rtx_freemem(rtx, envp);
|
||||
return HAWK_NULL;
|
||||
}
|
||||
ptr += tmp_ulen;
|
||||
}
|
||||
#endif
|
||||
|
||||
*ptr++ = '=';
|
||||
|
||||
{
|
||||
hawk_uch_t* vptr;
|
||||
|
||||
vptr = hawk_rtx_valtoucstrdup(rtx, HAWK_MAP_VPTR(pair), &vlen);
|
||||
if (HAWK_UNLIKELY(!vptr))
|
||||
{
|
||||
hawk_rtx_freemem(rtx, envp);
|
||||
return HAWK_NULL;
|
||||
}
|
||||
|
||||
HAWK_MEMCPY(ptr, vptr, vlen);
|
||||
ptr += vlen;
|
||||
hawk_rtx_freemem(rtx, vptr);
|
||||
}
|
||||
|
||||
*ptr++ = '\0';
|
||||
pair = hawk_map_getnextpair(map, &itr);
|
||||
}
|
||||
|
||||
*ptr++ = '\0';
|
||||
return envp;
|
||||
}
|
||||
|
||||
envp[count] = HAWK_NULL;
|
||||
return envp;
|
||||
return HAWK_NULL;
|
||||
}
|
||||
|
||||
static int make_additional_globals (hawk_rtx_t* rtx, xtn_t* xtn, const hawk_ooch_t* id, hawk_ooch_t* icf[])
|
||||
{
|
||||
#if defined(HAVE_CRT_EXTERNS_H)
|
||||
#if defined(_WIN32)
|
||||
#define SYSTEM_ENVIRON _environ
|
||||
#elif defined(HAVE_CRT_EXTERNS_H)
|
||||
#define environ (*(_NSGetEnviron()))
|
||||
#define SYSTEM_ENVIRON environ
|
||||
#else
|
||||
extern char** environ;
|
||||
#define SYSTEM_ENVIRON environ
|
||||
#endif
|
||||
if (build_argcv(rtx, xtn->gbl_argc, xtn->gbl_argv, id, icf) <= -1 ||
|
||||
build_environ(rtx, xtn->gbl_environ, environ) <= -1) return -1;
|
||||
build_environ(rtx, xtn->gbl_environ, SYSTEM_ENVIRON) <= -1) return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -509,19 +509,13 @@ int hawk_conv_bchars_to_uchars_upto_stopper_with_cmgr (
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
#if defined(_WIN32) || defined(__OS2__) || defined(__DOS__)
|
||||
# define IS_PATH_SEP(c) ((c) == '/' || (c) == '\\')
|
||||
#else
|
||||
# define IS_PATH_SEP(c) ((c) == '/')
|
||||
#endif
|
||||
|
||||
const hawk_uch_t* hawk_get_base_name_ucstr (const hawk_uch_t* path)
|
||||
{
|
||||
const hawk_uch_t* p, * last = HAWK_NULL;
|
||||
|
||||
for (p = path; *p != '\0'; p++)
|
||||
{
|
||||
if (IS_PATH_SEP(*p)) last = p;
|
||||
if (HAWK_IS_PATH_SEP(*p)) last = p;
|
||||
}
|
||||
|
||||
return last? (last + 1): path;
|
||||
@@ -533,7 +527,7 @@ const hawk_bch_t* hawk_get_base_name_bcstr (const hawk_bch_t* path)
|
||||
|
||||
for (p = path; *p != '\0'; p++)
|
||||
{
|
||||
if (IS_PATH_SEP(*p)) last = p;
|
||||
if (HAWK_IS_PATH_SEP(*p)) last = p;
|
||||
}
|
||||
|
||||
return last? (last + 1): path;
|
||||
@@ -546,7 +540,7 @@ const hawk_uch_t* hawk_get_base_name_uchars (const hawk_uch_t* path, hawk_oow_t
|
||||
|
||||
for (p = path; p < end; p++)
|
||||
{
|
||||
if (IS_PATH_SEP(*p)) last = p;
|
||||
if (HAWK_IS_PATH_SEP(*p)) last = p;
|
||||
}
|
||||
|
||||
return last? (last + 1): path;
|
||||
@@ -559,7 +553,7 @@ const hawk_bch_t* hawk_get_base_name_bchars (const hawk_bch_t* path, hawk_oow_t
|
||||
|
||||
for (p = path; p < end; p++)
|
||||
{
|
||||
if (IS_PATH_SEP(*p)) last = p;
|
||||
if (HAWK_IS_PATH_SEP(*p)) last = p;
|
||||
}
|
||||
|
||||
return last? (last + 1): path;
|
||||
|
||||
+51
-30
@@ -40,9 +40,11 @@
|
||||
|
||||
#if defined(_WIN32)
|
||||
# include <windows.h>
|
||||
# include <signal.h>
|
||||
#elif defined(__OS2__)
|
||||
# define INCL_DOSPROCESS
|
||||
# include <os2.h>
|
||||
# include <signal.h>
|
||||
#else
|
||||
# include <unistd.h>
|
||||
# include <signal.h>
|
||||
@@ -54,12 +56,12 @@ typedef HAWK::HawkStd HawkStd;
|
||||
typedef HAWK::HawkStd::Run Run;
|
||||
typedef HAWK::HawkStd::Value Value;
|
||||
|
||||
#ifdef _WIN32
|
||||
/*#ifdef _WIN32
|
||||
static BOOL WINAPI stop_run (DWORD ctrl_type);
|
||||
#else
|
||||
#else */
|
||||
static void stop_run (int sig);
|
||||
static void do_nothing (int sig);
|
||||
#endif
|
||||
/*#endif*/
|
||||
static void relay_signal (int sig);
|
||||
static int setsignal (int sig, void(*handler)(int), int restart);
|
||||
static void print_debug_return (hawk_rtx_t* rtx, hawk_val_t* ret);
|
||||
@@ -215,6 +217,15 @@ static void print_error (const hawk_bch_t* fmt, ...)
|
||||
va_end (va);
|
||||
}
|
||||
|
||||
static void print_warning (const hawk_bch_t* fmt, ...)
|
||||
{
|
||||
va_list va;
|
||||
fprintf (stderr, "WARNING: ");
|
||||
va_start (va, fmt);
|
||||
vfprintf (stderr, fmt, va);
|
||||
va_end (va);
|
||||
}
|
||||
|
||||
static void print_error(MyHawk& hawk)
|
||||
{
|
||||
hawk_errnum_t code = hawk.getErrorNumber();
|
||||
@@ -239,7 +250,8 @@ static void print_error(MyHawk& hawk)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
/*
|
||||
#if defined(_WIN32)
|
||||
static BOOL WINAPI stop_run (DWORD ctrl_type)
|
||||
{
|
||||
if (ctrl_type == CTRL_C_EVENT ||
|
||||
@@ -251,10 +263,11 @@ static BOOL WINAPI stop_run (DWORD ctrl_type)
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
#else
|
||||
#else */
|
||||
|
||||
static int setsignal (int sig, void(*handler)(int), int restart)
|
||||
{
|
||||
#if defined(HAVE_SIGACTION)
|
||||
struct sigaction sa_int;
|
||||
|
||||
sa_int.sa_handler = handler;
|
||||
@@ -264,17 +277,20 @@ static int setsignal (int sig, void(*handler)(int), int restart)
|
||||
|
||||
if (restart)
|
||||
{
|
||||
#ifdef SA_RESTART
|
||||
#if defined(SA_RESTART)
|
||||
sa_int.sa_flags |= SA_RESTART;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef SA_INTERRUPT
|
||||
#if defined(SA_INTERRUPT)
|
||||
sa_int.sa_flags |= SA_INTERRUPT;
|
||||
#endif
|
||||
}
|
||||
return sigaction(sig, &sa_int, NULL);
|
||||
#else
|
||||
return (signal(sig, handler) == SIG_ERR)? -1: 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void stop_run (int sig)
|
||||
@@ -288,27 +304,32 @@ static void do_nothing (int sig)
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
/*#endif*/
|
||||
|
||||
static void set_signal (void)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
/*#ifdef _WIN32
|
||||
SetConsoleCtrlHandler(stop_run, TRUE);
|
||||
#else
|
||||
#else*/
|
||||
/*setsignal(SIGINT, stop_run, 1); TO BE MORE COMPATIBLE WITH WIN32*/
|
||||
setsignal(SIGINT, stop_run, 0);
|
||||
#if defined(SIGPIPE)
|
||||
setsignal(SIGPIPE, do_nothing, 0);
|
||||
#endif
|
||||
/*#endif*/
|
||||
}
|
||||
|
||||
static void unset_signal(void)
|
||||
{
|
||||
/*
|
||||
#ifdef _WIN32
|
||||
SetConsoleCtrlHandler(stop_run, FALSE);
|
||||
#else
|
||||
#else*/
|
||||
setsignal(SIGINT, SIG_DFL, 1);
|
||||
#if defined(SIGPIPE)
|
||||
setsignal(SIGPIPE, SIG_DFL, 1);
|
||||
#endif
|
||||
/*#endif*/
|
||||
}
|
||||
|
||||
static void print_usage (FILE* out, const hawk_bch_t* argv0)
|
||||
@@ -505,7 +526,7 @@ static int handle_cmdline (MyHawk& hawk, int argc, hawk_bch_t* argv[], cmdline_t
|
||||
};
|
||||
hawk_bci_t c;
|
||||
|
||||
std::memset (cmdline, 0, HAWK_SIZEOF(*cmdline));
|
||||
std::memset(cmdline, 0, HAWK_SIZEOF(*cmdline));
|
||||
while ((c = hawk_get_bcli(argc, argv, &opt)) != HAWK_BCI_EOF)
|
||||
{
|
||||
switch (c)
|
||||
@@ -626,7 +647,7 @@ static int make_args_for_exec (cmdline_t* cmdline, MyHawk& hawk, MyHawk::Run* ru
|
||||
{
|
||||
if (cmdline->argv[i - 1].setStr(run, hawk.getArgument(i)) <= -1)
|
||||
{
|
||||
free_args_for_exec (cmdline);
|
||||
free_args_for_exec(cmdline);
|
||||
return -1;
|
||||
}
|
||||
cmdline->argc++;
|
||||
@@ -634,8 +655,8 @@ static int make_args_for_exec (cmdline_t* cmdline, MyHawk& hawk, MyHawk::Run* ru
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
free_args_for_exec (cmdline);
|
||||
hawk.setError (HAWK_ENOMEM);
|
||||
free_args_for_exec(cmdline);
|
||||
hawk.setError(HAWK_ENOMEM);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -716,7 +737,7 @@ static int hawk_main (MyHawk& hawk, int argc, hawk_bch_t* argv[])
|
||||
|
||||
if (cmdline.fs)
|
||||
{
|
||||
MyHawk::Value fs (run);
|
||||
MyHawk::Value fs(run);
|
||||
if (fs.setStr(cmdline.fs) <= -1)
|
||||
{
|
||||
print_error(hawk);
|
||||
@@ -769,7 +790,7 @@ static int hawk_main (MyHawk& hawk, int argc, hawk_bch_t* argv[])
|
||||
static HAWK_INLINE int execute_hawk (int argc, hawk_bch_t* argv[])
|
||||
{
|
||||
//HAWK::HeapMmgr hm (1000000);
|
||||
//MyHawk awk (&hm);
|
||||
//MyHawk awk(&hm);
|
||||
MyHawk hawk;
|
||||
|
||||
if (hawk.open() <= -1)
|
||||
@@ -779,9 +800,9 @@ static HAWK_INLINE int execute_hawk (int argc, hawk_bch_t* argv[])
|
||||
}
|
||||
app_hawk = &hawk;
|
||||
|
||||
set_signal ();
|
||||
set_signal();
|
||||
int n = hawk_main(hawk, argc, argv);
|
||||
unset_signal ();
|
||||
unset_signal();
|
||||
|
||||
app_hawk = HAWK_NULL;
|
||||
hawk.close();
|
||||
@@ -810,39 +831,39 @@ int main (int argc, hawk_bch_t* argv[])
|
||||
codepage = GetConsoleOutputCP();
|
||||
if (codepage == CP_UTF8)
|
||||
{
|
||||
/*SetConsoleOUtputCP (CP_UTF8);*/
|
||||
/*hawk_setdflcmgrbyid (HAWK_CMGR_UTF8);*/
|
||||
/*SetConsoleOUtputCP(CP_UTF8);*/
|
||||
/*hawk_setdflcmgrbyid(HAWK_CMGR_UTF8);*/
|
||||
}
|
||||
else
|
||||
{
|
||||
/* .codepage */
|
||||
hawk_fmt_uintmax_to_bcstr (locale, HAWK_COUNTOF(locale), codepage, 10, -1, '\0', ".");
|
||||
setlocale (LC_ALL, locale);
|
||||
/* hawk_setdflcmgrbyid (HAWK_CMGR_SLMB); */
|
||||
hawk_fmt_uintmax_to_bcstr(locale, HAWK_COUNTOF(locale), codepage, 10, -1, '\0', ".");
|
||||
setlocale(LC_ALL, locale);
|
||||
/* hawk_setdflcmgrbyid(HAWK_CMGR_SLMB); */
|
||||
}
|
||||
|
||||
#else
|
||||
setlocale (LC_ALL, "");
|
||||
/* hawk_setdflcmgrbyid (HAWK_CMGR_SLMB); */
|
||||
setlocale(LC_ALL, "");
|
||||
/* hawk_setdflcmgrbyid(HAWK_CMGR_SLMB); */
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
if (WSAStartup(MAKEWORD(2,0), &wsadata) != 0)
|
||||
print_warning ("Failed to start up winsock\n");
|
||||
print_warning("Failed to start up winsock\n");
|
||||
else sock_inited = 1;
|
||||
#elif defined(__DOS__)
|
||||
/* TODO: add an option to skip watt-32 */
|
||||
_watt_do_exit = 0; /* prevent sock_init from exiting upon failure */
|
||||
if (sock_init() != 0) print_warning ("Failed to initialize watt-32\n");
|
||||
if (sock_init() != 0) print_warning("Failed to initialize watt-32\n");
|
||||
else sock_inited = 1;
|
||||
#endif
|
||||
|
||||
ret = execute_hawk(argc, argv);
|
||||
|
||||
#if defined(_WIN32)
|
||||
if (sock_inited) WSACleanup ();
|
||||
if (sock_inited) WSACleanup();
|
||||
#elif defined(__DOS__)
|
||||
if (sock_inited) sock_exit ();
|
||||
if (sock_inited) sock_exit();
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
|
||||
+14
-9
@@ -1,15 +1,20 @@
|
||||
#include <Hawk-Sed.hpp>
|
||||
#include <hawk-fmt.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <locale.h>
|
||||
|
||||
#if defined(_WIN32)
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
static void print_error (const hawk_bch_t* fmt, ...)
|
||||
{
|
||||
va_list va;
|
||||
fprintf (stderr, "ERROR: ");
|
||||
va_start (va, fmt);
|
||||
vfprintf (stderr, fmt, va);
|
||||
va_end (va);
|
||||
fprintf(stderr, "ERROR: ");
|
||||
va_start(va, fmt);
|
||||
vfprintf(stderr, fmt, va);
|
||||
va_end(va);
|
||||
}
|
||||
|
||||
static void print_error (HAWK::SedStd& sed)
|
||||
@@ -105,20 +110,20 @@ int main (int argc, hawk_bch_t* argv[])
|
||||
codepage = GetConsoleOutputCP();
|
||||
if (codepage == CP_UTF8)
|
||||
{
|
||||
/*SetConsoleOUtputCP (CP_UTF8);*/
|
||||
/*hawk_setdflcmgrbyid (HAWK_CMGR_UTF8);*/
|
||||
/*SetConsoleOUtputCP(CP_UTF8);*/
|
||||
/*hawk_setdflcmgrbyid(HAWK_CMGR_UTF8);*/
|
||||
}
|
||||
else
|
||||
{
|
||||
/* .codepage */
|
||||
hawk_fmt_uintmax_to_bcstr (locale, HAWK_COUNTOF(locale), codepage, 10, -1, '\0', ".");
|
||||
setlocale (LC_ALL, locale);
|
||||
hawk_fmt_uintmax_to_bcstr(locale, HAWK_COUNTOF(locale), codepage, 10, -1, '\0', ".");
|
||||
setlocale(LC_ALL, locale);
|
||||
/* hawk_setdflcmgrbyid (HAWK_CMGR_SLMB); */
|
||||
}
|
||||
|
||||
#else
|
||||
setlocale (LC_ALL, "");
|
||||
/* hawk_setdflcmgrbyid (HAWK_CMGR_SLMB); */
|
||||
/* hawk_setdflcmgrbyid(HAWK_CMGR_SLMB); */
|
||||
#endif
|
||||
|
||||
ret = execute_sed(argc, argv);
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
REM set HAWK_TEST_COMPILER=Z:\path\to\hawk\bld-mingw64\bin\.libs\hawk.exe
|
||||
REM Z:\path\to\hawk\t\cmd-tap-driver.cmd --test-name h-011 --log-file h-011.log --trs-file h-011.trs -- Z:\path\to\hawk\t\t\run-hawk-test.cmd -f ..\..\t\h-011.hawk
|
||||
REM
|
||||
|
||||
@echo off
|
||||
setlocal EnableExtensions DisableDelayedExpansion
|
||||
|
||||
set "test_name="
|
||||
set "log_file="
|
||||
set "trs_file="
|
||||
|
||||
:parse
|
||||
if "%~1"=="" goto usage
|
||||
if "%~1"=="--" goto seen_separator
|
||||
if "%~1"=="--test-name" goto set_test_name
|
||||
if "%~1"=="--log-file" goto set_log_file
|
||||
if "%~1"=="--trs-file" goto set_trs_file
|
||||
|
||||
echo ERROR: unknown option %~1 1>&2
|
||||
goto usage_exit
|
||||
|
||||
:set_test_name
|
||||
if "%~2"=="" goto usage
|
||||
set "test_name=%~2"
|
||||
shift
|
||||
shift
|
||||
goto parse
|
||||
|
||||
:set_log_file
|
||||
if "%~2"=="" goto usage
|
||||
set "log_file=%~2"
|
||||
shift
|
||||
shift
|
||||
goto parse
|
||||
|
||||
:set_trs_file
|
||||
if "%~2"=="" goto usage
|
||||
set "trs_file=%~2"
|
||||
shift
|
||||
shift
|
||||
goto parse
|
||||
|
||||
:seen_separator
|
||||
shift
|
||||
|
||||
:run
|
||||
if "%~1"=="" goto usage
|
||||
if not defined test_name set "test_name=cmd-test"
|
||||
if not defined log_file set "log_file=%test_name%.log"
|
||||
if not defined trs_file set "trs_file=%test_name%.trs"
|
||||
|
||||
call %1 %2 %3 %4 %5 %6 %7 %8 %9 >"%log_file%" 2>&1
|
||||
set "cmd_status=%errorlevel%"
|
||||
|
||||
type "%log_file%"
|
||||
|
||||
set "result=PASS"
|
||||
if not "%cmd_status%"=="0" set "result=FAIL"
|
||||
|
||||
findstr /b /c:"not ok " "%log_file%" >nul 2>&1
|
||||
if not errorlevel 1 set "result=FAIL"
|
||||
|
||||
findstr /b /c:"1..0 # SKIP" "%log_file%" >nul 2>&1
|
||||
if not errorlevel 1 set "result=SKIP"
|
||||
|
||||
(
|
||||
echo :test-result: %result%
|
||||
echo :global-test-result: %result%
|
||||
echo :recheck: no
|
||||
echo :copy-in-global-log: no
|
||||
) >"%trs_file%"
|
||||
|
||||
echo %result%: %test_name%
|
||||
|
||||
if /i "%result%"=="PASS" exit /b 0
|
||||
if /i "%result%"=="SKIP" exit /b 0
|
||||
exit /b 1
|
||||
|
||||
:usage
|
||||
echo Usage: %~nx0 --test-name NAME [--log-file FILE] [--trs-file FILE] -- COMMAND [ARGS...] 1>&2
|
||||
|
||||
:usage_exit
|
||||
exit /b 2
|
||||
@@ -0,0 +1,29 @@
|
||||
@echo off
|
||||
setlocal EnableExtensions EnableDelayedExpansion
|
||||
|
||||
if defined HAWK_TEST_COMPILER (
|
||||
set "hawk_bin=%HAWK_TEST_COMPILER%"
|
||||
) else (
|
||||
set "hawk_bin=..\bin\hawk.exe"
|
||||
)
|
||||
|
||||
if defined HAWK_LOG_COMPILER set "hawk_bin=%HAWK_LOG_COMPILER%"
|
||||
|
||||
for %%I in ("%hawk_bin%") do (
|
||||
set "hawk_bin=%%~fI"
|
||||
set "hawk_dir=%%~dpI"
|
||||
)
|
||||
|
||||
if not "!hawk_dir:\.libs\=!"=="!hawk_dir!" (
|
||||
for %%I in ("!hawk_dir!..\..\lib\.libs") do (
|
||||
if exist "%%~fI" set "PATH=%%~fI;!PATH!"
|
||||
)
|
||||
)
|
||||
|
||||
if defined HAWK_TEST_OPTS (
|
||||
call "!hawk_bin!" %HAWK_TEST_OPTS% %*
|
||||
) else (
|
||||
call "!hawk_bin!" %*
|
||||
)
|
||||
|
||||
exit /b %errorlevel%
|
||||
Reference in New Issue
Block a user