diff --git a/README.md b/README.md index ba1f83e..203c826 100644 --- a/README.md +++ b/README.md @@ -137,6 +137,26 @@ briefly. ### Request message TODO: fill here +.BEGIN +.SCRIPT +.END +.EXIT +.KILL-WORKER +.SHOW-WORKERS + + +You can send a single-line script with a .SCRIPT command. + + .SCRIPT (printf "hello, world\n") + +If the script is long and contains line-breaks, enclose multiple .SCRIPT commands +with the .BEGIN and .END command. + + .BEGIN + .SCRIPT (printf "hello ") + .SCRIPT (printf "world\n") + .END + ### Reponse message There are two types of response messages. diff --git a/bin/main.c b/bin/main.c index 948951e..9718ba8 100644 --- a/bin/main.c +++ b/bin/main.c @@ -831,7 +831,7 @@ static int feed_loop (hcl_t* hcl, xtn_t* xtn, int cflags, int verbose) } /* [NOTE] it isn't a very nice idea to get this internal data and use it with read_input() */ - inarg = hcl_getbaseioarg(hcl); + inarg = hcl_getbaseinarg(hcl); while (1) { if (read_input(hcl, inarg) <= -1) goto oops; diff --git a/lib/hcl-s.c b/lib/hcl-s.c index 4e987c8..96ee0bf 100644 --- a/lib/hcl-s.c +++ b/lib/hcl-s.c @@ -1360,7 +1360,7 @@ int hcl_server_proto_handle_request (hcl_server_proto_t* proto) hcl_ooci_t c; int n; - hcl_setinloc (proto->hcl, 1, 1); + hcl_setbaseinloc (proto->hcl, 1, 1); /* do a special check bypassing get_token(). it checks if the script contents * come on the same line as .SCRIPT */ @@ -1396,7 +1396,10 @@ int hcl_server_proto_handle_request (hcl_server_proto_t* proto) } proto->worker->opstate = HCL_SERVER_WORKER_OPSTATE_COMPILE; - n = hcl_compile(proto->hcl, obj, HCL_COMPILE_CLEAR_CODE | HCL_COMPILE_CLEAR_FNBLK); + + /*n = hcl_compile(proto->hcl, obj, HCL_COMPILE_CLEAR_CODE | HCL_COMPILE_CLEAR_FNBLK);*/ + n = hcl_compile(proto->hcl, obj, 0); + hcl_freecnode (proto->hcl, obj); if (n <= -1) { diff --git a/lib/hcl.c b/lib/hcl.c index d6e0657..f2ea42f 100644 --- a/lib/hcl.c +++ b/lib/hcl.c @@ -379,12 +379,6 @@ void hcl_reset (hcl_t* hcl) hcl_gc (hcl, 1); } -void hcl_setinloc (hcl_t* hcl, hcl_oow_t line, hcl_oow_t colm) -{ - hcl->c->inarg.line = line; - hcl->c->inarg.colm = colm; -} - int hcl_setoption (hcl_t* hcl, hcl_option_t id, const void* value) { hcl_cb_t* cb; diff --git a/lib/hcl.h b/lib/hcl.h index 56b0a7a..0cccd8a 100644 --- a/lib/hcl.h +++ b/lib/hcl.h @@ -1969,12 +1969,6 @@ HCL_EXPORT void hcl_reset ( hcl_t* hcl ); -HCL_EXPORT void hcl_setinloc ( - hcl_t* hcl, - hcl_oow_t line, - hcl_oow_t colm -); - #if defined(HCL_HAVE_INLINE) static HCL_INLINE void* hcl_getxtn (hcl_t* hcl) { return (void*)((hcl_uint8_t*)hcl + hcl->_instsize); } static HCL_INLINE hcl_mmgr_t* hcl_getmmgr (hcl_t* hcl) { return hcl->_mmgr; } @@ -2150,10 +2144,16 @@ HCL_EXPORT void hcl_abort ( # define hcl_switchprocess(hcl) ((hcl)->switch_proc = 1) #endif -HCL_EXPORT hcl_ioinarg_t* hcl_getbaseioarg ( +HCL_EXPORT hcl_ioinarg_t* hcl_getbaseinarg ( hcl_t* hcl ); +HCL_EXPORT void hcl_setbaseinloc ( + hcl_t* hcl, + hcl_oow_t line, + hcl_oow_t colm +); + HCL_EXPORT int hcl_attachio ( hcl_t* hcl, hcl_ioimpl_t reader, diff --git a/lib/read.c b/lib/read.c index 4006e46..cdd0cf1 100644 --- a/lib/read.c +++ b/lib/read.c @@ -4056,7 +4056,13 @@ void hcl_detachio (hcl_t* hcl) } } -hcl_ioinarg_t* hcl_getbaseioarg (hcl_t* hcl) +hcl_ioinarg_t* hcl_getbaseinarg (hcl_t* hcl) { return &hcl->c->inarg; } + +void hcl_setbaseinloc (hcl_t* hcl, hcl_oow_t line, hcl_oow_t colm) +{ + hcl->c->inarg.line = line; + hcl->c->inarg.colm = colm; +}