summaryrefslogtreecommitdiffabout
path: root/ui-blob.c
authorLars Hjemli <hjemli@gmail.com>2008-03-24 15:50:57 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2008-03-24 15:50:57 (UTC)
commita4d1ca1dc6ff8171694d9e2280b6075a1beced0c (patch) (unidiff)
tree8ccfdd78b7fe61a54bf09c11a130cfbfa8ed50c8 /ui-blob.c
parentc5984a9896b39748e61daf6e620483749654b102 (diff)
downloadcgit-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>
Diffstat (limited to 'ui-blob.c') (more/less context) (ignore whitespace changes)
-rw-r--r--ui-blob.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/ui-blob.c b/ui-blob.c
index 3b29132..11589db 100644
--- a/ui-blob.c
+++ b/ui-blob.c
@@ -1,42 +1,43 @@
1/* ui-blob.c: show blob content 1/* ui-blob.c: show blob content
2 * 2 *
3 * Copyright (C) 2008 Lars Hjemli 3 * Copyright (C) 2008 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
12void cgit_print_blob(const char *hex, char *path) 13void cgit_print_blob(const char *hex, char *path)
13{ 14{
14 15
15 unsigned char sha1[20]; 16 unsigned char sha1[20];
16 enum object_type type; 17 enum object_type type;
17 unsigned char *buf; 18 unsigned char *buf;
18 unsigned long size; 19 unsigned long size;
19 20
20 if (get_sha1_hex(hex, sha1)){ 21 if (get_sha1_hex(hex, sha1)){
21 cgit_print_error(fmt("Bad hex value: %s", hex)); 22 cgit_print_error(fmt("Bad hex value: %s", hex));
22 return; 23 return;
23 } 24 }
24 25
25 type = sha1_object_info(sha1, &size); 26 type = sha1_object_info(sha1, &size);
26 if (type == OBJ_BAD) { 27 if (type == OBJ_BAD) {
27 cgit_print_error(fmt("Bad object name: %s", hex)); 28 cgit_print_error(fmt("Bad object name: %s", hex));
28 return; 29 return;
29 } 30 }
30 31
31 buf = read_sha1_file(sha1, &type, &size); 32 buf = read_sha1_file(sha1, &type, &size);
32 if (!buf) { 33 if (!buf) {
33 cgit_print_error(fmt("Error reading object %s", hex)); 34 cgit_print_error(fmt("Error reading object %s", hex));
34 return; 35 return;
35 } 36 }
36 37
37 buf[size] = '\0'; 38 buf[size] = '\0';
38 ctx.page.mimetype = "text/plain"; 39 ctx.page.mimetype = "text/plain";
39 ctx.page.filename = path; 40 ctx.page.filename = path;
40 cgit_print_http_headers(&ctx); 41 cgit_print_http_headers(&ctx);
41 write(htmlfd, buf, size); 42 write(htmlfd, buf, size);
42} 43}