pike.git / lib / modules / Protocols.pmod / Line.pmod

version» Context lines:

pike.git/lib/modules/Protocols.pmod/Line.pmod:1:   /* -  * $Id: Line.pmod,v 1.11 2000/09/28 03:38:51 hubbe Exp $ +  * $Id: Line.pmod,v 1.12 2000/12/16 22:32:01 nilsson Exp $    *    * Line-buffered protocol handling.    *    * Henrik Grubbström 1998-05-27    */      #pike __REAL_VERSION__      class simple   {    static object con; -  +  static constant newline = "\r\n";       function handle_data;    void handle_command(string data);       static int timeout; // Idle time before timeout.    static int timeout_time; // Time at which next timeout will occur.       static void send(string s)    {    send_q->put(s);
pike.git/lib/modules/Protocols.pmod/Line.pmod:62:    if (timeout > 0) {    timeout_time = time() + timeout;    }    }       static string multi_line_buffer = "";    static void _handle_command(string line)    {    if (handle_data) {    if (line != ".") { -  multi_line_buffer += line + "\r\n"; +  multi_line_buffer += line + newline;    } else {    function handle = handle_data;    string data = multi_line_buffer;    handle_data = 0;    multi_line_buffer = "";    handle(data);    }    } else {    handle_command(line);    }    }       static string read_buffer = "";       static string read_line()    { -  int i = search(read_buffer, "\r\n"); +  int i = search(read_buffer, newline);    if (i == -1) {    return 0;    } -  string data = read_buffer[..i-1]; // Not the "\r\n". -  read_buffer = read_buffer[i+2..]; +  string data = read_buffer[..i-1]; // Not the newline. +  read_buffer = read_buffer[i+sizeof(newline)..];       return data;    }       static void read_callback(mixed ignored, string data)    {    touch_time();       read_buffer += data;