Bug 451504 js/src/jslock.cpp failed to compile on Solaris x86 r=igor
[wine-gecko.git] / xpfe / bootstrap / showOSAlert.cpp
blob7d0d70b02a48550e4d1989dcb506ca2317d240e1
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is Mozilla Communicator client code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
23 * Don Bragg <dbragg@netscape.com>
25 * Alternatively, the contents of this file may be used under the terms of
26 * either of the GNU General Public License Version 2 or later (the "GPL"),
27 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
39 #include <stdio.h>
40 #include <string.h>
41 #include "nscore.h"
43 //defines and includes for previous installation cleanup process
44 #if defined (XP_WIN)
45 #include <windows.h>
46 #elif defined (XP_MAC)
47 #include <Dialogs.h>
48 #include <TextUtils.h>
49 #elif defined (XP_OS2)
50 #define INCL_DOS
51 #define INCL_WIN
52 #include <os2.h>
53 #endif
55 extern "C" void ShowOSAlert(const char* aMessage);
58 // The maximum allowed length of aMessage is 255 characters!
59 void ShowOSAlert(const char* aMessage)
61 #ifdef DEBUG_dbragg
62 printf("\n****Inside ShowOSAlert ***\n");
63 #endif
65 const PRInt32 max_len = 255;
66 char message_copy[max_len+1] = { 0 };
67 PRInt32 input_len = strlen(aMessage);
68 PRInt32 copy_len = (input_len > max_len) ? max_len : input_len;
69 strncpy(message_copy, aMessage, copy_len);
70 message_copy[copy_len] = 0;
72 #if defined (XP_WIN)
73 MessageBoxA(NULL, message_copy, NULL, MB_OK | MB_ICONERROR | MB_SETFOREGROUND );
74 #elif (XP_MAC)
75 short buttonClicked;
76 StandardAlert(kAlertStopAlert, c2pstr(message_copy), nil, nil, &buttonClicked);
77 #elif defined (XP_OS2)
78 /* Set our app to be a PM app before attempting Win calls */
79 PPIB ppib;
80 PTIB ptib;
81 DosGetInfoBlocks(&ptib, &ppib);
82 ppib->pib_ultype = 3;
83 HAB hab = WinInitialize(0);
84 HMQ hmq = WinCreateMsgQueue(hmq,0);
85 WinMessageBox( HWND_DESKTOP, HWND_DESKTOP, message_copy, "", 0, MB_OK);
86 WinDestroyMsgQueue(hmq);
87 WinTerminate(hab);
88 #endif
89 // It can't hurt to display the message on the console in any case,
90 // even if we have already tried to display it in a GUI window.
91 fprintf(stdout, "%s\n", aMessage);