Replace afs_ctime with strftime and friends
[openafs.git] / src / util / assert.c
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  *
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 /* ReallyAbort:  called from assert. May/85 */
11 #include <afsconfig.h>
12 #include <afs/param.h>
13
14 #include <roken.h>
15
16 #include "afsutil.h"
17
18 #ifdef AFS_NT40_ENV
19 void
20 afs_NTAbort(void)
21 {
22     DebugBreak();
23 }
24 #endif
25
26 #define TIMESTAMP_BUFFER_SIZE 26  /* including the null */
27
28 void
29 AssertionFailed(char *file, int line)
30 {
31     char tdate[TIMESTAMP_BUFFER_SIZE];
32     time_t when;
33     struct tm tm;
34
35     when = time(NULL);
36     strftime(tdate, sizeof(tdate), "%a %b %d %T %Y",
37              localtime_r(&when, &tm));
38     fprintf(stderr, "%sAssertion failed! file %s, line %d.\n", tdate, file,
39             line);
40     fflush(stderr);
41     afs_abort();
42 }