dthelp: Change to ANSI function definitions
[oweals/cde.git] / cde / programs / dtfile / FileManip.c
index 9b0dedf84463b4f642a3250b28cc78df952a2ae0..105c574bcb855da2a403fbe61e854a95dcaba75a 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: FileManip.c /main/10 1999/12/09 13:06:10 mgreess $ */
 /************************************<+>*************************************
  ****************************************************************************
  ****************************************************************************
  ************************************<+>*************************************/
 
-#if defined(SVR4) || defined(sco)
-#  if defined(USL) || defined(sco) || defined(__uxp__)
-#    include <sys/param.h>
-#    include <sys/types.h>
-#  endif
-#  ifdef sco
-#    include <sys/fs/s5param.h>
-#    define ROOTINO S5ROOTINO
-#  else
+#if defined(SVR4)
 #    include <sys/fs/ufs_fs.h>
 #    define ROOTINO UFSROOTINO
-#  endif       /* sco */
 #else
-#  if defined(linux)
+#  if defined(__linux__) || defined(CSRG_BASED)
 #    define ROOTINO 2
 #  endif
 #  include <sys/param.h>
-#endif /* SVR4 || sco */
+#endif /* SVR4 */
 
 #include <sys/types.h>
 
 #include <ufs/fs.h>
 #endif
 #else
-#ifdef __hp_osf
-#include <unistd.h>
-#include <limits.h>
-#include <ufs/fs.h>
-#include <sys/access.h>
-#else
 #ifdef __ultrix
 #include <unistd.h>
 #include <limits.h>
 #include <unistd.h>
 #endif
 #endif /* __ultrix */
-#endif /* __hp_osf */
 #endif /* sun */
 
-#ifdef __osf__
-#include <ufs/fs.h>
-#endif
-
 #include <Xm/Xm.h>
 
 #include <Xm/MwmUtil.h>
@@ -97,6 +99,7 @@
 #include <Dt/DtP.h>                     /* required for DtDirPaths type */
 #include <Dt/Connect.h>
 #include <Dt/DtNlUtils.h>
+#include <Dt/SharedProcs.h>
 
 #include "Encaps.h"
 #include "SharedProcs.h"
@@ -131,9 +134,9 @@ CheckAccess(
     uid_t save_ruid;
     gid_t save_rgid;
 
-#if defined(__hp_osf) || defined(__ultrix)
+#if defined(__ultrix)
 /*--------------------------------------------------------------------
- * access code for __hp_osf, __ultrix
+ * access code for __ultrix
  *------------------------------------------------------------------*/
 
       setreuid(geteuid(),-1);
@@ -178,7 +181,7 @@ CheckAccess(
 
    return access_priv;
 #endif /* BLS */
-#endif /* Apollo & OSF */
+#endif /* Apollo */
 }
 
 
@@ -206,7 +209,7 @@ FileOperationError(
    else
    {
      message_buf = XtMalloc(strlen(message1) + 1);
-     (void) sprintf(message_buf,message1);
+     (void) sprintf(message_buf, "%s", message1);
    }
 
    /*  Display an error dialog  */
@@ -522,10 +525,10 @@ MoveDir(
          /* pass in geometry, and other command lines params when available */
         if(type == TRASH_DIRECTORY)
            rc = execlp(DTCOPY, "dtfile_copy", "-move", "-confirmReplace",
-                "-confirmErrors", "-popDown","-checkPerms", source, target, 0);
+                "-confirmErrors", "-popDown","-checkPerms", source, target, NULL);
         else
            rc = execlp(DTCOPY, "dtfile_copy", "-move", "-confirmReplace",
-                "-confirmErrors", "-popDown", source, target, 0);
+                "-confirmErrors", "-popDown", source, target, NULL);
 
          /* call errorhandler */
          perror ("Could not exec child process \"dtfile_copy\"");
@@ -858,7 +861,7 @@ FileManip(
                char message_buf[512];
                char * tmpStr;
 
-               message_buf[0] = NULL;
+               message_buf[0] = '\0';
                tmpStr = (GETMESSAGE(11,30, "Cannot move or rename the folder %s.\nAll File Manager views displayed for a folder or its sub-folders\nmust be closed before a folder can be moved or renamed."));
                sprintf (message_buf, tmpStr, from);
                (*errorHandler) (w, message_buf, NULL);
@@ -972,11 +975,12 @@ FileManip(
    if (lstat (to, &s2) >= 0)                      /* <to> exists */
    {
       if ((stat (to, &s3) >= 0) &&
-#if defined(__hp_osf) || (__ultrix) || defined(__osf__) || defined(linux)
+#if defined(__ultrix) || defined(__linux__) || \
+       defined(CSRG_BASED)
            (((s3.st_mode & S_IFMT) == S_IFDIR)          /* if is a directory */
            || ((s3.st_mode & S_IFMT) == S_IFSOCK)) )    /* or a net special */
 #else
-#if defined(SVR4) || defined(_AIX) || defined(sco)
+#if defined(SVR4) || defined(_AIX)
            ((s3.st_mode & S_IFMT) == S_IFDIR) )         /* if is a directory */
 #else  /* (__hpux) */
            (((s3.st_mode & S_IFMT) == S_IFDIR)          /* if is a directory */
@@ -1276,12 +1280,12 @@ FileManip(
                  break;
              default:
                  unknown = True;
-                 sprintf(errnoMsg, GETMESSAGE(11,56, "(Unknown):"));
+                 sprintf(errnoMsg, "%s", GETMESSAGE(11,56, "(Unknown):"));
                  strerrormsg = strerror(errno);
                  break;
          }
 
-         /* If catmsg is NULL then one of the miscellanous error's occured.
+         /* If catmsg is NULL then one of the miscellanous error's occurred.
           * Set up a generic error message which will output the internal
           * error message.
           */
@@ -1292,7 +1296,7 @@ FileManip(
            else
              tmpStr = (GETMESSAGE(11,54, "The move of the file/folder failed\ndue to some internal error. The internal\nerror given is:"));
            catmsg = XtNewString(tmpStr);
-           tmpStr = (GETMESSAGE(11,55, "Please see your System Adminstrator"));
+           tmpStr = (GETMESSAGE(11,55, "Please see your System Administrator"));
            samsg = XtNewString(tmpStr);
          }