summaryrefslogtreecommitdiff
path: root/main.c
blob: b90cc5b4ba696c3bf04221dfd07731b38abb8eaa (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
27
28
29
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include "handle_devices.h"

int main(int argc, char** argv)
{
	system("reset");
	setvbuf(stdout, NULL, _IONBF, BUFSIZ);
	if (argc < 2) {
		show_device_options();
	} else if (argc == 2) {
		//open and print a single event
		unsigned long long event_num;
		char *end_ptr;
		event_num = strtoull(argv[1], &end_ptr, 10); 
		print_one_event(event_num);
	} else {
	      	//open and print multiple events  
		unsigned long long arg_event_nums[argc - 1];
		char* end_ptr;
		for(int i = 1; i < argc; ++i) {
			arg_event_nums[i-1] = strtoull(argv[i], &end_ptr, 10);
		} 
		print_multiple_events(argc - 1, arg_event_nums);
	}
	return 0;
}