Go to the source code of this file.
|
| int | checkFileArg (int name, FILE **filePtr, const char *optArg, const char *mode) |
| | Parses command line arguments and fills the CapConfig struct. More...
|
| |
| int | checkUIntArg (int name, unsigned int *value, const char *optArg) |
| | Checks if the provided argument is a valid integer and parses it. More...
|
| |
| void | parseArguments (int argc, char *argv[], CapConfig *cfg) |
| | Parses command line arguments and fills the CapConfig struct. More...
|
| |
| int | getInt (char *ptr) |
| | Parses an integer from a string. More...
|
| |
| double | getDouble (char *ptr) |
| | Parses a double from a string. More...
|
| |
| int | getDoublesFromStdin (size_t maxCount, double *arr) |
| | Reads doubles from standard input until EOF or maxCount is reached. More...
|
| |
| int | getIntsFromFile (size_t maxCount, int *arr, FILE *file) |
| | Reads integers from file until EOF or maxCount is reached. More...
|
| |
◆ checkFileArg()
| int checkFileArg |
( |
int |
name, |
|
|
FILE ** |
filePtr, |
|
|
const char * |
optArg, |
|
|
const char * |
mode |
|
) |
| |
Parses command line arguments and fills the CapConfig struct.
Also provides utility functions for checking and parsing arguments.
Checks if the provided argument is a valid file and opens it.
- Parameters
-
| name | The name of the argument (for error messages). |
| filePtr | Pointer to a FILE* that will be set to the opened file. |
| optArg | The argument string to check (should be a filename). |
| mode | The mode to open the file (e.g., "r" for read, "w" for write). |
- Returns
- 0 on success, non-zero on failure.
◆ checkUIntArg()
| int checkUIntArg |
( |
int |
name, |
|
|
unsigned int * |
value, |
|
|
const char * |
optArg |
|
) |
| |
Checks if the provided argument is a valid integer and parses it.
- Parameters
-
| name | The name of the argument (for error messages). |
| value | Pointer to an int that will be set to the parsed value. |
| optArg | The argument string to check (should be an integer). |
- Returns
- 0 on success, non-zero on failure.
◆ getDouble()
| double getDouble |
( |
char * |
ptr | ) |
|
Parses a double from a string.
- Parameters
-
- Returns
- The parsed double value.
◆ getDoublesFromStdin()
| int getDoublesFromStdin |
( |
size_t |
maxCount, |
|
|
double * |
arr |
|
) |
| |
Reads doubles from standard input until EOF or maxCount is reached.
- Parameters
-
| maxCount | The maximum number of doubles to read. |
| arr | Pointer to an array where the read doubles will be stored. |
- Returns
- The number of doubles successfully read.
Reads doubles from standard input until EOF or maxCount is reached.
Returns the number of doubles stored (>=0), or -1 on I/O/memory error.
◆ getInt()
Parses an integer from a string.
- Parameters
-
- Returns
- The parsed integer value.
◆ getIntsFromFile()
| int getIntsFromFile |
( |
size_t |
maxCount, |
|
|
int * |
arr, |
|
|
FILE * |
file |
|
) |
| |
Reads integers from file until EOF or maxCount is reached.
- Parameters
-
| maxCount | The maximum number of integers to read. |
| arr | Pointer to an array where the read integers will be stored. |
| file | Pointer to read integers from |
- Returns
- The number of integers successfully read.
◆ parseArguments()
| void parseArguments |
( |
int |
argc, |
|
|
char * |
argv[], |
|
|
CapConfig * |
cfg |
|
) |
| |
Parses command line arguments and fills the CapConfig struct.
- Parameters
-
| argc | The number of command line arguments. |
| argv | The array of command line argument strings. |
| cfg | Pointer to a CapConfig struct that will be filled with the parsed configuration. |