]>
Commit | Line | Data |
---|---|---|
c7de829c WD |
1 | /**************************************************************************** |
2 | * | |
3 | * SciTech OS Portability Manager Library | |
4 | * | |
5 | * ======================================================================== | |
6 | * | |
7 | * The contents of this file are subject to the SciTech MGL Public | |
8 | * License Version 1.0 (the "License"); you may not use this file | |
9 | * except in compliance with the License. You may obtain a copy of | |
10 | * the License at http://www.scitechsoft.com/mgl-license.txt | |
11 | * | |
12 | * Software distributed under the License is distributed on an | |
13 | * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or | |
14 | * implied. See the License for the specific language governing | |
15 | * rights and limitations under the License. | |
16 | * | |
17 | * The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. | |
18 | * | |
19 | * The Initial Developer of the Original Code is SciTech Software, Inc. | |
20 | * All Rights Reserved. | |
21 | * | |
22 | * ======================================================================== | |
23 | * | |
24 | * Language: ANSI C | |
25 | * Environment: Any | |
26 | * | |
27 | * Description: Main module containing debug checking features. | |
28 | * | |
29 | ****************************************************************************/ | |
30 | ||
31 | #include "pmapi.h" | |
32 | #ifdef __WIN32_VXD__ | |
33 | #include "vxdfile.h" | |
34 | #elif defined(__NT_DRIVER__) | |
35 | #include "ntdriver.h" | |
36 | #elif defined(__OS2_VDD__) | |
37 | #include "vddfile.h" | |
38 | #else | |
39 | #include <stdio.h> | |
40 | #include <stdlib.h> | |
41 | #include <string.h> | |
42 | #endif | |
43 | ||
44 | /*---------------------------- Global variables ---------------------------*/ | |
45 | ||
46 | /* {secret} */ | |
47 | void (*_CHK_fail)(int fatal,const char *msg,const char *cond,const char *file,int line) = _CHK_defaultFail; | |
48 | static char logFile[256] = ""; | |
49 | ||
50 | /*----------------------------- Implementation ----------------------------*/ | |
51 | ||
52 | #ifdef CHECKED | |
53 | void _CHK_defaultFail( | |
54 | int fatal, | |
55 | const char *msg, | |
56 | const char *cond, | |
57 | const char *file, | |
58 | int line) | |
59 | { | |
60 | FILE *f; | |
61 | char buf[256]; | |
62 | ||
63 | if (logFile[0] == 0) { | |
8bde7f77 WD |
64 | strcpy(logFile,PM_getNucleusPath()); |
65 | PM_backslash(logFile); | |
66 | strcat(logFile,"scitech.log"); | |
67 | } | |
c7de829c WD |
68 | if ((f = fopen(logFile,"a+")) != NULL) { |
69 | #if defined(__WIN32_VXD__) || defined(__OS2_VDD__) || defined(__NT_DRIVER__) | |
8bde7f77 WD |
70 | sprintf(buf,msg,cond,file,line); |
71 | fwrite(buf,1,strlen(buf),f); | |
c7de829c | 72 | #else |
8bde7f77 | 73 | fprintf(f,msg,cond,file,line); |
c7de829c | 74 | #endif |
8bde7f77 WD |
75 | fclose(f); |
76 | } | |
c7de829c | 77 | if (fatal) { |
8bde7f77 WD |
78 | sprintf(buf,"Check failed: check '%s' for details", logFile); |
79 | PM_fatalError(buf); | |
80 | } | |
c7de829c WD |
81 | } |
82 | #endif | |
83 | ||
84 | /**************************************************************************** | |
85 | DESCRIPTION: | |
86 | Sets the location of the debug log file. | |
87 | ||
88 | HEADER: | |
89 | pmapi.h | |
90 | ||
91 | PARAMETERS: | |
92 | logFilePath - Full file and path name to debug log file. | |
93 | ||
94 | REMARKS: | |
95 | Sets the name and location of the debug log file. The debug log file is | |
96 | created and written to when runtime checks, warnings and failure conditions | |
97 | are logged to disk when code is compiled in CHECKED mode. By default the | |
98 | log file is called 'scitech.log' and goes into the current SciTech Nucleus | |
99 | path for the application. You can use this function to set the filename | |
100 | and location of the debug log file to your own application specific | |
101 | directory. | |
102 | ****************************************************************************/ | |
103 | void PMAPI PM_setDebugLog( | |
104 | const char *logFilePath) | |
105 | { | |
106 | strcpy(logFile,logFilePath); | |
107 | } |