123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191 |
- #include "sys-defines.h"
- #include "extern.h"
- #ifdef MSDOS
- #include <unistd.h>
- #endif
- #ifdef PTHREAD_SUPPORT
- #ifdef HAVE_PTHREAD_H
- extern pthread_mutex_t _plotters_mutex;
- #endif
- #endif
- int
- _API_flushpl (S___(Plotter *_plotter))
- {
- int retval = 0;
- if (!_plotter->data->open)
- {
- _plotter->error (R___(_plotter)
- "flushpl: invalid operation");
- return -1;
- }
- switch ((int)_plotter->data->output_model)
- {
- case (int)PL_OUTPUT_NONE:
-
- break;
- case (int)PL_OUTPUT_ONE_PAGE:
- case (int)PL_OUTPUT_ONE_PAGE_AT_A_TIME:
- case (int)PL_OUTPUT_PAGES_ALL_AT_ONCE:
-
- if (_plotter->data->outfp)
- {
- if (fflush(_plotter->data->outfp) < 0
- #ifdef MSDOS
-
- || fsync (_plotter->data->outfp) < 0
- #endif
- )
- retval = -1;
- }
- #ifdef LIBPLOTTER
- if (_plotter->data->outstream)
- {
- _plotter->data->outstream->flush ();
- if (!(*(_plotter->data->outstream)))
- retval = -1;
- }
- #endif
- break;
-
- case (int)PL_OUTPUT_VIA_CUSTOM_ROUTINES:
- case (int)PL_OUTPUT_VIA_CUSTOM_ROUTINES_IN_REAL_TIME:
- case (int)PL_OUTPUT_VIA_CUSTOM_ROUTINES_TO_NON_STREAM:
-
- if (_plotter->flush_output (S___(_plotter)) == false)
- retval = -1;
- break;
- default:
- break;
- }
- if (retval < 0)
- _plotter->error (R___(_plotter) "the output stream is jammed");
- return retval;
- }
- bool
- _pl_g_flush_output (S___(Plotter *_plotter))
- {
- return true;
- }
- void
- _pl_g_flush_plotter_outstreams (S___(Plotter *_plotter))
- {
- #ifndef LIBPLOTTER
- #ifdef HAVE_NULL_FLUSH
- fflush ((FILE *)NULL);
- #else
- int i;
- #ifdef PTHREAD_SUPPORT
- #ifdef HAVE_PTHREAD_H
- pthread_mutex_lock (&_plotters_mutex);
- #endif
- #endif
- for (i = 0; i < _plotters_len; i++)
- if (_plotters[i])
- {
- if (_plotters[i]->data->outfp)
- fflush (_plotters[i]->data->outfp);
- if (_plotters[i]->data->errfp)
- fflush (_plotters[i]->data->errfp);
- }
- #ifdef PTHREAD_SUPPORT
- #ifdef HAVE_PTHREAD_H
- pthread_mutex_unlock (&_plotters_mutex);
- #endif
- #endif
- #endif
- #else
- int i;
- #ifdef PTHREAD_SUPPORT
- #ifdef HAVE_PTHREAD_H
- pthread_mutex_lock (&_plotters_mutex);
- #endif
- #endif
- #ifdef HAVE_NULL_FLUSH
- fflush ((FILE *)NULL);
- for (i = 0; i < _plotters_len; i++)
- if (_plotters[i])
- {
- if (_plotters[i]->data->outstream)
- _plotters[i]->data->outstream->flush ();
- if (_plotters[i]->data->errstream)
- _plotters[i]->data->errstream->flush ();
- }
- #else
- for (i = 0; i < _plotters_len; i++)
- if (_plotters[i])
- {
- if (_plotters[i]->data->outfp)
- fflush (_plotters[i]->data->outfp);
- if (_plotters[i]->data->errfp)
- fflush (_plotters[i]->data->errfp);
- if (_plotters[i]->data->outstream)
- _plotters[i]->data->outstream->flush ();
- if (_plotters[i]->data->errstream)
- _plotters[i]->data->errstream->flush ();
- }
- #endif
- #ifdef PTHREAD_SUPPORT
- #ifdef HAVE_PTHREAD_H
- pthread_mutex_unlock (&_plotters_mutex);
- #endif
- #endif
- #endif
- }
|