summaryrefslogtreecommitdiff
path: root/src/drivers/Posix/Fl_Posix_System_Driver.cxx
diff options
context:
space:
mode:
authorManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2022-11-15 10:09:01 +0100
committerManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2022-11-15 10:09:01 +0100
commit7f8f7c5b851f4e15cf95c6e819bff284b7fda7ca (patch)
tree48a51de221358f977c494a955b73ceca6cd679be /src/drivers/Posix/Fl_Posix_System_Driver.cxx
parent433a8e71e81c51a96f1d617fae5a3a4aac4efaeb (diff)
Add support of .svgz image files to fluid
The prototype of the public Fl_SVG_Image constructor is expanded to allow construction from in-memory, gzip'ed binary data.
Diffstat (limited to 'src/drivers/Posix/Fl_Posix_System_Driver.cxx')
-rw-r--r--src/drivers/Posix/Fl_Posix_System_Driver.cxx29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/drivers/Posix/Fl_Posix_System_Driver.cxx b/src/drivers/Posix/Fl_Posix_System_Driver.cxx
index dcf9e8f1a..ec43ea741 100644
--- a/src/drivers/Posix/Fl_Posix_System_Driver.cxx
+++ b/src/drivers/Posix/Fl_Posix_System_Driver.cxx
@@ -1,7 +1,7 @@
//
// Definition of Posix system driver (used by the X11, Wayland and macOS platforms).
//
-// Copyright 1998-2021 by Bill Spitzak and others.
+// Copyright 1998-2022 by Bill Spitzak and others.
//
// This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file. If this
@@ -308,6 +308,33 @@ bool Fl_Posix_System_Driver::probe_for_GTK(int major, int minor, void **p_ptr_gt
#endif // HAVE_DLSYM && HAVE_DLFCN_H
+int Fl_Posix_System_Driver::close_fd(int fd) { return close(fd); }
+
+int Fl_Posix_System_Driver::write_nonblocking_fd(int fdwrite, const unsigned char *&bytes, size_t &rest_bytes) {
+ if (rest_bytes > 0) {
+ ssize_t nw = write(fdwrite, bytes, rest_bytes);
+ if (nw == -1) {
+ close(fdwrite);
+ return 1; // error
+ }
+ bytes += nw;
+ rest_bytes -= nw;
+ if (rest_bytes == 0) close(fdwrite);
+ }
+ return 0; // success
+}
+
+void Fl_Posix_System_Driver::pipe_support(int &fdread, int &fdwrite, const unsigned char *unused, size_t unused_s) {
+ int fds[2];
+ if (pipe(fds)) { // create anonymous pipe
+ Fl_System_Driver::pipe_support(fdread, fdwrite, NULL, 0); // indicates error
+ } else {
+ fdread = fds[0];
+ fdwrite = fds[1];
+ fcntl(fdwrite, F_SETFL, O_NONBLOCK); // make pipe's write end non-blocking
+ }
+}
+
////////////////////////////////////////////////////////////////
// POSIX threading...
#if defined(HAVE_PTHREAD)