Introduction
Introduction Statistics Contact Development Disclaimer Help
tio.lisp - clic - Clic is an command line interactive client for gopher written…
git clone git://bitreich.org/clic/ git://hg6vgqziawt5s4dj.onion/clic/
Log
Files
Refs
Tags
LICENSE
---
tio.lisp (4612B)
---
1 ;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: FLEXI-STREAMS; Base: 1…
2 ;;; $Header: /usr/local/cvsrep/flexi-streams/io.lisp,v 1.2 2008/05/20 23…
3
4 ;;; Copyright (c) 2005-2008, Dr. Edmund Weitz. All rights reserved.
5
6 ;;; Redistribution and use in source and binary forms, with or without
7 ;;; modification, are permitted provided that the following conditions
8 ;;; are met:
9
10 ;;; * Redistributions of source code must retain the above copyright
11 ;;; notice, this list of conditions and the following disclaimer.
12
13 ;;; * Redistributions in binary form must reproduce the above
14 ;;; copyright notice, this list of conditions and the following
15 ;;; disclaimer in the documentation and/or other materials
16 ;;; provided with the distribution.
17
18 ;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED
19 ;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 ;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 ;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
22 ;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 ;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
24 ;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 ;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 ;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 ;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 ;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
30 (in-package :flexi-streams)
31
32 (defmethod reset-input-state ((flexi-io-stream flexi-io-stream))
33 "This method is used to clear any state associated with previous
34 input before output is attempted on the stream. It can fail if the
35 octet stack is not empty and the stream can't be `rewound'."
36 (declare #.*standard-optimize-settings*)
37 (with-accessors ((last-char-code flexi-stream-last-char-code)
38 (last-octet flexi-stream-last-octet)
39 (octet-stack flexi-stream-octet-stack)
40 (stream flexi-stream-stream))
41 flexi-io-stream
42 (when octet-stack
43 (unless (maybe-rewind stream (length octet-stack))
44 (error 'flexi-stream-out-of-sync-error
45 :stream flexi-io-stream))
46 (setq octet-stack nil))
47 (setq last-octet nil
48 last-char-code nil)))
49
50 (defmethod stream-write-byte :before ((stream flexi-io-stream) byte)
51 (declare #.*standard-optimize-settings*)
52 (declare (ignore byte))
53 (reset-input-state stream))
54
55 (defmethod stream-write-char :before ((stream flexi-io-stream) char)
56 (declare #.*standard-optimize-settings*)
57 (declare (ignore char))
58 (reset-input-state stream))
59
60 (defmethod stream-write-sequence :before ((stream flexi-io-stream) seque…
61 (declare #.*standard-optimize-settings*)
62 (declare (ignore sequence start end))
63 (reset-input-state stream))
64
65 (defmethod stream-clear-output :before ((stream flexi-io-stream))
66 (declare #.*standard-optimize-settings*)
67 (reset-input-state stream))
68
69 (defmethod reset-output-state ((flexi-io-stream flexi-io-stream))
70 "This method is used to clear any state associated with previous
71 output before the stream is used for input."
72 (declare #.*standard-optimize-settings*)
73 (with-accessors ((column flexi-stream-column))
74 flexi-io-stream
75 (setq column nil)))
76
77 (defmethod stream-read-byte :before ((stream flexi-io-stream))
78 (declare #.*standard-optimize-settings*)
79 (reset-output-state stream))
80
81 (defmethod stream-read-char :before ((stream flexi-io-stream))
82 (declare #.*standard-optimize-settings*)
83 (reset-output-state stream))
84
85 (defmethod stream-read-sequence :before ((stream flexi-io-stream) sequen…
86 (declare #.*standard-optimize-settings*)
87 (declare (ignore sequence start end))
88 (reset-output-state stream))
89
90 (defmethod stream-unread-char :before ((stream flexi-io-stream) char)
91 (declare #.*standard-optimize-settings*)
92 (declare (ignore char))
93 (reset-output-state stream))
94
95 (defmethod unread-byte :before (byte (stream flexi-io-stream))
96 (declare #.*standard-optimize-settings*)
97 (declare (ignore byte))
98 (reset-output-state stream))
99
100 (defmethod stream-clear-input :before ((stream flexi-io-stream))
101 (declare #.*standard-optimize-settings*)
102 (reset-output-state stream))
103
104 (defmethod write-byte* :after (byte (stream flexi-io-stream))
105 "Keep POSITION slot up to date even when performing output."
106 (declare #.*standard-optimize-settings*)
107 (declare (ignore byte))
108 (with-accessors ((position flexi-stream-position))
109 stream
110
You are viewing proxied material from bitreich.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.