From a34e702e482872a0fd238ae17e867df382a7c49b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=BCbinette=20=28Hubbe=29?= <hubbe@hubbe.net> Date: Sun, 26 Jul 1998 03:25:45 -0700 Subject: [PATCH] support for new threadsafe Stdio.pmod Rev: src/modules/files/file.c:1.116 Rev: src/modules/files/file_functions.h:1.5 --- src/modules/files/file.c | 42 +++++++++++++++++++++++++++++- src/modules/files/file_functions.h | 3 +++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/src/modules/files/file.c b/src/modules/files/file.c index 566b71d99d..58683e8cc7 100644 --- a/src/modules/files/file.c +++ b/src/modules/files/file.c @@ -5,7 +5,7 @@ \*/ #include "global.h" -RCSID("$Id: file.c,v 1.115 1998/07/20 21:12:15 hubbe Exp $"); +RCSID("$Id: file.c,v 1.116 1998/07/26 10:25:45 hubbe Exp $"); #include "fdlib.h" #include "interpret.h" #include "svalue.h" @@ -797,6 +797,46 @@ CBFUNCS(read_oob_callback) CBFUNCS(write_oob_callback) #endif +static void file__enable_callbacks(INT32 args) +{ +#define DO_TRIGGER(X) \ + if(IS_ZERO(& THIS->X )) \ + { \ + PIKE_CONCAT(set_,X)(FD, 0, 0); \ + check_internal_reference(THIS); \ + }else{ \ + PIKE_CONCAT(set_,X)(FD, PIKE_CONCAT(file_,X), THIS); \ + SET_INTERNAL_REFERENCE(THIS); \ + } + +DO_TRIGGER(read_callback) +DO_TRIGGER(write_callback) +#ifdef WITH_OOB +DO_TRIGGER(read_oob_callback) +DO_TRIGGER(write_oob_callback) +#endif + pop_n_elems(args); + push_int(0); +} + +static void file__disable_callbacks(INT32 args) +{ +#define DO_DISABLE(X) \ + PIKE_CONCAT(set_,X)(FD, 0, 0); \ + check_internal_reference(THIS); + + +DO_DISABLE(read_callback) +DO_DISABLE(write_callback) +#ifdef WITH_OOB +DO_DISABLE(read_oob_callback) +DO_DISABLE(write_oob_callback) +#endif + + pop_n_elems(args); + push_int(0); +} + static void file_write(INT32 args) { diff --git a/src/modules/files/file_functions.h b/src/modules/files/file_functions.h index ea43e755ad..b0b5367861 100644 --- a/src/modules/files/file_functions.h +++ b/src/modules/files/file_functions.h @@ -28,6 +28,9 @@ FILE_FUNC("set_write_oob_callback",file_set_write_oob_callback,"function(mixed:void)") #endif /* WITH_OOB */ + FILE_FUNC("_enable_callbacks",file__enable_callbacks,"function(:void)"); + FILE_FUNC("_disable_callbacks",file__disable_callbacks,"function(:void)"); + FILE_FUNC("set_blocking",file_set_blocking,"function(:void)") FILE_FUNC("query_fd",file_query_fd,"function(:int)") -- GitLab