libDtSearch: Coverity 86579
[oweals/cde.git] / cde / programs / dtfile / Main.c
index 0a4c5cddce022fad45f81d05208e1c2b3137d44a..4943a5f65305fbdabea037933158644df5fc5f62 100644 (file)
@@ -16,7 +16,7 @@
  * details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with these librararies and programs; if not, write
+ * 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
  */
 #include <sys/stat.h>
 #include <signal.h>
 
-#ifdef __osf__
+#if defined(CSRG_BASED)
 #include <sys/wait.h>
-#endif /* __osf__ */
+#endif /* CSRG_BASED */
 
 #include <errno.h>
 #include <pwd.h>
 #include <Xm/RowColumn.h>
 #include <Xm/MwmUtil.h>
 
+#include <Xm/IconFileP.h>
 #include <Dt/Icon.h>
 #include <Dt/IconP.h>
 #include <Dt/IconFile.h>
 #include <X11/Shell.h>
 #include <X11/Xatom.h>
 #include <Xm/Protocols.h>
-#include <X11/keysymdef.h>
 #ifdef HAVE_EDITRES
 #include <X11/Xmu/Editres.h>
 #endif
 #include <Dt/Session.h>
+#include <Dt/Dt.h>
 #include <Dt/DtP.h>
 #include <Dt/Connect.h>
 #include <Dt/FileM.h>
 #include <Dt/CommandM.h>
 #include <Dt/EnvControlP.h>
 #include <Dt/Dts.h>
+#include <Dt/SharedProcs.h>
 
 #include "Encaps.h"
 #include "SharedProcs.h"
 #include "Find.h"
 #include "ModAttr.h"
 
+/* From Command.c */
+extern void MoveCopyLinkHandler(Tt_message ttMsg, int opType);
+
+/* From Desktop.c */
+extern void PutOnWorkspaceHandler(Tt_message ttMsg);
+
+/* From Filter.c */
+extern void UpdateFilterAfterDBReread (DialogData * dialog_data);
+
+/* From ToolTalk.c */
+extern int InitializeToolTalkSession( Widget topLevel, int ttFd );
+extern Tt_status InitializeToolTalkProcid( int *ttFd, Widget topLevel, Boolean sendStarted );
+extern void FinalizeToolTalkSession();
+/* From Trash.c */
+void CloseTrash(Widget w, XtPointer client_data, XtPointer call_data) ;
+
+
+
 /* When openDir resource is set to NEW
    File Manager will use this prefix to find for a different icon
    to display.
@@ -955,9 +975,9 @@ XtActionsRec actionTable[] = {
 
 extern XtInputId ProcessToolTalkInputId;
 
-#ifdef __osf__
+#if defined(CSRG_BASED)
 extern void sigchld_handler(int);
-#endif /* __osf__ */
+#endif /* CSRG_BASED */
 
 int
 main(
@@ -971,14 +991,13 @@ main(
    struct timeval update_time_fs;
 #endif
    struct passwd * pw;
-   char current_directory[MAX_PATH];
+   char current_directory[MAX_PATH] = {0};
    struct passwd * pwInfo;
    char * homeDir;
    XEvent event;
    XtInputMask pending;
    Boolean eventDebugging;
    int offset;
-   KeySym keysym;
    int displayHeight;
    int displayWidth;
    Arg args[10];
@@ -1000,9 +1019,9 @@ main(
    Tt_pattern requests2Handle;
    Tt_message msg;
    Tt_status status;
-#ifdef __osf__
+#if defined(CSRG_BASED)
    struct sigaction sa, osa;
-#endif /* __osf__ */
+#endif /* CSRG_BASED */
    int session_flag = 0;
 
 #ifdef DT_PERFORMANCE
@@ -1012,7 +1031,7 @@ main(
    (void) signal (SIGINT, (void (*)())Stop);
 
    /* We don't want any zombie children, do we? */
-#ifdef __osf__
+#if defined(CSRG_BASED)
     sa.sa_handler = sigchld_handler;
     sigemptyset(&sa.sa_mask);
     sa.sa_flags   =  0;
@@ -1022,7 +1041,7 @@ main(
         ;
 #else
    (void) signal (SIGCHLD, SIG_IGN);
-#endif /* __osf__ */
+#endif /* CSRG_BASED */
    XtSetLanguageProc( NULL, NULL, NULL );
 
 #ifdef DT_PERFORMANCE
@@ -1050,12 +1069,6 @@ _DtPerfChkpntMsgSend("Begin XtInitialize");
                             option_list, XtNumber(option_list),
                             (int *)&argc, argv);
 
-/* MERGE START: May not need
-#ifdef __osf__
-   _XmColorObjCreate ( toplevel, NULL, NULL );
-#endif
-*/
-
 #ifdef DT_PERFORMANCE
    gettimeofday(&update_time_f, NULL);
    if (update_time_s.tv_usec > update_time_f.tv_usec) {
@@ -1626,7 +1639,7 @@ _DtPerfChkpntMsgSend("Begin XtInitialize");
    mod_attr_dialog = _DtInstallDialog (modAttrClass, True, True);
    help_dialog = _DtInstallDialog (helpClass, False, False);
 
-   if(special_view == True && special_restricted != NULL);
+   if(special_view == True && special_restricted != NULL) {
       if(strncmp(special_restricted, "~", 1) == 0)
       {
          char *ptr, *ptr1;
@@ -1637,6 +1650,7 @@ _DtPerfChkpntMsgSend("Begin XtInitialize");
          if(ptr1[0] == '\0')
             *ptr = '\0';
       }
+   }
 
    /* Setup the settings file if any to setup */
    RestoreSettingsFile();
@@ -1684,7 +1698,7 @@ _DtPerfChkpntMsgSend("Begin XtInitialize");
    /* go build 10 desktop windows */
    desktop_data = NULL;
    InitializeDesktopWindows(10, display);
-   InitializeDesktopGrid();
+   InitializeDesktopGrid(displayWidth, displayHeight);
 
    LoadDesktopInfo(application_args.session);
 
@@ -2016,7 +2030,7 @@ RestoreSettingsFile( void )
   else
   {
     XtFree(dtPath);
-    return;  /* we are comming up in a system mode (e.g. default) */
+    return;  /* we are coming up in a system mode (e.g. default) */
   }
 
 
@@ -2564,9 +2578,9 @@ SaveSession(
 {
    static char * name_list[] = { DTFILE_CLASS_NAME, NULL, NULL, NULL,
                                  NULL, NULL};
-   char view_number[5];
+   char view_number[11];
    char number[5];
-   char workspaceNumber[5];
+   char workspaceNumber[11];
    int fd;
    Atom * ws_presence = NULL;
    char * workspace_name=NULL;
@@ -2971,8 +2985,8 @@ RestoreSession(
    char * full_path = NULL;
    Boolean status=False;
    char * temp = NULL;
-   char wsNum[5];
-   char dialogNum[5];
+   char wsNum[11];
+   char dialogNum[11];
    int num_sec_help_dialogs;
    int i;
    int j;
@@ -2988,7 +3002,7 @@ RestoreSession(
       status = DtSessionRestorePath(toplevel, &full_path, path);
 
       if (!status)
-         return;
+         return(-1);
 
       if (stat(full_path, &stat_buf) != 0)
       {
@@ -3206,7 +3220,7 @@ LoadViews (
    XrmRepresentation rep_type;
    XrmValue value;
    static char * name_list[] = { DTFILE_CLASS_NAME, NULL, NULL };
-   char view_number[5];
+   char view_number[11];
    DialogData * dialog_data;
    FileMgrData * file_mgr_data;
    char * workspaces;
@@ -3400,17 +3414,16 @@ static void
 GetPWD(
         char current_directory[] )
 {
-   FILE * pwd_file;
-   register int i;
+   FILE * pwd_file = NULL;
+   int i = 0;
 
     /*  Open a pwd process and read the current working directory  */
     /*  from it.  If the open fails or a read fails, then display  */
     /*  the users home directory.                                  */
 
       pwd_file = popen ("pwd", "r");
-      i = 0;
 
-      if (pwd_file != NULL)
+      if (pwd_file)
       {
          while (1)
          {
@@ -3429,9 +3442,11 @@ GetPWD(
             i++;
          }
       }
-    (void) pclose (pwd_file);
-    current_directory[i] = '\0';
 
+      if (pwd_file)
+          pclose (pwd_file);
+
+      current_directory[i] = '\0';
 }
 
 /************************************************************************
@@ -3905,8 +3920,8 @@ void
 CloseView(
         DialogData *dialog_data )
 {
-   register int i;
-   register int j;
+   int i;
+   int j;
    FileMgrData * file_mgr_data;
    DialogData * tmpDialog_data;
    FileMgrRec * file_mgr_rec;
@@ -4393,7 +4408,7 @@ ViewDirectoryProc(
             XtFree(errTitle);
             XtFree(errMsg);
             XtFree(dmsg);
-            return;
+            return NULL;
          }
       }
    }
@@ -4454,7 +4469,7 @@ static void
 ViewHomeDirectoryHandler(
    Tt_message msg)
 {
-   register int i, j, k;
+   int i, j, k;
    struct passwd * pwInfo;
    char * homeDir;
    char * tmp_path;
@@ -4632,7 +4647,7 @@ static void
 ViewToolsDirectoryHandler(
    Tt_message msg)
 {
-   register int i;
+   int i;
    char * tmp_path = NULL;
    char * tool_dir = NULL;
    char * msgFile = NULL;
@@ -5124,7 +5139,7 @@ CleanUp (
    XRectangle textExtent;
    Position x, y;
 
-   if ((int) client_data == FM_POPUP)
+   if ((int)(XtArgVal) client_data == FM_POPUP)
      mbar = XtParent(w);
    else
      mbar = XmGetPostedFromWidget(XtParent(w));
@@ -5418,9 +5433,8 @@ static unsigned char
         unsigned char **ppchNext)
 {
     unsigned char *pchR = pchIn;
-    register int   i;
-#ifdef MULTIBYTE
-    register int   chlen;
+    int   i;
+    int   chlen;
 
     for (i = 0; ((chlen = mblen ((char *)pchIn, MB_CUR_MAX)) > 0); i++)
     /* find end of word: requires singlebyte whitespace terminator */
@@ -5432,19 +5446,8 @@ static unsigned char
         pchIn += chlen;
     }
 
-#else
-    for (i = 0; *pchIn && !isspace (*pchIn); i++, pchIn++)
-    /* find end of word */
-    {
-    }
-#endif
-
     /* skip to next word */
-#ifdef MULTIBYTE
     while (pchIn && (mblen ((char *)pchIn, MB_CUR_MAX) == 1) && isspace (*pchIn))
-#else
-    while (pchIn && isspace (*pchIn))
-#endif
     {
         *pchIn++;
     }
@@ -5992,9 +5995,9 @@ ForceMyIconClosed (
    char * host_name,
    char * directory_name)
 {
-   register int i;
-   register int j;
-   register int k;
+   int i;
+   int j;
+   int k;
    Arg args[1];
    FileViewData * file_view_data = NULL;
    DialogData *dialog_data;
@@ -6272,7 +6275,7 @@ FinalizeToolTalkSession();
 exit (1);
 }
 
-#ifdef __osf__
+#if defined(CSRG_BASED)
 extern void
 sigchld_handler(int signo)      /* Do not use the arg signo at the moment */
 {
@@ -6287,4 +6290,4 @@ sigchld_handler(int signo)      /* Do not use the arg signo at the moment */
     pid = waitpid(-1, &stat_loc, WNOHANG);
     /* Child exit handling code follows, if any */
 }
-#endif /* __osf__ */
+#endif /* CSRG_BASED */