pike.git / lib / 7.8 / modules / Stdio.pmod / module.pmod

version» Context lines:

pike.git/lib/7.8/modules/Stdio.pmod/module.pmod:1:   #pike 7.9      //! Pike 7.8 compatibility @[predef::Stdio] implementation.   //!   //! The main difference from later versions of Pike   //! is that @[Stdio.File] and @[Stdio.FILE] use   //! proxy functions defined in @[_Stdio.Fd_ref],   //! instead of accessing the file descriptors directly. + #pragma no_deprecation_warnings    - //! @decl inherit 7.8::Stdio + //! @decl inherit 7.9::Stdio      //! @ignore   inherit Stdio.module;   //! @endignore      //#define BACKEND_DEBUG   #ifdef BACKEND_DEBUG   #define BE_WERR(X) werror("FD %O: %s\n", _fd, X)   #else   #define BE_WERR(X)
pike.git/lib/7.8/modules/Stdio.pmod/module.pmod:761:    return this;    }       // FIXME: No way to specify the maximum to read.    protected int __stdio_read_callback()    {    BE_WERR("__stdio_read_callback()");       if (!___read_callback) {    if (___close_callback) { - #if 0 -  /* This code only works for the POLL case! */ -  if ((peek(0, 1) == -1) && (errno() == System.EPIPE)) - #endif /* 0 */ +     return __stdio_close_callback();    }    return 0;    }       if (!errno()) { - #if 0 -  if (!(::mode() & PROP_IS_NONBLOCKING)) -  error ("Read callback called on blocking socket!\n" -  "Callbacks: %O, %O\n" -  "Id: %O\n", -  ___read_callback, -  ___close_callback, -  ___id); - #endif /* 0 */ +        string s;   #ifdef STDIO_CALLBACK_TEST_MODE    s = ::read (1, 1);   #else    s = ::read(DATA_CHUNK_SIZE,1);   #endif    if (s) {    if(sizeof(s))    {
pike.git/lib/7.8/modules/Stdio.pmod/module.pmod:836:       if(errno())    BE_WERR (" got error " + strerror (errno()) + " from read()");       return ___fs_event_callback(___id, event_mask);    }       protected int __stdio_close_callback()    {    BE_WERR ("__stdio_close_callback()"); - #if 0 -  if (!(::mode() & PROP_IS_NONBLOCKING)) ::set_nonblocking(); - #endif /* 0 */ +        if (!___close_callback) return 0;       if (!errno()) {    // There's data to read...    //    // FIXME: This doesn't work well since the close callback might    // very well be called sometime later, due to an error if    // nothing else. What we really need is a special error callback    // from the backend. /mast
pike.git/lib/7.8/modules/Stdio.pmod/module.pmod:1391:    //! @decl void set_blocking_keep_callbacks()    //! Toggle between blocking and nonblocking,    //! without changing the callbacks.    //!    //! @seealso    //! @[set_nonblocking()], @[set_blocking()]       void set_blocking_keep_callbacks()    {    CHECK_OPEN(); - #if 0 -  ::_disable_callbacks(); // Thread safing // Unnecessary. /mast - #endif +     ::set_blocking(); - #if 0 -  ::_enable_callbacks(); - #endif +     }       void set_nonblocking_keep_callbacks()    {    CHECK_OPEN(); - #if 0 -  ::_disable_callbacks(); // Thread safing // Unnecessary. /mast - #endif +     ::set_nonblocking(); - #if 0 -  ::_enable_callbacks(); - #endif +     }       protected void destroy()    {    BE_WERR("destroy()");    // Avoid cyclic refs.    // Not a good idea; the fd may have been    // given to another object (assign() or dup()).    // /grubba 2004-04-07    // FREE_CB(read_callback);
pike.git/lib/7.8/modules/Stdio.pmod/module.pmod:2013:    {    if(sizeof(b) - bpos <= 0 && !getchar_get_data())    return -1;       if(sizeof(cached_lines))    getchar_updatelinecache();       return b[bpos++];    }   } -  - //! An instance of @tt{FILE("stderr")@}, the standard error stream. Use this - //! when you want to output error messages. - //! - //! @seealso - //! @[predef::werror()] - FILE stderr=FILE("stderr"); -  - //! An instance of @tt{FILE("stdout")@}, the standatd output stream. Use this - //! when you want to write anything to the standard output. - //! - //! @seealso - //! @[predef::write()] - FILE stdout=FILE("stdout"); -  - //! An instance of @tt{FILE("stdin")@}, the standard input stream. Use this - //! when you want to read anything from the standard input. - //! This example will read lines from standard input for as long as there - //! are more lines to read. Each line will then be written to stdout together - //! with the line number. We could use @[Stdio.stdout.write()] instead - //! of just @[write()], since they are the same function. - //! - //! @example - //! int main() - //! { - //! int line; - //! while(string s=Stdio.stdin.gets()) - //! write("%5d: %s\n", line++, s); - //! } - FILE stdin=FILE("stdin"); +