summaryrefslogtreecommitdiffabout
path: root/ui-snapshot.c
authorLars Hjemli <hjemli@gmail.com>2007-07-23 20:51:45 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2007-07-23 21:12:11 (UTC)
commit1221adbb581e222cfe932fe72fded2d8613112d9 (patch) (unidiff)
tree47da26e011ab57e31c5d28c9ba184478b7d50828 /ui-snapshot.c
parent43291e418ab6c736168effc017f9548bacb84e5e (diff)
downloadcgit-1221adbb581e222cfe932fe72fded2d8613112d9.zip
cgit-1221adbb581e222cfe932fe72fded2d8613112d9.tar.gz
cgit-1221adbb581e222cfe932fe72fded2d8613112d9.tar.bz2
ui-snapshot: whitespace/formatting cleanup
Introduce a #define for number of snapshot archive entries, move all decls to function entrypoint, remove some trailing whitespace and reformat a few lines. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (limited to 'ui-snapshot.c') (more/less context) (ignore whitespace changes)
-rw-r--r--ui-snapshot.c48
1 files changed, 24 insertions, 24 deletions
diff --git a/ui-snapshot.c b/ui-snapshot.c
index f9879ed..bd34a28 100644
--- a/ui-snapshot.c
+++ b/ui-snapshot.c
@@ -32,3 +32,3 @@ static int write_compressed_tar_archive(struct archiver_args *args,const char *f
32 chk_non_negative(dup2(rw[1],STDOUT_FILENO), "Redirecting output to compressor"); 32 chk_non_negative(dup2(rw[1],STDOUT_FILENO), "Redirecting output to compressor");
33 33
34 rv = write_tar_archive(args); 34 rv = write_tar_archive(args);
@@ -50,2 +50,3 @@ static int write_tar_gzip_archive(struct archiver_args *args)
50} 50}
51
51static int write_tar_bzip2_archive(struct archiver_args *args) 52static int write_tar_bzip2_archive(struct archiver_args *args)
@@ -67,2 +68,4 @@ static const struct snapshot_archive_t {
67 68
69#define snapshot_archives_len (sizeof(snapshot_archives) / sizeof(*snapshot_archives))
70
68void cgit_print_snapshot(struct cacheitem *item, const char *head, 71void cgit_print_snapshot(struct cacheitem *item, const char *head,
@@ -71,9 +74,10 @@ void cgit_print_snapshot(struct cacheitem *item, const char *head,
71{ 74{
72 int fnl = strlen(filename); 75 const struct snapshot_archive_t* sat;
73 int f, n; 76 struct archiver_args args;
74 77 struct commit *commit;
75 n = sizeof(snapshot_archives) / sizeof(*snapshot_archives); 78 unsigned char sha1[20];
76 for(f=0; f<n; f++) { 79 int f, sl, fnl = strlen(filename);
77 const struct snapshot_archive_t* sat = &snapshot_archives[f]; 80
78 int sl; 81 for(f=0; f<snapshot_archives_len; f++) {
82 sat = &snapshot_archives[f];
79 if(!(snapshots & sat->bit)) 83 if(!(snapshots & sat->bit))
@@ -83,7 +87,2 @@ void cgit_print_snapshot(struct cacheitem *item, const char *head,
83 continue; 87 continue;
84
85 struct archiver_args args;
86 struct commit *commit;
87 unsigned char sha1[20];
88
89 if (!hex) 88 if (!hex)
@@ -95,3 +94,2 @@ void cgit_print_snapshot(struct cacheitem *item, const char *head,
95 commit = lookup_commit_reference(sha1); 94 commit = lookup_commit_reference(sha1);
96
97 if(!commit) { 95 if(!commit) {
@@ -100,3 +98,2 @@ void cgit_print_snapshot(struct cacheitem *item, const char *head,
100 } 98 }
101
102 memset(&args,0,sizeof(args)); 99 memset(&args,0,sizeof(args));
@@ -104,3 +101,2 @@ void cgit_print_snapshot(struct cacheitem *item, const char *head,
104 args.tree = commit->tree; 101 args.tree = commit->tree;
105
106 cgit_print_snapshot_start(sat->mimetype, filename, item); 102 cgit_print_snapshot_start(sat->mimetype, filename, item);
@@ -115,8 +111,8 @@ void cgit_print_snapshot_links(const char *repo, const char *head,
115{ 111{
112 const struct snapshot_archive_t* sat;
116 char *filename; 113 char *filename;
117 int f, n; 114 int f;
118 115
119 n = sizeof(snapshot_archives) / sizeof(*snapshot_archives); 116 for(f=0; f<snapshot_archives_len; f++) {
120 for(f=0; f<n ;f++) { 117 sat = &snapshot_archives[f];
121 const struct snapshot_archive_t* sat = &snapshot_archives[f];
122 if(!(snapshots & sat->bit)) 118 if(!(snapshots & sat->bit))
@@ -133,6 +129,9 @@ int cgit_parse_snapshots_mask(const char *str)
133{ 129{
130 const struct snapshot_archive_t* sat;
134 static const char *delim = " \t,:/|;"; 131 static const char *delim = " \t,:/|;";
135 int f, tl, rv = 0; 132 int f, tl, rv = 0;
133
136 /* favor legacy setting */ 134 /* favor legacy setting */
137 if(atoi(str)) return 1; 135 if(atoi(str))
136 return 1;
138 for(;;) { 137 for(;;) {
@@ -142,5 +141,6 @@ int cgit_parse_snapshots_mask(const char *str)
142 break; 141 break;
143 for(f=0;f<(sizeof(snapshot_archives)/sizeof(*snapshot_archives));++f) { 142 for(f=0; f<snapshot_archives_len; f++) {
144 const struct snapshot_archive_t* sat = &snapshot_archives[f]; 143 sat = &snapshot_archives[f];
145 if(! ( strncmp(sat->suffix,str,tl) && strncmp(sat->suffix+1,str,tl-1) ) ) { 144 if(!(strncmp(sat->suffix, str, tl) &&
145 strncmp(sat->suffix+1, str, tl-1))) {
146 rv |= sat->bit; 146 rv |= sat->bit;