summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <programble@gmail.com>2018-02-22 15:30:12 -0500
committerJune McEnroe <programble@gmail.com>2018-02-22 15:30:12 -0500
commitd37e895fb7955f6090b02a125236282e1858b53c (patch)
tree3195d6be8245dbc5393a72944a779e12954fc358
parentHandle EINTR from kevent (diff)
downloadstream-d37e895fb7955f6090b02a125236282e1858b53c.tar.gz
stream-d37e895fb7955f6090b02a125236282e1858b53c.zip
Factor out STREAM_SIZE for ingest and broadcast
-rw-r--r--broadcast.c4
-rw-r--r--ingest.c4
-rw-r--r--stream.h17
3 files changed, 23 insertions, 2 deletions
diff --git a/broadcast.c b/broadcast.c
index c31112e..280a552 100644
--- a/broadcast.c
+++ b/broadcast.c
@@ -33,6 +33,8 @@
 #include <util.h>
 #endif
 
+#include "stream.h"
+
 static struct termios saveTerm;
 static void restoreTerm(void) {
     tcsetattr(STDERR_FILENO, TCSADRAIN, &saveTerm);
@@ -113,7 +115,7 @@ int main(int argc, char *argv[]) {
             if (writeSize < readSize) errx(EX_IOERR, "short write(%d)", remote);
 
             totalSize += readSize;
-            if (totalSize > 1024 * 1024) {
+            if (totalSize >= STREAM_SIZE) {
                 buf[0] = CTRL('L');
                 writeSize = write(pty, buf, 1);
                 if (writeSize < 0) err(EX_IOERR, "write(%d)", pty);
diff --git a/ingest.c b/ingest.c
index 9fa754d..6ba387b 100644
--- a/ingest.c
+++ b/ingest.c
@@ -22,6 +22,8 @@
 #include <sysexits.h>
 #include <unistd.h>
 
+#include "stream.h"
+
 int main(int argc, char *argv[]) {
     if (argc < 2) return EX_USAGE;
     const char *path = argv[1];
@@ -49,7 +51,7 @@ int main(int argc, char *argv[]) {
 
         char buf[4096];
         ssize_t totalSize = 0;
-        while (totalSize < 1024 * 1024) {
+        while (totalSize < STREAM_SIZE) {
             ssize_t readSize = read(remote, buf, sizeof(buf));
             if (readSize < 0) err(EX_IOERR, "read(%d)", remote);
             if (!readSize) return EX_OK;
diff --git a/stream.h b/stream.h
new file mode 100644
index 0000000..d719b7b
--- /dev/null
+++ b/stream.h
@@ -0,0 +1,17 @@
+/* Copyright (c) 2018, Curtis McEnroe <programble@gmail.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define STREAM_SIZE (1024 * 1024)
d>Update email addressesJune McEnroe 2020-04-23Call updateConsumer from handleError 1.2p1June McEnroe 2020-04-20Use . as ${LDLIBS.$@} separatorJune McEnroe 2020-04-05Error on invalid ISUPPORT values 1.2June McEnroe 2020-04-05Only set RCS on FreeBSDJune McEnroe 2020-04-05Log bans and unbansJune McEnroe 2020-04-05Parse mode types from ISUPPORTJune McEnroe 2020-04-05Add unscoop matchers for ban/unban eventsJune McEnroe 2020-04-05Check unscoop regexps with make testJune McEnroe 2020-04-05Add unscoop -n flag for checking regexpsJune McEnroe 2020-04-05Add Ban and Unban event typesJune McEnroe 2020-04-02Update styleJune McEnroe 2020-03-31Update unscoop catgirl matchersJune McEnroe 2020-03-31Fix writing verbose to stderrJune McEnroe 2020-03-02Include <>/-/* around nicks in scoop coloring 1.1June McEnroe 2020-03-02Replace .mk files with configure scriptJune McEnroe 2020-02-28Implement the causal.agency/consumer capabilityJune McEnroe 2020-02-22Include <>/-/* around nicks in coloringJune McEnroe 2020-02-22Use (almost) the full range of IRC colors for nicksJune McEnroe