<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>libnfc: mirror-subr.c Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.7.3 --> <div id="top"> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">libnfc <span id="projectnumber">1.4.2</span></div> </td> </tr> </tbody> </table> </div> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="annotated.html"><span>Data Structures</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> <li><a href="dirs.html"><span>Directories</span></a></li> </ul> </div> <div id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>Globals</span></a></li> </ul> </div> <div id="nav-path" class="navpath"> <ul> <li class="navelem"><a class="el" href="dir_fd1c9d0a8b12e3b9059fa72e8f6f49bb.html">libnfc</a> </li> </ul> </div> </div> <div class="header"> <div class="headertitle"> <h1>mirror-subr.c</h1> </div> </div> <div class="contents"> <a href="mirror-subr_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*-</span> <a name="l00002"></a>00002 <span class="comment"> * Public platform independent Near Field Communication (NFC) library</span> <a name="l00003"></a>00003 <span class="comment"> * </span> <a name="l00004"></a>00004 <span class="comment"> * Copyright (C) 2009, Roel Verdult</span> <a name="l00005"></a>00005 <span class="comment"> * </span> <a name="l00006"></a>00006 <span class="comment"> * This program is free software: you can redistribute it and/or modify it</span> <a name="l00007"></a>00007 <span class="comment"> * under the terms of the GNU Lesser General Public License as published by the</span> <a name="l00008"></a>00008 <span class="comment"> * Free Software Foundation, either version 3 of the License, or (at your</span> <a name="l00009"></a>00009 <span class="comment"> * option) any later version.</span> <a name="l00010"></a>00010 <span class="comment"> * </span> <a name="l00011"></a>00011 <span class="comment"> * This program is distributed in the hope that it will be useful, but WITHOUT</span> <a name="l00012"></a>00012 <span class="comment"> * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or</span> <a name="l00013"></a>00013 <span class="comment"> * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for</span> <a name="l00014"></a>00014 <span class="comment"> * more details.</span> <a name="l00015"></a>00015 <span class="comment"> *</span> <a name="l00016"></a>00016 <span class="comment"> * You should have received a copy of the GNU Lesser General Public License</span> <a name="l00017"></a>00017 <span class="comment"> * along with this program. If not, see <http://www.gnu.org/licenses/></span> <a name="l00018"></a>00018 <span class="comment"> */</span> <a name="l00019"></a>00019 <a name="l00025"></a>00025 <span class="preprocessor">#ifdef HAVE_CONFIG_H</span> <a name="l00026"></a>00026 <span class="preprocessor"></span><span class="preprocessor"># include "config.h"</span> <a name="l00027"></a>00027 <span class="preprocessor">#endif // HAVE_CONFIG_H</span> <a name="l00028"></a>00028 <span class="preprocessor"></span> <a name="l00029"></a>00029 <span class="preprocessor">#include <stdio.h></span> <a name="l00030"></a>00030 <a name="l00031"></a>00031 <span class="preprocessor">#include "<a class="code" href="mirror-subr_8h.html">mirror-subr.h</a>"</span> <a name="l00032"></a>00032 <a name="l00033"></a>00033 <span class="keyword">static</span> <span class="keyword">const</span> byte_t ByteMirror[256] = { <a name="l00034"></a>00034 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, 0x10, 0x90, 0x50, 0xd0, 0x30, <a name="l00035"></a>00035 0xb0, 0x70, 0xf0, 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, 0x18, 0x98, <a name="l00036"></a>00036 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, <a name="l00037"></a>00037 0xe4, 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, 0x0c, 0x8c, 0x4c, 0xcc, <a name="l00038"></a>00038 0x2c, 0xac, 0x6c, 0xec, 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, 0x02, <a name="l00039"></a>00039 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, <a name="l00040"></a>00040 0x72, 0xf2, 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, 0x1a, 0x9a, 0x5a, <a name="l00041"></a>00041 0xda, 0x3a, 0xba, 0x7a, 0xfa, 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, <a name="l00042"></a>00042 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, 0x0e, 0x8e, 0x4e, 0xce, 0x2e, <a name="l00043"></a>00043 0xae, 0x6e, 0xee, 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, 0x01, 0x81, <a name="l00044"></a>00044 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, <a name="l00045"></a>00045 0xf1, 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, 0x19, 0x99, 0x59, 0xd9, <a name="l00046"></a>00046 0x39, 0xb9, 0x79, 0xf9, 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, 0x15, <a name="l00047"></a>00047 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, <a name="l00048"></a>00048 0x6d, 0xed, 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, 0x03, 0x83, 0x43, <a name="l00049"></a>00049 0xc3, 0x23, 0xa3, 0x63, 0xe3, 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, <a name="l00050"></a>00050 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, <a name="l00051"></a>00051 0xbb, 0x7b, 0xfb, 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, 0x17, 0x97, <a name="l00052"></a>00052 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, <a name="l00053"></a>00053 0xef, 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff <a name="l00054"></a>00054 }; <a name="l00055"></a>00055 <a name="l00056"></a>00056 byte_t <a name="l00057"></a>00057 mirror (byte_t bt) <a name="l00058"></a>00058 { <a name="l00059"></a>00059 <span class="keywordflow">return</span> ByteMirror[bt]; <a name="l00060"></a>00060 } <a name="l00061"></a>00061 <a name="l00062"></a>00062 <span class="keywordtype">void</span> <a name="l00063"></a>00063 mirror_bytes (byte_t * pbts, <span class="keywordtype">size_t</span> szLen) <a name="l00064"></a>00064 { <a name="l00065"></a>00065 <span class="keywordtype">size_t</span> szByteNr; <a name="l00066"></a>00066 <a name="l00067"></a>00067 <span class="keywordflow">for</span> (szByteNr = 0; szByteNr < szLen; szByteNr++) { <a name="l00068"></a>00068 *pbts = ByteMirror[*pbts]; <a name="l00069"></a>00069 pbts++; <a name="l00070"></a>00070 } <a name="l00071"></a>00071 } <a name="l00072"></a>00072 <a name="l00073"></a>00073 uint32_t <a name="l00074"></a>00074 mirror32 (uint32_t ui32Bits) <a name="l00075"></a>00075 { <a name="l00076"></a>00076 mirror_bytes ((byte_t *) & ui32Bits, 4); <a name="l00077"></a>00077 <span class="keywordflow">return</span> ui32Bits; <a name="l00078"></a>00078 } <a name="l00079"></a>00079 <a name="l00080"></a>00080 uint64_t <a name="l00081"></a>00081 mirror64 (uint64_t ui64Bits) <a name="l00082"></a>00082 { <a name="l00083"></a>00083 mirror_bytes ((byte_t *) & ui64Bits, 8); <a name="l00084"></a>00084 <span class="keywordflow">return</span> ui64Bits; <a name="l00085"></a>00085 } </pre></div></div> </div> <hr class="footer"/><address class="footer"><small>Generated on Wed Feb 23 2011 for libnfc by  <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.3 </small></address> </body> </html>