-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.c
108 lines (93 loc) · 1.71 KB
/
client.c
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* #include "pomodoro.h" */
#include "client.h"
#define CMD_REMAINING "remaining"
#define CMD_PAUSE "pause"
#define CMD_CONTINUE "continue"
#define CMD_SKIP "skip"
#define CMD_START "start"
#define CMD_STOP "stop"
#define CMD_HELP "help"
static void usage()
{
printf("pomodoro client usage:\n");
printf("TODO\n");
exit(EXIT_SUCCESS);
}
static void cmd_unknown()
{
printf("use poc --help for more information\n");
exit(EXIT_SUCCESS);
}
static void cmd_remaining(int argc, char *argv[])
{
/* TODO */
printf("remaining\n");
exit(EXIT_SUCCESS);
}
static void cmd_pause(int argc, char *argv[])
{
/* TODO */
printf("pause\n");
exit(EXIT_SUCCESS);
}
static void cmd_continue(int argc, char *argv[])
{
/* TODO */
printf("continue\n");
exit(EXIT_SUCCESS);
}
static void cmd_skip(int argc, char *argv[])
{
/* TODO */
printf("skip\n");
exit(EXIT_SUCCESS);
}
static void cmd_start(int argc, char *argv[])
{
/* TODO */
printf("start\n");
exit(EXIT_SUCCESS);
}
static void cmd_stop(int argc, char *argv[])
{
/* TODO */
printf("stop\n");
exit(EXIT_SUCCESS);
}
int main(int argc, char *argv[])
{
if (argc < 2) {
cmd_unknown();
}
char *cmd = argv[1];
argc--;
argv++;
if (!strcmp(cmd, CMD_REMAINING)) {
cmd_remaining(argc, argv);
}
else if (!strcmp(cmd, CMD_PAUSE)) {
cmd_pause(argc, argv);
}
else if (!strcmp(cmd, CMD_CONTINUE)) {
cmd_continue(argc, argv);
}
else if (!strcmp(cmd, CMD_SKIP)) {
cmd_skip(argc, argv);
}
else if (!strcmp(cmd, CMD_START)) {
cmd_start(argc, argv);
}
else if (!strcmp(cmd, CMD_STOP)) {
cmd_stop(argc, argv);
}
else if (!strcmp(cmd, CMD_HELP)) {
usage();
}
else {
cmd_unknown();
}
return EXIT_FAILURE;
}