#include <stdint.h>#include <stdbool.h>#include <stdlib.h>#include "a2560k.h"Go to the source code of this file.
Data Structures | |
| struct | Coordinate |
Functions | |
| int32_t | General_Round (double the_float) |
| Round a float to the nearest integer value THINK C's and SAS/C's math.h don't include round() from: https://stackoverflow.com/questions/4572556/concise-way-to-implement-round-in-c. More... | |
| bool | General_StrToLower (char *the_string) |
| Convert a string, in place, to lower case This overwrites the string with a lower case version of itself. More... | |
| uint8_t | General_ToLower (uint8_t the_char) |
| Change the case of the passed character from upper to lower (if necessary) Scope is limited to characters A-Z, ascii. More... | |
| char * | General_StrlcpyWithAlloc (const char *src, size_t max_len) |
| Allocates memory for a new string and copies up to max_len - 1 characters from the NUL-terminated string src to the new string, NUL-terminating the result This is meant to be a one stop shop for getting a copy of a string. More... | |
| int16_t | General_Strlcpy (char *dst, const char *src, size_t max_len) |
| Copies up to max_len - 1 characters from the NUL-terminated string src to dst, NUL-terminating the result. More... | |
| int16_t | General_Strlcat (char *dst, const char *src, size_t max_len) |
| Copies up to max_len - 1 characters from the NUL-terminated string src and appends to the end of dst, NUL-terminating the result. More... | |
| int16_t | General_Strncmp (const char *string_1, const char *string_2, size_t max_len) |
| Makes a case sensitive comparison of the specified number of characters of the two passed strings Stops processing once max_len has been reached, or when one of the two strings has run out of characters. More... | |
| int16_t | General_Strncasecmp (const char *string_1, const char *string_2, size_t max_len) |
| Makes a case insensitive comparison of the specified number of characters of the two passed strings Stops processing once max_len has been reached, or when one of the two strings has run out of characters. More... | |
| int16_t | General_Strnlen (const char *the_string, size_t max_len) |
| Measure the length of a fixed-size string Safe(r) strlen function: will stop processing if no terminator found before max_len reached. More... | |
| bool | General_RectWithinRect (Rectangle r1, Rectangle r2) |
| Test if one rectangle is entirely within the bounds of another Rectangle. More... | |
| void | General_CopyRect (Rectangle *r1, Rectangle *r2) |
| Copy values of one rect to another. More... | |
| int16_t | General_CalculateRectDifference (Rectangle *r1, Rectangle *r2, Rectangle *diff_r1, Rectangle *diff_r2, Rectangle *diff_r3, Rectangle *diff_r4) |
| Calculate the difference between 2 rectangles and populate 0, 1, 2, 3, or 4 new rectangles with the difference If Rect 1 is larger than Rect 2, no new rect will be populated If Rect 1 is smaller than Rect 2 in one dimension (axis) only, 1 new rect will be populated If Rect 1 is smaller than Rect 2 in two dimensions (axes), 3 new rect will be populated If Rect 1 is same size as Rect 2 and moved in one dimension (axis) only, 1 new rect will be populated If Rect 1 is same size as Rect 2 and moved in two dimensions (axes), 3 new rect will be populated. More... | |
| bool | General_CalculateRectIntersection (Rectangle *r1, Rectangle *r2, Rectangle *intersect_r) |
| Calculate the intersection between 2 rectangles, storing result in the 3rd rect passed. More... | |
| char * | General_NamePart (const char *the_file_path) |
| return the first char of the last part of a file path if no path part detected, returns the original string not guaranteed that this is a FILENAME, as if you passed a path to a dir, it would return the DIR name ex: General_NamePart("/hd/yyy/zzz/myfile.txt") would return a pointer to 'myfile.txt'. More... | |
| char * | General_PathPart (const char *the_file_path) |
| Returns a pointer to the end of the next-to-last component of a path. More... | |
| bool | General_ExtractFileExtensionFromFilename (const char *the_file_name, char *the_extension) |
| Extract file extension into the passed char pointer, as new lowercased string pointer, if any found. More... | |
| bool | General_ExtractCoreFilename (const char *the_file_name, char *the_core_part) |
| Extract core part of the file name, not including the extension. More... | |
| void | General_DelayTicks (int32_t ticks) |
| Wait for the specified number of ticks before returning In multi-tasking ever becomes a thing, this is not a multi-tasking-friendly operation. More... | |
| void | General_DelaySeconds (uint16_t seconds) |
| Wait for the specified number of seconds before returning In multi-tasking ever becomes a thing, this is not a multi-tasking-friendly operation. More... | |
| uint32_t | General_ByteSwapLong (uint32_t long_needing_swap) |
| Swap bytes big endian <> little endian, for a long NOTE: for a word, see BSWAP() macro. | |
| int16_t General_CalculateRectDifference | ( | Rectangle * | r1, |
| Rectangle * | r2, | ||
| Rectangle * | diff_r1, | ||
| Rectangle * | diff_r2, | ||
| Rectangle * | diff_r3, | ||
| Rectangle * | diff_r4 | ||
| ) |
Calculate the difference between 2 rectangles and populate 0, 1, 2, 3, or 4 new rectangles with the difference If Rect 1 is larger than Rect 2, no new rect will be populated If Rect 1 is smaller than Rect 2 in one dimension (axis) only, 1 new rect will be populated If Rect 1 is smaller than Rect 2 in two dimensions (axes), 3 new rect will be populated If Rect 1 is same size as Rect 2 and moved in one dimension (axis) only, 1 new rect will be populated If Rect 1 is same size as Rect 2 and moved in two dimensions (axes), 3 new rect will be populated.
| r1 | - the lead, or foreground rect. When calculating a damage rect, this would typically be the rect of the window after it is moved/resized. |
| r2 | - the secondary, or background rect. When calculating a damage rect, this would typically be the rect of the window before it is moved/resized. |
| diff_r1 | - valid pointer to a rect object that will be populated if there is 1 or 3 difference rects resulting from the operation |
| diff_r2 | - valid pointer to a rect object that will be populated if there are 2 or more difference rects resulting from the operation |
| diff_r3 | - valid pointer to a rect object that will be populated if there are 3 or more difference rects resulting from the operation |
| diff_r4 | - valid pointer to a rect object that will be populated if there are 4 difference rects resulting from the operation |
Calculate the intersection between 2 rectangles, storing result in the 3rd rect passed.
| r1 | - valid pointer to a rect object |
| r2 | - valid pointer to a rect object |
| intersect_r | - valid pointer to a rect object that will contain the intersection rectangle, if any, at end of operation |
Copy values of one rect to another.
| r1 | - the rectangle to be overwritten (copied into) |
| r2 | - the rectangle to copy |
| void General_DelaySeconds | ( | uint16_t | seconds | ) |
Wait for the specified number of seconds before returning In multi-tasking ever becomes a thing, this is not a multi-tasking-friendly operation.
| void General_DelayTicks | ( | int32_t | ticks | ) |
Wait for the specified number of ticks before returning In multi-tasking ever becomes a thing, this is not a multi-tasking-friendly operation.
| bool General_ExtractCoreFilename | ( | const char * | the_file_name, |
| char * | the_core_part | ||
| ) |
Extract core part of the file name, not including the extension.
| the_file_name | - the file name to extract an extension from |
| the_core_part | - a pre-allocated buffer that will contain the pre-extension part of the file name, if any is detected. Must be large enough to hold the entire file name! No bounds checking is done. If no extension is found, this will contain an empty string. |
| bool General_ExtractFileExtensionFromFilename | ( | const char * | the_file_name, |
| char * | the_extension | ||
| ) |
Extract file extension into the passed char pointer, as new lowercased string pointer, if any found.
| the_file_name | - the file name to extract an extension from |
| the_extension | - a pre-allocated buffer that will contain the extension, if any is detected. Must be large enough to hold the extension! No bounds checking is done. |
| char * General_NamePart | ( | const char * | the_file_path | ) |
return the first char of the last part of a file path if no path part detected, returns the original string not guaranteed that this is a FILENAME, as if you passed a path to a dir, it would return the DIR name ex: General_NamePart("/hd/yyy/zzz/myfile.txt") would return a pointer to 'myfile.txt'.
ex: General_NamePart("myfile.txt") would return a pointer to 'myfile.txt'. amigaDOS compatibility function (see FilePart)
| char * General_PathPart | ( | const char * | the_file_path | ) |
Returns a pointer to the end of the next-to-last component of a path.
ex: General_PathPart("/hd/yyy/zzz/myfile.txt") would return a pointer to '/myfile.txt'. ex: General_PathPart("myfile.txt") would return a pointer to 'myfile.txt'. amigaDOS compatibility function (see PathPart)
Test if one rectangle is entirely within the bounds of another Rectangle.
| r1 | - the rectangle being tested |
| r2 | - the rectangle being measured to determine if r1 fits entirely within it |
| int32_t General_Round | ( | double | the_float | ) |
Round a float to the nearest integer value THINK C's and SAS/C's math.h don't include round() from: https://stackoverflow.com/questions/4572556/concise-way-to-implement-round-in-c.
| the_float | - a double value to round up/down |
| int16_t General_Strlcat | ( | char * | dst, |
| const char * | src, | ||
| size_t | max_len | ||
| ) |
Copies up to max_len - 1 characters from the NUL-terminated string src and appends to the end of dst, NUL-terminating the result.
| src | - The string to copy |
| dst | - The string to append to. Calling function is responsible for ensuring this string is allocated, and has at least as much storage as max_len. |
| max_len | - The maximum number of bytes to use in the destination string, including the terminator. If this is shorter than the length of src + length of dst + 1, the resulting copy string will be capped at max_len - 1. |
| int16_t General_Strlcpy | ( | char * | dst, |
| const char * | src, | ||
| size_t | max_len | ||
| ) |
Copies up to max_len - 1 characters from the NUL-terminated string src to dst, NUL-terminating the result.
| src | - The string to copy |
| dst | - The string to copy into. Calling function is responsible for ensuring this string is allocated, and has at least as much storage as max_len. |
| max_len | - The maximum number of bytes to use in the destination string, including the terminator. If this is shorter than the length of the source string + 1, the resulting copy string will be capped at max_len - 1. |
| char * General_StrlcpyWithAlloc | ( | const char * | src, |
| size_t | max_len | ||
| ) |
Allocates memory for a new string and copies up to max_len - 1 characters from the NUL-terminated string src to the new string, NUL-terminating the result This is meant to be a one stop shop for getting a copy of a string.
| src | - The string to copy |
| max_len | - The maximum number of bytes to use in the destination string, including the terminator. If this is shorter than the length of the source string + 1, the resulting copy string will be capped at max_len - 1. |
| int16_t General_Strncasecmp | ( | const char * | string_1, |
| const char * | string_2, | ||
| size_t | max_len | ||
| ) |
Makes a case insensitive comparison of the specified number of characters of the two passed strings Stops processing once max_len has been reached, or when one of the two strings has run out of characters.
Inspired by code from slashdot and apple open source https://stackoverflow.com/questions/5820810/case-insensitive-string-comparison-in-c https://opensource.apple.com/source/tcl/tcl-10/tcl/compat/strncasecmp.c.auto.html
| string_1 | - the first string to compare. |
| string_2 | - the second string to compare. |
| max_len | - the maximum number of characters to compare. Even if both strings are larger than this number, only this many characters will be compared. |
| int16_t General_Strncmp | ( | const char * | string_1, |
| const char * | string_2, | ||
| size_t | max_len | ||
| ) |
Makes a case sensitive comparison of the specified number of characters of the two passed strings Stops processing once max_len has been reached, or when one of the two strings has run out of characters.
http://home.snafu.de/kdschem/c.dir/strings.dir/strncmp.c TODO: compare this to other implementations, see which is faster. eg, https://opensource.apple.com/source/Libc/Libc-167/gen.subproj/i386.subproj/strncmp.c.auto.html
| string_1 | - the first string to compare. |
| string_2 | - the second string to compare. |
| max_len | - the maximum number of characters to compare. Even if both strings are larger than this number, only this many characters will be compared. |
| int16_t General_Strnlen | ( | const char * | the_string, |
| size_t | max_len | ||
| ) |
Measure the length of a fixed-size string Safe(r) strlen function: will stop processing if no terminator found before max_len reached.
| bool General_StrToLower | ( | char * | the_string | ) |
Convert a string, in place, to lower case This overwrites the string with a lower case version of itself.
Warning: no length check is in place. Calling function must verify string is well-formed (terminated).
| the_string | - the string to convert to lower case. |
| uint8_t General_ToLower | ( | uint8_t | the_char | ) |
Change the case of the passed character from upper to lower (if necessary) Scope is limited to characters A-Z, ascii.
replacement for tolower() in c library, which doesn't seem to work [in Amiga WB2K] for some reason.