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
20 #include <sys/types.h>
27 extern int fprintf ();
28 extern int tolower ();
31 extern char *strdup ();
37 * Extract last element of a name like /foo/bar/baz.
46 if (t == (char *)NULL)
58 register unsigned char c;
59 while ((c = *s) != '\0')
68 * Is file a newer than file b?
72 * a newer than b returns 1
73 * a older than b returns 0
74 * stat on a fails returns -1
75 * stat on b fails returns -2
76 * stat on a and b fails returns -3
87 register int status = 0;
89 fa_stat = stat (fa, &fa_sb);
93 fb_stat = stat (fb, &fb_sb);
100 return (fa_sb.st_mtime > fb_sb.st_mtime);
104 * Is path a directory?
113 status = stat (path, &sb);
118 return ((sb.st_mode & S_IFDIR) == S_IFDIR);
123 * Attempt a system () call. Return 1 for success and 0 for failure
124 * (handy for counting successes :-).
127 do_system_command (command)
134 * If we're debugging, don't really execute the command -- you never
135 * know what might be in that mangled string :-O.
138 fprintf (stderr, "\ntrying command: %s\n", command);
140 status = system (command);
142 /* check return value from system() function first */
145 "wait() for exit status of shell failed in function system()\n");
147 } else if (status == 127 || status == (127 << 8)) {
148 fprintf(stderr, "execution of the shell failed in function system()\n");
152 if (WIFSIGNALED(status))
154 else if (WEXITSTATUS(status)) {
155 gripe_system_command (status);