/usr/share/gnudatalanguage/lib/swap_endian_inplace.pro is in libgnudatalanguage0 0.9.7-2.
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 | ;+
;
; NAME:
; SWAP_ENDIAN_INPLACE
;
; PURPOSE:
; swaps endianness of data, including structs, without copying
;
; CATEGORY:
; Utility
;
; CALLING SEQUENCE:
; 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:
;
;
; PROCEDURE:
; - derivate from SWAP_ENDIAN
; - uses BYTEORDER
;
; MODIFICATION HISTORY:
; initial procedure SWAP_ENDIAN written by Marc Schellens, 2005
; 21-Jan-2006 : PC, switch statement, correct little endian detection
; July 2010: Maxime Lenoir for PDS Library compatibility
;
;-
; LICENCE:
; Copyright (C) 2010 Maxime Lenoir
; 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.
;
;-
pro SWAP_ENDIAN_INPLACE, dataIn,$
SWAP_IF_BIG_ENDIAN=ifBig, $
SWAP_IF_LITTLE_ENDIAN=ifLittle
ON_ERROR, 2
littleEndian = (BYTE(1,0,1))[0]
if littleEndian then begin
if KEYWORD_SET( ifBig) then return
endif else begin
if KEYWORD_SET( ifLittle) then return
endelse
type = SIZE( dataIn, /TYPE)
switch type of
1 : ;; BYTE
7 : return ;; STRING
2 : ;; INT
12: begin ;; UINT
BYTEORDER, dataIn, /SSWAP
break
end
3 : ;; LONG
4 : ;; FLOAT
6 : ;; COMPLEX
13: begin ;; ULONG
BYTEORDER, dataIn, /LSWAP
break
end
5 : ;; DOUBLE
9 : ;; DCOMPLEX
14: ;; INT64
15: begin ;; UINT64
BYTEORDER, dataIn, /L64SWAP
break
end
8 : begin ;; STRUCT
for i = 0, N_TAGS(dataIn)-1 do begin
data=dataIn.(i)
SWAP_ENDIAN_INPLACE, data
dataIn.(i)=data
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
end
|