Skip to content
Snippets Groups Projects
Select Git revision
  • 301e543b8a1be335e72f5475adac7b8d68f972a2
  • master default protected
  • 9.0
  • 8.0
  • nt-tools
  • 7.8
  • 7.6
  • 7.4
  • 7.2
  • 7.0
  • 0.6
  • rosuav/latex-markdown-renderer
  • rxnpatch/rxnpatch
  • marcus/gobject-introspection
  • rxnpatch/8.0
  • rosuav/pre-listening-ports
  • rosuav/async-annotations
  • rosuav/pgsql-ssl
  • rxnpatch/rxnpatch-broken/2023-10-06T094250
  • grubba/fdlib
  • grubba/wip/sakura/8.0
  • v8.0.2020
  • v8.0.2018
  • v8.0.2016
  • v8.0.2014
  • v8.0.2012
  • v8.0.2008
  • v8.0.2006
  • v8.0.2004
  • v8.0.2002
  • v8.0.2000
  • v8.0.1998
  • v8.0.1996
  • v8.0.1994
  • v8.0.1992
  • v8.0.1990
  • v8.0.1988
  • v8.0.1986
  • rxnpatch/clusters/8.0/2025-04-29T124414
  • rxnpatch/2025-04-29T124414
  • v8.0.1984
41 results

Line.pmod

Blame
  • Line.pmod 9.75 KiB
    /*
     * Line-buffered protocol handling.
     *
     * Henrik Grubbström 1998-05-27
     */
    
    #pike __REAL_VERSION__
    
    //! Simple nonblocking line-oriented I/O.
    class simple
    {
      protected object con;
    
      //! The sequence separating lines from eachother. "\r\n" by default.
      protected constant line_separator = "\r\n";
    
      //! If this variable has been set, multiple lines will be accumulated,
      //! until a line with a single @expr{"."@} (period) is received.
      //! @[handle_data()] will then be called with the accumulated data
      //! as the argument.
      //!
      //! @note
      //! @[handle_data()] is one-shot, ie it will be cleared when it is called.
      //!
      //! The line with the single @expr{"."@} (period) will not be in the
      //! accumulated data.
      //!
      //! @seealso
      //!   @[handle_command()]
      //!
      function(string:void) handle_data;
    
      //! This function will be called once for every line that is received.
      //!
      //! Overload this function as appropriate.
      //!
      //! @note
      //! It will not be called if @[handle_data()] has been set.
      //!
      //! @[line] will not contain the line separator.
      //!
      //! @seealso
      //! @[handle_data()]
      //!
      void handle_command(string line);
    
      protected int timeout;		// Idle time before timeout.
      protected int timeout_time;	// Time at which next timeout will occur.
    
      //! Queue some data to send.
      //!
      //! @seealso
      //! @[handle_command()], @[handle_data()], @[disconnect()]
      //!
      protected void send(string s)
      {
        send_q->put(s);
        con->set_write_callback(write_callback);
      }
    
      //! This function is called when a timeout occurrs.
      //! 
      //! Overload this function as appropriate.
      //!
      //! The default action is to shut down the connection immediately.
      //!
      //! @seealso
      //! @[create()], @[touch_time()]
      //!
      protected void do_timeout()