pax_global_header 0000666 0000000 0000000 00000000064 13057520021 0014505 g ustar 00root root 0000000 0000000 52 comment=9de8c755c2ff24117748a3271e8582bb8d4a6b6c nibbles-20170403-git/ 0000775 0000000 0000000 00000000000 13057520021 0014146 5 ustar 00root root 0000000 0000000 nibbles-20170403-git/.gitignore 0000664 0000000 0000000 00000000206 13057520021 0016134 0 ustar 00root root 0000000 0000000 *.fasl *.FASL *.ufasl *.ufsl *.dx32fsl *.dx64fsl *.pfsl *.dfsl *.p64fsl *.d64fsl *.lx32fsl *.lx64fsl *.fx32fsl *.fx64fsl *.fas *.lib nibbles-20170403-git/.travis.yml 0000664 0000000 0000000 00000000745 13057520021 0016265 0 ustar 00root root 0000000 0000000 language: common-lisp sudo: required env: matrix: - LISP=sbcl - LISP=ccl - LISP=clisp - LISP=abcl - LISP=allegro install: # Install cl-travis - curl https://raw.githubusercontent.com/luismbo/cl-travis/master/install.sh | bash script: - cl -l nibbles -l nibbles-tests -e '(setf *debugger-hook* (lambda (&rest ignorable) (declare (ignore ignorable)) (uiop:quit -1)))' -e '(rt:do-tests)' nibbles-20170403-git/LICENSE 0000664 0000000 0000000 00000002744 13057520021 0015162 0 ustar 00root root 0000000 0000000 Copyright (c) 2010, Nathan Froyd 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 copyright holders nor the names of contributors to this software 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 OWNER 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. nibbles-20170403-git/NEWS 0000664 0000000 0000000 00000002346 13057520021 0014652 0 ustar 00root root 0000000 0000000 hey emacs, show me an -*- mode: outline -*- * Version 0.13, released 2017-03-07 ** bug fixes Fixed problems reading elements into lists. Fixed DEFKNOWN issues on newer SBCL versions. (Thanks to Kenan Bölükbaşı.) ** new features Float accessors are now supported on ABCL. (Thanks to Robert Brown.) * Version 0.12, released 2014-10-08 ** bug fixes Better support for Allegro CL modern mode. (Thanks to Markus Flambard.) More correct code generation for x86-64 SBCL. ** new features Float accessors are now MAYBE-INLINE on SBCL. (Thanks to Jan Moringen.) * Version 0.11, released 2013-01-14 ** bug fixes IEEE-DOUBLE-REF/* now works correctly on CCL. IEEE-SINGLE-REF/* now works correctly on Allegro. (Thanks to Richard Billington for the bug report.) ** new features MAKE-OCTET-VECTOR and OCTET-VECTOR convenience functions have been added, along with the OCTET, OCTET-VECTOR, and SIMPLE-OCTET-VECTOR types. (Thanks to Jan Moringen.) Stream readers and writers for floats have been added, analogous to the existing functions for integers. These functionsn are only supported on implementations which support the array accessors (SBCL, CCL, CMUCL for double-floats; all those including Lispworks and Allegro for single-floats). nibbles-20170403-git/README 0000664 0000000 0000000 00000002763 13057520021 0015036 0 ustar 00root root 0000000 0000000 When dealing with network protocols and file formats, it's common to have to read or write 16-, 32-, or 64-bit datatypes in signed or unsigned flavors. Common Lisp sort of supports this by specifying :ELEMENT-TYPE for streams, but that facility is underspecified and there's nothing similar for read/write from octet vectors. What most people wind up doing is rolling their own small facility for their particular needs and calling it a day. This library attempts to be comprehensive and centralize such facilities. Functions to read 16-, 32-, and 64-bit quantities from octet vectors in signed or unsigned flavors are provided; these functions are also SETFable. Since it's sometimes desirable to read/write directly from streams, functions for doing so are also provided. On some implementations, reading/writing IEEE singles/doubles (i.e. SINGLE-FLOAT and DOUBLE-FLOAT) will also be supported. In addition to centralizing such facilities, NIBBLES also aspires to become a place where compiler optimizations can be written once and used everywhere. The intention is that (eventually): (nibbles:sb32ref/le vector index) will compile (with any necessary safety checks) to a MOVSX instruction on an x86oid processor in SBCL (or other implementations) if VECTOR and INDEX are of appropriate types. I remember reading a post on comp.lang.lisp that suggested the designers of Common Lisp ignored the realities of octets and endianness and so forth. This library is a small step towards remedying that deficiency. nibbles-20170403-git/doc/ 0000775 0000000 0000000 00000000000 13057520021 0014713 5 ustar 00root root 0000000 0000000 nibbles-20170403-git/doc/index.html 0000664 0000000 0000000 00000016616 13057520021 0016722 0 ustar 00root root 0000000 0000000
nibbles is a library for accessing multibyte integers from octet arrays and streams. While such accessors are straightforward to write, nibbles aims to centralize such facilities and also provide optimizations for them when appropriate.
nibbles can be downloaded at http://www.method-combination.net/lisp/files/nibbles.tar.gz. The latest version is 0.11.
It comes with an ASDF system definition, so (ASDF:OOS 'ASDF:LOAD-OP :NIBBLES) should be all that you need to get started.
nibbles is released under a MIT-like license; you can do pretty much anything you want to with the code except claim that you wrote it.
This family of functions accesses an unsigned 16-bit, 32-bit or 64-bit value stored in little-endian order starting at index in vector. vector must be a (VECTOR (UNSIGNED-BYTE 8)). These functions are SETFable. For instance:
CL-USER> (nibbles:ub16ref/le (coerce #(42 53) '(vector (unsigned-byte 8))) 0) 13610 CL-USER> (format nil "~X" *) "352A"
As the above, only the value is accessed in big-endian order. For instance:
CL-USER> (nibbles:ub16ref/be (coerce #(42 53) '(vector (unsigned-byte 8))) 0) 10805 CL-USER> (format nil "~X" *) "2A35"
As the above, only the value accessed is a signed value. For instance:
CL-USER> (nibbles:sb16ref/be (coerce #(81 92) '(vector (unsigned-byte 8))) 0) 20828 CL-USER> (nibbles:sb16ref/be (coerce #(129 135) '(vector (unsigned-byte 8))) 0) -32377 CL-USER> (format nil "~X ~X" ** *) "515C -7E79" CL-USER> (nibbles:sb16ref/le (coerce #(81 92) '(vector (unsigned-byte 8))) 0) 23633 CL-USER> (nibbles:sb16ref/le (coerce #(129 135) '(vector (unsigned-byte 8))) 0) -30847 CL-USER> (format nil "~X ~X" ** *) "5C51 -787F"
This family of functions reads an unsigned 16-bit, 32-bit, or 64-bit value from stream in little-endian order. stream must have an element-type of (UNSIGNED-BYTE 8).
As the above, only the value is read in big-endian order.
As the above, only the value is signed, rather than unsigned.
This family of functions writes an unsigned 16-bit, 32-bit, or 64-bit integer to stream in little-endian order. stream must have an element-type of (UNSIGNED-BYTE 8). The value written is returned.
As the above, only the value is read in big-endian order.
As the above, only the value is signed, rather than unsigned.