Compare commits
No commits in common. "91265cc0990ac44347b78e0960a8faace24e6bcb" and "5075fb8ad89337f29d31fceea26101da9c8c576e" have entirely different histories.
91265cc099
...
5075fb8ad8
17
makefile
17
makefile
|
@ -1,17 +1,8 @@
|
|||
CC=gcc
|
||||
SRC=pomo.c
|
||||
OUT=pomo
|
||||
STYLE_BLUEPRINT=webkit
|
||||
FORMATTER=clang-format -i -style=$(STYLE_BLUEPRINT)
|
||||
|
||||
build: $(SRC)
|
||||
$(CC) $(SRC) -o $(OUT)
|
||||
build:
|
||||
gcc pomo.c -o pomo
|
||||
|
||||
install:
|
||||
cp ./$(OUT) /bin/pomo
|
||||
cp ./pomo /bin/pomo
|
||||
|
||||
lint:
|
||||
clang-tidy $(SRC) --
|
||||
|
||||
format:
|
||||
$(FORMATTER) $(SRC)
|
||||
clang-tidy pomo.c --
|
||||
|
|
15
pomo.c
15
pomo.c
|
@ -1,7 +1,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
|
||||
#define MAX_MSG_LEN 100
|
||||
#define LEN(a) (sizeof(a) / sizeof(a[0]))
|
||||
|
@ -23,8 +23,7 @@ static Timers timers[] = {
|
|||
{ 900, "Time to take a longer rest!" },
|
||||
};
|
||||
|
||||
void spawn(char* argv[])
|
||||
{
|
||||
void spawn(char *argv[]){
|
||||
if (fork() == 0) {
|
||||
// we need to fork the process so that
|
||||
// when we exit the sent screen
|
||||
|
@ -36,8 +35,7 @@ void spawn(char* argv[])
|
|||
}
|
||||
}
|
||||
|
||||
void print_time_now()
|
||||
{
|
||||
void print_time_now(){
|
||||
time_t timer;
|
||||
char buffer[26];
|
||||
struct tm* tm_info;
|
||||
|
@ -47,10 +45,10 @@ void print_time_now()
|
|||
|
||||
strftime(buffer, 26, "%Y-%m-%d %H:%M:%S", tm_info);
|
||||
fprintf(stderr, "%s", buffer);
|
||||
|
||||
}
|
||||
|
||||
void display_message(char* msg)
|
||||
{
|
||||
void display_message(char *msg){
|
||||
char sh_command[MAX_MSG_LEN];
|
||||
snprintf(sh_command, MAX_MSG_LEN, "echo '%s' | sent", msg); // NOLINT: We are being carefull here by considering MAX_MSG_LEN explicitly.
|
||||
printf("%s", sh_command);
|
||||
|
@ -65,8 +63,7 @@ void display_message(char* msg)
|
|||
fprintf(stderr, " | %s\n", msg);
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
int main(int argc, char *argv[]){
|
||||
for(int i=0; ; i = (i+1) % LEN(timers)){
|
||||
display_message(timers[i].msg);
|
||||
sleep(timers[i].t);
|
||||
|
|
Loading…
Reference in New Issue
Block a user