diff options
| author | yctct <yctct@yctct.com> | 2026-09-13 18:58:14 +0200 |
|---|---|---|
| committer | yctct <yctct@yctct.com> | 2026-09-13 18:58:14 +0200 |
| commit | 47beba686ff9d2aab63738fba7176a5235703d05 (patch) | |
| tree | f839ed36a9e9d4476fcdc59379b17903abfa35c8 /src/validate_parameters.c | |
Add all files, first commit
Diffstat (limited to 'src/validate_parameters.c')
| -rw-r--r-- | src/validate_parameters.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/validate_parameters.c b/src/validate_parameters.c new file mode 100644 index 0000000..9f09250 --- /dev/null +++ b/src/validate_parameters.c @@ -0,0 +1,30 @@ +#include "codexion.h" +# include <stdlib.h> // for atoi(), malloc() +# include <string.h> // for strlen() +# include <stdio.h> // for printf() + +int valid_params(char **argv) +{ + int i; + + if (atoi(argv[1]) < 1) + { + printf("Not enough philos\n"); + return (0); + } + i = 2; + while (i <= 7) + { + if (atoi(argv[i++]) < 0) + { + printf("Input cannot be negative\n"); + return (0); + } + } + if (strcmp(argv[8], "fifo") != 0 && strcmp(argv[8], "edf") != 0) + { + printf("Scheduler must be either 'fifo' or 'edf'\n"); + return (0); + } + return (1); +} |
