commit 7cc5710f1582faf03fb730be853e8dadbe111786
parent 585e7f267e4859388c79109b984627a556c301f3
Author: Remy Noulin <loader2x@gmail.com>
Date: Sun, 20 May 2018 10:21:26 +0200
playStdin command
package.yml | 16 ++++++++++++++++
playStdin.c | 33 +++++++++++++++++++++++++++++++++
2 files changed, 49 insertions(+)
Diffstat:
2 files changed, 49 insertions(+), 0 deletions(-)
diff --git a/package.yml b/package.yml
@@ -0,0 +1,16 @@
+---
+ name: playStdin
+ version: 0.0.1
+ description: "play recorded stdin with the commnad recordStdin. Time delays between lines are kept"
+ bin: ./playStdin.c
+ repository:
+ type: git
+ url: git+https://github.com/RemyNoulin/playStdin.git
+ keywords:
+ - utility
+ - command
+ author: Remy
+ license: MIT
+ bugs:
+ url: https://github.com/RemyNoulin/playStdin/issues
+ homepage: https://github.com/RemyNoulin/playStdin#readme
diff --git a/playStdin.c b/playStdin.c
@@ -0,0 +1,33 @@
+#! /usr/bin/env sheepy
+
+#include "libsheepyObject.h"
+
+int main(int ARGC, char** ARGV) {
+
+ if (ARGC < 2) {
+ puts(BLD RED "Missing record name!" RST);
+ XFAILURE
+ }
+
+ FILE *f = fopen(ARGV[1], "r");
+ if (!f) {
+ puts(BLD RED "Couldn't open record file!" RST);
+ XFAILURE
+ }
+
+ char b[2*1024*1024];
+ while (fgets(b, sizeof b, f)) {
+ char **l = split(b, ",");
+ char *timeS = dequeueG(&l, unusedV);
+ char *s = join(l, ",");
+ freeG(l);
+
+ printf("%s", s);
+
+ u64 time = parseInt(timeS);
+ nanoSleep(time * 1000000);
+
+ freeManyS(timeS, s);
+ }
+ fclose(f);
+}