- bool direct_dependencies = FALSE;
- bool invert_dependencies = FALSE;
- bool header = FALSE;
- int i, c, debug_level = 0;
- int code;
-
- if ((_nc_progname = strrchr(argv[0], '/')) == NULL)
- _nc_progname = argv[0];
- else
- _nc_progname++;
+ struct stat sb;
+ return (stat(path, &sb) == 0
+ && (sb.st_mode & S_IFMT) == S_IFREG);
+}
+
+static bool
+is_a_directory(char *path)
+{
+ struct stat sb;
+ return (stat(path, &sb) == 0
+ && (sb.st_mode & S_IFMT) == S_IFDIR);
+}
+
+static char *
+get_directory(char *path)
+{
+ if (path != 0) {
+ if (!is_a_directory(path)
+ || access(path, R_OK | X_OK) != 0)
+ path = 0;
+ }
+ return path;
+}
+
+int
+main(int argc, char *argv[])
+{
+ bool direct_dependencies = FALSE;
+ bool invert_dependencies = FALSE;
+ bool header = FALSE;
+ int i, c;
+ int code;
+
+ _nc_progname = _nc_rootname(argv[0]);