-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtputs.c
95 lines (82 loc) · 1.13 KB
/
tputs.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#include "termcap.h"
#define DELAYS 1
char PC_;
#ifndef NULL
# define NULL ((char *)0)
#endif
#if !defined(OSK) && !defined(__OSK__)
short ospeed = 0;
#endif
#if DELAYS
static short time_tab[] = {
2000,
1333,
909,
743,
666,
333,
166,
83,
55,
50,
42,
28,
20,
14,
10,
5,
2
};
#endif
void tputs(const char *str, int lines_affected, void (*outfunc)(int))
{
#if DELAYS
register short time_delay = 0;
#endif
if (str == NULL)
return;
if (*str >= '0' && *str <= '9')
{
do
{
#if DELAYS
time_delay = time_delay * 10 + *str - '0';
#endif
str++;
} while (*str >= '0' && *str <= '9');
}
#if DELAYS
time_delay *= 10;
#endif
if (*str == '.' && *++str >= '0' && *str <= '9')
{
#if DELAYS
time_delay += *str - '0';
#endif
str++;
}
if (*str == '*')
{
#if DELAYS
time_delay *= lines_affected;
#endif
str++;
}
while (*str != '\0')
{
(*outfunc)(*str++);
}
#if DELAYS
if (time_delay != 0 && ospeed >= 0 && ospeed < 17)
{
register short i;
time_delay += time_tab[ospeed] / 2;
for (i = time_delay / time_tab[ospeed]; i > 0; i--)
{
(*outfunc)(PC_);
}
}
#else
if (lines_affected);
#endif
}