summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--.ntcoin_freebsd_tildeguru.swp0
-rwxr-xr-xntcoin0
-rwxr-xr-xntcoin_freebsd_tildeguru0
-rwxr-xr-xntcoin_openbsd_tildeinstitute0
-rw-r--r--pcoin.cpp0
-rw-r--r--popen2.c0
-rw-r--r--popen2.h0
-rw-r--r--tcoin.cpp0
-rwxr-xr-xutils/ftc6
-rwxr-xr-xutils/message-sum-tcoin-helper-supersummary.awk179
-rwxr-xr-xutils/message-sum-tcoin-helper.awk179
-rwxr-xr-xutils/message-tcoin-converter.awk193
-rwxr-xr-xutils/mst3
-rwxr-xr-xutils/mstss3
-rwxr-xr-xutils/mtc4
-rwxr-xr-xutils/tcc (renamed from tcc)0
16 files changed, 567 insertions, 0 deletions
diff --git a/.ntcoin_freebsd_tildeguru.swp b/.ntcoin_freebsd_tildeguru.swp
new file mode 100644
index 0000000..5fcf255
--- /dev/null
+++ b/.ntcoin_freebsd_tildeguru.swp
diff --git a/ntcoin b/ntcoin
index 87ecd1e..0b87c2f 100755
--- a/ntcoin
+++ b/ntcoin
diff --git a/ntcoin_freebsd_tildeguru b/ntcoin_freebsd_tildeguru
index 178863d..24e425e 100755
--- a/ntcoin_freebsd_tildeguru
+++ b/ntcoin_freebsd_tildeguru
diff --git a/ntcoin_openbsd_tildeinstitute b/ntcoin_openbsd_tildeinstitute
index dfd4141..aae37d0 100755
--- a/ntcoin_openbsd_tildeinstitute
+++ b/ntcoin_openbsd_tildeinstitute
diff --git a/pcoin.cpp b/pcoin.cpp
index 2d5a490..18b5a0e 100644
--- a/pcoin.cpp
+++ b/pcoin.cpp
diff --git a/popen2.c b/popen2.c
new file mode 100644
index 0000000..3434d51
--- /dev/null
+++ b/popen2.c
diff --git a/popen2.h b/popen2.h
new file mode 100644
index 0000000..1805632
--- /dev/null
+++ b/popen2.h
diff --git a/tcoin.cpp b/tcoin.cpp
index cd45961..4e51d7e 100644
--- a/tcoin.cpp
+++ b/tcoin.cpp
diff --git a/utils/ftc b/utils/ftc
new file mode 100755
index 0000000..132c41d
--- /dev/null
+++ b/utils/ftc
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+#ftc -> full tcoin check
+
+
+/usr/bin/diff <(/bin/ls /home/login/tcoin/*.txt | /usr/bin/xargs -n 1 /bin/cat) <(/bin/ls /home/login/tcoin/messages/* | /usr/bin/xargs -n 1 /home/login/bin/mstss)
diff --git a/utils/message-sum-tcoin-helper-supersummary.awk b/utils/message-sum-tcoin-helper-supersummary.awk
new file mode 100755
index 0000000..a5fb27f
--- /dev/null
+++ b/utils/message-sum-tcoin-helper-supersummary.awk
@@ -0,0 +1,179 @@
+#!/usr/bin/gawk -Mf
+
+#mst.awk -> message_sum_tcoin.awk
+
+BEGIN {
+  supersummary=1
+  summary=0
+  sum=0
+  sumplus=0
+  summinus=0
+  self_user=""
+  self_user_found=0
+  FS=""
+}
+
+(NR == 1) {
+  #Determining onlyo (only other-user) from first line (see /home/login/mst)
+  if($0 ~ /^[a-zA-Z0-9_.\-]+/) {
+    if(substr($0,NF-12) == "_messages.txt") {
+      onlyo=substr($0,1,NF-13)
+    }
+    else {
+      onlyo=$0
+    }
+  }
+}
+
+(NR != 1) {
+  term=0
+  other_user=""
+  other_user_found=0
+  if ($0 == "" || $1==" ") {
+    next
+  }
+
+  for (a=1;a!=NF;a++) {
+    # other-user determination
+    if ($a == ":" && a == 25) {
+      for (b=a+1;;b++) {
+        if ($b ~ /^[a-zA-Z0-9_\-]/) {
+          for(c=b;;c++) {
+            if ($c ~ /^[^a-zA-Z0-9_\-]?$/) {
+              break
+            }
+            else {
+              other_user = ((other_user) ($c))
+            }
+          }
+          break
+        }
+      }
+      other_user_found=1
+    }
+    # self-username determination
+    else if ($a == "<" && !self_user_found) {
+      for (b=a+1;;b++) {
+        if ($b == " ") {
+          for(c=b+1;;c++) {
+            if($c ~ /^[^a-zA-Z0-9_\-]?$/) {
+              break
+            }
+            else {
+              self_user = ((self_user) ($c))
+            }
+          }
+          break
+        }
+      }
+      if (!supersummary) { print "S:", self_user }
+      self_user_found = 1
+      break
+    }
+    else if ($a == ">" && !self_user_found) {
+      for (b=a+2;;b++) {
+        if($b ~ /^[^a-zA-Z0-9_\-]?$/) {
+          break
+        }
+        else {
+          self_user = ((self_user) ($b))
+        }
+      }
+      if (!supersummary) { print "S:", self_user }
+      self_user_found = 1
+      break
+    }
+  }
+
+  if (onlyo && (onlyo != other_user)) {
+    #print other_user, "SKIPPED!"
+    next
+  }
+
+  if (self_user == other_user) {
+    #print "EQUAL USER!"
+    next
+  }
+
+  for (i=1;i!=NF;i++) {
+    if (i <= 26 && !summary && !supersummary) {
+      old_ors=ORS;ORS=""; if (!supersummary) { print $i; } ORS=old_ors
+    }
+    else if ($i == "<") {
+      for(j=i+4;;j++) {
+        if ($j == ".") {
+          l=10
+          for(k=j+1;;k++) {
+            if ($k ~ /^[^0-9]/) {
+              break
+            }
+            term = term + $k/l
+            l=l*10
+          }
+          break
+        }
+        else if ($j ~ /^[^0-9]/) {
+          break
+        }
+        else {
+          term = term*10 + $j
+        }
+      }
+      sum = sum - term;
+      summinus = summinus + term;
+      olistminus[other_user] += term;
+      olist[other_user] -= term;
+      if(!summary && !supersummary) { print -1*term, "O:", other_user }
+      next
+    }
+    else if($i == ">") {
+      multiplier=1
+      for(j=i-5;;j--) {
+        if ($j == ".") {
+          multiplier=1
+          l=1
+          for(k=j-1;;k--) {
+            if ($k ~ /^[^0-9]/) {
+              break
+            }
+            term = term + ($k)*l;
+            l=l*10
+          }
+          break
+        }
+        else if ($j ~ /^[^0-9]/) {
+          break
+        }
+        else {
+          multiplier = multiplier*10
+          term = (term + $j)/10
+        }
+      }
+      term = term * multiplier
+      sum = sum + term;
+      sumplus = sumplus + term;
+      olistplus[other_user] += term;
+      olist[other_user] += term;
+      if (!summary && !supersummary) { print 1*term, "O:", other_user }
+      next
+    }
+  }
+}
+
+END {
+  if (!supersummary)
+  {
+    print "--USERLIST-START--"
+    for (key in olist) {
+      print key, 1*olist[key], "Cr:", 1*olistplus[key], "Dr:", -1*olistminus[key]
+    }
+    print "---USERLIST-END---"
+    print "GRAND TOTAL:", 1*sum
+    print "CREDIT:", 1*sumplus
+    print "DEBIT:", -1*summinus
+  }
+  else
+  {
+    printf "%.0f\n", 100*sum
+  }
+}
diff --git a/utils/message-sum-tcoin-helper.awk b/utils/message-sum-tcoin-helper.awk
new file mode 100755
index 0000000..1f2ec4b
--- /dev/null
+++ b/utils/message-sum-tcoin-helper.awk
@@ -0,0 +1,179 @@
+#!/usr/bin/gawk -Mf
+
+#mst.awk -> message_sum_tcoin.awk
+
+BEGIN {
+  supersummary=0
+  summary=0
+  sum=0
+  sumplus=0
+  summinus=0
+  self_user=""
+  self_user_found=0
+  FS=""
+}
+
+(NR == 1) {
+  #Determining onlyo (only other-user) from first line (see /home/login/mst)
+  if($0 ~ /^[a-zA-Z0-9_.\-]+/) {
+    if(substr($0,NF-12) == "_messages.txt") {
+      onlyo=substr($0,1,NF-13)
+    }
+    else {
+      onlyo=$0
+    }
+  }
+}
+
+(NR != 1) {
+  term=0
+  other_user=""
+  other_user_found=0
+  if ($0 == "" || $1==" ") {
+    next
+  }
+
+  for (a=1;a!=NF;a++) {
+    # other-user determination
+    if ($a == ":" && a == 25) {
+      for (b=a+1;;b++) {
+        if ($b ~ /^[a-zA-Z0-9_\-]/) {
+          for(c=b;;c++) {
+            if ($c ~ /^[^a-zA-Z0-9_\-]?$/) {
+              break
+            }
+            else {
+              other_user = ((other_user) ($c))
+            }
+          }
+          break
+        }
+      }
+      other_user_found=1
+    }
+    # self-username determination
+    else if ($a == "<" && !self_user_found) {
+      for (b=a+1;;b++) {
+        if ($b == " ") {
+          for(c=b+1;;c++) {
+            if($c ~ /^[^a-zA-Z0-9_\-]?$/) {
+              break
+            }
+            else {
+              self_user = ((self_user) ($c))
+            }
+          }
+          break
+        }
+      }
+      if (!supersummary) { print "S:", self_user }
+      self_user_found = 1
+      break
+    }
+    else if ($a == ">" && !self_user_found) {
+      for (b=a+2;;b++) {
+        if($b ~ /^[^a-zA-Z0-9_\-]?$/) {
+          break
+        }
+        else {
+          self_user = ((self_user) ($b))
+        }
+      }
+      if (!supersummary) { print "S:", self_user }
+      self_user_found = 1
+      break
+    }
+  }
+
+  if (onlyo && (onlyo != other_user)) {
+    #print other_user, "SKIPPED!"
+    next
+  }
+
+  if (self_user == other_user) {
+    #print "EQUAL USER!"
+    next
+  }
+
+  for (i=1;i!=NF;i++) {
+    if (i <= 26 && !summary && !supersummary) {
+      old_ors=ORS;ORS=""; if (!supersummary) { print $i; } ORS=old_ors
+    }
+    else if ($i == "<") {
+      for(j=i+4;;j++) {
+        if ($j == ".") {
+          l=10
+          for(k=j+1;;k++) {
+            if ($k ~ /^[^0-9]/) {
+              break
+            }
+            term = term + $k/l
+            l=l*10
+          }
+          break
+        }
+        else if ($j ~ /^[^0-9]/) {
+          break
+        }
+        else {
+          term = term*10 + $j
+        }
+      }
+      sum = sum - term;
+      summinus = summinus + term;
+      olistminus[other_user] += term;
+      olist[other_user] -= term;
+      if(!summary && !supersummary) { printf "%.2f %s %s\n", -1*term, "O:", other_user }
+      next
+    }
+    else if($i == ">") {
+      multiplier=1
+      for(j=i-5;;j--) {
+        if ($j == ".") {
+          multiplier=1
+          l=1
+          for(k=j-1;;k--) {
+            if ($k ~ /^[^0-9]/) {
+              break
+            }
+            term = term + ($k)*l;
+            l=l*10
+          }
+          break
+        }
+        else if ($j ~ /^[^0-9]/) {
+          break
+        }
+        else {
+          multiplier = multiplier*10
+          term = (term + $j)/10
+        }
+      }
+      term = term * multiplier
+      sum = sum + term;
+      sumplus = sumplus + term;
+      olistplus[other_user] += term;
+      olist[other_user] += term;
+      if (!summary && !supersummary) { printf "%.2f %s %s\n", 1*term, "O:", other_user }
+      next
+    }
+  }
+}
+
+END {
+  if (!supersummary)
+  {
+    print "--USERLIST-START--"
+    for (key in olist) {
+      printf "%s %.2f %s %.2f %s %s\n", key, 1*olist[key], "Cr:", 1*olistplus[key], "Dr:", -1*olistminus[key]
+    }
+    print "---USERLIST-END---"
+    printf "%s %.2f\n", "GRAND TOTAL:", 1*sum
+    printf "%s %.2f\n", "CREDIT:", 1*sumplus
+    printf "%s %.2f\n", "DEBIT:", -1*summinus
+  }
+  else
+  {
+    printf "%d\n", 100*sum
+  }
+}
diff --git a/utils/message-tcoin-converter.awk b/utils/message-tcoin-converter.awk
new file mode 100755
index 0000000..81ea0e4
--- /dev/null
+++ b/utils/message-tcoin-converter.awk
@@ -0,0 +1,193 @@
+#!/usr/bin/awk -f
+
+#mst.awk -> message_sum_tcoin.awk
+
+BEGIN {
+  tsv=1
+  summary=0
+  sum=0
+  sumplus=0
+  summinus=0
+  self_user=""
+  self_user_found=0
+  prev_self_txn=0
+  FS=""
+}
+
+(NR == 1) {
+  #Determining onlyo (only other-user) from first line (see /home/login/mst)
+  if($0 ~ /^[a-zA-Z0-9_.\-]+/) {
+    if(substr($0,NF-12) == "_messages.txt") {
+      onlyo=substr($0,1,NF-13)
+    }
+    else {
+      onlyo=$0
+    }
+  }
+}
+
+(NR != 1) {
+  term=0
+  other_user=""
+  other_user_found=0
+  if ($0 == "" || $1==" ") {
+    if($1==" " && !prev_self_txn) {
+      i=1;
+      while($i != ":") { ++i }
+      message_user = substr($0, 5, i-10); #position (i-5) - position (5) + 1 = length of message_user, where position (i-5) is the position of the last character of message_user
+      old_ofs=OFS;OFS="";print "\n", message_user, "\t", substr($0,i+2);OFS=old_ofs;
+    }
+    next
+  }
+
+  for (a=1;a!=NF;a++) {
+    # other-user determination
+    if ($a == ":" && a == 25) {
+      for (b=a+1;;b++) {
+        if ($b ~ /^[a-zA-Z0-9_\-]/) {
+          for(c=b;;c++) {
+            if ($c ~ /^[^a-zA-Z0-9_\-]?$/) {
+              break
+            }
+            else {
+              other_user = ((other_user) ($c))
+            }
+          }
+          break
+        }
+      }
+      other_user_found=1
+    }
+    # self-username determination
+    else if ($a == "<" && !self_user_found) {
+      for (b=a+1;;b++) {
+        if ($b == " ") {
+          for(c=b+1;;c++) {
+            if($c ~ /^[^a-zA-Z0-9_\-]?$/) {
+              break
+            }
+            else {
+              self_user = ((self_user) ($c))
+            }
+          }
+          break
+        }
+      }
+      if (!tsv) { print "S:", self_user }
+      self_user_found = 1
+      break
+    }
+    else if ($a == ">" && !self_user_found) {
+      for (b=a+2;;b++) {
+        if($b ~ /^[^a-zA-Z0-9_\-]?$/) {
+          break
+        }
+        else {
+          self_user = ((self_user) ($b))
+        }
+      }
+      if (!tsv) { print "S:", self_user }
+      self_user_found = 1
+      break
+    }
+  }
+
+  if (onlyo && (onlyo != other_user)) {
+    #print other_user, "SKIPPED!"
+    next
+  }
+
+  if (self_user == other_user) {
+    prev_self_txn = 1
+    #print "EQUAL USER!"
+    next
+  }
+  else {
+    prev_self_txn = 0
+  }
+
+  for (i=1;i!=NF;i++) {
+    if (i <= 26 && !summary) {
+      if(tsv && i == 25) {
+        old_ors=ORS;ORS="";print "\t";ORS=old_ors
+      }
+      else if(tsv && i == 26) {
+        #do nothing, don't print the "space"
+      }
+      else {
+        old_ors=ORS;ORS="";print $i;ORS=old_ors
+      }
+    }
+    else if ($i == "<") {
+      for(j=i+4;;j++) {
+        if ($j == ".") {
+          l=10
+          for(k=j+1;;k++) {
+            if ($k ~ /^[^0-9]/) {
+              break
+            }
+            term = term + $k/l
+            l=l*10
+          }
+          break
+        }
+        else if ($j ~ /^[^0-9]/) {
+          break
+        }
+        else {
+          term = term*10 + $j
+        }
+      }
+      sum = sum - term;
+      summinus = summinus + term;
+      olistminus[other_user] += term;
+      olist[other_user] -= term;
+      if(!summary) { if(tsv){ old_ofs=OFS;OFS="\t"; print other_user, self_user, -1*term; OFS=old_ofs } else { print -1*term, "O:", other_user } }
+      next
+    }
+    else if($i == ">") {
+      multiplier=1
+      for(j=i-5;;j--) {
+        if ($j == ".") {
+          multiplier=1
+          l=1
+          for(k=j-1;;k--) {
+            if ($k ~ /^[^0-9]/) {
+              break
+            }
+            term = term + ($k)*l;
+            l=l*10
+          }
+          break
+        }
+        else if ($j ~ /^[^0-9]/) {
+          break
+        }
+        else {
+          multiplier = multiplier*10
+          term = (term + $j)/10
+        }
+      }
+      term = term * multiplier
+      sum = sum + term;
+      sumplus = sumplus + term;
+      olistplus[other_user] += term;
+      olist[other_user] += term;
+      if (!summary) {  if(tsv){ old_ofs=OFS;OFS="\t"; print other_user, self_user, term; OFS=old_ofs } else{ print 1*term, "O:", other_user } }
+      next
+    }
+  }
+}
+
+END {
+  if(!tsv) {
+    print "--USERLIST-START--"
+    for (key in olist) {
+      print key, 1*olist[key], "Cr:", 1*olistplus[key], "Dr:", -1*olistminus[key]
+    }
+    print "---USERLIST-END---"
+    print "GRAND TOTAL:", 1*sum
+    print "CREDIT:", 1*sumplus
+    print "DEBIT:", -1*summinus
+  }
+}
diff --git a/utils/mst b/utils/mst
new file mode 100755
index 0000000..1524ac3
--- /dev/null
+++ b/utils/mst
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+(/bin/echo "$2"; /bin/cat "$1") | /home/login/bin/message-sum-tcoin-helper.awk -
diff --git a/utils/mstss b/utils/mstss
new file mode 100755
index 0000000..d66cccf
--- /dev/null
+++ b/utils/mstss
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+(/bin/echo "$2"; /bin/cat "$1") | /home/login/bin/message-sum-tcoin-helper-supersummary.awk -
diff --git a/utils/mtc b/utils/mtc
new file mode 100755
index 0000000..ba14d90
--- /dev/null
+++ b/utils/mtc
@@ -0,0 +1,4 @@
+#!/bin/bash
+#Message Tcoin Converter
+(/bin/echo;/bin/cat "$1") | /home/login/bin/message-tcoin-converter.awk - | /bin/sed -e 'H;${x;s/\n\n/\t/g;p;};d' | /usr/bin/awk -F'\t' -v OFS='\t'  '$1 {cmd="/bin/date -d \""$1"\" +%s"; cmd | getline $1; close(cmd)} 1' -
+
diff --git a/tcc b/utils/tcc
index ac32743..ac32743 100755
--- a/tcc
+++ b/utils/tcc