00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #ifndef KEY
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 #include <stdio.h>
00050 #include <stdlib.h>
00051 #include "defalias.h"
00052 #include <sys/types.h>
00053 #ifdef _BSD
00054 #include <sys/time.h>
00055 #else
00056 #include <time.h>
00057 #endif
00058
00059 extern float
00060 secnds_vms (float *start)
00061 {
00062 #ifdef _BSD
00063 struct timeval curtime;
00064 struct timezone zone;
00065 #else
00066 struct tm *t;
00067 #endif
00068
00069 time_t hms;
00070
00071 #if defined(_SYSV) || defined(_SYSTYPE_SVR4)
00072 if ((hms = time(0)) == -1)
00073 {
00074 perror("secnds");
00075 exit(99);
00076 }
00077
00078 t = localtime(&hms);
00079 return((t->tm_sec+t->tm_min*60+t->tm_hour*3600) - *start);
00080 #endif
00081
00082 #ifdef _BSD
00083 if (gettimeofday(&curtime, &zone) == -1)
00084 {
00085 perror("secnds");
00086 exit(99);
00087 }
00088 hms = (time_t) curtime.tv_sec - (time_t) zone.tz_minuteswest * 60;
00089 hms %= 86400;
00090 if ( hms<0 ) hms+= 86400;
00091 return( (float) hms + ((float) curtime.tv_usec / 1000000.0) - *start );
00092 #endif
00093
00094 #ifdef KEY
00095 if ((hms = time(0)) == -1)
00096 {
00097 perror("secnds");
00098 exit(99);
00099 }
00100 struct tm result;
00101 t = localtime_r(&hms, &result);
00102 return((t->tm_sec+t->tm_min*60+t->tm_hour*3600) - *start);
00103 #endif
00104 }
00105
00106 defalias(secnds_vms, secnds_);
00107
00108 double dsecnds_vms(start)
00109 double *start;
00110 {
00111 #ifdef _BSD
00112 struct timeval curtime;
00113 struct timezone zone;
00114 #else
00115 struct tm *t;
00116 #endif
00117
00118 time_t hms;
00119
00120 #if defined(_SYSV) || defined(_SYSTYPE_SVR4)
00121 if ((hms = time(0)) == -1)
00122 {
00123 perror("secnds");
00124 exit(99);
00125 }
00126
00127 t = localtime(&hms);
00128 return((double) (t->tm_sec+t->tm_min*60+t->tm_hour*3600) - *start);
00129 #endif
00130
00131 #ifdef _BSD
00132 if (gettimeofday(&curtime, &zone) == -1)
00133 {
00134 perror("secnds");
00135 exit(99);
00136 }
00137 hms = (time_t) curtime.tv_sec - (time_t) zone.tz_minuteswest * 60;
00138 hms %= 86400;
00139 if ( hms<0 ) hms+= 86400;
00140 return( (double) hms + ((double) curtime.tv_usec / 1000000.0) - *start );
00141 #endif
00142
00143 #ifdef KEY
00144 if ((hms = time(0)) == -1)
00145 {
00146 perror("secnds");
00147 exit(99);
00148 }
00149 struct tm result;
00150 t = localtime_r(&hms, &result);
00151 return((double) (t->tm_sec+t->tm_min*60+t->tm_hour*3600) - *start);
00152 #endif
00153 }
00154
00155 defalias(dsecnds_vms, dsecnds_);
00156
00157 #endif // KEY