File: convert_reader_h.pl

package info (click to toggle)
ccid 1.4.26-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 3,676 kB
  • ctags: 1,416
  • sloc: ansic: 9,977; sh: 4,594; lex: 242; makefile: 144; perl: 97
file content (43 lines) | stat: -rwxr-xr-x 1,308 bytes parent folder | download | duplicates (12)
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
#!/usr/bin/env perl

#    convert_reader_h.pl: convert reader.h.in in reader.h with
#
#    Copyright (C) 2008  Ludovic Rousseau  <ludovic.rousseau@free.fr>
#
#    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.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License along
#    with this program; if not, write to the Free Software Foundation, Inc.,
#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

use warnings;
use strict;

my $text = 
"#ifdef __BIG_ENDIAN__
#define HOST_TO_CCID_16(x) ((((x) >> 8) & 0xFF) + ((x & 0xFF) << 8))
#define HOST_TO_CCID_32(x) ((((x) >> 24) & 0xFF) + (((x) >> 8) & 0xFF00) + ((x & 0xFF00) << 8) + (((x) & 0xFF) << 24))
#else
#define HOST_TO_CCID_16(x) (x)
#define HOST_TO_CCID_32(x) (x)
#endif
";

while (<>)
{
	if (m/host_to_ccid_16/)
	{
		print $text;
		<>;
		next;
	}
	print;
}