...

Source file src/github.com/xi2/xz/dec_util.go

Documentation: github.com/xi2/xz

     1  /*
     2   * XZ decompressor utility functions
     3   *
     4   * Author: Michael Cross <https://github.com/xi2>
     5   *
     6   * This file has been put into the public domain.
     7   * You can do whatever you want with this file.
     8   */
     9  
    10  package xz
    11  
    12  func getLE32(buf []byte) uint32 {
    13  	return uint32(buf[0]) |
    14  		uint32(buf[1])<<8 |
    15  		uint32(buf[2])<<16 |
    16  		uint32(buf[3])<<24
    17  }
    18  
    19  func getBE32(buf []byte) uint32 {
    20  	return uint32(buf[0])<<24 |
    21  		uint32(buf[1])<<16 |
    22  		uint32(buf[2])<<8 |
    23  		uint32(buf[3])
    24  }
    25  
    26  func putLE32(val uint32, buf []byte) {
    27  	buf[0] = byte(val)
    28  	buf[1] = byte(val >> 8)
    29  	buf[2] = byte(val >> 16)
    30  	buf[3] = byte(val >> 24)
    31  	return
    32  }
    33  
    34  func putBE32(val uint32, buf []byte) {
    35  	buf[0] = byte(val >> 24)
    36  	buf[1] = byte(val >> 16)
    37  	buf[2] = byte(val >> 8)
    38  	buf[3] = byte(val)
    39  	return
    40  }
    41  
    42  func putLE64(val uint64, buf []byte) {
    43  	buf[0] = byte(val)
    44  	buf[1] = byte(val >> 8)
    45  	buf[2] = byte(val >> 16)
    46  	buf[3] = byte(val >> 24)
    47  	buf[4] = byte(val >> 32)
    48  	buf[5] = byte(val >> 40)
    49  	buf[6] = byte(val >> 48)
    50  	buf[7] = byte(val >> 56)
    51  	return
    52  }
    53  

View as plain text