forked from Vorago/iwb
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhandler.cpp
More file actions
65 lines (54 loc) · 1.42 KB
/
handler.cpp
File metadata and controls
65 lines (54 loc) · 1.42 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
* File: handler.cpp
* Author: vorago
*
* Created on March 1, 2011, 8:03 PM
*/
#include "include/handler.hpp"
namespace iwb {
Handler::Handler() {
}
Handler::~Handler() {
}
bool* Handler::getLoadFlag() {
return &loadFlag;
}
bool* Handler::getSaveFlag() {
return &saveFlag;
}
bool Handler::handleArguments(int argc, char* argv[], Capture **cpt, int *resWidth, int* resHeight) {
int cam;
// Argument handling block
if (argc >= 2) {
char *endptr;
cam = strtol(argv[1], &endptr, 10);
if (*endptr == '\0') {
*cpt = new Capture(cam);
} else {
*cpt = new Capture(argv[1]);
}
} else {
cam = 0;
*cpt = new Capture(cam);
}
/**
* Process resolution in second parameter.
* If none is given, use 800x600.
*/
if (argc == 3) {
char* str = argv[2];
char* pch;
pch = strchr(str, 'x');
if (pch == NULL) {
printf("Resolution which was expected in the second argument should "
"be of the form of 1024x768");
return false;
}
pch[0] = '\0';
pch++;
*resWidth = atoi(str);
*resHeight = atoi(pch);
}
return true;
}
}