/usr/share/gnudatalanguage/lib/swap_endian.pro is in libgnudatalanguage0 0.9.7-6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | ;+
;
;
;
; NAME:
; SWAP_ENDIAN
;
; PURPOSE:
; swaps endianness of data, including structs
;
;
; CATEGORY:
; Utility
;
; CALLING SEQUENCE:
; result = SWAP_ENDIAN( data)
;
;
; KEYWORD PARAMETERS:
; SWAP_IF_BIG_ENDIAN: only perform action if machine is big endian.
; SWAP_IF_LITTLE_ENDIAN: only perform action if machine is little endian.
;
; OUTPUTS:
; result: same datatype and structure as input with reversed byte order
;
;
; PROCEDURE:
; uses BYTEORDER
;
;
; MODIFICATION HISTORY:
; Written by: Marc Schellens, 2005
; 21-Jan-2006 : PC, switch statement, correct little endian detection
;
;-
; LICENCE:
; Copyright (C) 2005, M. Schellens, 2006, P. Chanial
; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version.
;
;-
function SWAP_ENDIAN, dataIn,$
SWAP_IF_BIG_ENDIAN=ifBig, $
SWAP_IF_LITTLE_ENDIAN=ifLittle
on_error, 2
dataOut = dataIn
littleEndian = (byte(1,0,1))[0]
if littleEndian then begin
if keyword_set( ifBig) then return, dataOut
endif else begin
if keyword_set( ifLittle) then return, dataOut
endelse
type = size( dataIn, /TYPE)
switch type of
1 : ;; BYTE
7 : return, dataOut ;; STRING
2 : ;; INT
12: begin ;; UINT
byteorder, dataOut, /SSWAP
break
end
3 : ;; LONG
4 : ;; FLOAT
6 : ;; COMPLEX
13: begin ;; ULONG
byteorder, dataOut, /LSWAP
break
end
5 : ;; DOUBLE
9 : ;; DCOMPLEX
14: ;; INT64
15: begin ;; UINT64
byteorder, dataOut, /L64SWAP
break
end
8 : begin ;; STRUCT
for i = 0, n_tags( dataOut)-1 do begin
dataOut.(i) = swap_endian(dataOut.(i))
endfor
break
end
10: message, 'Unable to swap reference data type.'
11: message, 'Unable to swap object reference data type.'
else: message, 'Internal error: Unknown type: '+strtrim(type,1)
endswitch
return, dataOut
end
|