From 8d299570e99e41074dba214f180d29058605eb91 Mon Sep 17 00:00:00 2001 From: discomfitor Date: Tue, 16 Aug 2011 19:04:25 -0400 Subject: [PATCH] add queue popping functions --- liblrzip.c | 18 ++++++++++++++++++ liblrzip.h | 2 ++ 2 files changed, 20 insertions(+) diff --git a/liblrzip.c b/liblrzip.c index 576f89b..2895da9 100644 --- a/liblrzip.c +++ b/liblrzip.c @@ -277,6 +277,15 @@ bool lrzip_file_del(Lrzip *lr, FILE *file) return true; } +FILE *lrzip_file_pop(Lrzip *lr) +{ + FILE *ret; + if ((!lr) || (!lr->infile_buckets)) return NULL; + ret = lr->infiles[0]; + lrzip_file_del(lr, ret); + return ret; +} + void lrzip_files_clear(Lrzip *lr) { if ((!lr) || (!lr->infile_buckets)) return; @@ -328,6 +337,15 @@ bool lrzip_filename_del(Lrzip *lr, const char *file) return true; } +const char *lrzip_filename_pop(Lrzip *lr) +{ + static char buf[4096]; + if ((!lr) || (!lr->infilename_buckets)) return NULL; + strcat(buf, lr->infilenames[0]); + lrzip_filename_del(lr, buf); + return &buf[0]; +} + void lrzip_filenames_clear(Lrzip *lr) { size_t x; diff --git a/liblrzip.h b/liblrzip.h index 39aeb15..4c29319 100644 --- a/liblrzip.h +++ b/liblrzip.h @@ -87,9 +87,11 @@ FILE **lrzip_files_get(Lrzip *lr); char **lrzip_filenames_get(Lrzip *lr); bool lrzip_file_add(Lrzip *lr, FILE *file); bool lrzip_file_del(Lrzip *lr, FILE *file); +FILE *lrzip_file_pop(Lrzip *lr); void lrzip_files_clear(Lrzip *lr); bool lrzip_filename_add(Lrzip *lr, const char *file); bool lrzip_filename_del(Lrzip *lr, const char *file); +const char *lrzip_filename_pop(Lrzip *lr); void lrzip_filenames_clear(Lrzip *lr); void lrzip_suffix_set(Lrzip *lr, const char *suffix); const char *lrzip_suffix_get(Lrzip *lr);