diff options
author | Lars Hjemli | 2008-03-24 16:00:27 +0100 |
---|---|---|
committer | Lars Hjemli | 2008-03-24 16:00:27 +0100 |
commit | f34478cbe0214a201e7ecef3e79ed6c957b7beee (patch) | |
tree | 1ee05da742488cab51a06e083d26b7b58d829b43 /shared.c | |
parent | e0e4478e7b4812f822d60a13a33525f8e529e1e8 (diff) | |
download | cgit-f34478cbe0214a201e7ecef3e79ed6c957b7beee.tar.gz cgit-f34478cbe0214a201e7ecef3e79ed6c957b7beee.tar.bz2 cgit-f34478cbe0214a201e7ecef3e79ed6c957b7beee.zip |
Refactor snapshot support
The snapshot support needs to be split between output- and config-related
functions to get the layering between shared.c and ui-*.c right. There
is also some codestyle-issues which needs fixing to make the snapshot
functions more similar to the rest of the cgit code.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (limited to 'shared.c')
-rw-r--r-- | shared.c | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -479,3 +479,30 @@ void cgit_diff_commit(struct commit *commit, filepair_fn fn) | |||
479 | old_sha1 = commit->parents->item->object.sha1; | 479 | old_sha1 = commit->parents->item->object.sha1; |
480 | cgit_diff_tree(old_sha1, commit->object.sha1, fn, NULL); | 480 | cgit_diff_tree(old_sha1, commit->object.sha1, fn, NULL); |
481 | } | 481 | } |
482 | |||
483 | int cgit_parse_snapshots_mask(const char *str) | ||
484 | { | ||
485 | const struct cgit_snapshot_format *f; | ||
486 | static const char *delim = " \t,:/|;"; | ||
487 | int tl, sl, rv = 0; | ||
488 | |||
489 | /* favor legacy setting */ | ||
490 | if(atoi(str)) | ||
491 | return 1; | ||
492 | for(;;) { | ||
493 | str += strspn(str,delim); | ||
494 | tl = strcspn(str,delim); | ||
495 | if (!tl) | ||
496 | break; | ||
497 | for (f = cgit_snapshot_formats; f->suffix; f++) { | ||
498 | sl = strlen(f->suffix); | ||
499 | if((tl == sl && !strncmp(f->suffix, str, tl)) || | ||
500 | (tl == sl-1 && !strncmp(f->suffix+1, str, tl-1))) { | ||
501 | rv |= f->bit; | ||
502 | break; | ||
503 | } | ||
504 | } | ||
505 | str += tl; | ||
506 | } | ||
507 | return rv; | ||
508 | } | ||