pike.git / lib / modules / Stdio.pmod

version» Context lines:

pike.git/lib/modules/Stdio.pmod:1: - // $Id: Stdio.pmod,v 1.33 1998/07/28 23:53:17 hubbe Exp $ + // $Id: Stdio.pmod,v 1.34 1998/09/01 17:13:10 hubbe Exp $      #include <string.h>      inherit files;      class File   {    inherit Fd_ref;       mixed ___read_callback;    mixed ___write_callback;    mixed ___close_callback;   #if constant(__HAVE_OOB__)_    mixed ___read_oob_callback;    mixed ___write_oob_callback;   #endif    mixed ___id;      #ifdef __STDIO_DEBUG    string __closed_backtrace; -  + #define CHECK_OPEN() \ +  if(!_fd) \ +  { \ +  throw(({ \ +  "Stdio.File(): line "+__LINE__+" on closed file.\n"+ \ +  (__closed_backtrace ? \ +  sprintf("File was closed from:\n %-=200s\n",__closed_backtrace) : \ +  "This file has never been open.\n" ), \ +  backtrace()})); \ +  \ +  } + #else + #define CHECK_OPEN()   #endif       int errno()    {    return _fd && ::errno();    }       int open(string file, string mode, void|int bits)    {    _fd=Fd();
pike.git/lib/modules/Stdio.pmod:168:    int close(void|string how)    {    if(::close(how||"rw"))    {    _fd=0;   #ifdef __STDIO_DEBUG    __closed_backtrace=master()->describe_backtrace(backtrace());   #endif    }    return 1; - #if 0 -  if(how) -  { -  if(::close(how)) -  _fd=0; -  }else{ -  _fd=0; +     } - #endif -  } +        static void __stdio_read_callback()    {   #if defined(__STDIO_DEBUG) && !defined(__NT__)    if(!::peek())    throw( ({"Read callback with no data to read!\n",backtrace()}) );   #endif    string s=::read(8192,1);    if(s && strlen(s))    {
pike.git/lib/modules/Stdio.pmod:218: Inside #if constant(__HAVE_OOB__)_
      static void __stdio_write_oob_callback() { ___write_oob_callback(___id); }   #endif      #define SET(X,Y) ::set_##X ((___##X = (Y)) && __stdio_##X)   #define _SET(X,Y) _fd->_##X=(___##X = (Y)) && __stdio_##X      #define CBFUNC(X) \    void set_##X (mixed l##X) \    { \ +  CHECK_OPEN(); \    SET( X , l##X ); \    } \    \    mixed query_##X () \    { \    return ___##X; \    }       CBFUNC(read_callback)    CBFUNC(write_callback)
pike.git/lib/modules/Stdio.pmod:247:       void set_nonblocking(mixed|void rcb,    mixed|void wcb,    mixed|void ccb,   #if constant(__HAVE_OOB__)_    mixed|void roobcb,    mixed|void woobcb   #endif    )    { - #ifdef __STDIO_DEBUG -  if(!_fd) -  { -  throw(({ -  "Stdio.File(): set_nonblocking on closed file.\n"+ -  (__closed_backtrace ? -  sprintf("File was closed from:\n %-=200s\n",__closed_backtrace) : -  "This file has never been open.\n" ), -  backtrace()})); -  -  } - #endif +  CHECK_OPEN();    ::_disable_callbacks(); // Thread safing       _SET(read_callback,rcb);    _SET(write_callback,wcb);    ___close_callback=ccb;      #if constant(__HAVE_OOB__)_    _SET(read_oob_callback,roobcb);    _SET(write_oob_callback,woobcb);   #endif
pike.git/lib/modules/Stdio.pmod:287:    }   #else    ::set_nonblocking();   #endif    ::_enable_callbacks();       }       void set_blocking()    { +  CHECK_OPEN();    SET(read_callback,0);    SET(write_callback,0);    ___close_callback=0;   #if constant(__HAVE_OOB__)_    SET(read_oob_callback,0);    SET(write_oob_callback,0);   #endif    ::set_blocking();    }   };