@@ 1,20 @@
+#!/bin/sh
+
+# Absolute path to this script, e.g. /home/user/bin/foo.sh
+SCRIPT=$(readlink -f "$0")
+# Absolute path this script is in, thus /home/user/bin
+SCRIPTPATH=$(dirname "$SCRIPT")
+#echo $SCRIPTPATH
+cd $SCRIPTPATH
+
+if [ "$1" = "clean" ]
+then
+rm -drf bin
+else
+
+if [ -z ${CC+x} ]; then CC=gcc; fi
+
+mkdir -p bin
+$CC -g -O3 src/main.c -o bin/timekeep
+
+fi
@@ 1,46 @@
+#include "types.h"
+#include <unistd.h>
+#include <time.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <termios.h>
+
+struct termios orig_termios;
+void disableRawMode() {
+ tcsetattr(STDIN_FILENO, TCSAFLUSH, &orig_termios);
+}
+void enableRawMode() {
+ tcgetattr(STDIN_FILENO, &orig_termios);
+ atexit(disableRawMode);
+ struct termios raw = orig_termios;
+ raw.c_lflag &= ~(ECHO | ICANON);
+ tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw);
+}
+
+int main(s32 argc, char** argv)
+{
+ enableRawMode();
+ u8 is_going = 0;
+ while(1)
+ {
+ char character;
+ if(!read(STDIN_FILENO, &character, 1))
+ { return 1; }
+ time_t now_time = time(0);
+ if(character == 's' && !is_going)
+ {
+ fprintf(stdout, "start_time %llu\n", (u64)now_time);
+ fprintf(stderr, "start_time %llu\n", (u64)now_time);
+ is_going = 1;
+ }
+ else if(character == 'e' && is_going)
+ {
+ fprintf(stdout, "end_time %llu\n", (u64)now_time);
+ fprintf(stderr, "end_time %llu\n", (u64)now_time);
+ is_going = 0;
+ }
+ else if(character == 'q')
+ { return 0; }
+ }
+}
@@ 1,35 @@
+
+
+#ifndef __TYPES_H
+#define __TYPES_H
+
+#include <stdint.h>
+#include <float.h>
+
+typedef int8_t s8;
+typedef uint8_t u8;
+typedef int16_t s16;
+typedef uint16_t u16;
+typedef int32_t s32;
+typedef uint32_t u32;
+typedef int64_t s64;
+typedef uint64_t u64;
+
+#define S8_MIN INT8_MIN
+#define S8_MAX INT8_MAX
+#define U8_MAX UINT8_MAX
+#define S16_MIN INT16_MIN
+#define S16_MAX INT16_MAX
+#define U16_MAX UINT16_MAX
+#define S32_MIN INT32_MIN
+#define S32_MAX INT32_MAX
+#define U32_MAX UINT32_MAX
+#define S64_MIN INT64_MIN
+#define S64_MAX INT64_MAX
+#define U64_MAX UINT64_MAX
+
+typedef float f32;
+typedef double f64;
+typedef long double f128;
+
+#endif