kopia lustrzana https://gitlab.com/sane-project/website
				
				
				
			
		
			
				
	
	
		
			90 wiersze
		
	
	
		
			3.8 KiB
		
	
	
	
		
			HTML
		
	
	
			
		
		
	
	
			90 wiersze
		
	
	
		
			3.8 KiB
		
	
	
	
		
			HTML
		
	
	
| <html><body>
 | |
| <a href="doc017.html"><img src=../icons/next.gif alt="Next"></a>
 | |
| <a href="doc000.html"><img src=../icons/up.gif alt="Up"></a>
 | |
| <a href="doc015.html"><img src=../icons/previous.gif alt="Previous"></a>
 | |
| <a href="doc000.html"><img src=../icons/contents.gif alt="Contents"></a>
 | |
| <a href="doc019.html"><img src=../icons/index.gif alt="Index"></a>
 | |
| <hr>
 | |
| 
 | |
| <title>Data Type Encoding</title>
 | |
| <h2><a name="s5.1">5.1 Data Type Encoding</a></h2>
 | |
| 
 | |
| <p><h3><a name="s5.1.1">5.1.1 Primitive Data Types</a></h3>
 | |
| 
 | |
| <p>The four primitive types of the SANE standard are encoded as follows:
 | |
| <dl>
 | |
| 
 | |
| <p><dt><tt>SANE_Byte<a name="i140"></tt>:<dd> A byte is encoded as an 8 bit value.
 | |
|   Since the transport protocol is assumed to be byte-orientd, the bit
 | |
|   order is irrelevant.
 | |
| 
 | |
| <p><dt><tt>SANE_Word<a name="i141"></tt>:<dd> A word is encoded as 4 bytes (32
 | |
|   bits).  The bytes are ordered from most-significant to
 | |
|   least-significant byte (big-endian byte-order).
 | |
| 
 | |
| <p><dt><tt>SANE_Char<a name="i142"></tt>:<dd> A character is currently encoded as an 8-bit
 | |
|   ISO LATIN-1 value.  An extension to support wider character sets (16 or 32
 | |
|   bits) is planned for the future, but not supported at this point.
 | |
| 
 | |
| <p><dt><tt>SANE_String<a name="i143"></tt>:<dd> A string pointer is encoded as a
 | |
|   <tt>SANE_Char</tt> array.  The trailing NUL byte is considered part
 | |
|   of the array and a <tt>NULL</tt> pointer is encoded as a zero-length
 | |
|   array.
 | |
|   
 | |
| <dt><tt>SANE_Handle<a name="i144"></tt>:<dd> A handle is encoded like a word.
 | |
|   The network backend needs to take care of converting these integer
 | |
|   values to the opaque pointer values that are presented to the user
 | |
|   of the network backend.  Similarly, the SANE daemon needs to take
 | |
|   care of converting the opaque pointer values it receives from its
 | |
|   backends into 32-bit integers suitable for use for network encoding.
 | |
| 
 | |
| <p><dt><em>enumeration types<a name="i145"></em>:<dd> Enumeration types are encoded
 | |
|   like words.
 | |
| 
 | |
| <p></dl>
 | |
| 
 | |
| <p><h3><a name="s5.1.2">5.1.2 Type Constructors</a></h3>
 | |
| 
 | |
| <p>Closely following the type constructors of the C language, the SANE network
 | |
| protocol supports the following four constructors:
 | |
| <dl>
 | |
| 
 | |
| <p><dt><em>pointer<a name="i146"></em>:<dd> A pointer is encoded by a word that indicates
 | |
|   whether the pointer is a NULL-pointer which is then followed by the
 | |
|   value that the pointer points to (in the case of a non-NULL pointer;
 | |
|   in the case of a NULL pointer, no bytes are encoded for the pointer
 | |
|   value).
 | |
| 
 | |
| <p><dt><em>array<a name="i147"></em>:<dd> An array is encoded by a word that indicates
 | |
|   the length of the array followed by the values of the elements in
 | |
|   the array.  The length may be zero in which case no bytes are
 | |
|   encoded for the element values.
 | |
| 
 | |
| <p><dt><em>structure<a name="i148"></em>:<dd> A structure is encoded by simply encoding the
 | |
|   structure members in the order in which they appear in the
 | |
|   corresponding C type declaration.
 | |
| 
 | |
| <p><dt><em>union<a name="i149"></em>:<dd> A union must always be accompanied by a tag
 | |
|   value that indicates which of the union members is the currently the
 | |
|   active one.  For this reason, the union itself is encoded simply by
 | |
|   encoding the value of the currently active member.
 | |
| 
 | |
| <p></dl>
 | |
| 
 | |
| <p>Note that for type constructors, the pointer, element, or member
 | |
| values themselves may have a constructed type.  Thus, the above rules
 | |
| should be applied recursively until a sequence of primitive types has
 | |
| been found.
 | |
| 
 | |
| <p>Also SANE had no need for encoding of circular structures.  This
 | |
| greatly simplifies the network protocol.
 | |
| 
 | |
| <p><p><hr>
 | |
| <a href="doc017.html"><img src=../icons/next.gif alt="Next"></a>
 | |
| <a href="doc000.html"><img src=../icons/up.gif alt="Up"></a>
 | |
| <a href="doc015.html"><img src=../icons/previous.gif alt="Previous"></a>
 | |
| <a href="doc000.html"><img src=../icons/contents.gif alt="Contents"></a>
 | |
| <a href="doc019.html"><img src=../icons/index.gif alt="Index"></a>
 | |
| <hr>
 | |
| </body></html>
 |