#|-------------------- 1.3.1 |# "./html/" 0 #|-------------------- 1.3.1 |# "./html/doctype.html" 5064
Provides XML doctypes as strings
Exports strings corresponding to standard XML (XHTML, HTML) doctypes.
#;1> (use doctype)
#;2> (print doctype:xhtml-1.0-strict)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">Public domain.
This extension provides a wrapper around SRFI 37 (args-fold). The main goal is to let the user parse command-line arguments without having to write a lot of similar support code every time.
By default, options and operands (non-options) are collected into two lists and returned by the parser, and unrecognized options complain and display help. Therefore, it is very possible not to write any option-procs, operand-procs, or unrecognized-procs as required by SRFI 37. However, the capability to customize is there should you need it.
Additionally, the help text for your options can be generated for you, so your options and usage information don't get out of sync.
Make an args:option record, suitable for passing to args:parse.
OPTION-NAME ... is a sequence of short or long option names. They must be literal symbols; single-character symbols become short options, and longer symbols become long options. So (args:make-option (c cookie) ...) specifies a short option -c and long option --cookie. Under the hood, (c cookie) becomes '(#\c "cookie"), as expected by SRFI 37's OPTION.
ARG-DATA is either a pair (ARG-TYPE ARG-NAME) or a plain keyword ARG-TYPE. ARG-TYPE is a keyword that specifies whether the option takes an argument:
| #:required | Argument is required |
| #:optional | Argument is optional |
| #:none | No argument (actually, any other value than #:required or #:optional is interpreted as #:none) |
ARG-NAME, if provided, is a string specifying the name of the argument. This name is used in the help text produced by args:usage.
BODY is an optional sequence of statements executed when this option is encountered. Behind the scenes, BODY is wrapped in code which adds the current option and its argument to the final options alist. So, simply leave BODY blank and options will be collected for you. BODY is an option-processor as defined in SRFI 37, and has access to the variables OPT (the current #<option>), NAME (the option name) and ARG (argument value or #f).
Parse ARGS, a list of command-line arguments given as strings, and return two values: an alist of option names (symbols) and their values, and a list of operands (non-option arguments).
Operands are returned in order, but options are returned in reverse order. Duplicate options are retained in the options alist, so this lets ASSQ find the last occurrence of any duplicate option on the command line. A (name . value) pair is added for each alias of every option found, so any alias is a valid lookup key.
OPTIONS-LIST is a list of accepted options, each created by args:make-option.
OPTIONALS is an optional sequence of keywords and values:
| #:operand-proc PROC | calls PROC for each operand, with arguments OPERAND OPTIONS OPERANDS |
| #:unrecognized-proc PROC | calls PROC for each unrecognized option, with arguments OPTION NAME ARG OPTIONS OPERANDS |
The default operand-proc is a no-op, and the default unrecognized-proc issues an error message and calls the help option's processor. See the args-fold documentation for usage information and an explanation of the procedure arguments; OPTIONS and OPERANDS are seed values.
List of option names (strings or single characters, as in SRFI 37) to be considered 'help' options, in order of preference. args:parse uses this to select a help option from the option list it is passed. This is currently used only for unrecognized options, for which the help option is automatically invoked.
By default, --help, -h and -? are considered help options.
Well-behaved programs display help or usage text when invoked with an option such as --help. args:usage will generate a formatted list of options in the GNU style, from a list of args:options. Around this you might place a descriptive header and footer.
Generate a formatted list of options from OPTION-LIST, and return a string suitable for embedding into help text. The single string consists of multiple lines, with a newline at the end of each line. Thus, a typical use would be (print (args:usage opts)).
We don't auto-format the left column (the option keys) based on the length of the longest option, but you can override it manually. Example:
(parameterize ((args:width 40)) (args:usage opts))
These are suitable for use with #:operand-proc or #:unrecognized-proc in args:parse. Most users will probably not customize these procedures themselves, but a couple useful prefabricated ones are provided.
Silently ignore unrecognized options, and omit from the options alist.
Silently add unrecognized options to the options alist.
Return a procedure suitable for using as an operand procedure in args:parse. Provides the arguments OPERAND, OPTIONS, and OPERANDS to the BODY; where OPERAND is the current operand (as in args-fold) and OPTIONS and OPERANDS are SEEDS (as in args-fold) and should not be modified. Also wraps BODY in code that adds the operand to the final operand list (seed).
The name args:make-option is verbose.
(use args)
(define opts
(list (args:make-option (c cookie) #:none "give me cookie"
(print "cookie was tasty"))
(args:make-option (d) (optional: "LEVEL") "debug level [default: 1]")
(args:make-option (e elephant) #:required "flatten the argument"
(print "elephant: arg is " arg))
(args:make-option (f file) (required: "NAME") "parse file NAME")
(args:make-option (v V version) #:none "Display version"
(print "args-example $Revision: 1.3 $")
(exit))
(args:make-option (abc) #:none "Recite the alphabet")
(args:make-option (h help) #:none "Display this text"
(usage))))
(define (usage)
(with-output-to-port (current-error-port)
(lambda ()
(print "Usage: " (car (argv)) " [options...] [files...]")
(newline)
(print (args:usage opts))
(print "Report bugs to zbigniewsz at gmail.")))
(exit 1))
(receive (options operands)
(args:parse (command-line-arguments) opts)
(print "-e -> " (alist-ref 'elephant options))) ;; 'e or 'elephant both work
;; If command line is --cookie -e test -e hello:
;; cookie was tasty
;; elephant: arg is test
;; elephant: arg is hello
;; -e -> hello
;; If command line is --cookie -e test --foo:
#|
cookie was tasty
elephant: arg is test
./args-example: unrecognized option: foo
Usage: ./args-example [options...] [files...]
-c, --cookie give me cookie
-d [LEVEL] debug level [default: 1]
-e, --elephant=ARG flatten the argument
-f, --file=NAME parse file NAME
-v, -V, --version Display version
--abc Recite the alphabet
-h, --help Display this text
Report bugs to zbigniewsz at gmail.
|#
Additional examples can be found in args-examples.scm.
Copyright (c) 2005, 2006 Jim "Zb" Ursetto. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
eggdoc is an SXML documentation tool which produces HTML pages for Chicken eggs. It uses the sxml-transforms extension to transform your SXML via a comprehensive XML stylesheet, simplifying the creation of egg documentation. It's also quite customizable.
Transform the SXML document DOC using the optional SXSLT stylesheet STYLESHEET. If not specified, the built-in stylesheet will be used, which is also accessible with (eggdoc:make-stylesheet).
Returns the default SXSLT stylesheet. This is a procedure because the stylesheet is built dynamically using the contents of the SXML document DOC. For example, the value of the (name) tag is retrieved at build time and inserted in the header and the usage information.
You can append to or modify this stylesheet and then pass it to eggdoc->html. This is done in doctype's eggdoc to provide a new tag, (strings), which makes the SXML much cleaner.
The DOCTYPE for this document, typically as defined in the doctype extension. This defaults to doctype:xhtml-1.0-strict.
CSS text inserted verbatim between the document's <style> tags. This must be <!-- wrapped in HTML comments -->. The default is quite reasonable.
If you wish to source a CSS file instead of inserting the text directly, you can override the eggdoc-style tag in the default stylesheet to do so.
Use this procedure inside a stylesheet to generate a new signature tag, just like procedure or macro. It expands to a (definition (signatures (signature ...))) expression. For example,
(eggdoc->html doc `( ,@(eggdoc:make-stylesheet doc)
(constant *macro* . ,eggdoc:make-defsig)
(method *macro* . ,eggdoc:make-defsig) ))
will create new constant and method tags.
Document section tags must be nested in the order section -> subsection -> subsubsection -> subsubsubsection. You may not nest section tags of the same level, as in (section "name" (section ...)), and you may not skip a level. eggdoc won't complain if you violate these rules—the HTML driver is pretty lax—but the appearance will be off and eggdoc-texinfo will fail on such a document. eggdoc-texinfo is more sensitive to malformed documents, so it is recommended to generate .info and .pdf output as well to ensure your document is correct.
documentation, examples, and license are section tags in disguise. In particular, (documentation (section ...)) is invalid; use (documentation (subsection ...)).
Complete examples for the Chicken extensions args, doctype, eggdoc, hostinfo, sxml-tools, sxml-transforms, and vector-lib are provided in the egg under src/. These all validate as XHTML Strict 1.0.
Also, eggdoc has become the standard documentation tool for Chicken eggs, and an eggdoc source file is included in many eggs. Unpack (untar) the egg by hand, or browse the SVN egg repository, to access the source.
Copyright (c) 2005, 2006 Jim "Zb" Ursetto. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
s*ZVUjzm^֨F5ZWn5U/6qZrO`a>0a?֜oө/O׃kmgwGOM)i UcF 89ZāYeN7*QET Z.bس( k~M 35M|7kCI;~w_hlR'q{RFy+W^67Iʮ3ٱ|/b As^F6 )i\Ӹ>77h~{:/&:? Q)3Q*ZCH$8ujḔ291y$e=T#0(s#o B ^J\;?Ks\M=QHX,-E`+UT6 v*E% n%vP,"f=ke$#QY͙{x9̝c]3gG8$jwGi5NTB#KN*2%٩ʂLXʓ* 4!j Lȝ:'8 tP2F_̚0dN%Y* d'.@.uF3/ #|-------------------- 1.3.1 |# "./html/sxml-transforms.html" 6884
The SXML transformations (to XML, SXML, and HTML) from the SSAX project
Oleg Kiselyov. Port by Zbigniew
This egg provides the SXML transforms available in the SSAX/SXML Sourceforge project. It incorporates one main extension, and an auxiliary one:
entag-xhtml closes XHTML tags properly in an HTML compatible way. entag is now an alias for entag-xhtml, so this behaviour is the default. entag-html is an alias for the original entag.
Newlines before open tags in the rendered HTML output are omitted for inline elements, such as tt and strong. This prevents the introduction of extraneous whitespace.
Also, the universal conversion rules have been augmented a bit:
Quotes character references given by strings ENTITY-NAME ....
Example: (& "ndash" "quot") => "–""
Provides pre-post-order-composable, a variant of pre-post-order which always outputs strictly-conformant SXML. This comes from sxml-to-sxml.scm.
Oleg's site is the main resource. Be sure to read his examples and the ones in the SSAX repository (also included in the egg). The following papers were of great help:
Also, the eggdoc extension makes heavy use of sxml-transforms.
The sxml-transforms code is in the public domain.
This extension performs host, protocol and service information lookups via underlying calls to gethostbyname(3), getprotobyname(3), and getservbyname(3). Depending on your system, this may consult DNS, NIS, /etc/hosts, /etc/services, /etc/protocols, and so on.
A simple interface is provided for the most commmon queries. Also provided is a more comprehensive interface using records, which contain all data available in a lookup.
IP addresses are represented by 4 (IPv4) or 16 (IPv6) byte u8vectors. The interface requires, and returns, addresses in this format; functions are provided to convert between the string and u8vector representations. However, the "do what I want" procedures (e.g. host-information) will do the conversion for you.
Quickly perform the most common lookups. Convenient and efficient for one-off use, but perform a new lookup each time. They return #f on failure.
Look up u8vector IPADDR and return hostname as string.
Look up string PROTOCOL-NAME and return protocol number.
Look up PROTOCOL-NUMBER and return protocol name as string.
Look up SERVICE-PORT number and return service name as string. Optional PROTO argument, which must be a string, constrains lookup to that protocol.
Look up string SERVICE-NAME and return the canonical port for that service. Optional PROTO argument as above.
Some lookups return a host, protocol, or service record. These records print nicely on the screen, for convenient interactive use.
Retrieves the address field of the hostinfo record h. Accessors are similar for other records and their fields.
| name | Hostname |
| addresses | A vector of one or more u8vector IP addresses |
| aliases | A vector of any alternate hostnames |
| address | The first IP address (u8vector) in addresses |
| type | 'AF_INET (IPv4) or 'AF_INET6 (IPv6) |
| length | IP address length in bytes |
| name | Protocol name |
| number | Protocol number |
| aliases | Vector of alternate names for this protocol |
| name | Service name |
| number | Service number |
| aliases | Vector of alternate names for this service |
| protocol | Name of protocol this service uses |
These lookups correspond to those described in Short and sweet, but return a full record. The entire record is filled in a single system call.
These decipher your argument, call the appropriate lookup, and return an information record.
Look up and return a hostinfo record, or #f. HOST is a string hostname, a string numeric IP address, or a u8vector IP address.
Look up and return a protoinfo record, or #f. PROTO is a protocol number or string name.
Look up and return a servinfo record, or #f. SERVICE is a service number or string name. PROTO is an optional protocol number or string name, which will constrain lookups to that particular protocol.
NOTE: if the protocol number is illegal, an error is thrown, since this was probably unintentional.
Convert an IPv4 or IPv6 address string in canonical format to a u8vector, which can be considered an "IP address object". Returns #f on failure.
Convert a 4 (IPv4) or 16 (IPv6) element u8vector to a string in canonical format. Throws an error if the u8vector is not 4 or 16 bytes long. This call should only fail on system error, in which case it will return #f (perhaps not the best behaviour).
IPv6 lookup is not yet supported. However, IPv6<->string conversion works fine.
System errors return failure (#f) and so are indistinguishable from failed lookups. They should probably signal an error or an exception.
(host-information "www.call-with-current-continuation.org")
(host-information '#u8(194 97 107 133))
(host-information "194.97.107.133")
; => #,(hostinfo name: "www003.lifemedien.de"
; addresses: #(#u8(194 97 107 133))
; aliases: #("www.call-with-current-continuation.org"))
(ip->hostname '#u8(194 97 107 133)) ; "www003.lifemedien.de"
(string->ip "0708::0901") ; #u8(7 8 0 0 0 0 0 0 0 0 0 0 0 0 9 1)
(ip->string '#u8(127 0 0 1)) ; "127.0.0.1"
(hostinfo-aliases
(hostname->hostinfo
(ip->hostname
(hostname->ip
(hostinfo-name
(host-information "www.call-with-current-continuation.org"))))))
; => #("www.call-with-current-continuation.org")
(protocol-information 17)
; => #,(protoinfo name: "udp" number: 17 aliases: #("UDP"))
(protoinfo-name (protocol-information 2)) ; => "igmp"
(protoinfo-aliases (protocol-name->protoinfo
(protocol-number->name
(protoinfo-number
(protocol-information "ospf"))))) ; => #("OSPFIGP")
(protocol-name->number "OSPFIGP") ; 89 (you can look up aliases, too)
(servinfo-protocol (service-name->servinfo
(service-port->name
(servinfo-port (service-information "ssh")))))
; => "udp" (yes, really)
(service-information "ssh" "tcp")
; => #,(servinfo name: "ssh" port: 22 aliases: #() protocol: "tcp")
(service-information "ssh" "tco") ; => #f
(service-information 512 "tcp")
; #,(servinfo name: "exec" port: 512 aliases: #() protocol: "tcp")
(service-information 512 "udp")
; #,(servinfo name: "comsat" port: 512 aliases: #("biff") protocol: "udp")
(service-information 512 17) ; same as previous
(service-information 512 170000)
; Error: (service-information) illegal protocol number: 170000Copyright (c) 2005, 2006 Jim "Zb" Ursetto. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The sxml-tools from the SSAX project at Sourceforge.
Oleg Kiselyov, Kirill Lisovsky, Dmitry Lizorkin. Port by Zbigniew
This egg provides most of the sxml-tools available in the SSAX/SXML Sourceforge project. It incorporates several different extensions:
Much documentation is available at Lisovsky's XML page and the SSAX homepage. For serious use, you will probably want to untar the egg and study the source and the included tests. See the README.txt file in the egg for details.
xlink, xlink-parser, fragments and guides are not provided as extensions, but they are included in the egg as source.
Although these files are pretty interdependent, they could be broken down further into separate extensions. sxpath could be pulled out, for example, with the caveat that txpath parsing would result in an error.
Not everything is tested, since tests are not provided for all functionality.
Examples are available in the sxml-tools documentation (see above). This one is a straightforward example of SXPath. Additionally, the sxml-tools tests are included in the egg. Untar it and read the README.txt file for details.
The sxml-tools are in the public domain.
Reference implementation of SRFI-43: Vector library
Taylor Campbell; port by Zbigniew
See the SRFI-43 document for full documentation on the reference implementation.
The reference implementation on srfi.schemers.org is buggy (as of 24 May 2005). This code is actually derived from Taylor Campbell's updated version.
Also included are the following user-visible fixes:
Additionally, list->vector and reverse-list->vector accept optional START and END arguments:
Produce a vector containing the elements in LIST, which must be a proper list, between START, whose default is 0, and END, whose default is the length of LIST. It is suggested that if the length of LIST is known in advance, the START and END arguments be passed, so that list->vector need not call length itself.
Produces the same output as list->vector, but in reverse order.
This brings them more in line with vector->list and reverse-vector->list, which also take START and END arguments.
Copyright (c) 2005, 2006 Jim "Zb" Ursetto. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.