send a string to the terminal, possibly padded with trailing NULs */
| 484 | |
| 485 | /* send a string to the terminal, possibly padded with trailing NULs */ |
| 486 | void |
| 487 | tputs(const char *string, /* characters to output */ |
| 488 | int range, /* number of lines affected, used for `*' delays */ |
| 489 | int (*output_func)(int)) /* actual output routine; |
| 490 | * return value ignored */ |
| 491 | { |
| 492 | int c, num = 0; |
| 493 | const char *p = string; |
| 494 | |
| 495 | if (!p || !*p) |
| 496 | return; |
| 497 | |
| 498 | /* pick out padding prefix, if any */ |
| 499 | if (*p >= '0' && *p <= '9') { |
| 500 | do { /* note: scale `num' by 10 to accommodate fraction */ |
| 501 | num += (*p++ - '0'), num *= 10; |
| 502 | } while (*p >= '0' && *p <= '9'); |
| 503 | if (*p == '.') |
| 504 | ++p, num += (*p >= '0' && *p <= '9') ? (*p++ - '0') : 0; |
| 505 | if (*p == '*') |
| 506 | ++p, num *= range; |
| 507 | } |
| 508 | |
| 509 | /* output the string */ |
| 510 | while ((c = *p++) != '\0') { |
| 511 | if (c == '\200') |
| 512 | c = '\0'; /* undo tgetstr's encoding */ |
| 513 | (void) (*output_func)(c); |
| 514 | } |
| 515 | |
| 516 | #ifndef NO_DELAY_PADDING |
| 517 | /* perform padding */ |
| 518 | if (num) { |
| 519 | long pad; |
| 520 | |
| 521 | /* figure out how many chars needed to produce desired elapsed time */ |
| 522 | pad = (long) baud_rates[ospeed]; |
| 523 | if (pad < 0) |
| 524 | pad *= -100L; |
| 525 | pad *= (long) num; |
| 526 | /* 100000 == 10 bits/char * (1000 millisec/sec scaled by 10) */ |
| 527 | num = (int) (pad / 100000L); /* number of characters */ |
| 528 | |
| 529 | c = PC; /* assume output_func isn't allowed to change PC */ |
| 530 | while (--num >= 0) |
| 531 | (void) (*output_func)(c); |
| 532 | } |
| 533 | #endif /* !NO_DELAY_PADDING */ |
| 534 | |
| 535 | return; |
| 536 | } |
| 537 | |
| 538 | /*tclib.c*/ |