ajutil.c
Datatypes: none
Exit functions
Sections: exit
Functions for exiting cleanly.
Functions: ajExit ajExitAbort ajExitBad
Calls 'exit' with a successful code (zero), but first calls ajReset to
call memory clean up and debug reporting functions.
No cleanup or reporting routines are called. Simply crashes.
Synopsis
Prototype
void ajExit (
void
);
Type | Name | Read/Write | Description |
void | | RETURN | |
Returns
Description
Calls 'exit' with a successful code (zero), but first calls ajReset to
call memory clean up and debug reporting functions.
No cleanup or reporting routines are called. Simply crashes.
See Also
See other functions in this section
Availability
In release 6.4.0
Exits without flushing any files. Needed for exit from, for example,
a failed system call (ajFileNewInPipe, and so on) where the parent
process has open output files, and the child process needs to exit
without affecting them. Failure to exit this way can mean the output
buffer is flushed twice.
Calls '_exit' with an unsuccessful code (EXIT_FAILURE defined in stdlib.h).
No cleanup or reporting routines are called. Simply crashes.
Synopsis
Prototype
void ajExitAbort (
void
);
Type | Name | Read/Write | Description |
void | | RETURN | |
Returns
Description
Exits without flushing any files. Needed for exit from, for example,
a failed system call (ajFileNewInPipe, and so on) where the parent
process has open output files, and the child process needs to exit
without affecting them. Failure to exit this way can mean the output
buffer is flushed twice.
Calls '_exit' with an unsuccessful code (EXIT_FAILURE defined in stdlib.h).
No cleanup or reporting routines are called. Simply crashes.
See Also
See other functions in this section
Availability
In release 6.4.0
Calls 'exit' with an unsuccessful code (EXIT_FAILURE defined in stdlib.h).
No cleanup or reporting routines are called. Simply crashes.
Synopsis
Prototype
void ajExitBad (
void
);
Type | Name | Read/Write | Description |
void | | RETURN | |
Returns
Description
Calls 'exit' with an unsuccessful code (EXIT_FAILURE defined in stdlib.h).
No cleanup or reporting routines are called. Simply crashes.
See Also
See other functions in this section
Availability
In release 6.4.0
Functions for memory cleanup
Functions: ajReset
Cleans up all internal memory by calling cleanup routines which
can report on resource usage etc.
Intended to be called at the end of processing by exit functions.
Synopsis
Prototype
void ajReset (
void
);
Type | Name | Read/Write | Description |
void | | RETURN | |
Returns
Description
Cleans up all internal memory by calling cleanup routines which
can report on resource usage etc.
Intended to be called at the end of processing by exit functions.
See Also
See other functions in this section
Availability
In release 6.4.0
Functions for manipulating bytes.
Functions: ajByteRevInt ajByteRevLen2 ajByteRevLen2u ajByteRevLen4 ajByteRevLen4u ajByteRevLen8 ajByteRevLen8u ajByteRevLong ajByteRevShort ajByteRevUint ajByteRevUlong
Reverses the byte order in an integer.
Synopsis
Prototype
void ajByteRevInt (
ajint* ival
);
Type | Name | Read/Write | Description |
ajint* | ival | Modify | Integer in wrong byte order.
Returned in correct order. |
void | | RETURN | |
Input & Output
ival: | (Modify) | Integer in wrong byte order.
Returned in correct order. |
Returns
Description
Reverses the byte order in an integer.
See Also
See other functions in this section
Availability
In release 6.4.0
Reverses the byte order in a 2 byte integer.
Intended for cases where the number of bytes is known, for
example when reading a binary file.
Synopsis
Prototype
void ajByteRevLen2 (
ajshort* sval
);
Type | Name | Read/Write | Description |
ajshort* | sval | Modify | Short integer in wrong byte order.
Returned in correct order. |
void | | RETURN | |
Input & Output
sval: | (Modify) | Short integer in wrong byte order.
Returned in correct order. |
Returns
Description
Reverses the byte order in a 2 byte integer.
Intended for cases where the number of bytes is known, for
example when reading a binary file.
See Also
See other functions in this section
Availability
In release 6.4.0
Reverses the byte order in a 2 byte integer.
Intended for cases where the number of bytes is known, for
example when reading a binary file.
Synopsis
Prototype
void ajByteRevLen2u (
ajushort* sval
);
Type | Name | Read/Write | Description |
ajushort* | sval | Modify | Short integer in wrong byte order.
Returned in correct order. |
void | | RETURN | |
Input & Output
sval: | (Modify) | Short integer in wrong byte order.
Returned in correct order. |
Returns
Description
Reverses the byte order in a 2 byte integer.
Intended for cases where the number of bytes is known, for
example when reading a binary file.
See Also
See other functions in this section
Availability
In release 6.4.0
Reverses the byte order in a 4 byte integer.
Intended for cases where the number of bytes is known, for
example when reading a binary file.
Synopsis
Prototype
void ajByteRevLen4 (
ajint* ival
);
Type | Name | Read/Write | Description |
ajint* | ival | Modify | Integer in wrong byte order.
Returned in correct order. |
void | | RETURN | |
Input & Output
ival: | (Modify) | Integer in wrong byte order.
Returned in correct order. |
Returns
Description
Reverses the byte order in a 4 byte integer.
Intended for cases where the number of bytes is known, for
example when reading a binary file.
See Also
See other functions in this section
Availability
In release 6.4.0
Reverses the byte order in a 4 byte integer.
Intended for cases where the number of bytes is known, for
example when reading a binary file.
Synopsis
Prototype
void ajByteRevLen4u (
ajuint* ival
);
Type | Name | Read/Write | Description |
ajuint* | ival | Modify | Integer in wrong byte order.
Returned in correct order. |
void | | RETURN | |
Input & Output
ival: | (Modify) | Integer in wrong byte order.
Returned in correct order. |
Returns
Description
Reverses the byte order in a 4 byte integer.
Intended for cases where the number of bytes is known, for
example when reading a binary file.
See Also
See other functions in this section
Availability
In release 6.4.0
Reverses the byte order in an 8 byte long.
Intended for cases where the number of bytes is known, for
example when reading a binary file.
Synopsis
Prototype
void ajByteRevLen8 (
ajlong* lval
);
Type | Name | Read/Write | Description |
ajlong* | lval | Modify | Integer in wrong byte order.
Returned in correct order. |
void | | RETURN | |
Input & Output
lval: | (Modify) | Integer in wrong byte order.
Returned in correct order. |
Returns
Description
Reverses the byte order in an 8 byte long.
Intended for cases where the number of bytes is known, for
example when reading a binary file.
See Also
See other functions in this section
Availability
In release 6.4.0
Reverses the byte order in an 8 byte long.
Intended for cases where the number of bytes is known, for
example when reading a binary file.
Synopsis
Prototype
void ajByteRevLen8u (
ajulong* lval
);
Type | Name | Read/Write | Description |
ajulong* | lval | Modify | Integer in wrong byte order.
Returned in correct order. |
void | | RETURN | |
Input & Output
lval: | (Modify) | Integer in wrong byte order.
Returned in correct order. |
Returns
Description
Reverses the byte order in an 8 byte long.
Intended for cases where the number of bytes is known, for
example when reading a binary file.
See Also
See other functions in this section
Availability
In release 6.4.0
Reverses the byte order in a long.
Synopsis
Prototype
void ajByteRevLong (
ajlong* lval
);
Type | Name | Read/Write | Description |
ajlong* | lval | Modify | Integer in wrong byte order.
Returned in correct order. |
void | | RETURN | |
Input & Output
lval: | (Modify) | Integer in wrong byte order.
Returned in correct order. |
Returns
Description
Reverses the byte order in a long.
See Also
See other functions in this section
Availability
In release 6.4.0
Reverses the byte order in a short integer.
Synopsis
Prototype
void ajByteRevShort (
ajshort* sval
);
Type | Name | Read/Write | Description |
ajshort* | sval | Modify | Short integer in wrong byte order.
Returned in correct order. |
void | | RETURN | |
Input & Output
sval: | (Modify) | Short integer in wrong byte order.
Returned in correct order. |
Returns
Description
Reverses the byte order in a short integer.
See Also
See other functions in this section
Availability
In release 6.4.0
Reverses the byte order in an unsigned integer.
Synopsis
Prototype
void ajByteRevUint (
ajuint* ival
);
Type | Name | Read/Write | Description |
ajuint* | ival | Modify | Unsigned integer in wrong byte order.
Returned in correct order. |
void | | RETURN | |
Input & Output
ival: | (Modify) | Unsigned integer in wrong byte order.
Returned in correct order. |
Returns
Description
Reverses the byte order in an unsigned integer.
See Also
See other functions in this section
Availability
In release 6.4.0
Reverses the byte order in an unsigned long.
Synopsis
Prototype
void ajByteRevUlong (
ajulong* lval
);
Type | Name | Read/Write | Description |
ajulong* | lval | Modify | Integer in wrong byte order.
Returned in correct order. |
void | | RETURN | |
Input & Output
lval: | (Modify) | Integer in wrong byte order.
Returned in correct order. |
Returns
Description
Reverses the byte order in an unsigned long.
See Also
See other functions in this section
Availability
In release 6.4.0
Miscellaneous utility functions.
Functions: ajUtilBase64DecodeC ajUtilBase64EncodeC ajUtilCatch ajUtilGetBigendian ajUtilGetUid ajUtilLoginfo
Decode a base 64 string
Synopsis
Prototype
size_t ajUtilBase64DecodeC (
AjPStr* Pdest,
const char* src
);
Type | Name | Read/Write | Description |
AjPStr* | Pdest | Output | Decoded string |
const char* | src | Input | source base64 string |
size_t | | RETURN | Length of decoded string (zero if decode error) |
Input
src: | (Input) | source base64 string |
Output
Pdest: | (Output) | Decoded string |
Returns
size_t: | Length of decoded string (zero if decode error) |
Description
Decode a base 64 string
See Also
See other functions in this section
Availability
In release 6.4.0
Decode a base 64 string
Synopsis
Prototype
AjBool ajUtilBase64EncodeC (
AjPStr* Pdest,
size_t size,
const unsigned char* src
);
Type | Name | Read/Write | Description |
AjPStr* | Pdest | Modify | Encoded string |
size_t | size | Input | Size of data to encode |
const unsigned char* | src | Input | source data |
AjBool | | RETURN | True on success |
Input
size: | (Input) | Size of data to encode |
src: | (Input) | source data |
Input & Output
Pdest: | (Modify) | Encoded string |
Returns
Description
Decode a base 64 string
See Also
See other functions in this section
Availability
In release 6.4.0
Dummy function to be called in special cases so it can be used when
debugging in GDB.
To use, simply put a call to ajUtilCatch() into your code, and use
"break ajUtilCatch" in gdb to get a traceback.
Synopsis
Prototype
void ajUtilCatch (
void
);
Type | Name | Read/Write | Description |
void | | RETURN | |
Returns
Description
Dummy function to be called in special cases so it can be used when
debugging in GDB.
To use, simply put a call to ajUtilCatch() into your code, and use
"break ajUtilCatch" in gdb to get a traceback.
See Also
See other functions in this section
Availability
In release 6.4.0
Tests whether the host system uses big endian byte order.
Synopsis
Prototype
AjBool ajUtilGetBigendian (
void
);
Type | Name | Read/Write | Description |
AjBool | | RETURN | ajTrue if host is big endian. |
Returns
AjBool: | ajTrue if host is big endian. |
Description
Tests whether the host system uses big endian byte order.
See Also
See other functions in this section
Availability
In release 6.4.0
Returns the user's userid
Synopsis
Prototype
AjBool ajUtilGetUid (
AjPStr* Puid
);
Type | Name | Read/Write | Description |
AjPStr* | Puid | Output | String to return result |
AjBool | | RETURN | ajTrue on success |
Output
Puid: | (Output) | String to return result |
Returns
Description
Returns the user's userid
See Also
See other functions in this section
Availability
In release 6.4.0
If a log file is in use, writes run details to end of file.
Synopsis
Prototype
void ajUtilLoginfo (
void
);
Type | Name | Read/Write | Description |
void | | RETURN | |
Returns
Description
If a log file is in use, writes run details to end of file.
See Also
See other functions in this section
Availability
In release 6.4.0
Functions providing information about the run-time environment
Functions: ajUtilGetCmdline ajUtilGetInputs ajUtilGetProgram
Returns the original command line as qualifiers and values with newline
delimiters
Synopsis
Prototype
const AjPStr ajUtilGetCmdline (
void
);
Type | Name | Read/Write | Description |
const AjPStr | | RETURN | Commandline with newlines between qualifiers
and parameters |
Returns
const AjPStr: | Commandline with newlines between qualifiers
and parameters |
Description
Returns the original command line as qualifiers and values with newline
delimiters
See Also
See other functions in this section
Availability
In release 6.4.0
Returns the user non-default inputs in commandline form
Synopsis
Prototype
const AjPStr ajUtilGetInputs (
void
);
Type | Name | Read/Write | Description |
const AjPStr | | RETURN | Commandline with newlines between qualifiers
and parameters |
Returns
const AjPStr: | Commandline with newlines between qualifiers
and parameters |
Description
Returns the user non-default inputs in commandline form
See Also
See other functions in this section
Availability
In release 6.4.0
Returns the application (program) name from the ACD definition.
Synopsis
Prototype
const AjPStr ajUtilGetProgram (
void
);
Type | Name | Read/Write | Description |
const AjPStr | | RETURN | Program name |
Returns
const AjPStr: | Program name |
Description
Returns the application (program) name from the ACD definition.
See Also
See other functions in this section
Availability
In release 6.4.0