ULONG CalcChecksum(
APTR memory,
ULONG size)
Calculate a checksum for a given area of memory.
memory - Start here
size - This many bytes. Must be a multiple of sizeof(ULONG)
The checksum for the memory. If you store the checksum somewhere
in the area and run CalcChecksum() again, the result will be 0.
To achieve this, you must set the place, where the checksum will
be placed later, to 0 before you call the function.
ULONG mem[512];
mem[0] = 0; // Store checksum here
mem[0] = CalcChecksum (mem, sizeof (mem));
if (CalcChecksum (mem, sizeof (mem))
printf ("Something is wrong !!\n");
else
printf ("Data is unchanged.\n");
This function is not part of a library and may thus be called
any time.
static int FindNextNodes(
APTR memPtr,
struct PNode ** before,
struct PNode ** after)
Returns the addresses of the PNodes right before and right right
after memPtr.
memPtr - The address to look for
before - Pointer to a pointer to PNode where the address of
the node right before memPtr will be stored.
after - Pointer to a pointer to PNode where the address of
the node right after memPtr will be stored.
The number of found PNodes. *before will contain a pointer to
the PNode which is before memPtr or which contains memPtr or NULL
if there is no node before PNode. *after will contain a pointer
to the first PNode which comes right after memPtr or NULL if no
PNode follows memPtr.
Must not be called before Purify_Init().
static struct PNode * FindNode(
APTR memPtr)
Searches for the PNode which contains memPtr.
memPtr - A pointer into a piece of memory previously made known
with Purify_AddMemory.
A pointer to a PNode which contains the memPtr or NULL if there
is no such pointer. No error will be printed.
Must not be called before Purify_Init().
void hexdump(
const void * data,
IPTR offset,
ULONG count)
Prints a hexdump of the data beginning at 'data'. The format
is like this:
xxxxxxxx: dddddddd dddddddd dddddddd dddddddd aaaaaaaaaaaaaaaa
Where x is the address (8 chars hex), dd is a data byte (2 chars
hex) and a is the ASCII representation of a data byte or "." if
the data byte is not printable.
data - Start here with the dump
offset - This offset is used as the address in the output. If
you give 0L here, then the first address will be
00000000. If you give (IPTR)data here, then the
first address will be the memory address of the data.
count - How many bytes to print.
BOOL IsDosEntryA(
char * Name,
ULONG Flags)
There is a need in file/directory processing where an application
may need to determine whether a path is just a volume/device or
assignment name.
Name - The path to test.
Flags - Any combination of the following:
LDF_ASSIGNS
LDF_DEVICES
LDF_VOLUMES
BOOL Success;
...
Success = IsDosEntryA("Work:", LDF_VOLUMES)
if (Success == TRUE)
{
...
}
Requires the programmer to open the utility.library and initialise
UtilityBase.
In future releases the buffer size will be set via a taglist.
int kprintf(
const char * fmt,
...)
Formats fmt with the specified arguments like printf() (and *not*
like RawDoFmt()) and uses a secure way to deliver the message to
the user; ie. the user *will* see this message no matter what.
fmt - printf()-style format string
The number of characters output.
This function is not part of a library and may thus be called
any time.
void Purify_SetState(
APTR memPtr,
ULONG size,
ULONG state)
Brings a block of memory into a certain state (eg. empty, initialized,
read-only). memPtr and size must be within a block beforehand
declared with Purify_AddMemory().
memPtr - Where to start
size - How many bytes after memPtr
state - The new state of the memory:
PMS_EMPTY - The memory may be read from and written to,
but any read before the first write will yield an
error (read from uninitialized memory).
PMS_INITIALIZED - The memory has been initialized and may
be read and writen to.
PMS_READONLY - The memory may be read but not written to.
PMS_FREE - The memory may not be read from or written to.
BOOL ReadByte(
struct Hook * hook,
UBYTE * dataptr,
void * stream)
Reads one big endian 8bit value from a streamhook.
hook - Streamhook
dataptr - Put the data here
stream - Read from this stream
The function returns TRUE on success. On success, the value
read is written into dataptr. On failure, FALSE is returned and the
contents of dataptr are not changed.
This function reads big endian values from a streamhook even on
little endian machines.
BOOL ReadDouble(
struct Hook * hook,
DOUBLE * dataptr,
void * stream)
Reads one big endian 64bit double precision floating point value
from a streamhook.
hook - Streamhook
dataptr - Put the data here
stream - Read from this stream
The function returns TRUE on success. On success, the value
read is written into dataptr. On failure, FALSE is returned and the
contents of dataptr are not changed.
This function reads big endian values from a streamhook even on
little endian machines.
BOOL ReadFloat(
struct Hook * hook,
FLOAT * dataptr,
void * stream)
Reads one big endian 32bit floating point value from a streamhook.
hook - Streamhook
dataptr - Put the data here
stream - Read from this stream
The function returns TRUE on success. On success, the value
read is written into dataptr. On failure, FALSE is returned and the
contents of dataptr are not changed.
This function reads big endian values from a streamhook even on
little endian machines.
BOOL ReadLong(
struct Hook * hook,
ULONG * dataptr,
void * stream)
Reads one big endian 32bit value from a streamhook.
hook - Streamhook
dataptr - Put the data here
stream - Read from this stream
The function returns TRUE on success. On success, the value
read is written into dataptr. On failure, FALSE is returned and the
contents of dataptr are not changed.
This function reads big endian values from a streamhook even on
little endian machines.
BOOL ReadString(
struct Hook * hook,
STRPTR * dataptr,
void * stream)
Reads one C string from a streamhook.
hook - Streamhook
dataptr - Put the data here. If you don't need the string anymore,
call FreeVec() to free it.
stream - Read from this stream
The function returns TRUE on success. On success, the string
read is written into dataptr. On failure, FALSE is returned and the
contents of dataptr are not changed. The string must be freed with
FreeVec().
This function reads big endian values from a streamhook even on
little endian machines.
BOOL ReadStruct(
struct Hook * hook,
APTR * dataptr,
void * stream,
const IPTR * sd)
Reads one big endian structure from a streamhook.
hook - Streamhook
dataptr - Put the data here. If NULL, a new memory block is allocated
stream - Read from this stream
sd - Description of the structure to be read. The first element
is the size of the structure.
The function returns TRUE on success. On success, the value
read is written into dataptr. On failure, FALSE is returned and the
contents of dataptr are not changed.
This function reads big endian values from a streamhook even on
little endian machines.
BOOL ReadWord(
struct Hook * hook,
UWORD * dataptr,
void * stream)
Reads one big endian 16bit value from a streamhook.
hook - Streamhook
dataptr - Put the data here
stream - Read from this stream
The function returns TRUE on success. On success, the value
read is written into dataptr. On failure, FALSE is returned and the
contents of dataptr are not changed.
This function reads big endian values from a streamhook even on
little endian machines.
APTR RemoveSList(
APTR * list,
APTR node)
Remove the node from a single linked list.
list - Pointer to the pointer which contains the first element
of the single linked list.
node - The node which is to be removed.
Returns the node if it was in the list.
This function is not part of a library and may thus be called
any time.
int rkprintf(
const STRPTR mainSystem,
const STRPTR subSystem,
int level,
const UBYTE * fmt,
...)
Call kprintf if debugging for this main and subsystem is enabled
at a level larger than the level above. The minimal level is 1
(this way, debugging can be disabled in the debug config file
by giving a level of 0).
You should not call this function directly but use the rbug
macro. The rbug macro does some magic to make the handling
more simple.
mainSystem - The main system. Use one of the DBG_MAINSYSTEM_*
macros to avoid typos.
subSystem - The part of the main system. Use one of the
DBG_*_SUBSYSTEM_* macros.
level - The debug level. Higher levels should give more details.
The lowest level is 1.
fmt - printf()-style format string
The number of characters output.
if (cache)
{
...
D(rbug(INTUITION, INPUTHANDLER, 3,
"allocating event from cache (%p)", event
));
...
}
This function is not part of a library and may thus be called
any time.
IPTR RT_IntAdd(
int rtt,
const char * file,
int line,
...)
Adds a resource to be tracked. The arguments after
line depend on the type of resource to be traced:
RTT_ALLOCMEM: APTR memPtr,
ULONG size)
rtt - Type of the resource
file - The file RT_IntAdd was called it
line - The line of the file
task - The task to be added
memPtr - Pointer to a piece of memory to be tracked
size - The size of the memory beginning at memPtr
IPTR RT_IntCheck(
int rtt,
const char * file,
int line,
int op,
...)
Checks a resource. Will print an error if the resource is not found
or has already been freed or if the type of the resource doesn't
match. The arguments after line depend on the type of resource to
be traced:
RTT_ALLOCMEM: APTR memPtr,
ULONG size)
rtt - Type of the resource
file - The file RT_IntCheck was called it
line - The line of the file
task - The task to be added
memPtr - Pointer to a piece of memory to be tracked
size - The size of the memory beginning at memPtr
All strings must be static.
void RT_IntEnter(
const char * function,
const char * file,
int line)
Tells the RT that a new function is about to be entered. This is used
to make it easier to track an error.
function - name of the function to be entered
file - file with the call of the function
line - Line-number of the call
All strings must be static.
IPTR RT_IntFree(
int rtt,
const char * file,
int line,
...)
Stops tracing of a resource. The arguments after
line depend on the type of resource to be traced.
rtt - Type of the resource
file - The file RT_IntAdd was called it
line - The line of the file
All strings must be static.
void RT_IntTrack(
int rtt,
const char * file,
int line,
APTR res,
...)
Adds a resource to be tracked. The arguments after
line depend on the type of resource to be traced.
The resource is marked as "must not be freed by the
user".
rtt - Type of the resource
file - The file RT_IntAdd was called it
line - The line of the file
res - Pointer to the resouce
BOOL WriteDouble(
struct Hook * hook,
DOUBLE data,
void * stream)
Writes one big endian 64bit double precision floating point value
to a streamhook.
hook - Write to this streamhook
data - Data to be written
stream - Stream passed to streamhook
The function returns TRUE on success and FALSE otherwise.
See IoErr() for the reason in case of an error.
This function writes big endian values to a file even on little
endian machines.
BOOL WriteStruct(
struct Hook * hook,
void * data,
void * stream,
const IPTR * sd)
Writes one big endian structure to a streamhook.
hook - Write to this streamhook
data - Data to be written
stream - Stream passed to streamhook
sd - Description of the structure to be written. The first element
is the size of the structure.
The function returns TRUE on success and FALSE otherwise. In error,
you can examine IoErr() to find out what was wrong.
This function writes big endian values to a file even on little
endian machines.