summaryrefslogtreecommitdiff
path: root/ui-snapshot.c
diff options
context:
space:
mode:
authorMichael Krelin <hacker@klever.net>2007-07-21 02:05:34 +0200
committerMichael Krelin <hacker@klever.net>2007-07-21 02:05:34 +0200
commit18a99bdf879953307d6ae6eb56c2117a4c074b0d (patch)
tree2d950fec688892398edd232f6e133b97e1a61e51 /ui-snapshot.c
parent4a92cbb7fd1084764dfe9b97a163f1084c790b15 (diff)
downloadcgit-18a99bdf879953307d6ae6eb56c2117a4c074b0d.tar.gz
cgit-18a99bdf879953307d6ae6eb56c2117a4c074b0d.tar.bz2
cgit-18a99bdf879953307d6ae6eb56c2117a4c074b0d.zip
introduced .tar.bz2 snapshots
- reworked write_tar_gzip_archive to handle arbitrary filter as a write_compressed_tar_archive - reformatted whitespaces in the said function to adhere to common cgit standards - added wrappers around write_compressed_tar_archive for .tar.gz and .tar.bz2 - added a hint for vim to use 8 characters shift width by default Signed-off-by: Michael Krelin <hacker@klever.net>
Diffstat (limited to '')
-rw-r--r--ui-snapshot.c73
1 files changed, 42 insertions, 31 deletions
diff --git a/ui-snapshot.c b/ui-snapshot.c
index 649569f..f623f35 100644
--- a/ui-snapshot.c
+++ b/ui-snapshot.c
@@ -8,40 +8,49 @@
#include "cgit.h"
-static int write_tar_gzip_archive(struct archiver_args *args)
+static int write_compressed_tar_archive(struct archiver_args *args,const char *filter)
{
- int rw[2];
- pid_t gzpid;
- int stdout2;
- int status;
- int rv;
+ int rw[2];
+ pid_t gzpid;
+ int stdout2;
+ int status;
+ int rv;
+
+ stdout2 = chk_non_negative(dup(STDIN_FILENO), "Preserving STDOUT before compressing");
+ chk_zero(pipe(rw), "Opening pipe from compressor subprocess");
+ gzpid = chk_non_negative(fork(), "Forking compressor subprocess");
+ if(gzpid==0) {
+ /* child */
+ chk_zero(close(rw[1]), "Closing write end of pipe in child");
+ chk_zero(close(STDIN_FILENO), "Closing STDIN");
+ chk_non_negative(dup2(rw[0],STDIN_FILENO), "Redirecting compressor input to stdin");
+ execlp(filter,filter,NULL);
+ _exit(-1);
+ }
+ /* parent */
+ chk_zero(close(rw[0]), "Closing read end of pipe");
+ chk_non_negative(dup2(rw[1],STDOUT_FILENO), "Redirecting output to compressor");
+
+ rv = write_tar_archive(args);
- stdout2 = chk_non_negative(dup(STDIN_FILENO), "Preserving STDOUT before compressing");
- chk_zero(pipe(rw), "Opening pipe from compressor subprocess");
- gzpid = chk_non_negative(fork(), "Forking compressor subprocess");
- if(gzpid==0) {
- /* child */
- chk_zero(close(rw[1]), "Closing write end of pipe in child");
- chk_zero(close(STDIN_FILENO), "Closing STDIN");
- chk_non_negative(dup2(rw[0],STDIN_FILENO), "Redirecting compressor input to stdin");
- execlp("gzip","gzip",NULL);
- _exit(-1);
- }
- /* parent */
- chk_zero(close(rw[0]), "Closing read end of pipe");
- chk_non_negative(dup2(rw[1],STDOUT_FILENO), "Redirecting output to compressor");
-
- rv = write_tar_archive(args);
+ chk_zero(close(STDOUT_FILENO), "Closing STDOUT redirected to compressor");
+ chk_non_negative(dup2(stdout2,STDOUT_FILENO), "Restoring uncompressed STDOUT");
+ chk_zero(close(stdout2), "Closing uncompressed STDOUT");
+ chk_zero(close(rw[1]), "Closing write end of pipe in parent");
+ chk_positive(waitpid(gzpid,&status,0), "Waiting on compressor process");
+ if(! ( WIFEXITED(status) && WEXITSTATUS(status)==0 ) )
+ cgit_print_error("Failed to compress archive");
- chk_zero(close(STDOUT_FILENO), "Closing STDOUT redirected to compressor");
- chk_non_negative(dup2(stdout2,STDOUT_FILENO), "Restoring uncompressed STDOUT");
- chk_zero(close(stdout2), "Closing uncompressed STDOUT");
- chk_zero(close(rw[1]), "Closing write end of pipe in parent");
- chk_positive(waitpid(gzpid,&status,0), "Waiting on compressor process");
- if(! ( WIFEXITED(status) && WEXITSTATUS(status)==0 ) )
- cgit_print_error("Failed to compress archive");
+ return rv;
+}
- return rv;
+static int write_tar_gzip_archive(struct archiver_args *args)
+{
+ return write_compressed_tar_archive(args,"gzip");
+}
+static int write_tar_bzip2_archive(struct archiver_args *args)
+{
+ return write_compressed_tar_archive(args,"bzip2");
}
static const struct snapshot_archive_t {
@@ -50,7 +59,8 @@ static const struct snapshot_archive_t {
write_archive_fn_t write_func;
} snapshot_archives[] = {
{ ".zip", "application/x-zip", write_zip_archive },
- { ".tar.gz", "application/x-gzip", write_tar_gzip_archive }
+ { ".tar.gz", "application/x-tar", write_tar_gzip_archive },
+ { ".tar.bz2", "application/x-tar", write_tar_bzip2_archive }
};
void cgit_print_snapshot(struct cacheitem *item, const char *hex,
@@ -102,3 +112,4 @@ void cgit_print_snapshot_links(const char *repo,const char *hex)
fmt("id=%s&amp;name=%s",hex,filename)), filename);
}
}
+/* vim:set sw=8: */
31 +0100'>2009-11-08Added Italian translation. Thanks to Ponsi.René 'Necoro' Neumann3-0/+1166 2009-10-28Changelogv0.13.10.13René 'Necoro' Neumann1-0/+4 2009-10-28Corrected config path handling.René 'Necoro' Neumann2-9/+6 Now also the 2.1 portage does not include / anymore. Handle this. (cherry picked from commit 58c5b49ae6d822f07879bf7f6a87271b77e7e75d) 2009-10-28Corrected config path handling.René 'Necoro' Neumann2-9/+6 Now also the 2.1 portage does not include / anymore. Handle this. 2009-10-24Fix the segfault in GLib due to wrong encodingRené 'Necoro' Neumann1-0/+1 2009-10-24Wrong debug message in new_version pluginRené 'Necoro' Neumann1-1/+1 2009-10-24Update TRANSLATING to use gitRené 'Necoro' Neumann1-2/+15 2009-10-24Also show revision during startup and with -vRené 'Necoro' Neumann1-1/+5 2009-10-24Adding revison info to version output.René 'Necoro' Neumann3-2/+44 As the revision is no longer encoded in the version, it needs to be printed whereever it is useful. This commit adds it to the 'About' window and to the exception infos. 2009-10-23Turn new_version plugin from a mess into sth useful.René 'Necoro' Neumann2-10/+10 2009-10-23Honor branches different from masterRené 'Necoro' Neumann1-2/+4 2009-10-23Change the new_version plugin to use git.René 'Necoro' Neumann2-32/+33 Use 'git ls-remote' to check for the current HEAD revision. Additionally the revision is no longer put into the version number, but into an extra variable REVISION. 2009-10-15Objectified all the functional stuff in backend.__init__.René 'Necoro' Neumann2-32/+34 Moved all the function in backend.__init__ into the SystemWrapper class. And also make loading the real system lazy. Reason: So I do not need to care about whether anything imports the system before the MainWindow is started. 2009-10-08Enhance the splash window handling.René 'Necoro' Neumann2-2/+9 Now the splash window is forced to stay on top. Hopes no users are going to complain ;). Additionally, the splash window is destroyed opposed to only hidden. As it is not reused, there is no use in keeping it alive. (cherry picked from commit 0a30d24e34493a2f56ba801facf4daba711d363e) 2009-10-08Enhance the splash window handling.René 'Necoro' Neumann2-2/+9 Now the splash window is forced to stay on top. Hopes no users are going to complain ;). Additionally, the splash window is destroyed opposed to only hidden. As it is not reused, there is no use in keeping it alive. 2009-10-05Some more stuff to ignoreRené 'Necoro' Neumann1-0/+3 2009-10-05Renamed the ignore fileRené 'Necoro' Neumann1-0/+0 2009-10-05Update NEWSRené 'Necoro' Neumann1-0/+1 2009-10-05Also allow 'unselect all' in the PkgListRené 'Necoro' Neumann1-1/+10 2009-10-05Now have it the sorted way in PkgListsRené 'Necoro' Neumann2-3/+9 2009-10-05Enhanced system.sort_package_list to also sort CPVsRené 'Necoro' Neumann5-27/+38 2009-10-05Added an PkgList window and rewrote UpdateWindow and WorldListWindow to use itRené 'Necoro' Neumann3-39/+63 2009-10-05Add uninstall button and rename to PkgListWindowRené 'Necoro' Neumann1-2/+17 2009-10-05First quick hack to have a world listRené 'Necoro' Neumann3-2/+24