X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Ftinfo%2Flib_print.c;h=e5abd4de614533964c0b3c4e9d4b1a2e711f7c69;hp=63ac648b5439cc317543442edfedfa9340b7c8c2;hb=85201fb67296429954e5c0a7784ec2c21a900c1d;hpb=0eb88fc5281804773e2a0c7a488a4452463535ce diff --git a/ncurses/tinfo/lib_print.c b/ncurses/tinfo/lib_print.c index 63ac648b..e5abd4de 100644 --- a/ncurses/tinfo/lib_print.c +++ b/ncurses/tinfo/lib_print.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998 Free Software Foundation, Inc. * + * Copyright (c) 1998-2006,2009 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -29,51 +29,51 @@ /**************************************************************************** * Author: Zeyd M. Ben-Halim 1992,1995 * * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + * and: Juergen Pfeifer * ****************************************************************************/ - #include -#include +#ifndef CUR +#define CUR SP_TERMTYPE +#endif -MODULE_ID("$Id: lib_print.c,v 1.11 1999/02/27 19:59:05 tom Exp $") +MODULE_ID("$Id: lib_print.c,v 1.19 2009/06/06 20:26:17 tom Exp $") -int mcprint(char *data, int len) +NCURSES_EXPORT(int) +NCURSES_SP_NAME(mcprint) (NCURSES_SP_DCLx char *data, int len) /* ship binary character data to the printer via mc4/mc5/mc5p */ { - char *mybuf, *switchon; - size_t onsize, offsize, res; + char *mybuf, *switchon; + size_t onsize, offsize, res; errno = 0; - if (!cur_term || (!prtr_non && (!prtr_on || !prtr_off))) - { + if (!HasTInfoTerminal(SP_PARM) || (!prtr_non && (!prtr_on || !prtr_off))) { errno = ENODEV; - return(ERR); + return (ERR); } - if (prtr_non) - { - switchon = tparm(prtr_non, len); + if (prtr_non) { + switchon = TPARM_1(prtr_non, len); onsize = strlen(switchon); offsize = 0; - } - else - { + } else { switchon = prtr_on; onsize = strlen(prtr_on); offsize = strlen(prtr_off); } - if ((mybuf = typeMalloc(char, onsize + len + offsize + 1)) == (char *)0) - { + if (switchon == 0 + || (mybuf = typeMalloc(char, onsize + len + offsize + 1)) == 0) { errno = ENOMEM; - return(ERR); + return (ERR); } (void) strcpy(mybuf, switchon); - memcpy(mybuf + onsize, data, len); + memcpy(mybuf + onsize, data, (unsigned) len); if (offsize) - (void) strcpy(mybuf + onsize + len, prtr_off); + (void) strcpy(mybuf + onsize + len, prtr_off); /* * We're relying on the atomicity of UNIX writes here. The @@ -82,15 +82,24 @@ int mcprint(char *data, int len) * data has actually been shipped to the terminal. If the write(2) * operation is truly atomic we're protected from this. */ - res = write(cur_term->Filedes, mybuf, onsize + len + offsize); + res = write(TerminalOf(SP_PARM)->Filedes, mybuf, onsize + len + offsize); /* * By giving up our scheduler slot here we increase the odds that the * kernel will ship the contiguous clist items from the last write * immediately. */ +#ifndef __MINGW32__ (void) sleep(0); - +#endif free(mybuf); - return(res); + return (res); +} + +#if NCURSES_SP_FUNCS && !defined(USE_TERM_DRIVER) +NCURSES_EXPORT(int) +mcprint(char *data, int len) +{ + return NCURSES_SP_NAME(mcprint) (CURRENT_SCREEN, data, len); } +#endif