author | Lars Hjemli <hjemli@gmail.com> | 2008-03-24 00:00:36 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2008-03-24 00:01:28 (UTC) |
commit | b608e88adb6f77328288afb6dd0eddf674fc9b5b (patch) (unidiff) | |
tree | e194a466ba00d67bc037c76329ca050e84e1223b /ui-snapshot.c | |
parent | f3c1a187fe2bc33f8423cd535d5045899699995b (diff) | |
download | cgit-b608e88adb6f77328288afb6dd0eddf674fc9b5b.zip cgit-b608e88adb6f77328288afb6dd0eddf674fc9b5b.tar.gz cgit-b608e88adb6f77328288afb6dd0eddf674fc9b5b.tar.bz2 |
Remove obsolete cacheitem parameter to ui-functions
This parameter hasn't been used for a very long time...
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | ui-snapshot.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/ui-snapshot.c b/ui-snapshot.c index 4449803..c741469 100644 --- a/ui-snapshot.c +++ b/ui-snapshot.c | |||
@@ -24,98 +24,97 @@ static int write_compressed_tar_archive(struct archiver_args *args,const char *f | |||
24 | /* child */ | 24 | /* child */ |
25 | chk_zero(close(rw[1]), "Closing write end of pipe in child"); | 25 | chk_zero(close(rw[1]), "Closing write end of pipe in child"); |
26 | chk_zero(close(STDIN_FILENO), "Closing STDIN"); | 26 | chk_zero(close(STDIN_FILENO), "Closing STDIN"); |
27 | chk_non_negative(dup2(rw[0],STDIN_FILENO), "Redirecting compressor input to stdin"); | 27 | chk_non_negative(dup2(rw[0],STDIN_FILENO), "Redirecting compressor input to stdin"); |
28 | execlp(filter,filter,NULL); | 28 | execlp(filter,filter,NULL); |
29 | _exit(-1); | 29 | _exit(-1); |
30 | } | 30 | } |
31 | /* parent */ | 31 | /* parent */ |
32 | chk_zero(close(rw[0]), "Closing read end of pipe"); | 32 | chk_zero(close(rw[0]), "Closing read end of pipe"); |
33 | chk_non_negative(dup2(rw[1],STDOUT_FILENO), "Redirecting output to compressor"); | 33 | chk_non_negative(dup2(rw[1],STDOUT_FILENO), "Redirecting output to compressor"); |
34 | 34 | ||
35 | rv = write_tar_archive(args); | 35 | rv = write_tar_archive(args); |
36 | 36 | ||
37 | chk_zero(close(STDOUT_FILENO), "Closing STDOUT redirected to compressor"); | 37 | chk_zero(close(STDOUT_FILENO), "Closing STDOUT redirected to compressor"); |
38 | chk_non_negative(dup2(stdout2,STDOUT_FILENO), "Restoring uncompressed STDOUT"); | 38 | chk_non_negative(dup2(stdout2,STDOUT_FILENO), "Restoring uncompressed STDOUT"); |
39 | chk_zero(close(stdout2), "Closing uncompressed STDOUT"); | 39 | chk_zero(close(stdout2), "Closing uncompressed STDOUT"); |
40 | chk_zero(close(rw[1]), "Closing write end of pipe in parent"); | 40 | chk_zero(close(rw[1]), "Closing write end of pipe in parent"); |
41 | chk_positive(waitpid(gzpid,&status,0), "Waiting on compressor process"); | 41 | chk_positive(waitpid(gzpid,&status,0), "Waiting on compressor process"); |
42 | if(! ( WIFEXITED(status) && WEXITSTATUS(status)==0 ) ) | 42 | if(! ( WIFEXITED(status) && WEXITSTATUS(status)==0 ) ) |
43 | cgit_print_error("Failed to compress archive"); | 43 | cgit_print_error("Failed to compress archive"); |
44 | 44 | ||
45 | return rv; | 45 | return rv; |
46 | } | 46 | } |
47 | 47 | ||
48 | static int write_tar_gzip_archive(struct archiver_args *args) | 48 | static int write_tar_gzip_archive(struct archiver_args *args) |
49 | { | 49 | { |
50 | return write_compressed_tar_archive(args,"gzip"); | 50 | return write_compressed_tar_archive(args,"gzip"); |
51 | } | 51 | } |
52 | 52 | ||
53 | static int write_tar_bzip2_archive(struct archiver_args *args) | 53 | static int write_tar_bzip2_archive(struct archiver_args *args) |
54 | { | 54 | { |
55 | return write_compressed_tar_archive(args,"bzip2"); | 55 | return write_compressed_tar_archive(args,"bzip2"); |
56 | } | 56 | } |
57 | 57 | ||
58 | static const struct snapshot_archive_t { | 58 | static const struct snapshot_archive_t { |
59 | const char *suffix; | 59 | const char *suffix; |
60 | const char *mimetype; | 60 | const char *mimetype; |
61 | write_archive_fn_t write_func; | 61 | write_archive_fn_t write_func; |
62 | int bit; | 62 | int bit; |
63 | }snapshot_archives[] = { | 63 | }snapshot_archives[] = { |
64 | { ".zip", "application/x-zip", write_zip_archive, 0x1 }, | 64 | { ".zip", "application/x-zip", write_zip_archive, 0x1 }, |
65 | { ".tar.gz", "application/x-tar", write_tar_gzip_archive, 0x2 }, | 65 | { ".tar.gz", "application/x-tar", write_tar_gzip_archive, 0x2 }, |
66 | { ".tar.bz2", "application/x-tar", write_tar_bzip2_archive, 0x4 }, | 66 | { ".tar.bz2", "application/x-tar", write_tar_bzip2_archive, 0x4 }, |
67 | { ".tar", "application/x-tar", write_tar_archive, 0x8 } | 67 | { ".tar", "application/x-tar", write_tar_archive, 0x8 } |
68 | }; | 68 | }; |
69 | 69 | ||
70 | #define snapshot_archives_len (sizeof(snapshot_archives) / sizeof(*snapshot_archives)) | 70 | #define snapshot_archives_len (sizeof(snapshot_archives) / sizeof(*snapshot_archives)) |
71 | 71 | ||
72 | void cgit_print_snapshot(struct cacheitem *item, const char *head, | 72 | void cgit_print_snapshot(const char *head, const char *hex, const char *prefix, |
73 | const char *hex, const char *prefix, | ||
74 | const char *filename, int snapshots) | 73 | const char *filename, int snapshots) |
75 | { | 74 | { |
76 | const struct snapshot_archive_t* sat; | 75 | const struct snapshot_archive_t* sat; |
77 | struct archiver_args args; | 76 | struct archiver_args args; |
78 | struct commit *commit; | 77 | struct commit *commit; |
79 | unsigned char sha1[20]; | 78 | unsigned char sha1[20]; |
80 | int f, sl, fnl = strlen(filename); | 79 | int f, sl, fnl = strlen(filename); |
81 | 80 | ||
82 | for(f=0; f<snapshot_archives_len; f++) { | 81 | for(f=0; f<snapshot_archives_len; f++) { |
83 | sat = &snapshot_archives[f]; | 82 | sat = &snapshot_archives[f]; |
84 | if(!(snapshots & sat->bit)) | 83 | if(!(snapshots & sat->bit)) |
85 | continue; | 84 | continue; |
86 | sl = strlen(sat->suffix); | 85 | sl = strlen(sat->suffix); |
87 | if(fnl<sl || strcmp(&filename[fnl-sl],sat->suffix)) | 86 | if(fnl<sl || strcmp(&filename[fnl-sl],sat->suffix)) |
88 | continue; | 87 | continue; |
89 | if (!hex) | 88 | if (!hex) |
90 | hex = head; | 89 | hex = head; |
91 | if(get_sha1(hex, sha1)) { | 90 | if(get_sha1(hex, sha1)) { |
92 | cgit_print_error(fmt("Bad object id: %s", hex)); | 91 | cgit_print_error(fmt("Bad object id: %s", hex)); |
93 | return; | 92 | return; |
94 | } | 93 | } |
95 | commit = lookup_commit_reference(sha1); | 94 | commit = lookup_commit_reference(sha1); |
96 | if(!commit) { | 95 | if(!commit) { |
97 | cgit_print_error(fmt("Not a commit reference: %s", hex)); | 96 | cgit_print_error(fmt("Not a commit reference: %s", hex)); |
98 | return;; | 97 | return;; |
99 | } | 98 | } |
100 | memset(&args,0,sizeof(args)); | 99 | memset(&args,0,sizeof(args)); |
101 | args.base = fmt("%s/", prefix); | 100 | args.base = fmt("%s/", prefix); |
102 | args.tree = commit->tree; | 101 | args.tree = commit->tree; |
103 | args.time = commit->date; | 102 | args.time = commit->date; |
104 | ctx.page.mimetype = xstrdup(sat->mimetype); | 103 | ctx.page.mimetype = xstrdup(sat->mimetype); |
105 | ctx.page.filename = xstrdup(filename); | 104 | ctx.page.filename = xstrdup(filename); |
106 | cgit_print_http_headers(&ctx); | 105 | cgit_print_http_headers(&ctx); |
107 | (*sat->write_func)(&args); | 106 | (*sat->write_func)(&args); |
108 | return; | 107 | return; |
109 | } | 108 | } |
110 | cgit_print_error(fmt("Unsupported snapshot format: %s", filename)); | 109 | cgit_print_error(fmt("Unsupported snapshot format: %s", filename)); |
111 | } | 110 | } |
112 | 111 | ||
113 | void cgit_print_snapshot_links(const char *repo, const char *head, | 112 | void cgit_print_snapshot_links(const char *repo, const char *head, |
114 | const char *hex, int snapshots) | 113 | const char *hex, int snapshots) |
115 | { | 114 | { |
116 | const struct snapshot_archive_t* sat; | 115 | const struct snapshot_archive_t* sat; |
117 | char *filename; | 116 | char *filename; |
118 | int f; | 117 | int f; |
119 | 118 | ||
120 | for(f=0; f<snapshot_archives_len; f++) { | 119 | for(f=0; f<snapshot_archives_len; f++) { |
121 | sat = &snapshot_archives[f]; | 120 | sat = &snapshot_archives[f]; |