summaryrefslogtreecommitdiff
path: root/ui-blob.c
diff options
context:
space:
mode:
authorLars Hjemli <hjemli@gmail.com>2007-05-09 00:48:09 +0200
committerLars Hjemli <hjemli@gmail.com>2007-05-09 00:48:09 +0200
commitca8eb8fc8f71ee0a40015c323619f776840b6503 (patch)
treef74a114ba19c215bffe8362bf8e63495155ebef4 /ui-blob.c
parent7250a154678477a1e8260efbc9810ec389754ef9 (diff)
downloadcgit-ca8eb8fc8f71ee0a40015c323619f776840b6503.tar.gz
cgit-ca8eb8fc8f71ee0a40015c323619f776840b6503.tar.bz2
cgit-ca8eb8fc8f71ee0a40015c323619f776840b6503.zip
Add support for downloading single blobs
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (limited to '')
-rw-r--r--ui-blob.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/ui-blob.c b/ui-blob.c
new file mode 100644
index 0000000..f5b844b
--- /dev/null
+++ b/ui-blob.c
@@ -0,0 +1,31 @@
+#include "cgit.h"
+
+void cgit_print_blob(struct cacheitem *item, const char *hex, char *path)
+{
+
+ unsigned char sha1[20];
+ enum object_type type;
+ unsigned char *buf;
+ unsigned long size;
+
+ if (get_sha1_hex(hex, sha1)){
+ cgit_print_error(fmt("Bad hex value: %s", hex));
+ return;
+ }
+
+ type = sha1_object_info(sha1, &size);
+ if (type == OBJ_BAD) {
+ cgit_print_error(fmt("Bad object name: %s", hex));
+ return;
+ }
+
+ buf = read_sha1_file(sha1, &type, &size);
+ if (!buf) {
+ cgit_print_error(fmt("Error reading object %s", hex));
+ return;
+ }
+
+ buf[size] = '\0';
+ cgit_print_snapshot_start("text/plain", path, item);
+ write(htmlfd, buf, size);
+}
wRené 'Necoro' Neumann2-22/+40 2010-03-16Rewrote the database initialization to be a class instead of a functionRené 'Necoro' Neumann5-50/+76 2010-03-14Better debug messages when updating database formatsRené 'Necoro' Neumann1-0/+2 2010-03-14Show a dialog if no email is givenRené 'Necoro' Neumann5-44/+87 2010-03-14Send more files for bug mailsRené 'Necoro' Neumann4-118/+194 2010-03-14Rewrote Session as to use the normal ConfigParser and not our own oneRené 'Necoro' Neumann2-68/+50 (cherry picked from commit 397a31e6deb851de102bca3d7c8d754f40b0656d) 2010-03-07Fix setup.pyRené 'Necoro' Neumann1-1/+1 2010-03-06Read translators from fileRené 'Necoro' Neumann4-9/+8 2010-03-06Updated NEWSRené 'Necoro' Neumann1-0/+3 2010-03-06Improved setup.py; also install the better-icon imageRené 'Necoro' Neumann1-8/+21 2010-03-06Only show best_icon, if the package can be installed w/o unmaskingRené 'Necoro' Neumann1-2/+2 2010-03-06Improved better_icon.René 'Necoro' Neumann1-78/+38 2010-03-06Show icon to signal the best package versionRené 'Necoro' Neumann1-1/+15 2010-03-06improved image handlingRené 'Necoro' Neumann2-7/+3 2010-03-05Use 'clear' instead of 'delete' for the search lineRené 'Necoro' Neumann1-1/+1 2010-03-05Corrected typoRené 'Necoro' Neumann6-9/+9 2010-03-05Updated german translationRené 'Necoro' Neumann2-538/+528 2010-03-05Reorderd parts of the menuRené 'Necoro' Neumann1-3/+3 2010-03-05Use existing translation for search typesRené 'Necoro' Neumann1-1/+1 2010-03-05Fixed bug in preference windowRené 'Necoro' Neumann1-2/+0 2010-03-05Fixed copyrightRené 'Necoro' Neumann66-66/+66 2010-03-05Handle portage warnings by our logging systemRené 'Necoro' Neumann1-0/+10 2010-03-05Ignore swap files in gitRené 'Necoro' Neumann1-0/+1 2010-03-05Clean up one 'deprecated' message from portageRené 'Necoro' Neumann1-1/+1 2010-03-05Save current search type in sessionRené 'Necoro' Neumann2-6/+17 2010-03-05Added combo box for selecting the search type to main windowRené 'Necoro' Neumann3-5/+43 2010-03-05Previous commits done more correct :PRené 'Necoro' Neumann2-6/+6 2010-03-05Fix commit 7449bc5fb8fRené 'Necoro' Neumann1-3/+3 2010-03-05Ignore swap files in gitRené 'Necoro' Neumann1-0/+1 2010-03-05Added some textual descriptionsRené 'Necoro' Neumann2-1/+8 2010-03-05Add description support to the databasesRené 'Necoro' Neumann4-8/+55 2010-03-04Also parse descriptions from eixRené 'Necoro' Neumann1-2/+2 2009-11-08Added Italian translation. Thanks to Ponsi.René 'Necoro' Neumann3-0/+1166 2009-11-05Remove the 'geneticize_list' stuff. It is so ancient, it stinks :PRené 'Necoro' Neumann1-19/+6