4 * Copyright (c) 1990, 1991, John W. Eaton.
6 * You may distribute under the terms of the GNU General Public
7 * License as specified in the file COPYING that comes with the man
12 * Department of Chemical Engineering
13 * The University of Texas at Austin
21 #include <sys/types.h>
31 * Extract last element of a name like /foo/bar/baz.
39 if (t == (char *)NULL)
48 downcase (unsigned char *s)
51 while ((c = *s) != '\0')
60 * Is file a newer than file b?
64 * a newer than b returns 1
65 * a older than b returns 0
66 * stat on a fails returns -1
67 * stat on b fails returns -2
68 * stat on a and b fails returns -3
71 is_newer (char *fa, char *fb)
79 fa_stat = stat (fa, &fa_sb);
83 fb_stat = stat (fb, &fb_sb);
90 return (fa_sb.st_mtime > fb_sb.st_mtime);
94 * Is path a directory?
97 is_directory (char *path)
102 status = stat (path, &sb);
107 return ((sb.st_mode & S_IFDIR) == S_IFDIR);
112 * Attempt a system () call. Return 1 for success and 0 for failure
113 * (handy for counting successes :-).
116 do_system_command (char *command)
121 * If we're debugging, don't really execute the command -- you never
122 * know what might be in that mangled string :-O.
125 fprintf (stderr, "\ntrying command: %s\n", command);
127 status = system (command);
129 /* check return value from system() function first */
132 "wait() for exit status of shell failed in function system()\n");
134 } else if (status == 127 || status == (127 << 8)) {
135 fprintf(stderr, "execution of the shell failed in function system()\n");
139 if (WIFSIGNALED(status))
141 else if (WEXITSTATUS(status)) {
142 gripe_system_command (status);