#ifdef __hpux
#include <ndir.h> /* opendir(), directory(3C) */
-#else
-#if SVR4 || sco
+#elif defined(SVR4) || defined(CSRG_BASED)
#include <dirent.h> /* opendir(), directory(3C) */
#else
#include <sys/dir.h>
-#ifdef __apollo
-#include <X11/apollosys.h> /* needed for S_ISDIR macro */
-#endif
#endif
-#endif
-
#include <Xm/Xm.h>
/* load the filename into the name element */
p = strstr (in_filename, PALETTE_SUFFIX);
- *p = '\0';
+ if(p) {
+ *p = '\0';
+ }
strcpy(new_palette->name, in_filename);
/*
strcat(filename, PALETTE_SUFFIX);
/* open the file for writing */
-#if defined(linux)
+#if defined(__linux__)
if( (fd = open( filename, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR)) == -1)
#else
if( (fd = open( filename, O_RDWR | O_CREAT)) == -1)
if (hm_pl_DB )
XrmPutFileDatabase(hm_pl_DB, desc_file);
/* make the file read, write */
- chmod(desc_file,438);
+ if(chmod(desc_file,438) == -1) {
+ fprintf(stderr, "failed to chmod '%s', %s\n", desc_file, strerror(errno));
+ }
+
XtFree(desc_file);
XtFree(desc_name);
{
char *filename1 = "abcdefghijklmno";
char *filename2 = "abcdefghijklmn";
- int fd, fd1;
+ int fd = -1, fd1 = -1;
char *tmpfile1, *tmpfile2;
/* get the $HOME environment varible and constuct the full file name */
strcat(tmpfile1, DT_PAL_DIR);
strcat(tmpfile1, filename1);
-#if defined(linux)
+#if defined(__linux__)
if( (fd = open( tmpfile1, O_CREAT, S_IRUSR | S_IWUSR)) == -1)
#else
if( (fd = open( tmpfile1, O_CREAT)) == -1)
strcat(tmpfile2, DT_PAL_DIR);
strcat(tmpfile2, filename2);
-#if defined(linux)
+#if defined(__linux__)
if( (fd1 = open(tmpfile2, O_CREAT | O_EXCL, S_IRUSR | S_IWUSR)) == -1)
#else
if( (fd1 = open(tmpfile2, O_CREAT | O_EXCL)) == -1)
XtFree(tmpfile1);
XtFree(tmpfile2);
close(fd);
- close(fd1);
+ if(fd1 != -1) {
+ close(fd1);
+ }
}