summaryrefslogtreecommitdiff
path: root/data.c
diff options
context:
space:
mode:
Diffstat (limited to 'data.c')
-rw-r--r--data.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/data.c b/data.c
index f36c01d..c545535 100644
--- a/data.c
+++ b/data.c
@@ -359,7 +359,7 @@ d_char *index_list(const char *fn, int max)
359} 359}
360 360
361 361
362d_char *index_list_desc(const char *fn, int max) 362d_char *index_list_desc(const char *fn, int skip, int show)
363/* returns an index as a list, in reverse order */ 363/* returns an index as a list, in reverse order */
364{ 364{
365 d_char *list = NULL; 365 d_char *list = NULL;
@@ -372,9 +372,9 @@ d_char *index_list_desc(const char *fn, int max)
372 char line[256]; 372 char line[256];
373 list = xs_list_new(); 373 list = xs_list_new();
374 374
375 /* move to the end minus one entry */ 375 /* move to the end minus one entry (or more, if skipping entries) */
376 if (!fseek(f, 0, SEEK_END) && !fseek(f, -33, SEEK_CUR)) { 376 if (!fseek(f, 0, SEEK_END) && !fseek(f, (skip + 1) * -33, SEEK_CUR)) {
377 while (n < max && fgets(line, sizeof(line), f) != NULL) { 377 while (n < show && fgets(line, sizeof(line), f) != NULL) {
378 line[32] = '\0'; 378 line[32] = '\0';
379 list = xs_list_append(list, line); 379 list = xs_list_append(list, line);
380 n++; 380 n++;
@@ -856,7 +856,7 @@ d_char *timeline_top_level(d_char *list)
856} 856}
857 857
858 858
859d_char *timeline_simple_list(snac *snac, const char *idx_name, int max) 859d_char *timeline_simple_list(snac *snac, const char *idx_name, int skip, int show)
860/* returns a timeline (with all entries) */ 860/* returns a timeline (with all entries) */
861{ 861{
862 int c_max; 862 int c_max;
@@ -865,19 +865,19 @@ d_char *timeline_simple_list(snac *snac, const char *idx_name, int max)
865 c_max = xs_number_get(xs_dict_get(srv_config, "max_timeline_entries")); 865 c_max = xs_number_get(xs_dict_get(srv_config, "max_timeline_entries"));
866 866
867 /* never more timeline entries than the configured maximum */ 867 /* never more timeline entries than the configured maximum */
868 if (max > c_max) 868 if (show > c_max)
869 max = c_max; 869 show = c_max;
870 870
871 xs *idx = xs_fmt("%s/%s.idx", snac->basedir, idx_name); 871 xs *idx = xs_fmt("%s/%s.idx", snac->basedir, idx_name);
872 872
873 return index_list_desc(idx, max); 873 return index_list_desc(idx, skip, show);
874} 874}
875 875
876 876
877d_char *timeline_list(snac *snac, const char *idx_name, int max) 877d_char *timeline_list(snac *snac, const char *idx_name, int skip, int show)
878/* returns a timeline (only top level entries) */ 878/* returns a timeline (only top level entries) */
879{ 879{
880 xs *list = timeline_simple_list(snac, idx_name, max); 880 xs *list = timeline_simple_list(snac, idx_name, skip, show);
881 881
882 return timeline_top_level(list); 882 return timeline_top_level(list);
883} 883}