+int chk_zero(int result, char *msg)
+{
+ if (result != 0)
+ die("%s: %s", msg, strerror(errno));
+ return result;
+}
+
+int chk_positive(int result, char *msg)
+{
+ if (result <= 0)
+ die("%s: %s", msg, strerror(errno));
+ return result;
+}
+
+struct repoinfo *add_repo(const char *url)
+{
+ struct repoinfo *ret;
+
+ if (++cgit_repolist.count > cgit_repolist.length) {
+ if (cgit_repolist.length == 0)
+ cgit_repolist.length = 8;
+ else
+ cgit_repolist.length *= 2;
+ cgit_repolist.repos = xrealloc(cgit_repolist.repos,
+ cgit_repolist.length *
+ sizeof(struct repoinfo));
+ }
+
+ ret = &cgit_repolist.repos[cgit_repolist.count-1];
+ ret->url = xstrdup(url);
+ ret->name = ret->url;
+ ret->path = NULL;
+ ret->desc = NULL;
+ ret->owner = NULL;
+ ret->snapshots = cgit_snapshots;
+ return ret;
+}
+