Version 7.0
Copyright © 2021 Lowell D. Thomas
APG
… an ABNF Parser Generator
tools.h
Go to the documentation of this file.
1 /* *************************************************************************************
2  Copyright (c) 2021, Lowell D. Thomas
3  All rights reserved.
4 
5  This file is part of APG Version 7.0.
6  APG Version 7.0 may be used under the terms of the BSD 2-Clause License.
7 
8  Redistribution and use in source and binary forms, with or without
9  modification, are permitted provided that the following conditions are met:
10 
11  1. Redistributions of source code must retain the above copyright notice, this
12  list of conditions and the following disclaimer.
13 
14  2. Redistributions in binary form must reproduce the above copyright notice,
15  this list of conditions and the following disclaimer in the documentation
16  and/or other materials provided with the distribution.
17 
18  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 
29 * *************************************************************************************/
30 #ifndef TOOLS_H_
31 #define TOOLS_H_
32 
37 int iStriCmp(const char* cpStrl, const char* cpStrr);
38 abool bIsBigEndian(void);
39 
47 abool bMultiplyLong(luint luiL, luint luiR, luint* luipA);
49 abool bSumLong(luint uiL, luint uiR, luint* uipA);
50 abool bMultiply32(uint32_t uiL, uint32_t uiR, uint32_t* uipA);
51 abool bSum32(uint32_t uiL, uint32_t uiR, uint32_t* uipA);
52 abool bMultiply(aint uiL, aint uiR, aint* uipA);
53 abool bSum(aint uiL, aint uiR, aint* uipA);
55 
68 apg_phrase* spStrToPhrase(const char* cpStr, apg_phrase* spPhrase);
70 char* cpPhraseToStr(apg_phrase* spPhrase, char* cpStr);
73 
84 uint32_t* uipStrToUint32(const char* cpStr, uint32_t* uipBuf, aint* uipLen);
86 char* cpUint32ToStr(uint32_t* uipBuf, aint uiLen, char* cpStr);
87 u32_phrase sStrToPhrase32(const char* cpStr, uint32_t* acpBuf);
88 char* cpPhrase32ToStr(u32_phrase* spPhrase, char* cpStr);
91 
92 #endif /* TOOLS_H_ */
cpUint32ToStr
char * cpUint32ToStr(uint32_t *uipBuf, aint uiLen, char *cpStr)
Convert an array of 32-bit unsigned integers to a null-terminated ASCII string.
Definition: tools.c:336
sStrToPhrase32
u32_phrase sStrToPhrase32(const char *cpStr, uint32_t *acpBuf)
Convert an ASCII, null-terminated string to a 32-bit phrase.
Definition: tools.c:360
spStrToPhrase
apg_phrase * spStrToPhrase(const char *cpStr, apg_phrase *spPhrase)
Convert an ASCII, null-terminated string to an achar phrase.
Definition: tools.c:237
bMultiply
abool bMultiply(aint uiL, aint uiR, aint *uipA)
Multiply two APG unsigned integers with overflow notification.
Definition: tools.c:189
bMultiplyLong
abool bMultiplyLong(luint luiL, luint luiR, luint *luipA)
Multiply two long unsigned integers with overflow notification.
Definition: tools.c:110
aint
uint_fast32_t aint
The APG parser's unsigned integer type.
Definition: apg.h:79
apg_phrase
Defines a pointer to an achar array plus its length. That is, a phrase as is often used by APG.
Definition: lib.h:60
luint
uintmax_t luint
luint is used to cast integers suitable for the %"PRIuMAX" printf format.
Definition: apg.h:133
bSum
abool bSum(aint uiL, aint uiR, aint *uipA)
Sum two unsigned integers with overflow notification.
Definition: tools.c:209
bSum32
abool bSum32(uint32_t uiL, uint32_t uiR, uint32_t *uipA)
Sum two 32-bit unsigned integers with overflow notification.
Definition: tools.c:170
bMultiply32
abool bMultiply32(uint32_t uiL, uint32_t uiR, uint32_t *uipA)
Multiply two 32-bit unsigned integers with overflow notification.
Definition: tools.c:150
cpPhraseToStr
char * cpPhraseToStr(apg_phrase *spPhrase, char *cpStr)
Convert a phrase of achar characters to a null-terminated ASCII string.
Definition: tools.c:264
uipStrToUint32
uint32_t * uipStrToUint32(const char *cpStr, uint32_t *uipBuf, aint *uipLen)
Convert an ASCII, null-terminated string to an 32-bit unsigned integer array.
Definition: tools.c:313
cpPhrase32ToStr
char * cpPhrase32ToStr(u32_phrase *spPhrase, char *cpStr)
Convert a 32-bit phrase to a null-terminated ASCII string.
Definition: tools.c:382
abool
uint8_t abool
abool is the APG bool type.
Definition: apg.h:140
bIsPhraseAscii
abool bIsPhraseAscii(apg_phrase *spPhrase)
Determine if a phrase consists entirely of printable ASCII characters.
Definition: tools.c:287
iStriCmp
int iStriCmp(const char *cpStrl, const char *cpStrr)
Compare two strings. A case-insensitive version of strcmp().
Definition: tools.c:53
bSumLong
abool bSumLong(luint uiL, luint uiR, luint *uipA)
Add two long unsigned integers with overflow notification.
Definition: tools.c:131
u32_phrase
Defines a pointer to an array of 32-bit unsigned integers plus its length. Typically needed by Unicod...
Definition: lib.h:73
bIsBigEndian
abool bIsBigEndian(void)
Determine if the current machine uses big endian word storage.
Definition: tools.c:96
bIsPhrase32Ascii
abool bIsPhrase32Ascii(u32_phrase *spPhrase)
Determine if a 32-bit phrase consists entirely of printable ASCII characters.
Definition: tools.c:405
APG Version 7.0 is licensed under the 2-Clause BSD License,
an Open Source Initiative Approved License.