+/*
+ * innduct
+ * tailing reliable realtime streaming feeder for inn
+ * infile.c - monitoring and handling of input files
+ *
+ * Copyright (C) 2010 Ian Jackson <ijackson@chiark.greenend.org.uk>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * (I believe that when you compile and link this as part of the inn2
+ * build, with the Makefile runes I have provided, all the libraries
+ * and files which end up included in innduct are licence-compatible
+ * with GPLv3. If not then please let me know. -Ian Jackson.)
+ */
+
+#include "innduct.h"
+
/*========== monitoring of input files ==========*/
static void feedfile_eof(InputFile *ipf) {
}
}
-static InputFile *open_input_file(const char *path) {
+InputFile *open_input_file(const char *path) {
int fd= open(path, O_RDWR);
if (fd<0) {
if (errno==ENOENT) return 0;
return ipf;
}
-static void close_input_file(InputFile *ipf) { /* does not free */
+void close_input_file(InputFile *ipf) { /* does not free */
assert(!ipf->readable_callback); /* must have had ->on_cancel */
assert(!ipf->filemon); /* must have had inputfile_reading_stop */
assert(!ipf->rd); /* must have had inputfile_reading_stop */
ipf->readable_callback= 0;
}
-static void tailing_make_readable(InputFile *ipf) {
+void tailing_make_readable(InputFile *ipf) {
dbg("**TRACT** ipf=%p makereadable rcb=%p",ipf,
(void*)ipf?ipf->readable_callback:0);
if (!ipf || !ipf->readable_callback) /* so callers can be naive */
OOP_RD_SHORTREC_LONG,
};
-static void inputfile_reading_resume(InputFile *ipf) {
+void inputfile_reading_resume(InputFile *ipf) {
if (!ipf->rd) return;
if (!ipf->paused) return;
ipf->paused= 0;
}
-static void inputfile_reading_pause(InputFile *ipf) {
+void inputfile_reading_pause(InputFile *ipf) {
if (!ipf->rd) return;
if (ipf->paused) return;
oop_rd_cancel(ipf->rd);
ipf->paused= 1;
}
-static void inputfile_reading_start(InputFile *ipf) {
+void inputfile_reading_start(InputFile *ipf) {
assert(!ipf->rd);
ipf->readable.on_readable= tailing_on_readable;
ipf->readable.on_cancel= tailing_on_cancel;
inputfile_reading_resume(ipf);
}
-static void inputfile_reading_stop(InputFile *ipf) {
+void inputfile_reading_stop(InputFile *ipf) {
assert(ipf->rd);
inputfile_reading_pause(ipf);
oop_rd_delete(ipf->rd);
tailing_make_readable(flushing_input_file);
}
+char *dbg_report_ipf(InputFile *ipf) {
+ if (!ipf) return xasprintf("none");
+
+ const char *slash= strrchr(ipf->path,'/');
+ const char *path= slash ? slash+1 : ipf->path;
+
+ return xasprintf("%p/%s:queue=%d,ip=%ld,autodef=%ld,off=%ld,fd=%d%s%s%s",
+ ipf, path,
+ ipf->queue.count, ipf->inprogress, ipf->autodefer,
+ (long)ipf->offset, ipf->fd,
+ ipf->rd ? "" : ",!rd",
+ ipf->skippinglong ? "*skiplong" : "",
+ ipf->rd && ipf->paused ? "*paused" : "");
+}