author | Lars Hjemli <hjemli@gmail.com> | 2008-03-24 15:50:57 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2008-03-24 15:50:57 (UTC) |
commit | a4d1ca1dc6ff8171694d9e2280b6075a1beced0c (patch) (unidiff) | |
tree | 8ccfdd78b7fe61a54bf09c11a130cfbfa8ed50c8 /ui-tree.c | |
parent | c5984a9896b39748e61daf6e620483749654b102 (diff) | |
download | cgit-a4d1ca1dc6ff8171694d9e2280b6075a1beced0c.zip cgit-a4d1ca1dc6ff8171694d9e2280b6075a1beced0c.tar.gz cgit-a4d1ca1dc6ff8171694d9e2280b6075a1beced0c.tar.bz2 |
Add ui-shared.h
This is finally a proper headerfile for the shared ui-functions which
used to reside in cgit.h
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | ui-tree.c | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -1,74 +1,75 @@ | |||
1 | /* ui-tree.c: functions for tree output | 1 | /* ui-tree.c: functions for tree output |
2 | * | 2 | * |
3 | * Copyright (C) 2006 Lars Hjemli | 3 | * Copyright (C) 2006 Lars Hjemli |
4 | * | 4 | * |
5 | * Licensed under GNU General Public License v2 | 5 | * Licensed under GNU General Public License v2 |
6 | * (see COPYING for full license text) | 6 | * (see COPYING for full license text) |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include "cgit.h" | 9 | #include "cgit.h" |
10 | #include "html.h" | 10 | #include "html.h" |
11 | #include "ui-shared.h" | ||
11 | 12 | ||
12 | char *curr_rev; | 13 | char *curr_rev; |
13 | char *match_path; | 14 | char *match_path; |
14 | int header = 0; | 15 | int header = 0; |
15 | 16 | ||
16 | static void print_object(const unsigned char *sha1, char *path) | 17 | static void print_object(const unsigned char *sha1, char *path) |
17 | { | 18 | { |
18 | enum object_type type; | 19 | enum object_type type; |
19 | char *buf; | 20 | char *buf; |
20 | unsigned long size, lineno, start, idx; | 21 | unsigned long size, lineno, start, idx; |
21 | const char *linefmt = "<tr><td class='no'><a id='n%1$d' name='n%1$d' href='#n%1$d'>%1$d</a></td><td class='txt'>"; | 22 | const char *linefmt = "<tr><td class='no'><a id='n%1$d' name='n%1$d' href='#n%1$d'>%1$d</a></td><td class='txt'>"; |
22 | 23 | ||
23 | type = sha1_object_info(sha1, &size); | 24 | type = sha1_object_info(sha1, &size); |
24 | if (type == OBJ_BAD) { | 25 | if (type == OBJ_BAD) { |
25 | cgit_print_error(fmt("Bad object name: %s", | 26 | cgit_print_error(fmt("Bad object name: %s", |
26 | sha1_to_hex(sha1))); | 27 | sha1_to_hex(sha1))); |
27 | return; | 28 | return; |
28 | } | 29 | } |
29 | 30 | ||
30 | buf = read_sha1_file(sha1, &type, &size); | 31 | buf = read_sha1_file(sha1, &type, &size); |
31 | if (!buf) { | 32 | if (!buf) { |
32 | cgit_print_error(fmt("Error reading object %s", | 33 | cgit_print_error(fmt("Error reading object %s", |
33 | sha1_to_hex(sha1))); | 34 | sha1_to_hex(sha1))); |
34 | return; | 35 | return; |
35 | } | 36 | } |
36 | 37 | ||
37 | html(" blob: <a href='"); | 38 | html(" blob: <a href='"); |
38 | html_attr(cgit_pageurl(ctx.qry.repo, "blob", fmt("id=%s", sha1_to_hex(sha1)))); | 39 | html_attr(cgit_pageurl(ctx.qry.repo, "blob", fmt("id=%s", sha1_to_hex(sha1)))); |
39 | htmlf("'>%s</a>",sha1_to_hex(sha1)); | 40 | htmlf("'>%s</a>",sha1_to_hex(sha1)); |
40 | 41 | ||
41 | html("<table summary='blob content' class='blob'>\n"); | 42 | html("<table summary='blob content' class='blob'>\n"); |
42 | idx = 0; | 43 | idx = 0; |
43 | start = 0; | 44 | start = 0; |
44 | lineno = 0; | 45 | lineno = 0; |
45 | while(idx < size) { | 46 | while(idx < size) { |
46 | if (buf[idx] == '\n') { | 47 | if (buf[idx] == '\n') { |
47 | buf[idx] = '\0'; | 48 | buf[idx] = '\0'; |
48 | htmlf(linefmt, ++lineno); | 49 | htmlf(linefmt, ++lineno); |
49 | html_txt(buf + start); | 50 | html_txt(buf + start); |
50 | html("</td></tr>\n"); | 51 | html("</td></tr>\n"); |
51 | start = idx + 1; | 52 | start = idx + 1; |
52 | } | 53 | } |
53 | idx++; | 54 | idx++; |
54 | } | 55 | } |
55 | htmlf(linefmt, ++lineno); | 56 | htmlf(linefmt, ++lineno); |
56 | html_txt(buf + start); | 57 | html_txt(buf + start); |
57 | html("</td></tr>\n"); | 58 | html("</td></tr>\n"); |
58 | html("</table>\n"); | 59 | html("</table>\n"); |
59 | } | 60 | } |
60 | 61 | ||
61 | 62 | ||
62 | static int ls_item(const unsigned char *sha1, const char *base, int baselen, | 63 | static int ls_item(const unsigned char *sha1, const char *base, int baselen, |
63 | const char *pathname, unsigned int mode, int stage) | 64 | const char *pathname, unsigned int mode, int stage) |
64 | { | 65 | { |
65 | char *name; | 66 | char *name; |
66 | char *fullpath; | 67 | char *fullpath; |
67 | enum object_type type; | 68 | enum object_type type; |
68 | unsigned long size = 0; | 69 | unsigned long size = 0; |
69 | 70 | ||
70 | name = xstrdup(pathname); | 71 | name = xstrdup(pathname); |
71 | fullpath = fmt("%s%s%s", ctx.qry.path ? ctx.qry.path : "", | 72 | fullpath = fmt("%s%s%s", ctx.qry.path ? ctx.qry.path : "", |
72 | ctx.qry.path ? "/" : "", name); | 73 | ctx.qry.path ? "/" : "", name); |
73 | 74 | ||
74 | type = sha1_object_info(sha1, &size); | 75 | type = sha1_object_info(sha1, &size); |