Commit f200aee5 authored by Niels Möller's avatar Niels Möller
Browse files

*** empty log message ***

Rev: doc/NOTES:1.2
Rev: src/read_scan.c:1.1
Rev: src/read_scan.h:1.1
parent 0665402a
......@@ -89,3 +89,11 @@ with remaining child processes even after that the first process has
died (i.e. after that it has received exit-status or exit-signal from
the server). In this case, the client should be considered not to send
EOF until it detects EOF on stdin.
PTY REFERENCES (from Keresztg)
the code of tnlited
http://viks.mvrop.org/networking/sock_advanced_tut.html
Text-Terminal-HOWTO
http://www.developer.ibm.com/library/ref/about4.1/df4commo.html
/* read_scan.c
*
* Buffered reader, which passes characters one at a time to a
* scanner.
*
* $Id$ */
/* lsh, an implementation of the ssh protocol
*
* Copyright (C) 1998 Niels Möller
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "read_scan.h"
#include "xalloc.h"
#define CLASS_DEFINE
#include "read_scan.h.x"
#undef CLASS_DEFINE
#include "read_scan.c.x"
/* CLASS:
(class
(name read_scan)
(super read_handler)
(vars
(buffer_size . size_t)
(scanner object scanner)))
*/
static int do_read_scan(struct read_handler **h,
struct abstract_read *read)
{
CAST(read_scan, closure, *h);
UINT8 *buffer = alloca(closure->buffer_size);
int n = A_READ(read, closure->buffer_size, buffer);
int i;
switch(n)
{
case 0:
return LSH_OK | LSH_GOON;
case A_FAIL:
(void) SCAN(closure->scanner, TOKEN_ERROR);
return LSH_FAIL | LSH_DIE;
case A_EOF:
return LSH_CLOSE | SCAN(closure->scanner, TOKEN_EOF);
}
for (i = 0; i<n; i++)
{
int res;
if (!closure->scanner)
return LSH_CLOSE;
res = SCAN(closure->scanner, buffer[i]);
if (LSH_FAILUREP(res))
return res;
}
return LSH_OK | LSH_GOON;
}
struct read_handler *make_read_scan(size_t buffer_size, struct scanner *scanner)
{
NEW(read_scan, closure);
closure->buffer_size = buffer_size;
closure->scanner = scanner;
closure->super.handler = do_read_scan;
return &closure->super;
}
/* read_scan.h
*
* Buffered reader, which passes characters one at a time to a
* scanner.
*
* $Id$ */
/* lsh, an implementation of the ssh protocol
*
* Copyright (C) 1998 Niels Möller
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef LSH_READ_SCAN_H_INCLUDED
#define LSH_READ_SCAN_H_INCLUDED
#include "abstract_io.h"
#define CLASS_DECLARE
#include "read_scan.h.x"
#undef CLASS_DECLARE
/* CLASS:
(class
(name scanner)
(vars
;; Returns some combination of LSH_OK, LSH_FAIL and LSH_CLOSE.
(scan indirect-method int int)))
*/
#define TOKEN_EOF -1
#define TOKEN_EOS -2
#define TOKEN_ERROR -3
#define SCAN(s, t) ((s)-(&(s), (t)))
struct read_handler *make_read_scan(size_t buffer_size, struct scanner *scanner);
#endif /* LSH_READ_SCAN_H_INCLUDED */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment