summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorAnton Luka Šijanec <anton@sijanec.eu>2023-01-10 23:49:18 +0100
committerAnton Luka Šijanec <anton@sijanec.eu>2023-01-10 23:49:18 +0100
commit6be4125be5c6883504836a7fbc151730bdc38280 (patch)
tree394dec26f4f6d2df4d296a485b8584c9cc39fcfc /utils
parentmetadl works, but wastes bandwidth (diff)
downloadtravnik-6be4125be5c6883504836a7fbc151730bdc38280.tar
travnik-6be4125be5c6883504836a7fbc151730bdc38280.tar.gz
travnik-6be4125be5c6883504836a7fbc151730bdc38280.tar.bz2
travnik-6be4125be5c6883504836a7fbc151730bdc38280.tar.lz
travnik-6be4125be5c6883504836a7fbc151730bdc38280.tar.xz
travnik-6be4125be5c6883504836a7fbc151730bdc38280.tar.zst
travnik-6be4125be5c6883504836a7fbc151730bdc38280.zip
Diffstat (limited to 'utils')
-rw-r--r--utils/midpoint.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/utils/midpoint.c b/utils/midpoint.c
index c736143..60ad65c 100644
--- a/utils/midpoint.c
+++ b/utils/midpoint.c
@@ -4,7 +4,7 @@
int main (int argc, char ** argv) {
if (argc < 3)
- error_at_line(1, 0, __FILE__, __LINE__, "%s <bin|add|subtract|divide|midpoint> <a> [b]", S0(argv[0]));
+ error_at_line(1, 0, __FILE__, __LINE__, "%s <bin|add|subtract|divide|midpoint|closer> <a> [b] [t]", S0(argv[0]));
if (argv[1][0] == 'b' || argv[1][0] == 'B') {
unsigned char a[strlen(argv[2])/2+1];
a[strlen(argv[2])/2] = '\0';
@@ -38,6 +38,13 @@ int main (int argc, char ** argv) {
char out[41];
out[40] = '\0';
unsigned char r[20];
+ if (argv[1][0] == 'c' || argv[1][0] == 'C') {
+ if (!argv[4] || strlen(argv[4]) != 40)
+ error_at_line(4, 0, __FILE__, __LINE__, "(!t || strlen(t) != 40) && closer");
+ unsigned char t[20];
+ hex2bin(t, argv[4], 20);
+ return closer(a, b, t);
+ }
if (argv[1][0] == 'a' || argv[1][0] == 'A') {
memcpy(r, a, 20);
add(r, b);