systemSetup

system setup, configuration and dotfiles
git clone https://noulin.net/git/systemSetup.git
Log | Files | Refs | README | LICENSE

atMyHistory.c (806B)


      1 #! /usr/bin/env sheepy
      2 #include "libsheepyObject.h"
      3 #define H "~//myhistory.txt"
      4 #define HE "~//myhistoryExit.txt"
      5 #define HP "~//myhistoryPath.txt"
      6 #define HB "~//myhistory.bin"
      7 
      8 int main(int ARGC, char** ARGV) {
      9   initLibsheepy(ARGV[0]);
     10 
     11   if (not ARGV[1]) ret 0;
     12 
     13   u64 index = parseInt(ARGV[1]);
     14 
     15   cleanCharP(hbp) = expandHomeG(HB);
     16 
     17   u8 *buf = null;
     18   size_t hlen = readFile(hbp, (void**)&buf);
     19 
     20   u8 *e = buf;
     21   cleanAllocateSmallJson(a);
     22 
     23   u64 count = 1;
     24   do {
     25     u32 len = *(u32*)e;
     26     if (count == index) {
     27       cleanAllocateSmallBytes(b);
     28       o(b,set, e+4, len-8);
     29       deserialG(a, b);
     30       // a = [path,exit code, date, command]
     31       puts(getG(a, rtChar, 3));
     32       break;
     33     }
     34     e += len;
     35     inc count;
     36 
     37   } while(e < buf + hlen);
     38 
     39   ret 0;
     40 }
     41 // vim: set expandtab ts=2 sw=2: