|
diff --git a/shared.c b/shared.c index 1a5b866..65fc8b2 100644 --- a/ shared.c+++ b/ shared.c |
|
@@ -65,48 +65,55 @@ int cgit_get_cmd_index(const char *cmd) |
65 | static char *cmds[] = {"log", "commit", "diff", "tree", "blob", |
65 | static char *cmds[] = {"log", "commit", "diff", "tree", "blob", |
66 | "snapshot", NULL}; |
66 | "snapshot", NULL}; |
67 | int i; |
67 | int i; |
68 | |
68 | |
69 | for(i = 0; cmds[i]; i++) |
69 | for(i = 0; cmds[i]; i++) |
70 | if (!strcmp(cmd, cmds[i])) |
70 | if (!strcmp(cmd, cmds[i])) |
71 | return i + 1; |
71 | return i + 1; |
72 | return 0; |
72 | return 0; |
73 | } |
73 | } |
74 | |
74 | |
75 | int chk_zero(int result, char *msg) |
75 | int chk_zero(int result, char *msg) |
76 | { |
76 | { |
77 | if (result != 0) |
77 | if (result != 0) |
78 | die("%s: %s", msg, strerror(errno)); |
78 | die("%s: %s", msg, strerror(errno)); |
79 | return result; |
79 | return result; |
80 | } |
80 | } |
81 | |
81 | |
82 | int chk_positive(int result, char *msg) |
82 | int chk_positive(int result, char *msg) |
83 | { |
83 | { |
84 | if (result <= 0) |
84 | if (result <= 0) |
85 | die("%s: %s", msg, strerror(errno)); |
85 | die("%s: %s", msg, strerror(errno)); |
86 | return result; |
86 | return result; |
87 | } |
87 | } |
88 | |
88 | |
| |
89 | int chk_non_negative(int result, char *msg) |
| |
90 | { |
| |
91 | if (result < 0) |
| |
92 | die("%s: %s",msg, strerror(errno)); |
| |
93 | return result; |
| |
94 | } |
| |
95 | |
89 | struct repoinfo *add_repo(const char *url) |
96 | struct repoinfo *add_repo(const char *url) |
90 | { |
97 | { |
91 | struct repoinfo *ret; |
98 | struct repoinfo *ret; |
92 | |
99 | |
93 | if (++cgit_repolist.count > cgit_repolist.length) { |
100 | if (++cgit_repolist.count > cgit_repolist.length) { |
94 | if (cgit_repolist.length == 0) |
101 | if (cgit_repolist.length == 0) |
95 | cgit_repolist.length = 8; |
102 | cgit_repolist.length = 8; |
96 | else |
103 | else |
97 | cgit_repolist.length *= 2; |
104 | cgit_repolist.length *= 2; |
98 | cgit_repolist.repos = xrealloc(cgit_repolist.repos, |
105 | cgit_repolist.repos = xrealloc(cgit_repolist.repos, |
99 | cgit_repolist.length * |
106 | cgit_repolist.length * |
100 | sizeof(struct repoinfo)); |
107 | sizeof(struct repoinfo)); |
101 | } |
108 | } |
102 | |
109 | |
103 | ret = &cgit_repolist.repos[cgit_repolist.count-1]; |
110 | ret = &cgit_repolist.repos[cgit_repolist.count-1]; |
104 | ret->url = xstrdup(url); |
111 | ret->url = xstrdup(url); |
105 | ret->name = ret->url; |
112 | ret->name = ret->url; |
106 | ret->path = NULL; |
113 | ret->path = NULL; |
107 | ret->desc = NULL; |
114 | ret->desc = NULL; |
108 | ret->owner = NULL; |
115 | ret->owner = NULL; |
109 | ret->group = cgit_repo_group; |
116 | ret->group = cgit_repo_group; |
110 | ret->defbranch = "master"; |
117 | ret->defbranch = "master"; |
111 | ret->snapshots = cgit_snapshots; |
118 | ret->snapshots = cgit_snapshots; |
112 | ret->enable_log_filecount = cgit_enable_log_filecount; |
119 | ret->enable_log_filecount = cgit_enable_log_filecount; |
|