emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 7f3877e: Bindat examples in source, not manual


From: Paul Eggert
Subject: [Emacs-diffs] master 7f3877e: Bindat examples in source, not manual
Date: Thu, 20 Sep 2018 20:44:29 -0400 (EDT)

branch: master
commit 7f3877e83405a089b580fe9d0342dc0b6c08cbfc
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>

    Bindat examples in source, not manual
    
    * doc/lispref/processes.texi (Bindat Examples): Remove, fixing
    a FIXME in the manual.  The long example had bitrotted to some
    extent, compared to the more-up-to-date example in bindat.el
    commentary, which apparently what people were referring to
    anyway.  The short example was confusing and not that useful
    and will be obsolescent anyway if we change timestamp format.
---
 doc/lispref/elisp.texi     |   1 -
 doc/lispref/processes.texi | 130 ---------------------------------------------
 2 files changed, 131 deletions(-)

diff --git a/doc/lispref/elisp.texi b/doc/lispref/elisp.texi
index 0a445a3..a615fcb 100644
--- a/doc/lispref/elisp.texi
+++ b/doc/lispref/elisp.texi
@@ -1391,7 +1391,6 @@ Packing and Unpacking Byte Arrays
 
 * Bindat Spec::             Describing data layout.
 * Bindat Functions::        Doing the unpacking and packing.
-* Bindat Examples::         Samples of what bindat.el can do for you!
 
 Emacs Display
 
diff --git a/doc/lispref/processes.texi b/doc/lispref/processes.texi
index f9ba703..89ad1cf 100644
--- a/doc/lispref/processes.texi
+++ b/doc/lispref/processes.texi
@@ -3126,7 +3126,6 @@ direction is also known as @dfn{serializing} or 
@dfn{packing}.
 @menu
 * Bindat Spec::         Describing data layout.
 * Bindat Functions::    Doing the unpacking and packing.
-* Bindat Examples::     Samples of what bindat.el can do for you!
 @end menu
 
 @node Bindat Spec
@@ -3369,132 +3368,3 @@ dotted notation.
      @result{} "127.0.0.1"
 @end example
 @end defun
-
address@hidden Bindat Examples
address@hidden Examples of Byte Unpacking and Packing
address@hidden FIXME?  This seems a very long example for something that is not 
used
address@hidden very often.  As of 25.2, gdb-mi.el is the only user of bindat.el 
in Emacs.
address@hidden Maybe one or both of these examples should just be moved to the
address@hidden commentary of bindat.el.
-
-  Here are two complete examples that use bindat.el.
-The first shows simple byte packing:
-
address@hidden
-(require 'bindat)
-
-(defun rfc868-payload ()
-  (bindat-pack
-   '((now-hi u16)
-     (now-lo u16))
-   ;; Emacs uses Unix epoch, while RFC868 epoch
-   ;; is 1900-01-01 00:00:00, which is 2208988800
-   ;; (or #x83aa7e80) seconds more.
-   (let ((now (time-add nil '(#x83aa #x7e80))))
-     `((now-hi . ,(car now))
-       (now-lo . ,(cadr now))))))
-
-(let ((s (rfc868-payload)))
-  (list (multibyte-string-p s)
-        (mapconcat (lambda (byte)
-                     (format "%02x" byte))
-                   s " ")
-        (current-time-string)))
-     @result{} (nil "dc 6d 17 01" "Fri Mar 10 13:13:53 2017")
address@hidden lisp
-
-The following is an example of defining and unpacking a complex
-structure.  Consider the following C structures:
-
address@hidden
-struct header @{
-    unsigned long    dest_ip;
-    unsigned long    src_ip;
-    unsigned short   dest_port;
-    unsigned short   src_port;
address@hidden;
-
-struct data @{
-    unsigned char    type;
-    unsigned char    opcode;
-    unsigned short   length;  /* in network byte order  */
-    unsigned char    id[8];   /* null-terminated string  */
-    unsigned char    data[/* (length + 3) & ~3 */];
address@hidden;
-
-struct packet @{
-    struct header    header;
-    unsigned long    counters[2];  /* in little endian order  */
-    unsigned char    items;
-    unsigned char    filler[3];
-    struct data      item[/* items */];
-
address@hidden;
address@hidden example
-
-The corresponding data layout specification is:
-
address@hidden
-(setq header-spec
-      '((dest-ip   ip)
-        (src-ip    ip)
-        (dest-port u16)
-        (src-port  u16)))
-
-(setq data-spec
-      '((type      u8)
-        (opcode    u8)
-        (length    u16)  ; network byte order
-        (id        strz 8)
-        (data      vec (length))
-        (align     4)))
-
-(setq packet-spec
-      '((header    struct header-spec)
-        (counters  vec 2 u32r)   ; little endian order
-        (items     u8)
-        (fill      3)
-        (item      repeat (items)
-                   (struct data-spec))))
address@hidden lisp
-
-A binary data representation is:
-
address@hidden
-(setq binary-data
-      [ 192 168 1 100 192 168 1 101 01 28 21 32
-        160 134 1 0 5 1 0 0 2 0 0 0
-        2 3 0 5 ?A ?B ?C ?D ?E ?F 0 0 1 2 3 4 5 0 0 0
-        1 4 0 7 ?B ?C ?D ?E ?F ?G 0 0 6 7 8 9 10 11 12 0 ])
address@hidden lisp
-
-The corresponding decoded structure is:
-
address@hidden
-(setq decoded (bindat-unpack packet-spec binary-data))
-     @result{}
-((header
-  (dest-ip   . [192 168 1 100])
-  (src-ip    . [192 168 1 101])
-  (dest-port . 284)
-  (src-port  . 5408))
- (counters . [100000 261])
- (items . 2)
- (item ((data . [1 2 3 4 5])
-        (id . "ABCDEF")
-        (length . 5)
-        (opcode . 3)
-        (type . 2))
-       ((data . [6 7 8 9 10 11 12])
-        (id . "BCDEFG")
-        (length . 7)
-        (opcode . 4)
-        (type . 1))))
address@hidden lisp
-
-An example of fetching data from this structure:
-
address@hidden
-(bindat-get-field decoded 'item 1 'id)
-     @result{} "BCDEFG"
address@hidden lisp



reply via email to

[Prev in Thread] Current Thread [Next in Thread]