1*12720SWyllys.Ingersoll@Sun.COM /*
2*12720SWyllys.Ingersoll@Sun.COM * CDDL HEADER START
3*12720SWyllys.Ingersoll@Sun.COM *
4*12720SWyllys.Ingersoll@Sun.COM * The contents of this file are subject to the terms of the
5*12720SWyllys.Ingersoll@Sun.COM * Common Development and Distribution License (the "License").
6*12720SWyllys.Ingersoll@Sun.COM * You may not use this file except in compliance with the License.
7*12720SWyllys.Ingersoll@Sun.COM *
8*12720SWyllys.Ingersoll@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*12720SWyllys.Ingersoll@Sun.COM * or http://www.opensolaris.org/os/licensing.
10*12720SWyllys.Ingersoll@Sun.COM * See the License for the specific language governing permissions
11*12720SWyllys.Ingersoll@Sun.COM * and limitations under the License.
12*12720SWyllys.Ingersoll@Sun.COM *
13*12720SWyllys.Ingersoll@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each
14*12720SWyllys.Ingersoll@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*12720SWyllys.Ingersoll@Sun.COM * If applicable, add the following below this CDDL HEADER, with the
16*12720SWyllys.Ingersoll@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying
17*12720SWyllys.Ingersoll@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner]
18*12720SWyllys.Ingersoll@Sun.COM *
19*12720SWyllys.Ingersoll@Sun.COM * CDDL HEADER END
20*12720SWyllys.Ingersoll@Sun.COM */
21*12720SWyllys.Ingersoll@Sun.COM
22*12720SWyllys.Ingersoll@Sun.COM /*
23*12720SWyllys.Ingersoll@Sun.COM * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
24*12720SWyllys.Ingersoll@Sun.COM */
25*12720SWyllys.Ingersoll@Sun.COM
26*12720SWyllys.Ingersoll@Sun.COM /**
27*12720SWyllys.Ingersoll@Sun.COM * \file KMSAgentFatalState.cpp
28*12720SWyllys.Ingersoll@Sun.COM */
29*12720SWyllys.Ingersoll@Sun.COM #include <stdio.h>
30*12720SWyllys.Ingersoll@Sun.COM #include <string.h>
31*12720SWyllys.Ingersoll@Sun.COM
32*12720SWyllys.Ingersoll@Sun.COM #include "SYSCommon.h"
33*12720SWyllys.Ingersoll@Sun.COM #include "KMSAgentStringUtilities.h"
34*12720SWyllys.Ingersoll@Sun.COM #include "KMSAuditLogger.h"
35*12720SWyllys.Ingersoll@Sun.COM
36*12720SWyllys.Ingersoll@Sun.COM #define MAX_TIME_STAMP_LENGTH 30
37*12720SWyllys.Ingersoll@Sun.COM
38*12720SWyllys.Ingersoll@Sun.COM #ifndef METAWARE
39*12720SWyllys.Ingersoll@Sun.COM /**
40*12720SWyllys.Ingersoll@Sun.COM * append the state of the application in the <KMSAgentAuditLogger> log file.
41*12720SWyllys.Ingersoll@Sun.COM */
process_fatal_application_state(const char * sFile,const char * sFunction,int iLine,const char * sAdditionalText)42*12720SWyllys.Ingersoll@Sun.COM void process_fatal_application_state(const char* sFile,
43*12720SWyllys.Ingersoll@Sun.COM const char* sFunction,
44*12720SWyllys.Ingersoll@Sun.COM int iLine,
45*12720SWyllys.Ingersoll@Sun.COM const char* sAdditionalText)
46*12720SWyllys.Ingersoll@Sun.COM {
47*12720SWyllys.Ingersoll@Sun.COM
48*12720SWyllys.Ingersoll@Sun.COM // File format: <date/time>,<operation>,<retention>,<audit id>,<network adddress>,<message>
49*12720SWyllys.Ingersoll@Sun.COM char sFileLogEntry[MAX_LOG_FILE_LINE_LENGTH];
50*12720SWyllys.Ingersoll@Sun.COM char sTimeStamp[MAX_TIME_STAMP_LENGTH];
51*12720SWyllys.Ingersoll@Sun.COM char sLine[20];
52*12720SWyllys.Ingersoll@Sun.COM
53*12720SWyllys.Ingersoll@Sun.COM GetCurrentDateTimeISO8601UTC(sTimeStamp, MAX_TIME_STAMP_LENGTH);
54*12720SWyllys.Ingersoll@Sun.COM Int64ToUTF8(sLine, iLine, false, false);
55*12720SWyllys.Ingersoll@Sun.COM
56*12720SWyllys.Ingersoll@Sun.COM strncpy(sFileLogEntry, "A fatal application error has occurred. Date: ", sizeof(sFileLogEntry));
57*12720SWyllys.Ingersoll@Sun.COM
58*12720SWyllys.Ingersoll@Sun.COM sFileLogEntry[sizeof(sFileLogEntry)-1] = '\0';
59*12720SWyllys.Ingersoll@Sun.COM
60*12720SWyllys.Ingersoll@Sun.COM strncat(sFileLogEntry, sTimeStamp, MAX_LOG_FILE_LINE_LENGTH - strlen(sFileLogEntry));
61*12720SWyllys.Ingersoll@Sun.COM
62*12720SWyllys.Ingersoll@Sun.COM strncat(sFileLogEntry, " File: ", MAX_LOG_FILE_LINE_LENGTH - strlen(sFileLogEntry));
63*12720SWyllys.Ingersoll@Sun.COM
64*12720SWyllys.Ingersoll@Sun.COM strncat(sFileLogEntry, sFile, MAX_LOG_FILE_LINE_LENGTH - strlen(sFileLogEntry));
65*12720SWyllys.Ingersoll@Sun.COM
66*12720SWyllys.Ingersoll@Sun.COM strncat(sFileLogEntry, " Function: ", MAX_LOG_FILE_LINE_LENGTH - strlen(sFileLogEntry));
67*12720SWyllys.Ingersoll@Sun.COM
68*12720SWyllys.Ingersoll@Sun.COM strncat(sFileLogEntry, sFunction, MAX_LOG_FILE_LINE_LENGTH - strlen(sFileLogEntry));
69*12720SWyllys.Ingersoll@Sun.COM
70*12720SWyllys.Ingersoll@Sun.COM strncat(sFileLogEntry, " Line: ", MAX_LOG_FILE_LINE_LENGTH - strlen(sFileLogEntry));
71*12720SWyllys.Ingersoll@Sun.COM
72*12720SWyllys.Ingersoll@Sun.COM strncat(sFileLogEntry, sLine, MAX_LOG_FILE_LINE_LENGTH - strlen(sFileLogEntry));
73*12720SWyllys.Ingersoll@Sun.COM
74*12720SWyllys.Ingersoll@Sun.COM LogToFile( 0, sFileLogEntry );
75*12720SWyllys.Ingersoll@Sun.COM
76*12720SWyllys.Ingersoll@Sun.COM exit( -1 );
77*12720SWyllys.Ingersoll@Sun.COM }
78*12720SWyllys.Ingersoll@Sun.COM
79*12720SWyllys.Ingersoll@Sun.COM #endif
80