#ifdef HAVE_PROCESS_H
# include <process.h> /* getpid() */
#endif
-#ifdef HAVE_UTIME_H
-# include <utime.h>
-#endif
#include <errno.h>
#include <fcntl.h>
#include <assert.h>
#include <stdarg.h>
#include <locale.h>
+#if HAVE_UTIME
+# include <sys/types.h>
+# ifdef HAVE_UTIME_H
+# include <utime.h>
+# endif
+
+# ifdef HAVE_SYS_UTIME_H
+# include <sys/utime.h>
+# endif
+#endif
+
+#include <sys/time.h>
+
#include <sys/stat.h>
/* For TIOCGWINSZ and friends: */
-#ifdef HAVE_SYS_IOCTL_H
-# include <sys/ioctl.h>
-#endif
+#include <sys/ioctl.h>
#ifdef HAVE_TERMIOS_H
# include <termios.h>
#endif
void
touch (const char *file, time_t tm)
{
+#if HAVE_UTIME
+# ifdef HAVE_STRUCT_UTIMBUF
+ struct utimbuf times;
+# else
+ struct {
+ time_t actime;
+ time_t modtime;
+ } times;
+# endif
+ times.modtime = tm;
+ times.actime = time (NULL);
+ if (utime (file, ×) == -1)
+ logprintf (LOG_NOTQUIET, "utime(%s): %s\n", file, strerror (errno));
+#else
struct timespec timespecs[2];
int fd;
logprintf (LOG_NOTQUIET, "futimens(%s): %s\n", file, strerror (errno));
close (fd);
+#endif
}
/* Checks if FILE is a symbolic link, and removes it if it is. Does
open_id = 13;
fd = open( fname, /* File name. */
flags, /* Flags. */
- 0777, /* Mode for default protection.
-*/
+ 0777, /* Mode for default protection. */
"rfm=stmlf", /* Stream_LF. */
OPEN_OPT_ARGS); /* Access callback. */
}
ringpos = (ringpos + 1) % RING_SIZE;
return buf;
}
+
+/* Converts the byte to bits format if --bits option is enabled
+ */
+wgint
+convert_to_bits (wgint num)
+{
+ if (opt.bits_fmt)
+ return num * 8;
+ return num;
+}
+
\f
/* Determine the width of the terminal we're running on. If that's
not possible, return 0. */