Changeset 988 for vendor/current/lib/util/time.h
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/lib/util/time.h
r740 r988 25 25 #define _SAMBA_TIME_H_ 26 26 27 #i fndef _PUBLIC_28 # define _PUBLIC_29 # endif27 #include <stdbool.h> 28 #include <stdint.h> 29 #include <talloc.h> 30 30 31 31 #ifndef TIME_T_MIN … … 49 49 External access to time_t_min and time_t_max. 50 50 **/ 51 _PUBLIC_time_t get_time_t_max(void);51 time_t get_time_t_max(void); 52 52 53 53 /** 54 54 a gettimeofday wrapper 55 55 **/ 56 _PUBLIC_void GetTimeOfDay(struct timeval *tval);56 void GetTimeOfDay(struct timeval *tval); 57 57 58 58 /** 59 59 a wrapper to preferably get the monotonic time 60 60 **/ 61 _PUBLIC_void clock_gettime_mono(struct timespec *tp);61 void clock_gettime_mono(struct timespec *tp); 62 62 63 63 /** 64 64 a wrapper to preferably get the monotonic time in s 65 65 **/ 66 _PUBLIC_time_t time_mono(time_t *t);66 time_t time_mono(time_t *t); 67 67 68 68 /** … … 70 70 It's originally in "100ns units since jan 1st 1601" 71 71 **/ 72 _PUBLIC_time_t nt_time_to_unix(NTTIME nt);72 time_t nt_time_to_unix(NTTIME nt); 73 73 74 74 /** … … 76 76 This takes GMT as input 77 77 **/ 78 _PUBLIC_void unix_to_nt_time(NTTIME *nt, time_t t);78 void unix_to_nt_time(NTTIME *nt, time_t t); 79 79 80 80 /** 81 81 check if it's a null unix time 82 82 **/ 83 _PUBLIC_bool null_time(time_t t);83 bool null_time(time_t t); 84 84 85 85 /** 86 86 check if it's a null NTTIME 87 87 **/ 88 _PUBLIC_bool null_nttime(NTTIME t);88 bool null_nttime(NTTIME t); 89 89 90 90 /** … … 92 92 This takes GMT time and puts local time in the buffer 93 93 **/ 94 _PUBLIC_void push_dos_date(uint8_t *buf, int offset, time_t unixdate, int zone_offset);94 void push_dos_date(uint8_t *buf, int offset, time_t unixdate, int zone_offset); 95 95 96 96 /** … … 98 98 This takes GMT time and puts local time in the buffer 99 99 **/ 100 _PUBLIC_void push_dos_date2(uint8_t *buf,int offset,time_t unixdate, int zone_offset);100 void push_dos_date2(uint8_t *buf,int offset,time_t unixdate, int zone_offset); 101 101 102 102 /** … … 105 105 localtime for this sort of date) 106 106 **/ 107 _PUBLIC_void push_dos_date3(uint8_t *buf,int offset,time_t unixdate, int zone_offset);107 void push_dos_date3(uint8_t *buf,int offset,time_t unixdate, int zone_offset); 108 108 109 109 /** … … 111 111 localtime) 112 112 **/ 113 _PUBLIC_time_t pull_dos_date(const uint8_t *date_ptr, int zone_offset);113 time_t pull_dos_date(const uint8_t *date_ptr, int zone_offset); 114 114 115 115 /** 116 116 like make_unix_date() but the words are reversed 117 117 **/ 118 _PUBLIC_time_t pull_dos_date2(const uint8_t *date_ptr, int zone_offset);118 time_t pull_dos_date2(const uint8_t *date_ptr, int zone_offset); 119 119 120 120 /** … … 122 122 these generally arrive as localtimes, with corresponding DST 123 123 **/ 124 _PUBLIC_time_t pull_dos_date3(const uint8_t *date_ptr, int zone_offset);124 time_t pull_dos_date3(const uint8_t *date_ptr, int zone_offset); 125 125 126 126 /** … … 142 142 return a HTTP/1.0 time string 143 143 **/ 144 _PUBLIC_char *http_timestring(TALLOC_CTX *mem_ctx, time_t t);144 char *http_timestring(TALLOC_CTX *mem_ctx, time_t t); 145 145 146 146 /** … … 149 149 format is %a %b %e %X %Y %Z 150 150 **/ 151 _PUBLIC_char *timestring(TALLOC_CTX *mem_ctx, time_t t);151 char *timestring(TALLOC_CTX *mem_ctx, time_t t); 152 152 153 153 /** 154 154 return a talloced string representing a NTTIME for human consumption 155 155 */ 156 _PUBLIC_const char *nt_time_string(TALLOC_CTX *mem_ctx, NTTIME nt);156 const char *nt_time_string(TALLOC_CTX *mem_ctx, NTTIME nt); 157 157 158 158 /** 159 159 put a NTTIME into a packet 160 160 */ 161 _PUBLIC_void push_nttime(uint8_t *base, uint16_t offset, NTTIME t);161 void push_nttime(uint8_t *base, uint16_t offset, NTTIME t); 162 162 163 163 /** 164 164 pull a NTTIME from a packet 165 165 */ 166 _PUBLIC_NTTIME pull_nttime(uint8_t *base, uint16_t offset);166 NTTIME pull_nttime(uint8_t *base, uint16_t offset); 167 167 168 168 /** 169 169 parse a nttime as a large integer in a string and return a NTTIME 170 170 */ 171 _PUBLIC_NTTIME nttime_from_string(const char *s);171 NTTIME nttime_from_string(const char *s); 172 172 173 173 /** 174 174 return (tv1 - tv2) in microseconds 175 175 */ 176 _PUBLIC_int64_t usec_time_diff(const struct timeval *tv1, const struct timeval *tv2);176 int64_t usec_time_diff(const struct timeval *tv1, const struct timeval *tv2); 177 177 178 178 /** 179 179 return (tp1 - tp2) in nanoseconds 180 180 */ 181 _PUBLIC_int64_t nsec_time_diff(const struct timespec *tp1, const struct timespec *tp2);181 int64_t nsec_time_diff(const struct timespec *tp1, const struct timespec *tp2); 182 182 183 183 /** 184 184 return a zero timeval 185 185 */ 186 _PUBLIC_struct timeval timeval_zero(void);186 struct timeval timeval_zero(void); 187 187 188 188 /** 189 189 return true if a timeval is zero 190 190 */ 191 _PUBLIC_bool timeval_is_zero(const struct timeval *tv);191 bool timeval_is_zero(const struct timeval *tv); 192 192 193 193 /** 194 194 return a timeval for the current time 195 195 */ 196 _PUBLIC_struct timeval timeval_current(void);196 struct timeval timeval_current(void); 197 197 198 198 /** 199 199 return a timeval struct with the given elements 200 200 */ 201 _PUBLIC_struct timeval timeval_set(uint32_t secs, uint32_t usecs);201 struct timeval timeval_set(uint32_t secs, uint32_t usecs); 202 202 203 203 /** 204 204 return a timeval ofs microseconds after tv 205 205 */ 206 _PUBLIC_struct timeval timeval_add(const struct timeval *tv,206 struct timeval timeval_add(const struct timeval *tv, 207 207 uint32_t secs, uint32_t usecs); 208 208 … … 216 216 return a timeval secs/usecs into the future 217 217 */ 218 _PUBLIC_ struct timeval timeval_current_ofs(uint32_t secs, uint32_t usecs); 218 struct timeval timeval_current_ofs(uint32_t secs, uint32_t usecs); 219 220 /** 221 return a timeval milliseconds into the future 222 */ 223 struct timeval timeval_current_ofs_msec(uint32_t msecs); 224 225 /** 226 return a timeval microseconds into the future 227 */ 228 struct timeval timeval_current_ofs_usec(uint32_t usecs); 219 229 220 230 /** … … 224 234 Return 1 if tv1 > tv2 225 235 */ 226 _PUBLIC_int timeval_compare(const struct timeval *tv1, const struct timeval *tv2);236 int timeval_compare(const struct timeval *tv1, const struct timeval *tv2); 227 237 228 238 /** 229 239 return true if a timer is in the past 230 240 */ 231 _PUBLIC_bool timeval_expired(const struct timeval *tv);241 bool timeval_expired(const struct timeval *tv); 232 242 233 243 /** 234 244 return the number of seconds elapsed between two times 235 245 */ 236 _PUBLIC_double timeval_elapsed2(const struct timeval *tv1, const struct timeval *tv2);246 double timeval_elapsed2(const struct timeval *tv1, const struct timeval *tv2); 237 247 238 248 /** 239 249 return the number of seconds elapsed since a given time 240 250 */ 241 _PUBLIC_ double timeval_elapsed(const struct timeval *tv); 251 double timeval_elapsed(const struct timeval *tv); 252 253 /** 254 return the number of seconds elapsed between two times 255 */ 256 double timespec_elapsed2(const struct timespec *ts1, 257 const struct timespec *ts2); 258 /** 259 return the number of seconds elapsed since a given time 260 */ 261 double timespec_elapsed(const struct timespec *ts); 242 262 243 263 /** 244 264 return the lesser of two timevals 245 265 */ 246 _PUBLIC_struct timeval timeval_min(const struct timeval *tv1,266 struct timeval timeval_min(const struct timeval *tv1, 247 267 const struct timeval *tv2); 248 268 … … 250 270 return the greater of two timevals 251 271 */ 252 _PUBLIC_struct timeval timeval_max(const struct timeval *tv1,272 struct timeval timeval_max(const struct timeval *tv1, 253 273 const struct timeval *tv2); 254 274 … … 258 278 (this is *tv2 - *tv1) 259 279 */ 260 _PUBLIC_struct timeval timeval_until(const struct timeval *tv1,280 struct timeval timeval_until(const struct timeval *tv1, 261 281 const struct timeval *tv2); 262 282 … … 264 284 convert a timeval to a NTTIME 265 285 */ 266 _PUBLIC_NTTIME timeval_to_nttime(const struct timeval *tv);286 NTTIME timeval_to_nttime(const struct timeval *tv); 267 287 268 288 /** 269 289 convert a NTTIME to a timeval 270 290 */ 271 _PUBLIC_void nttime_to_timeval(struct timeval *tv, NTTIME t);291 void nttime_to_timeval(struct timeval *tv, NTTIME t); 272 292 273 293 /** 274 294 return the UTC offset in seconds west of UTC, or 0 if it cannot be determined 275 295 */ 276 _PUBLIC_int get_time_zone(time_t t);296 int get_time_zone(time_t t); 277 297 278 298 /** … … 283 303 void interpret_dos_date(uint32_t date,int *year,int *month,int *day,int *hour,int *minute,int *second); 284 304 285 struct timespec nt_time_to_unix_timespec(NTTIME *nt);305 struct timespec nt_time_to_unix_timespec(NTTIME nt); 286 306 287 307 time_t convert_timespec_to_time_t(struct timespec ts); … … 291 311 bool null_timespec(struct timespec ts); 292 312 293 /** Extra minutes to add to the normal GMT to local time conversion. */ 294 extern int extra_time_offset; 313 struct timespec convert_timeval_to_timespec(const struct timeval tv); 314 struct timeval convert_timespec_to_timeval(const struct timespec ts); 315 struct timespec timespec_current(void); 316 struct timespec timespec_min(const struct timespec *ts1, 317 const struct timespec *ts2); 318 int timespec_compare(const struct timespec *ts1, const struct timespec *ts2); 319 void round_timespec_to_sec(struct timespec *ts); 320 void round_timespec_to_usec(struct timespec *ts); 321 NTTIME unix_timespec_to_nt_time(struct timespec ts); 295 322 296 323 #endif /* _SAMBA_TIME_H_ */
Note:
See TracChangeset
for help on using the changeset viewer.