aboutsummaryrefslogtreecommitdiff
path: root/args.c
blob: 5fe2f8905d0310e8c8ef8a4a4c1bca395b044a51 (plain)
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
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <getopt.h>

#include "args.h"

void parse_args(client_state* state, int argc, char* argv[]) {
	static struct option long_opts[] = {
		{"lines", required_argument, 0, 'l'},
		{0, 0, 0, 0}
	};

    int opt;
    int long_index = 0;
	while ((opt = getopt_long(argc, argv, "l:", long_opts, &long_index)) != -1) {
		switch (opt) {
		case 'l':
			state->lines = atoi(optarg);
			break;
		default:
			fprintf(stderr, "Usage: NOT WHAT YOU TYPED\n");
			break;
		}
	}
}