dtdocbook: Coverity 86763
[oweals/cde.git] / cde / programs / dtlogin / dtchooser.c
index 9fc02da1344c524a5f2a95844935195a1c263af4..d299a26805102501764cd9961c6f0b504eaa12d2 100644 (file)
@@ -1,3 +1,25 @@
+/*
+ * CDE - Common Desktop Environment
+ *
+ * Copyright (c) 1993-2012, The Open Group. All rights reserved.
+ *
+ * These libraries and programs are free software; you can
+ * redistribute them and/or modify them under the terms of the GNU
+ * Lesser General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * These libraries and programs are distributed in the hope that
+ * they will be useful, but WITHOUT ANY WARRANTY; without even the
+ * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with these libraries and programs; if not, write
+ * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
+ * Floor, Boston, MA 02110-1301 USA
+ */
 /* $TOG: dtchooser.c /main/8 1998/04/20 12:56:18 mgreess $ */
 /*                                                                      *
  * (c) Copyright 1993, 1994 Hewlett-Packard Company                     *
@@ -67,8 +89,9 @@
 #include       "vgmsg.h"
 #include        <Dt/MenuButton.h>
 
-
-
+#ifdef USE_XINERAMA
+#include <DtXinerama.h>
+#endif
 
 
 /***************************************************************************
@@ -242,6 +265,13 @@ static
        XtRString, sizeof(char *), XtOffset(AppInfoPtr, languageList),
        XtRString, NULL                                                 },
 
+#if defined(USE_XINERAMA)
+    { "xineramaPreferredScreen",        "XineramaPreferredScreen",
+        XtRInt, sizeof(int), XtOffset(AppInfoPtr, xineramaPreferredScreen),
+        XtRImmediate, (XtPointer) 0
+        },
+#endif
+
 #if defined (ENABLE_DYNAMIC_LANGLIST)
     {"languageListCmd", "LanguageListCmd",
         XtRString, sizeof(char *), XtOffset(AppInfoPtr, languageListCmd),
@@ -286,7 +316,7 @@ MakeRootCursor( void )
 void 
 MakeBackground( void )
 {
-    register int i;
+    int i;
 
     /*
      * Get resources first
@@ -400,7 +430,7 @@ MakeBackground( void )
 void 
 MakeButtons( void )
 {
-    register int i;
+    int i;
 
     Dimension  width;
 
@@ -629,19 +659,20 @@ MakeChooser( void )
 void 
 MakeDialog( DialogType dtype )
 {
-    register int i, j;
+    int i, j;
 
     int                width;
     
-    FILE       *fp, *fopen();
+    FILE       *fp = NULL, *fopen();
     char       buffer[128];
     char       *str;
 
     Widget     w, text;
     Dimension  txt_width, txt_height;
     XmString   ok, cancel, nw, sv;
-    
-    
+
+    Widget      tlev;
+
     /*
      *  do things common to all dialogs...
      */
@@ -662,13 +693,25 @@ MakeDialog( DialogType dtype )
      *  create the various dialogs...
      */
 
+    /* JET - check the matte widget, and if non-null, well use that as
+     * the parent for dialogs.  Otherwise use table (the original
+     * toplevel widget for this func).  This is useful for Xinerama so
+     * that child dialogs are centered on the matte, and not the whole
+     * SLS screen.
+     */
+    if (matte != (Widget)NULL)
+      tlev = matte;
+    else
+      tlev = table;
+
+
     switch (dtype) {
 
     case error:
        xmstr = ReadCatalogXms(MC_ERROR_SET, MC_LOGIN, "");
        XtSetArg(argt[i], XmNmessageString,             xmstr           ); i++;
 
-       w = XmCreateErrorDialog(table, "error_message", argt, i);
+       w = XmCreateErrorDialog(tlev, "error_message", argt, i);
        XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
        XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
 
@@ -679,7 +722,7 @@ MakeDialog( DialogType dtype )
     case help:
        xmstr = ReadCatalogXms(MC_HELP_SET, MC_HELP, MC_DEF_HELP);
        XtSetArg(argt[i], XmNmessageString,             xmstr           ); i++;
-       w = XmCreateInformationDialog(table, "help_message", argt, i);
+       w = XmCreateInformationDialog(tlev, "help_message", argt, i);
        XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
         XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
 
@@ -706,13 +749,8 @@ MakeDialog( DialogType dtype )
 
     case copyright:
        if ((fp = fopen(COPYRIGHT,"r")) == NULL)
-#if defined( __hp_osf )
-           xmstr = XmStringCreate("Cannot open copyright file '/usr/X11/copyright'.",
-                               XmFONTLIST_DEFAULT_TAG);
-#else
            xmstr = XmStringCreate("Cannot open copyright file '/etc/copyright'.",
                                XmFONTLIST_DEFAULT_TAG);
-#endif
        else {
            xmstr = (XmString) NULL;
        
@@ -729,10 +767,12 @@ MakeDialog( DialogType dtype )
            }       
        }
 
-       fclose(fp);
+       if(fp) {
+               fclose(fp);
+       }
        XtSetArg(argt[i], XmNmessageString,             xmstr           ); i++;
 
-       w = XmCreateInformationDialog(table, "copyright_msg", argt, i);
+       w = XmCreateInformationDialog(tlev, "copyright_msg", argt, i);
        XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
        XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
        
@@ -752,7 +792,7 @@ MakeDialog( DialogType dtype )
        XtSetArg(argt[i], XmNokLabelString,             nw              ); i++;
        XtSetArg(argt[i], XmNcancelLabelString,         sv              ); i++;
 
-       w = XmCreateWarningDialog(table, "hostname_msg", argt, i);
+       w = XmCreateWarningDialog(tlev, "hostname_msg", argt, i);
 
        XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
 
@@ -769,7 +809,7 @@ MakeDialog( DialogType dtype )
                            MC_DEF_PASSWD_EXPIRED);
        XtSetArg(argt[i], XmNmessageString,             xmstr           ); i++;
 
-       w = XmCreateQuestionDialog(table, "password_msg", argt, i);
+       w = XmCreateQuestionDialog(tlev, "password_msg", argt, i);
 
        XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
 
@@ -780,7 +820,7 @@ MakeDialog( DialogType dtype )
     case help_chooser:
        xmstr = ReadCatalogXms(MC_HELP_SET, MC_HELP_CHOOSER, MC_DEF_HELP_CHOOSER);
 
-       w = XmCreateInformationDialog(table, "help_message", argt, i);
+       w = XmCreateInformationDialog(tlev, "help_message", argt, i);
         XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
         XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
 
@@ -987,7 +1027,7 @@ MakeOptionsMenu( void )
 static int 
 ErrorHandler( Display *dpy, XErrorEvent *event )
 {
-    return;
+    return 0;
 }