| 1 |
;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: CHUNGA; Base: 10 -*- |
|---|
| 2 |
;;; $Header: /usr/local/cvsrep/chunga/specials.lisp,v 1.12 2008/05/24 03:06:22 edi Exp $ |
|---|
| 3 |
|
|---|
| 4 |
;;; Copyright (c) 2006-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 :chunga) |
|---|
| 31 |
|
|---|
| 32 |
(defmacro define-constant (name value &optional doc) |
|---|
| 33 |
"A version of DEFCONSTANT for, cough, /strict/ CL implementations." |
|---|
| 34 |
;; See <http://www.sbcl.org/manual/Defining-Constants.html> |
|---|
| 35 |
`(defconstant ,name (if (boundp ',name) (symbol-value ',name) ,value) |
|---|
| 36 |
,@(when doc (list doc)))) |
|---|
| 37 |
|
|---|
| 38 |
#+:lispworks |
|---|
| 39 |
(editor:setup-indent "define-constant" 1 2 4) |
|---|
| 40 |
|
|---|
| 41 |
(defconstant +output-buffer-size+ 8192 |
|---|
| 42 |
"Size of the initial output buffer for chunked output.") |
|---|
| 43 |
|
|---|
| 44 |
(define-constant +crlf+ |
|---|
| 45 |
(make-array 2 :element-type '(unsigned-byte 8) |
|---|
| 46 |
:initial-contents (mapcar 'char-code '(#\Return #\Linefeed))) |
|---|
| 47 |
"A 2-element array consisting of the character codes for a CRLF |
|---|
| 48 |
sequence.") |
|---|
| 49 |
|
|---|
| 50 |
(define-constant +hex-digits+ '#.(coerce "0123456789ABCDEF" 'list) |
|---|
| 51 |
"The hexadecimal digits.") |
|---|
| 52 |
|
|---|
| 53 |
(defvar *current-error-message* nil |
|---|
| 54 |
"Used by the parsing functions in `read.lisp' as an |
|---|
| 55 |
introduction to a standardized error message about unexpected |
|---|
| 56 |
characters unless it is NIL.") |
|---|
| 57 |
|
|---|
| 58 |
(defvar *current-error-function* nil |
|---|
| 59 |
"Used by the functions in `read.lisp' as a function to signal |
|---|
| 60 |
errors about unexpected characters when *CURRENT-ERROR-MESSAGE* |
|---|
| 61 |
is NIL.") |
|---|
| 62 |
|
|---|
| 63 |
(defvar *accept-bogus-eols* nil |
|---|
| 64 |
"Some web servers do not respond with a correct CRLF line ending for |
|---|
| 65 |
HTTP headers but with a lone linefeed or carriage return instead. If |
|---|
| 66 |
this variable is bound to a true value, READ-LINE* will treat a lone |
|---|
| 67 |
LF or CR character as an acceptable end of line. The initial value is |
|---|
| 68 |
NIL.") |
|---|
| 69 |
|
|---|
| 70 |
(defvar *treat-semicolon-as-continuation* nil |
|---|
| 71 |
"According to John Foderaro, Netscape v3 web servers bogusly split |
|---|
| 72 |
Set-Cookie headers over multiple lines which means that we'd have to |
|---|
| 73 |
treat Set-Cookie headers ending with a semicolon as incomplete and |
|---|
| 74 |
combine them with the next header. This will only be done if this |
|---|
| 75 |
variable has a true value, though.") |
|---|
| 76 |
|
|---|
| 77 |
(defvar *char-buffer* nil |
|---|
| 78 |
"A `buffer' for one character. Used by PEEK-CHAR* and |
|---|
| 79 |
UNREAD-CHAR*.") |
|---|
| 80 |
|
|---|
| 81 |
(pushnew :chunga *features*) |
|---|
| 82 |
|
|---|
| 83 |
;; stuff for Nikodemus Siivola's HYPERDOC |
|---|
| 84 |
;; see <http://common-lisp.net/project/hyperdoc/> |
|---|
| 85 |
;; and <http://www.cliki.net/hyperdoc> |
|---|
| 86 |
;; also used by LW-ADD-ONS |
|---|
| 87 |
|
|---|
| 88 |
(defvar *hyperdoc-base-uri* "http://weitz.de/chunga/") |
|---|
| 89 |
|
|---|
| 90 |
(let ((exported-symbols-alist |
|---|
| 91 |
(loop for symbol being the external-symbols of :chunga |
|---|
| 92 |
collect (cons symbol |
|---|
| 93 |
(concatenate 'string |
|---|
| 94 |
"#" |
|---|
| 95 |
(string-downcase symbol)))))) |
|---|
| 96 |
(defun hyperdoc-lookup (symbol type) |
|---|
| 97 |
(declare (ignore type)) |
|---|
| 98 |
(cdr (assoc symbol |
|---|
| 99 |
exported-symbols-alist |
|---|
| 100 |
:test #'eq)))) |
|---|