dthelp: Change to ANSI function definitions
[oweals/cde.git] / cde / programs / dtfile / FileMgr.c
index 5cda9f0697d5a6faf61d5751413bc55504644cd9..0cc15646324c2f44c2f1ec6cbbd4d2413f968e44 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/types.h>
 #include <pwd.h>
 #include <string.h>
+#include <stdint.h>
 #include <sys/stat.h>
+#include <ctype.h>
 
 #include <Xm/XmP.h>
 #include <Xm/CascadeB.h>
 #include <X11/ShellP.h>
 #include <X11/Shell.h>
 #include <X11/Xatom.h>
-#include <X11/keysymdef.h>
 
 #include <Xm/Protocols.h>
 
 #include <Dt/HourGlass.h>
 #include <Dt/DtNlUtils.h>
 #include <Dt/Dts.h>
+#include <Dt/SharedProcs.h>
+#include <Dt/Wsm.h>
 
 #include <Xm/DragIcon.h>
 #include <Xm/DragC.h>
 #include "Prefs.h"
 #include "SharedMsgs.h"
 #include "IconicPath.h"
+#include "DtSvcInternal.h"
 
 
 /*  Dialog classes installed by Main.c  */
@@ -504,8 +508,7 @@ char translations_da[] = "\
 :<Key>osfPageUp:FMInput(@)\n\
 :<Key>F1:DrawingAreaInput() ManagerGadgetHelp()\n\
 s c a <Key>c: ActivateClist(@)\n\
-~s ~m ~a <Key>Return:DrawingAreaInput() ManagerParentActivate()\n\
-<Key>Return:DrawingAreaInput() ManagerGadgetSelect()\n\
+~s ~m ~a <Key>Return:DrawingAreaInput() ManagerParentActivate() ManagerGadgetSelect()\n\
 <Key>space:DrawingAreaInput() ManagerGadgetSelect()\n\
 :<Key>plus:DrawingAreaInput() ManagerGadgetSelect()\n\
 :<Key>minus:DrawingAreaInput() ManagerGadgetSelect()\n\
@@ -976,7 +979,7 @@ Create(
    XtSetValues (file_mgr_rec->vertical_scroll_bar, args, 2);
 
 
-   /*  Add an event handler to catch resizes occuring on the scrolled  */
+   /*  Add an event handler to catch resizes occurring on the scrolled  */
    /*  window, in order to force a relayout of the icons.              */
 
    XtAddEventHandler (file_mgr_rec->scroll_window, StructureNotifyMask,
@@ -2334,11 +2337,7 @@ ActivateClist(
         (( isalpha( tmp[i] ) ) ? (message[i] = (int)(tmp[i]) - 1) : (message[i] = tmp[i]));
       };
 
-#ifdef __osf__
-      sscanf( params[0], "%lx", &fileMgrRec );
-#else
       sscanf( params[0], "%p", (void **) &fileMgrRec );
-#endif
       _DtMessage(toplevel, title, message, NULL, HelpRequestCB);
       XtFree( title );
       XtFree( message );
@@ -2411,6 +2410,7 @@ GetSessionDir(
          char *user_session_str;
          char *toolbox_dir;
          char *current_dir;
+         size_t len = 0;
 
          root_toolbox = (file_mgr_data->host);
 
@@ -2422,19 +2422,26 @@ GetSessionDir(
          toolbox_dir = file_mgr_data->current_directory;
          toolbox_dir += strlen(file_mgr_data->restricted_directory);
 
-         current_dir = XtMalloc(strlen(root_toolbox) +
-                                strlen(user_session_str) +
-                                strlen(toolbox_dir) + 1);
-         sprintf(current_dir, "%s%s%s", root_toolbox,
-                                        user_session_str,
-                                        toolbox_dir);
-         file_mgr_data->current_directory = current_dir;
-
-         file_mgr_data->restricted_directory = XtMalloc(strlen(root_toolbox) +
-                                                 strlen(user_session_str) +
-                                                 1);
-         sprintf(file_mgr_data->restricted_directory, "%s%s", root_toolbox,
-                                                              user_session_str);
+         len = strlen(root_toolbox) +
+             strlen(user_session_str) +
+             strlen(toolbox_dir) + 1;
+         current_dir = XtMalloc(len);
+         if (current_dir)
+         {
+             snprintf(current_dir, len, "%s%s%s", root_toolbox,
+                      user_session_str,
+                      toolbox_dir);
+             file_mgr_data->current_directory = current_dir;
+         }
+
+         len = strlen(root_toolbox) + strlen(user_session_str) + 1;
+         file_mgr_data->restricted_directory = XtMalloc(len);
+         if (file_mgr_data->restricted_directory)
+         {
+             snprintf(file_mgr_data->restricted_directory, len, "%s%s",
+                      root_toolbox,
+                      user_session_str);
+         }
       }
       else
       {
@@ -2533,10 +2540,11 @@ BranchListToString(
    int i;
    Boolean first = True;
    char * branch_name;
+   int rv;
 
    if (*value != NULL)
    {
-      (void) write (fd, out_buf, strlen (out_buf));
+      rv = write (fd, out_buf, strlen (out_buf));
 
       i = 0;
       branch_name = (*value)[i];
@@ -2544,17 +2552,17 @@ BranchListToString(
       while (branch_name != NULL)
       {
          if (!first)
-            (void) write (fd, ", ", strlen (", "));
+            rv = write (fd, ", ", strlen (", "));
          else
             first = False;
 
-         (void) write (fd, branch_name, strlen (branch_name));
+         rv = write (fd, branch_name, strlen (branch_name));
 
          i++;
          branch_name = (*value)[i];
       }
 
-      (void) write (fd, "\n", strlen ("\n"));
+      rv = write (fd, "\n", strlen ("\n"));
    }
 }
 
@@ -2577,10 +2585,11 @@ SelectionListToString(
    Boolean first = True;
    FileViewData * file_view_data;
    DirectorySet * directory_set;
+   int rv; /* probably should actually check this... */
 
    if (*value != NULL)
    {
-      (void) write (fd, out_buf, strlen (out_buf));
+      rv = write (fd, out_buf, strlen (out_buf));
 
       i = 0;
       file_view_data = (*value)[i];
@@ -2591,24 +2600,24 @@ SelectionListToString(
          directory_set  = (DirectorySet *) file_view_data->directory_set;
 
          if (!first)
-            (void) write (fd, ", ", strlen (", "));
+             rv =  write (fd, ", ", strlen (", "));
          else
             first = False;
 
 
-         (void) write (fd, directory_set->name, strlen (directory_set->name));
+         rv = write (fd, directory_set->name, strlen (directory_set->name));
 
          if (strcmp (directory_set->name, "/") != 0)
-            (void) write (fd, "/", strlen ("/"));
+            rv = write (fd, "/", strlen ("/"));
 
-         (void) write (fd, file_view_data->file_data->file_name,
-                strlen (file_view_data->file_data->file_name));
+         rv = write (fd, file_view_data->file_data->file_name,
+                     strlen (file_view_data->file_data->file_name));
 
          i++;
          file_view_data = (*value)[i];
       }
 
-      (void) write (fd, "\n", strlen ("\n"));
+      rv = write (fd, "\n", strlen ("\n"));
    }
 
 }
@@ -5071,7 +5080,7 @@ ShowChangeDirField (
 
    if (w)
    {
-      if((int)client_data == FM_POPUP)
+      if((intptr_t) client_data == FM_POPUP)
          mbar = XtParent(w);
       else
          mbar = XmGetPostedFromWidget(XtParent(w));
@@ -5516,7 +5525,7 @@ CheckMoveType(
    Atom     pCurrent;
    Screen   *currentScreen;
    int      screen;
-   char * workspace_name;
+   char * workspace_name = NULL;
    Display  *display;
    Boolean value;
 
@@ -5716,7 +5725,7 @@ CheckMoveType(
       {
         int len = strlen(to);
         char notHere = 0x0;
-        int workspace_num;
+        int workspace_num = 1;
 
         for( i = 0; i < desktop_data->numWorkspaces; ++i )
         {
@@ -6385,11 +6394,7 @@ FMInput(
 
     if( *(params[0]) != '@' )
     {
-#ifdef __osf__
-        sscanf( params[0], "%lx", &fileMgrRec );
-#else
         sscanf( params[0], "%p", (void **) &fileMgrRec );
-#endif
       FileWindowInputCallback( wid, (XtPointer)fileMgrRec, (XtPointer)&cb );
     }