about summary refs log tree commit diff
path: root/scan-tree.c
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2010-07-29 17:52:29 +0200
committerLars Hjemli <hjemli@gmail.com>2010-08-04 03:09:32 +0200
commit3516502aa0df95ecc241caa30161741f59e4e600 (patch)
tree345978808d18796444729f74eb139c8289bcb1c2 /scan-tree.c
parentcommit-links.sh: Seperate the expressions for filtering commit messages. (diff)
downloadcgit-pink-3516502aa0df95ecc241caa30161741f59e4e600.tar.gz
cgit-pink-3516502aa0df95ecc241caa30161741f59e4e600.zip
Add support for 'project-list' option
This option specifies the location of a projectlist file as used by
gitweb - when 'scan-tree' is later specified, only the projects listed in
the projectlist file will be added.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (limited to '')
-rw-r--r--scan-tree.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/scan-tree.c b/scan-tree.c
index 1e18f3c..9bf9b38 100644
--- a/scan-tree.c
+++ b/scan-tree.c
@@ -1,3 +1,12 @@
+/* scan-tree.c
+ * 
+ * Copyright (C) 2008-2009 Lars Hjemli
+ * Copyright (C) 2010 Jason A. Donenfeld <Jason@zx2c4.com>
+ *
+ * Licensed under GNU General Public License v2
+ *   (see COPYING for full license text)
+ */
+
 #include "cgit.h"
 #include "configfile.h"
 #include "html.h"
@@ -142,6 +151,34 @@ static void scan_path(const char *base, const char *path, repo_config_fn fn)
 	closedir(dir);
 }
 
+#define lastc(s) s[strlen(s) - 1]
+
+void scan_projects(const char *path, const char *projectsfile, repo_config_fn fn)
+{
+	char line[MAX_PATH * 2], *z;
+	FILE *projects;
+	int err;
+	
+	projects = fopen(projectsfile, "r");
+	if (!projects) {
+		fprintf(stderr, "Error opening projectsfile %s: %s (%d)\n",
+			projectsfile, strerror(errno), errno);
+	}
+	while (fgets(line, sizeof(line), projects) != NULL) {
+		for (z = &lastc(line);
+		     strlen(line) && strchr("\n\r", *z);
+		     z = &lastc(line))
+			*z = '\0';
+		if (strlen(line))
+			scan_path(path, fmt("%s/%s", path, line), fn);
+	}
+	if ((err = ferror(projects))) {
+		fprintf(stderr, "Error reading from projectsfile %s: %s (%d)\n",
+			projectsfile, strerror(err), err);
+	}
+	fclose(projects);
+}
+
 void scan_tree(const char *path, repo_config_fn fn)
 {
 	scan_path(path, path, fn);
I love how simple this is. 2021-02-07Set cursor theme and sizeJune McEnroe 2021-02-07Use scrot for up -s if no screencaptureJune McEnroe Still missing putting the URL in an X selection. 2021-02-07Enable mouse acceleration in XJune McEnroe 2021-02-07Set colours for Xt and cwmJune McEnroe And increase XTerm internalBorder. 2021-02-07Set urgency on bell in xtermJune McEnroe 2021-02-07Add bindings for brightness controlJune McEnroe Weirdly the Fn key doesn't change how the F row registers... I wonder if I can do something about that. 2021-02-07Set X key repeat rateJune McEnroe 2021-02-07Bump font size to 12June McEnroe 11 is what I use on macOS, but I feel like my eyes are working harder here. 2021-02-07Fully configure and rebind cwmJune McEnroe This is sort of a mix of trying to emulate macOS somewhat for my muscle memory and just rebinding some of the cwm defaults to use 4- rather than M-. 2021-02-07Add BintiJune McEnroe 2021-02-07Finish configuring xtermJune McEnroe 2021-02-06Enable tapping, reverse scroll, set scaling in wsconsctlJune McEnroe 2021-02-06Set root window to black on purple snowJune McEnroe 2021-02-06Add xmodmap configurationJune McEnroe 2021-02-06Add initial OpenBSD X configurationJune McEnroe cwm still needs a lot more rebinding, and I need to actually look at its other options. xterm definitely still needs some configuration, but I at least managed to get it to use a decent looking font. Very happy that OpenBSD includes Luxi Mono, which is what my usual font, Go Mono, is based on anyway. Still missing is xmodmap and such. 2021-02-06Add xterm output to schemeJune McEnroe