|
tico 0.1
Mechanical Watch Terminal Timegrapher
|
#include "parseargs.h"#include "config.h"#include "printing.h"#include <errno.h>#include <getopt.h>#include <limits.h>#include <math.h>#include <stdlib.h>#include <string.h>#include <unistd.h>#include <ctype.h>
Functions | |
| int | checkUIntArg (int name, unsigned int *value, const char *optArg) |
| Checks if the provided argument is a valid integer and parses it. More... | |
| int | checkFileArg (int name, FILE **filePtr, const char *optArg, const char *mode) |
| Parses command line arguments and fills the CapConfig struct. 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 one line from stdin and parses up to maxCount doubles into array. More... | |
| int | getIntsFromFile (size_t maxCount, int *arr, FILE *file) |
| Reads integers from file until EOF or maxCount is reached. More... | |
| 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.
| 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). |
| int checkUIntArg | ( | int | name, |
| unsigned int * | value, | ||
| const char * | optArg | ||
| ) |
Checks if the provided argument is a valid integer and parses it.
| 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). |
| double getDouble | ( | char * | ptr | ) |
Parses a double from a string.
| ptr | The string to parse. |
| int getDoublesFromStdin | ( | size_t | maxCount, |
| double * | arr | ||
| ) |
Reads one line from stdin and parses up to maxCount doubles into array.
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.
| int getInt | ( | char * | ptr | ) |
Parses an integer from a string.
| ptr | The string to parse. |
| int getIntsFromFile | ( | size_t | maxCount, |
| int * | arr, | ||
| FILE * | file | ||
| ) |
Reads integers from file until EOF or maxCount is reached.
| 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 |
| void parseArguments | ( | int | argc, |
| char * | argv[], | ||
| CapConfig * | cfg | ||
| ) |