4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
30 #pragma ident "%Z%%M% %I% %E% SMI"
35 * The following macro computes the number of seconds to sleep
36 * AFTER waiting for the system buffers to be drained.
40 * - A percentage (perhaps even >100%) of the time it would
41 * take to print the printer's buffer. Use this if it appears
42 * the printers are affected if the port is closed before they
45 * - 0. Use this to avoid any extra sleep after waiting for the
46 * system buffers to be flushed.
48 * - N > 0. Use this to have a fixed sleep after flushing the
51 * The sleep period can be overridden by a single command line argument.
53 /* 25% of the print-full-buffer time, plus 1 */
54 #define LONG_ENOUGH(BUFSZ,CPS) (1 + ((250 * BUFSZ) / CPS) / 1000)
63 main(int argc
, char *argv
[])
65 extern char *getenv();
76 * Wait for the output to drain.
78 ioctl (1, TCSBRK
, (struct termio
*)1);
81 * Decide how long to sleep.
83 if (argc
!= 2 || (sleep_time
= atoi(argv
[1])) < 0)
84 if ((TERM
= getenv("TERM"))) {
85 tidbit (TERM
, "bufsz", &bufsz
);
86 tidbit (TERM
, "cps", &cps
);
87 if (cps
> 0 && bufsz
> 0)
88 sleep_time
= LONG_ENOUGH(bufsz
, cps
);
93 * Wait ``long enough'' for the printer to finish
94 * printing what's in its buffer.