Go to the source code of this file.
Detailed Description
Miscellaneous functions.
Definition in file misc.c.
Function Documentation
| void browser_open |
( |
const char * |
url | ) |
|
Opens an url in the system's default browser.
- Parameters:
-
Definition at line 156 of file misc.c.
| void convert_newline |
( |
char * |
str | ) |
|
Replaces "\n" by a newline char.
Since we are replacing 2 chars by 1, no overflow should happen.
- Parameters:
-
| line | Text to replace into. |
Definition at line 140 of file misc.c.
| unsigned long isqrt |
( |
unsigned long |
n | ) |
|
Computes the integer square root.
- Parameters:
-
| n | Number of which to compute the root. |
- Returns:
- Integer square root.
Definition at line 36 of file misc.c.
| char* package_get_version_full |
( |
char * |
dst, |
|
|
size_t |
dstlen |
|
) |
| |
Get the full package version as string.
If patch version is 0, it will not be appended to the version string.
- Parameters:
-
| dst | Where to store the version. |
| dstlen | Size of dst. |
- Returns:
- 'dst'.
Definition at line 208 of file misc.c.
| char* package_get_version_partial |
( |
char * |
dst, |
|
|
size_t |
dstlen |
|
) |
| |
Get the partial package version. This means that the patch version will not be included, even if it's not 0.
- Parameters:
-
| dst | Where to store the version. |
| dstlen | Size of dst. |
- Returns:
- 'dst'
Definition at line 224 of file misc.c.
| void* reallocz |
( |
void * |
ptr, |
|
|
size_t |
old_size, |
|
|
size_t |
new_size |
|
) |
| |
Like realloc(), but if more bytes are being allocated, they get set to 0 using memset().
- Parameters:
-
| ptr | Original pointer. |
| old_size | Size of the pointer. |
| new_size | New size the pointer should have. |
- Returns:
- Resized pointer, NULL on failure.
Definition at line 123 of file misc.c.
| int rndm |
( |
int |
min, |
|
|
int |
max |
|
) |
| |
Calculates a random number between min and max.
It is suggested one uses this function rather than RANDOM()%, as it would appear that a number of off-by-one-errors exist due to improper use of %.
This should also prevent SIGFPE.
- Parameters:
-
| min | Starting range. |
| max | Ending range. |
- Returns:
- The random number.
Definition at line 190 of file misc.c.
| size_t split_string |
( |
char * |
str, |
|
|
char * |
array[], |
|
|
size_t |
array_size, |
|
|
char |
sep |
|
) |
| |
Splits a string delimited by passed in sep value into characters into an array of strings.
- Parameters:
-
| str | The string to be split; will be modified. |
| array | The string array; will be filled with pointers into str. |
| array_size | The number of elements in array; if str contains more fields excess fields are not split but included into the last element. |
| sep | Separator to use. |
- Returns:
- The number of elements found; always less or equal to
array_size.
Definition at line 72 of file misc.c.