Changeset 740 for vendor/current/source3/utils/net_cache.c
- Timestamp:
- Nov 14, 2012, 12:59:34 PM (13 years ago)
- File:
-
- 1 edited
-
vendor/current/source3/utils/net_cache.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source3/utils/net_cache.c
r414 r740 34 34 * Both of them are defined by first arg of gencache_iterate() routine. 35 35 */ 36 static void print_cache_entry(const char* keystr, const char* datastr,36 static void print_cache_entry(const char* keystr, , 37 37 const time_t timeout, void* dptr) 38 38 { 39 39 char *timeout_str; 40 40 char *alloc_str = NULL; 41 42 41 43 time_t now_t = time(NULL); 42 struct tm timeout_tm, *now_tm; 43 /* localtime returns statically allocated pointer, so timeout_tm 44 has to be copied somewhere else */ 45 46 now_tm = localtime(&timeout); 47 if (!now_tm) { 44 struct tm timeout_tm, now_tm; 45 struct tm *ptimeout_tm, *pnow_tm; 46 47 ptimeout_tm = localtime_r(&timeout, &timeout_tm); 48 if (ptimeout_tm == NULL) { 48 49 return; 49 50 } 50 memcpy(&timeout_tm, now_tm, sizeof(struct tm)); 51 now_tm = localtime(&now_t); 52 if (!now_tm) { 51 pnow_tm = localtime_r(&now_t, &now_tm); 52 if (pnow_tm == NULL) { 53 53 return; 54 54 } 55 55 56 56 /* form up timeout string depending whether it's today's date or not */ 57 if (timeout_tm.tm_year != now_tm ->tm_year ||58 timeout_tm.tm_mon != now_tm ->tm_mon ||59 timeout_tm.tm_mday != now_tm ->tm_mday) {57 if (timeout_tm.tm_year != now_tmtm_year || 58 timeout_tm.tm_mon != now_tmtm_mon || 59 timeout_tm.tm_mday != now_tmtm_mday) { 60 60 61 61 timeout_str = asctime(&timeout_tm); … … 72 72 } 73 73 74 75 76 77 78 79 80 81 82 83 84 85 74 86 d_printf(_("Key: %s\t Timeout: %s\t Value: %s %s\n"), keystr, 75 87 timeout_str, datastr, timeout > now_t ? "": _("(expired)")); … … 221 233 { 222 234 const char* keystr = argv[0]; 223 char* valuestr = NULL;235 ; 224 236 time_t timeout; 225 237 … … 231 243 } 232 244 233 if (gencache_get (keystr, &valuestr, &timeout)) {234 print_cache_entry(keystr, value str, timeout, NULL);235 SAFE_FREE(valuestr);245 if (gencache_get)) { 246 print_cache_entry(keystr, value, timeout, NULL); 247 ); 236 248 return 0; 237 249 } … … 261 273 262 274 pattern = argv[0]; 263 gencache_iterate (print_cache_entry, NULL, pattern);275 gencache_iterate(print_cache_entry, NULL, pattern); 264 276 return 0; 265 277 } … … 285 297 return 0; 286 298 } 287 gencache_iterate (print_cache_entry, NULL, pattern);299 gencache_iterate(print_cache_entry, NULL, pattern); 288 300 return 0; 289 301 }
Note:
See TracChangeset
for help on using the changeset viewer.
