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
22 #include <sys/types.h>
29 extern int fprintf ();
30 extern int tolower ();
33 extern char *strdup ();
39 * Extract last element of a name like /foo/bar/baz.
48 if (t == (char *)NULL)
60 register unsigned char c;
61 while ((c = *s) != '\0')
70 * Is file a newer than file b?
74 * a newer than b returns 1
75 * a older than b returns 0
76 * stat on a fails returns -1
77 * stat on b fails returns -2
78 * stat on a and b fails returns -3
89 register int status = 0;
91 fa_stat = stat (fa, &fa_sb);
95 fb_stat = stat (fb, &fb_sb);
102 return (fa_sb.st_mtime > fb_sb.st_mtime);
106 * Is path a directory?
115 status = stat (path, &sb);
120 return ((sb.st_mode & S_IFDIR) == S_IFDIR);
125 * Is path a regular file?
134 status = stat (path, &sb);
139 return ((sb.st_mode & S_IFREG) == S_IFREG);
143 * Attempt a system () call. Return 1 for success and 0 for failure
144 * (handy for counting successes :-).
147 do_system_command (command)
154 * If we're debugging, don't really execute the command -- you never
155 * know what might be in that mangled string :-O.
158 fprintf (stderr, "\ntrying command: %s\n", command);
160 status = system (command);
162 /* check return value from system() function first */
165 "wait() for exit status of shell failed in function system()\n");
167 } else if (status == 127 || status == (127 << 8)) {
168 fprintf(stderr, "execution of the shell failed in function system()\n");
172 if (WIFSIGNALED(status))
174 else if (WEXITSTATUS(status)) {
175 gripe_system_command (status);