-
Notifications
You must be signed in to change notification settings - Fork 0
/
args.h
36 lines (31 loc) · 828 Bytes
/
args.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#pragma once
/**
* @file args.h
* @brief Parsing argv options. This is required only from week 10.
*
* @author Valérian Rousset
*/
#include <stddef.h> // for size_t
/**
* @brief containt parsed arguments
*/
typedef struct{
size_t N;
size_t W;
size_t R;
} args_t;
/**
* @brief enum for the supported_args flag of parse_opt_args
*/
typedef enum {
TOTAL_SERVERS = 1 << 0,
GET_NEEDED = 1 << 1,
PUT_NEEDED = 1 << 2
} args_kind;
/**
* @brief parse optional arguments
* @param supported_args OR'ed flags of supported options
* @param rem_argv ref to array of string to check for argument, with last elem == NULL
* @return malloc'ed user inputed values, default when not set, or NULL altogether, when an error occured
*/
args_t *parse_opt_args(size_t supported_args, char ***rem_argv);