|
NCBI Home IEB Home C Toolkit docs C++ Toolkit source browser C Toolkit source browser (2) |
NCBI C Toolkit Cross ReferenceC/vibrant/diagnost.c |
source navigation diff markup identifier search freetext search file search |
1 /* diagnost.c
2 * ===========================================================================
3 *
4 * PUBLIC DOMAIN NOTICE
5 * National Center for Biotechnology Information (NCBI)
6 *
7 * This software/database is a "United States Government Work" under the
8 * terms of the United States Copyright Act. It was written as part of
9 * the author's official duties as a United States Government employee and
10 * thus cannot be copyrighted. This software/database is freely available
11 * to the public for use. The National Library of Medicine and the U.S.
12 * Government do not place any restriction on its use or reproduction.
13 * We would, however, appreciate having the NCBI and the author cited in
14 * any work or product based on this material
15 *
16 * Although all reasonable efforts have been taken to ensure the accuracy
17 * and reliability of the software and data, the NLM and the U.S.
18 * Government do not and cannot warrant the performance or results that
19 * may be obtained by using this software or data. The NLM and the U.S.
20 * Government disclaim all warranties, express or implied, including
21 * warranties of performance, merchantability or fitness for any particular
22 * purpose.
23 *
24 * ===========================================================================
25 *
26 * File Name: diagnost.c
27 *
28 * Author: Alex Smirnov
29 *
30 * Version Creation Date: 03/29/95
31 *
32 * $Revision: 6.1 $
33 *
34 * File Description:
35 *
36 * Modifications:
37 * --------------------------------------------------------------------------
38 * Date Name Description of modification
39 * ------- ---------- -----------------------------------------------------
40 *
41 * ==========================================================================
42 */
43
44 #include <vibrant.h>
45 #ifndef _PDIAGNOS_
46 #include <pdiagnos.h>
47 #endif
48
49 /*****************************************************************************
50 *
51 * LOCAL VARIABLE
52 *
53 *****************************************************************************/
54 static Nlm_DiagArea diagArea;
55
56 /*****************************************************************************
57 *
58 * EXTERN FUNCTION
59 *
60 *****************************************************************************/
61 void Nlm_DiagReset ( void )
62 {
63 diagArea.total = (Uint2)0;
64 diagArea.hasErrorRec = 0;
65 }
66
67 void Nlm_DiagPutRecord ( Int1 recordType,
68 CharPtr className, CharPtr functionName,
69 CharPtr msg )
70 {
71 CharPtr daMsg;
72 Int2 i, pos;
73
74 switch ( recordType ) {
75 case DA_ERROR:
76 diagArea.hasErrorRec = 1;
77 case DA_WARNING:
78 break;
79 default:
80 return;
81 }
82 i = (Int2)diagArea.total;
83 if ( i == NLM_DDA_SIZE ) i--;
84 diagArea.total = (Uint2)(i+1);
85 diagArea.records[i].recordType = recordType;
86 daMsg = &(diagArea.records[i].recordStr[0]);
87 *daMsg = daMsg[NLM_DDA_MSGLEN - 1 ] = (Char)0;
88 pos = 0;
89 if ( className != NULL ){
90 StringNCpy_0 ( &(diagArea.records[i].recordStr[pos]), className,
91 NLM_DDA_MSGLEN - pos - 1 );
92 pos = (Int2)StringLen ( &(diagArea.records[i].recordStr[0]) );
93 if ( pos == (NLM_DDA_MSGLEN - 1) ) return;
94 StringCpy ( &(diagArea.records[i].recordStr[pos]), ":");
95 pos++;
96 }
97 if ( (functionName != NULL) && (pos < (NLM_DDA_MSGLEN-1)) ){
98 StringNCpy_0 ( &(diagArea.records[i].recordStr[pos]), functionName,
99 NLM_DDA_MSGLEN - pos - 1 );
100 pos = (Int2)StringLen ( &(diagArea.records[i].recordStr[0]) );
101 if ( pos == (NLM_DDA_MSGLEN - 1) ) return;
102 StringCpy ( &(diagArea.records[i].recordStr[pos]), ":");
103 pos++;
104 }
105 if ( (msg != NULL) && (pos < (NLM_DDA_MSGLEN-1)) ){
106 StringNCpy_0 ( &(diagArea.records[i].recordStr[pos]), msg,
107 NLM_DDA_MSGLEN - pos - 1 );
108 }
109 }
110
111 Uint1 Nlm_DiagGetRecordCount ( void )
112 {
113 return (Uint1)(diagArea.total);
114 }
115
116 Boolean Nlm_DiagHasErrorRec ( void )
117 {
118 if ( diagArea.hasErrorRec ) return TRUE;
119 return FALSE;
120 }
121
122 Int1 Nlm_DiagGetRecordType ( Uint1 recordIndex )
123 {
124 if ( recordIndex < (Uint1)(diagArea.total) ){
125 return diagArea.records[recordIndex].recordType;
126 }
127 return DA_NONE;
128 }
129
130 CharPtr Nlm_DiagGetRecordStr ( Uint1 recordIndex )
131 {
132 if ( recordIndex < (Uint1)(diagArea.total) ){
133 return &(diagArea.records[recordIndex].recordStr[0]);
134 }
135 return NULL;
136 }
137
138 |
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more information. |