salinit.cxx (1a6da4ce) salinit.cxx (c99cd5fc)
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 5 unchanged lines hidden (view full) ---

14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 5 unchanged lines hidden (view full) ---

14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22#include <stdio.h>
22
23
23
24#define INCL_DOS
25#include <os2.h>
26
27#include "precompiled_sal.hxx"
28#include "sal/config.h"
29
30#include "osl/process.h"
31#include "sal/main.h"
32#include "sal/types.h"
33
24#include "sal/types.h"
25
34// for exception logging
35#include <stdio.h>
36#include <string.h>
37#include <setjmp.h>
38
26#ifdef __cplusplus
39extern "C" {
27extern "C" {
28#endif
40
41/*----------------------------------------------------------------------------*/
42
29
30/*----------------------------------------------------------------------------*/
31
43static CHAR szOOoExe[CCHMAXPATH];
44
45static FILE* APIENTRY _oslExceptOpenLogFile(VOID)
46{
47 FILE *file;
48 DATETIME DT;
49 PPIB pib;
50 PSZ slash;
51
52 // get executable fullpath
53 DosGetInfoBlocks(NULL, &pib);
54 DosQueryModuleName(pib->pib_hmte, sizeof(szOOoExe), szOOoExe);
55 // truncate to exe name
56 slash = (PSZ)strrchr( szOOoExe, '.');
57 *slash = '\0';
58 // make log path
59 strcat( szOOoExe, ".log");
60
61 file = fopen( szOOoExe, "a");
62 if (!file) { // e.g. readonly drive
63 // try again, usually C exist and is writable
64 file = fopen( "c:\\OOo.log", "a");
65 }
66 if (file) {
67 DosGetDateTime(&DT);
68 fprintf(file, "\nTrap message -- Date: %04d-%02d-%02d, Time: %02d:%02d:%02d\n",
69 DT.year, DT.month, DT.day,
70 DT.hours, DT.minutes, DT.seconds);
71 fprintf(file, "-------------------------------------------------------\n"
72 "\nAn internal error occurred (Built " __DATE__ "-" __TIME__ ").\n");
73
74 }
75
76 // ok, return handle
77 return (file);
78}
79
80/*----------------------------------------------------------------------------*/
81
82#if 0 // until exceptions restored OSL_DEBUG_LEVEL == 0
83static EXCEPTSTRUCT g_excptstruct = {0};
84#endif
85
32// replaced by macros in sal/main.h
86void SAL_CALL sal_detail_initialize(int argc, char ** argv)
87{
33void SAL_CALL sal_detail_initialize(int argc, char ** argv)
34{
88 APIRET rc = -1;
89
90#if 0 // until exceptions restored OSL_DEBUG_LEVEL == 0
91 excRegisterHooks(_oslExceptOpenLogFile, NULL, NULL, FALSE);
92
93 g_excptstruct.RegRec2.pfnHandler = (PFN)excHandlerLoud;
94 g_excptstruct.arc = DosSetExceptionHandler(
95 (PEXCEPTIONREGISTRATIONRECORD)&(g_excptstruct.RegRec2));
96
97 if (g_excptstruct.arc)
98 if (G_pfnExcHookError)
99 G_pfnExcHookError(__FILE__, __LINE__, __FUNCTION__, g_excptstruct.arc);
100 else
101 DosBeep(1000, 1000);
102 g_excptstruct.ulExcpt = setjmp(g_excptstruct.RegRec2.jmpThread);
103#endif
104
105 osl_setCommandArgs(argc, argv);
35 printf("Dead code\n");
36 exit(1);
106}
107
108void SAL_CALL sal_detail_deinitialize()
109{
37}
38
39void SAL_CALL sal_detail_deinitialize()
40{
110 APIRET rc = -1;
111
112#if 0 // until exceptions restored OSL_DEBUG_LEVEL == 0
113 rc = DosUnsetExceptionHandler((PEXCEPTIONREGISTRATIONRECORD)&(g_excptstruct.RegRec2));
114#endif
41 printf("Dead code\n");
42 exit(1);
115}
116
43}
44
117}
45#ifdef __cplusplus
46} // extern "C"
47#endif