1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: salinit.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
34 #include "precompiled_sal.hxx"
35 #include "sal/config.h"
37 #include "osl/process.h"
39 #include "sal/types.h"
41 // for exception logging
45 #include "helpers/except.h"
49 /*----------------------------------------------------------------------------*/
51 static CHAR szOOoExe
[CCHMAXPATH
];
53 static FILE* APIENTRY
_oslExceptOpenLogFile(VOID
)
60 // get executable fullpath
61 DosGetInfoBlocks(NULL
, &pib
);
62 DosQueryModuleName(pib
->pib_hmte
, sizeof(szOOoExe
), szOOoExe
);
63 // truncate to exe name
64 slash
= (PSZ
)strrchr( szOOoExe
, '.');
67 strcat( szOOoExe
, ".log");
69 file
= fopen( szOOoExe
, "a");
70 if (!file
) { // e.g. readonly drive
71 // try again, usually C exist and is writable
72 file
= fopen( "c:\\OOo.log", "a");
76 fprintf(file
, "\nTrap message -- Date: %04d-%02d-%02d, Time: %02d:%02d:%02d\n",
77 DT
.year
, DT
.month
, DT
.day
,
78 DT
.hours
, DT
.minutes
, DT
.seconds
);
79 fprintf(file
, "-------------------------------------------------------\n"
80 "\nAn internal error occurred (Built " __DATE__
"-" __TIME__
").\n");
88 /*----------------------------------------------------------------------------*/
90 static EXCEPTSTRUCT g_excptstruct
= {0};
92 void SAL_CALL
sal_detail_initialize(int argc
, char ** argv
)
96 #if OSL_DEBUG_LEVEL == 0
97 excRegisterHooks(_oslExceptOpenLogFile
, NULL
, NULL
, FALSE
);
99 g_excptstruct
.RegRec2
.pfnHandler
= (PFN
)excHandlerLoud
;
100 g_excptstruct
.arc
= DosSetExceptionHandler(
101 (PEXCEPTIONREGISTRATIONRECORD
)&(g_excptstruct
.RegRec2
));
103 if (g_excptstruct
.arc
)
104 if (G_pfnExcHookError
)
105 G_pfnExcHookError(__FILE__
, __LINE__
, __FUNCTION__
, g_excptstruct
.arc
);
108 g_excptstruct
.ulExcpt
= setjmp(g_excptstruct
.RegRec2
.jmpThread
);
111 osl_setCommandArgs(argc
, argv
);
114 void SAL_CALL
sal_detail_deinitialize()
118 #if OSL_DEBUG_LEVEL == 0
119 rc
= DosUnsetExceptionHandler((PEXCEPTIONREGISTRATIONRECORD
)&(g_excptstruct
.RegRec2
));