Version 6.3
Copyright © 2005 - 2012 Lowell D. Thomas
APG
  … ABNF Parser Generator
All Data Structures Files Functions Variables Typedefs Macros Pages
Functions
Tools.c File Reference

A small chest of helpful tools. More...

#include "Apg.h"
#include "Private.h"

Go to the source code of this file.

Functions

void vDefaultAlertHandler (unsigned int uiLine, const char *cpFile)
 
int apg_stricmp (const char *cpLhs, const char *cpRhs)
 
void vCharToAChar (apg_achar *acpAChars, const char *cpChars, apg_uint uiLen)
 
apg_uint uiACharToStringSize (const apg_achar *acpAChars, apg_uint uiALen)
 
apg_uint uiACharToString (char *cpChars, apg_uint uiCLen, const apg_achar *acpAChars, apg_uint uiALen)
 

Detailed Description

A small chest of helpful tools.

Definition in file Tools.c.

Function Documentation

◆ apg_stricmp()

int apg_stricmp ( const char *  cpLhs,
const char *  cpRhs 
)

Case-insensitive: compares two strings. The two strings are compared, character for character. NOTE: stricmp() is non-ANSI and therefore, not used

Parameters
cpLhspointer to the left of the two strings to compare
cpRhspointer to the right of the two strings to compare
Returns
0 if the two strings are case-insensitively equal
-1 if the left string is less than the right string
+1 if the left string is greater than the right string

Definition at line 46 of file Tools.c.

◆ uiACharToString()

apg_uint uiACharToString ( char *  cpChars,
apg_uint  uiCLen,
const apg_achar acpAChars,
apg_uint  uiALen 
)

Converts a string of alphabet characters to a null-terminated printable ASCII string. Non-printing characters are of the form: <xFF>. Brackets are used to distinguish the hex format from adjacent printing characters of "x" and "F", for example. The worst case scenario is that all translated characters will be of the form <xFF>, where sizeof(apg_achar) is 1 for example. To be safe, the cpChars buffer size, uiCLen, should be at least: uiALen * ((sizeof(apg_achar) * 2) + 3) plus 1 for terminating null. To get the exact size in advance, see uiACharToStringSize().

Parameters
cpCharspointer to the buffer to receive the printable, 8-bit character string
uiCLenlength of the cpChars buffer
acpACharspointer the apg_achar character string
uiALenthe number of apg_achar characters
See also
uiACharToStringSize()
Returns
the number of apg_achar characters translated. If < uiAlen, the translation was truncated due to insufficient buffer length, uiCLen

Definition at line 197 of file Tools.c.

◆ uiACharToStringSize()

apg_uint uiACharToStringSize ( const apg_achar acpAChars,
apg_uint  uiALen 
)

Calculate the size of the string translated by uiACharToString()

Parameters
acpACharspointer the apg_achar character string
uiALenthe number of apg_achar characters
See also
uiACharToString()
Returns
the calculated size

Definition at line 165 of file Tools.c.

◆ vCharToAChar()

void vCharToAChar ( apg_achar acpAChars,
const char *  cpChars,
apg_uint  uiLen 
)

Convert an ASCII, 8-bit character string to an apg_achar character string.

Parameters
acpACharspointer to the apg_achar character string
cpCharspointer to the 8-bit character string to convert
uiLenthe number of characters to convert

Definition at line 79 of file Tools.c.

◆ vDefaultAlertHandler()

void vDefaultAlertHandler ( unsigned int  uiLine,
const char *  cpFile 
)

The default alert handler. (Simply exits the program.)

Parameters
uiLinethe line number where the alert was generated.
cpFilename of the file where the alert was generated.

Definition at line 33 of file Tools.c.

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, see http://www.gnu.org/licenses/licenses.html or write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.