summaryrefslogtreecommitdiffabout
path: root/ui-tree.c
Unidiff
Diffstat (limited to 'ui-tree.c') (more/less context) (ignore whitespace changes)
-rw-r--r--ui-tree.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/ui-tree.c b/ui-tree.c
index 816e121..caf6a9e 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -1,94 +1,94 @@
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 <ctype.h> 9#include <ctype.h>
10#include "cgit.h" 10#include "cgit.h"
11#include "html.h" 11#include "html.h"
12#include "ui-shared.h" 12#include "ui-shared.h"
13 13
14char *curr_rev; 14char *curr_rev;
15char *match_path; 15char *match_path;
16int header = 0; 16int header = 0;
17 17
18static void print_text_buffer(const char *name, char *buf, unsigned long size) 18static void print_text_buffer(const char *name, char *buf, unsigned long size)
19{ 19{
20 unsigned long lineno, idx; 20 unsigned long lineno, idx;
21 const char *numberfmt = 21 const char *numberfmt =
22 "<a class='no' id='n%1$d' name='n%1$d' href='#n%1$d'>%1$d</a>\n"; 22 "<a class='no' id='n%1$d' name='n%1$d' href='#n%1$d'>%1$d</a>\n";
23 23
24 html("<table summary='blob content' class='blob'>\n"); 24 html("<table summary='blob content' class='blob'>\n");
25 if (ctx.cfg.source_filter) { 25 if (ctx.repo->source_filter) {
26 html("<tr><td class='lines'><pre><code>"); 26 html("<tr><td class='lines'><pre><code>");
27 ctx.cfg.source_filter->argv[1] = xstrdup(name); 27 ctx.repo->source_filter->argv[1] = xstrdup(name);
28 cgit_open_filter(ctx.cfg.source_filter); 28 cgit_open_filter(ctx.repo->source_filter);
29 write(STDOUT_FILENO, buf, size); 29 write(STDOUT_FILENO, buf, size);
30 cgit_close_filter(ctx.cfg.source_filter); 30 cgit_close_filter(ctx.repo->source_filter);
31 html("</code></pre></td></tr></table>\n"); 31 html("</code></pre></td></tr></table>\n");
32 return; 32 return;
33 } 33 }
34 34
35 html("<tr><td class='linenumbers'><pre>"); 35 html("<tr><td class='linenumbers'><pre>");
36 idx = 0; 36 idx = 0;
37 lineno = 0; 37 lineno = 0;
38 38
39 if (size) { 39 if (size) {
40 htmlf(numberfmt, ++lineno); 40 htmlf(numberfmt, ++lineno);
41 while(idx < size - 1) { // skip absolute last newline 41 while(idx < size - 1) { // skip absolute last newline
42 if (buf[idx] == '\n') 42 if (buf[idx] == '\n')
43 htmlf(numberfmt, ++lineno); 43 htmlf(numberfmt, ++lineno);
44 idx++; 44 idx++;
45 } 45 }
46 } 46 }
47 html("</pre></td>\n"); 47 html("</pre></td>\n");
48 html("<td class='lines'><pre><code>"); 48 html("<td class='lines'><pre><code>");
49 html_txt(buf); 49 html_txt(buf);
50 html("</code></pre></td></tr></table>\n"); 50 html("</code></pre></td></tr></table>\n");
51} 51}
52 52
53#define ROWLEN 32 53#define ROWLEN 32
54 54
55static void print_binary_buffer(char *buf, unsigned long size) 55static void print_binary_buffer(char *buf, unsigned long size)
56{ 56{
57 unsigned long ofs, idx; 57 unsigned long ofs, idx;
58 static char ascii[ROWLEN + 1]; 58 static char ascii[ROWLEN + 1];
59 59
60 html("<table summary='blob content' class='bin-blob'>\n"); 60 html("<table summary='blob content' class='bin-blob'>\n");
61 html("<tr><th>ofs</th><th>hex dump</th><th>ascii</th></tr>"); 61 html("<tr><th>ofs</th><th>hex dump</th><th>ascii</th></tr>");
62 for (ofs = 0; ofs < size; ofs += ROWLEN, buf += ROWLEN) { 62 for (ofs = 0; ofs < size; ofs += ROWLEN, buf += ROWLEN) {
63 htmlf("<tr><td class='right'>%04x</td><td class='hex'>", ofs); 63 htmlf("<tr><td class='right'>%04x</td><td class='hex'>", ofs);
64 for (idx = 0; idx < ROWLEN && ofs + idx < size; idx++) 64 for (idx = 0; idx < ROWLEN && ofs + idx < size; idx++)
65 htmlf("%*s%02x", 65 htmlf("%*s%02x",
66 idx == 16 ? 4 : 1, "", 66 idx == 16 ? 4 : 1, "",
67 buf[idx] & 0xff); 67 buf[idx] & 0xff);
68 html(" </td><td class='hex'>"); 68 html(" </td><td class='hex'>");
69 for (idx = 0; idx < ROWLEN && ofs + idx < size; idx++) 69 for (idx = 0; idx < ROWLEN && ofs + idx < size; idx++)
70 ascii[idx] = isgraph(buf[idx]) ? buf[idx] : '.'; 70 ascii[idx] = isgraph(buf[idx]) ? buf[idx] : '.';
71 ascii[idx] = '\0'; 71 ascii[idx] = '\0';
72 html_txt(ascii); 72 html_txt(ascii);
73 html("</td></tr>\n"); 73 html("</td></tr>\n");
74 } 74 }
75 html("</table>\n"); 75 html("</table>\n");
76} 76}
77 77
78static void print_object(const unsigned char *sha1, char *path, const char *basename) 78static void print_object(const unsigned char *sha1, char *path, const char *basename)
79{ 79{
80 enum object_type type; 80 enum object_type type;
81 char *buf; 81 char *buf;
82 unsigned long size; 82 unsigned long size;
83 83
84 type = sha1_object_info(sha1, &size); 84 type = sha1_object_info(sha1, &size);
85 if (type == OBJ_BAD) { 85 if (type == OBJ_BAD) {
86 cgit_print_error(fmt("Bad object name: %s", 86 cgit_print_error(fmt("Bad object name: %s",
87 sha1_to_hex(sha1))); 87 sha1_to_hex(sha1)));
88 return; 88 return;
89 } 89 }
90 90
91 buf = read_sha1_file(sha1, &type, &size); 91 buf = read_sha1_file(sha1, &type, &size);
92 if (!buf) { 92 if (!buf) {
93 cgit_print_error(fmt("Error reading object %s", 93 cgit_print_error(fmt("Error reading object %s",
94 sha1_to_hex(sha1))); 94 sha1_to_hex(sha1)));