OSSP CVS Repository

ossp - Difference in ossp-pkg/tai/tai_lib.c versions 1.4 and 1.5
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/tai/tai_lib.c 1.4 -> 1.5

--- tai_lib.c    2002/05/01 18:48:34     1.4
+++ tai_lib.c    2002/05/29 08:32:53     1.5
@@ -239,11 +239,29 @@
 
 tai_rc_t tai_op(tai_t *tai, tai_op_t op, ...)
 {
+    tai_rc_t rc = TAI_ERR_IMP;
     va_list ap;
 
     if (tai == NULL)
         return TAI_ERR_ARG;
     va_start(ap, op); 
+    if ((op == TAI_OP_NE) || (op == TAI_OP_EQ) || (op == TAI_OP_LT) || (op == TAI_OP_LE) || (op == TAI_OP_GT) || (op == TAI_OP_GE)) {
+        tai_t *tai1, *tai2;
+        unsigned long s1, s2;
+
+        tai1 = tai;
+        tai2 = (tai_t *)va_arg(ap, void *);
+        s1 = tai1->tai_sec + (60 * tai1->tai_min) + (60 * 60 * tai1->tai_hour) + (60 * 60 * 24 * tai1->tai_yday) + (60 * 60 * 24 * 365 * tai1->tai_year) + tai1->tai_gmtoff;
+        s2 = tai2->tai_sec + (60 * tai2->tai_min) + (60 * 60 * tai2->tai_hour) + (60 * 60 * 24 * tai2->tai_yday) + (60 * 60 * 24 * 365 * tai2->tai_year) + tai2->tai_gmtoff;
+        switch (op) {
+            case TAI_OP_NE: rc = s2 != s1 ? TAI_OK: TAI_FALSE;
+            case TAI_OP_EQ: rc = s2 == s1 ? TAI_OK: TAI_FALSE;
+            case TAI_OP_LT: rc = s2 <  s1 ? TAI_OK: TAI_FALSE;
+            case TAI_OP_LE: rc = s2 <= s1 ? TAI_OK: TAI_FALSE;
+            case TAI_OP_GT: rc = s2 >  s1 ? TAI_OK: TAI_FALSE;
+            case TAI_OP_GE: rc = s2 >= s1 ? TAI_OK: TAI_FALSE;
+        }
+    }
     va_end(ap); 
-    return TAI_ERR_IMP;
+    return rc;
 }

CVSTrac 2.0.1