|
|
1.1 ! root 1: #include "hdr.h" ! 2: ! 3: Time ! 4: gettime() ! 5: { ! 6: char buf[64]; ! 7: Time t; ! 8: ! 9: if(cmd(4, "timer", buf, "%c%c%c", 0x61, 0x0C, 1)){ ! 10: t.h = t.m = t.s = t.f = 0; ! 11: return(t); ! 12: } ! 13: return(atotime(buf+2)); ! 14: } ! 15: ! 16: settimer(t, who) ! 17: Time t; ! 18: { ! 19: cmd(0, "settimer", (char *)0, "%c%c%t", 0x44, who, t); ! 20: } ! 21: ! 22: timer(type) ! 23: { ! 24: char buf[64]; ! 25: Time t; ! 26: ! 27: if(cmd(4, "timer", buf, "%c%c%c", 0x61, 0x0C, type)) ! 28: return; ! 29: t = atotime(buf+2); ! 30: switch(buf[1]) ! 31: { ! 32: case 0x04: print("LTC: %T\n", t); break; ! 33: case 0x14: print("corrected LTC: %T\n", t); break; ! 34: case 0x06: print("VITC: %T\n", t); break; ! 35: case 0x00: print("TIMER-1: %T\n", t); break; ! 36: case 0x01: print("TIMER-2: %T\n", t); break; ! 37: default: print("unexpect timer return type %2.2ux\n", buf[1]); ! 38: } ! 39: } ! 40: ! 41: Time ! 42: atotime(b) ! 43: char *b; ! 44: { ! 45: #define M(x) ((((x)>>4)&0x7)*10 + ((x)&0xF)) ! 46: Time t; ! 47: ! 48: t.f = M(b[0]&0x3F); ! 49: t.s = M(b[1]); ! 50: t.m = M(b[2]); ! 51: t.h = M(b[3]); ! 52: return(t); ! 53: } ! 54: ! 55: taddfr(t, n) ! 56: register Time *t; ! 57: { ! 58: t->f += n; ! 59: if(t->f >= 30){ ! 60: t->s += t->f/30; ! 61: t->f %= 30; ! 62: if(t->s >= 60){ ! 63: t->m += t->s/60; ! 64: t->s %= 60; ! 65: if(t->m >= 60){ ! 66: t->h += t->m/60; ! 67: t->m %= 60; ! 68: } ! 69: } ! 70: } ! 71: } ! 72: ! 73: timecmp(t0, t1) ! 74: Time t0, t1; ! 75: { ! 76: register k; ! 77: ! 78: if(k = t0.h - t1.h) return(k); ! 79: if(k = t0.m - t1.m) return(k); ! 80: if(k = t0.s - t1.s) return(k); ! 81: return(t0.f - t1.f); ! 82: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.