ajutil.c

Datatypes: none


Datatype: none

Exit functions

Sections: exit


Section: exit

Functions for exiting cleanly.

Functions: ajExit ajExitAbort ajExitBad


Function ajExit

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
);

TypeNameRead/WriteDescription
void RETURN

Returns
void:No return value

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

Function ajExitAbort

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
);

TypeNameRead/WriteDescription
void RETURN

Returns
void:No return value

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

Function ajExitBad

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
);

TypeNameRead/WriteDescription
void RETURN

Returns
void:No return value

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

Section: reset

Functions for memory cleanup

Functions: ajReset


Function 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
);

TypeNameRead/WriteDescription
void RETURN

Returns
void:No return value

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

Section: byte manipulation functions

Functions for manipulating bytes.

Functions: ajByteRevInt ajByteRevLen2 ajByteRevLen2u ajByteRevLen4 ajByteRevLen4u ajByteRevLen8 ajByteRevLen8u ajByteRevLong ajByteRevShort ajByteRevUint ajByteRevUlong


Function ajByteRevInt

Reverses the byte order in an integer.

Synopsis

Prototype
void ajByteRevInt (
      ajint* ival
);

TypeNameRead/WriteDescription
ajint*ivalModifyInteger in wrong byte order. Returned in correct order.
void RETURN

Input & Output
ival:(Modify)Integer in wrong byte order. Returned in correct order.
Returns
void:No return value

Description

Reverses the byte order in an integer.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajByteRevLen2

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
);

TypeNameRead/WriteDescription
ajshort*svalModifyShort 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
void:No return value

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

Function ajByteRevLen2u

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
);

TypeNameRead/WriteDescription
ajushort*svalModifyShort 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
void:No return value

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

Function ajByteRevLen4

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
);

TypeNameRead/WriteDescription
ajint*ivalModifyInteger in wrong byte order. Returned in correct order.
void RETURN

Input & Output
ival:(Modify)Integer in wrong byte order. Returned in correct order.
Returns
void:No return value

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

Function ajByteRevLen4u

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
);

TypeNameRead/WriteDescription
ajuint*ivalModifyInteger in wrong byte order. Returned in correct order.
void RETURN

Input & Output
ival:(Modify)Integer in wrong byte order. Returned in correct order.
Returns
void:No return value

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

Function ajByteRevLen8

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
);

TypeNameRead/WriteDescription
ajlong*lvalModifyInteger in wrong byte order. Returned in correct order.
void RETURN

Input & Output
lval:(Modify)Integer in wrong byte order. Returned in correct order.
Returns
void:No return value

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

Function ajByteRevLen8u

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
);

TypeNameRead/WriteDescription
ajulong*lvalModifyInteger in wrong byte order. Returned in correct order.
void RETURN

Input & Output
lval:(Modify)Integer in wrong byte order. Returned in correct order.
Returns
void:No return value

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

Function ajByteRevLong

Reverses the byte order in a long.

Synopsis

Prototype
void ajByteRevLong (
      ajlong* lval
);

TypeNameRead/WriteDescription
ajlong*lvalModifyInteger in wrong byte order. Returned in correct order.
void RETURN

Input & Output
lval:(Modify)Integer in wrong byte order. Returned in correct order.
Returns
void:No return value

Description

Reverses the byte order in a long.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajByteRevShort

Reverses the byte order in a short integer.

Synopsis

Prototype
void ajByteRevShort (
      ajshort* sval
);

TypeNameRead/WriteDescription
ajshort*svalModifyShort 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
void:No return value

Description

Reverses the byte order in a short integer.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajByteRevUint

Reverses the byte order in an unsigned integer.

Synopsis

Prototype
void ajByteRevUint (
      ajuint* ival
);

TypeNameRead/WriteDescription
ajuint*ivalModifyUnsigned 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
void:No return value

Description

Reverses the byte order in an unsigned integer.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajByteRevUlong

Reverses the byte order in an unsigned long.

Synopsis

Prototype
void ajByteRevUlong (
      ajulong* lval
);

TypeNameRead/WriteDescription
ajulong*lvalModifyInteger in wrong byte order. Returned in correct order.
void RETURN

Input & Output
lval:(Modify)Integer in wrong byte order. Returned in correct order.
Returns
void:No return value

Description

Reverses the byte order in an unsigned long.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: Miscellaneous utility functions

Miscellaneous utility functions.

Functions: ajUtilBase64DecodeC ajUtilBase64EncodeC ajUtilCatch ajUtilGetBigendian ajUtilGetUid ajUtilLoginfo


Function ajUtilBase64DecodeC

Decode a base 64 string

Synopsis

Prototype
size_t ajUtilBase64DecodeC (
      AjPStr* Pdest,
      const char* src
);

TypeNameRead/WriteDescription
AjPStr*PdestOutputDecoded string
const char*srcInputsource base64 string
size_t RETURNLength 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

Function ajUtilBase64EncodeC

Decode a base 64 string

Synopsis

Prototype
AjBool ajUtilBase64EncodeC (
      AjPStr* Pdest,
      size_t size,
      const unsigned char* src
);

TypeNameRead/WriteDescription
AjPStr*PdestModifyEncoded string
size_tsizeInputSize of data to encode
const unsigned char*srcInputsource data
AjBool RETURNTrue on success

Input
size:(Input)Size of data to encode
src:(Input)source data
Input & Output
Pdest:(Modify)Encoded string
Returns
AjBool:True on success

Description

Decode a base 64 string

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajUtilCatch

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
);

TypeNameRead/WriteDescription
void RETURN

Returns
void:No return value

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

Function ajUtilGetBigendian

Tests whether the host system uses big endian byte order.

Synopsis

Prototype
AjBool ajUtilGetBigendian (
      void
);

TypeNameRead/WriteDescription
AjBool RETURNajTrue 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

Function ajUtilGetUid

Returns the user's userid

Synopsis

Prototype
AjBool ajUtilGetUid (
      AjPStr* Puid
);

TypeNameRead/WriteDescription
AjPStr*PuidOutputString to return result
AjBool RETURNajTrue on success

Output
Puid:(Output)String to return result
Returns
AjBool:ajTrue on success

Description

Returns the user's userid

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajUtilLoginfo

If a log file is in use, writes run details to end of file.

Synopsis

Prototype
void ajUtilLoginfo (
      void
);

TypeNameRead/WriteDescription
void RETURN

Returns
void:No return value

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

Section: provenance

Functions providing information about the run-time environment

Functions: ajUtilGetCmdline ajUtilGetInputs ajUtilGetProgram


Function ajUtilGetCmdline

Returns the original command line as qualifiers and values with newline delimiters

Synopsis

Prototype
const AjPStr ajUtilGetCmdline (
      void
);

TypeNameRead/WriteDescription
const AjPStr RETURNCommandline 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

Function ajUtilGetInputs

Returns the user non-default inputs in commandline form

Synopsis

Prototype
const AjPStr ajUtilGetInputs (
      void
);

TypeNameRead/WriteDescription
const AjPStr RETURNCommandline 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

Function ajUtilGetProgram

Returns the application (program) name from the ACD definition.

Synopsis

Prototype
const AjPStr ajUtilGetProgram (
      void
);

TypeNameRead/WriteDescription
const AjPStr RETURNProgram 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