InChI
 
Loading...
Searching...
No Matches
ikey_base26.h
Go to the documentation of this file.
1/*
2 * International Chemical Identifier (InChI)
3 * Version 1
4 * Software version 1.07
5 * April 30, 2024
6 *
7 * MIT License
8 *
9 * Copyright (c) 2024 IUPAC and InChI Trust
10 *
11 * Permission is hereby granted, free of charge, to any person obtaining a copy
12 * of this software and associated documentation files (the "Software"), to deal
13 * in the Software without restriction, including without limitation the rights
14 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 * copies of the Software, and to permit persons to whom the Software is
16 * furnished to do so, subject to the following conditions:
17 *
18 * The above copyright notice and this permission notice shall be included in all
19 * copies or substantial portions of the Software.
20 *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 * SOFTWARE.
28*
29* The InChI library and programs are free software developed under the
30 * auspices of the International Union of Pure and Applied Chemistry (IUPAC).
31 * Originally developed at NIST.
32 * Modifications and additions by IUPAC and the InChI Trust.
33 * Some portions of code were developed/changed by external contributors
34 * (either contractor or volunteer) which are listed in the file
35 * 'External-contributors' included in this distribution.
36 *
37 * info@inchi-trust.org
38 *
39*/
40
41
42#ifndef _IKEY_BASE26_H_
43#define _IKEY_BASE26_H_
44
45/*
46 Base-26 encoding procedures.
47
48 'Base26' characters here are considered to be uppercase English
49 letters 'A..Z'
50*/
51
52
53/* Uncomment the next line to fix base-26 encoding bug */
54/*#define FIX_BASE26_ENC_BUG 1*/
55
56typedef unsigned int UINT32;
57typedef unsigned short int UINT16;
58
59#ifdef __cplusplus
60extern "C" {
61#endif
62
63/* Get a character representing 1st 14-bit triplet
64 (bits 0..13 of contiguous array of octets) */
65 const char* base26_triplet_1( const unsigned char *a );
66 /* Get a character representing 2nd 14-bit triplet (bits 14..27) */
67 const char* base26_triplet_2( const unsigned char *a );
68 /* Get a character representing 3rd 14-bit triplet (bits 28..41) */
69 const char* base26_triplet_3( const unsigned char *a );
70 /* Get a character representing 4th 14-bit triplet (bits 42..55) */
71 const char* base26_triplet_4( const unsigned char *a );
72
73 /*
74 Tail dublets
75 */
76
77 /* Get dublet (bits 28..36) */
78 const char* base26_dublet_for_bits_28_to_36( unsigned char *a );
79 /* Get dublet (bits 56..64) */
80 const char* base26_dublet_for_bits_56_to_64( unsigned char *a );
81 /* Calculate check character for the string. */
82 const char base26_checksum( const char *str );
83 /* Get hash extension in hexadecimal representation for the major block.
84 Len(extension) = 256 - 65 = 191 bit. */
85 void get_xtra_hash_major_hex( const unsigned char *a, char* szXtra );
86 /* Get hash extension in hexadecimal representation for the minor block.
87 Len(extension) = 256 - 37 = 219 bit. */
88 void get_xtra_hash_minor_hex( const unsigned char *a, char* szXtra );
89
90 /* Used instead of isupper() to avoid locale interference. */
91#define isbase26(_c) ( ((unsigned)(_c) >= 'A') && ((unsigned)(_c) <= 'Z') )
92
93#ifdef __cplusplus
94}
95#endif
96
97
98#endif /* _IKEY_BASE26_H_ */
const char * base26_triplet_2(const unsigned char *a)
Definition ikey_base26.c:1191
const char * base26_triplet_3(const unsigned char *a)
Definition ikey_base26.c:1212
const char base26_checksum(const char *str)
void get_xtra_hash_minor_hex(const unsigned char *a, char *szXtra)
Definition ikey_base26.c:1328
const char * base26_dublet_for_bits_56_to_64(unsigned char *a)
Definition ikey_base26.c:1287
void get_xtra_hash_major_hex(const unsigned char *a, char *szXtra)
Definition ikey_base26.c:1307
const char * base26_triplet_1(const unsigned char *a)
Definition ikey_base26.c:1173
unsigned short int UINT16
Definition ikey_base26.h:57
const char * base26_triplet_4(const unsigned char *a)
Definition ikey_base26.c:1233
const char * base26_dublet_for_bits_28_to_36(unsigned char *a)
Definition ikey_base26.c:1262
unsigned int UINT32
Definition ikey_base26.h:56