Mercurial > hg > xemacs-beta
comparison src/termcap.c @ 442:abe6d1db359e r21-2-36
Import from CVS: tag r21-2-36
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:35:02 +0200 |
parents | 84b14dcb0985 |
children | 943eaba38521 |
comparison
equal
deleted
inserted
replaced
441:72a7cfa4a488 | 442:abe6d1db359e |
---|---|
92 | 92 |
93 /* The pointer to the data made by tgetent is left here | 93 /* The pointer to the data made by tgetent is left here |
94 for tgetnum, tgetflag and tgetstr to find. */ | 94 for tgetnum, tgetflag and tgetstr to find. */ |
95 static char *term_entry; | 95 static char *term_entry; |
96 | 96 |
97 static CONST char *tgetst1 (CONST char *ptr, char **area); | 97 static const char *tgetst1 (const char *ptr, char **area); |
98 | 98 |
99 /* Search entry BP for capability CAP. | 99 /* Search entry BP for capability CAP. |
100 Return a pointer to the capability (in BP) if found, | 100 Return a pointer to the capability (in BP) if found, |
101 0 if not found. */ | 101 0 if not found. */ |
102 | 102 |
103 static CONST char * | 103 static const char * |
104 find_capability (bp, cap) | 104 find_capability (bp, cap) |
105 CONST char *bp; | 105 const char *bp; |
106 CONST char *cap; | 106 const char *cap; |
107 { | 107 { |
108 for (; *bp; bp++) | 108 for (; *bp; bp++) |
109 if (bp[0] == ':' | 109 if (bp[0] == ':' |
110 && bp[1] == cap[0] | 110 && bp[1] == cap[0] |
111 && bp[2] == cap[1]) | 111 && bp[2] == cap[1]) |
113 return 0; | 113 return 0; |
114 } | 114 } |
115 | 115 |
116 int | 116 int |
117 tgetnum (cap) | 117 tgetnum (cap) |
118 CONST char *cap; | 118 const char *cap; |
119 { | 119 { |
120 CONST char *ptr = find_capability (term_entry, cap); | 120 const char *ptr = find_capability (term_entry, cap); |
121 if (!ptr || ptr[-1] != '#') | 121 if (!ptr || ptr[-1] != '#') |
122 return -1; | 122 return -1; |
123 return atoi (ptr); | 123 return atoi (ptr); |
124 } | 124 } |
125 | 125 |
126 int | 126 int |
127 tgetflag (cap) | 127 tgetflag (cap) |
128 CONST char *cap; | 128 const char *cap; |
129 { | 129 { |
130 CONST char *ptr = find_capability (term_entry, cap); | 130 const char *ptr = find_capability (term_entry, cap); |
131 return 0 != ptr && ptr[-1] == ':'; | 131 return 0 != ptr && ptr[-1] == ':'; |
132 } | 132 } |
133 | 133 |
134 /* Look up a string-valued capability CAP. | 134 /* Look up a string-valued capability CAP. |
135 If AREA is nonzero, it points to a pointer to a block in which | 135 If AREA is nonzero, it points to a pointer to a block in which |
136 to store the string. That pointer is advanced over the space used. | 136 to store the string. That pointer is advanced over the space used. |
137 If AREA is zero, space is allocated with `malloc'. */ | 137 If AREA is zero, space is allocated with `malloc'. */ |
138 | 138 |
139 CONST char * | 139 const char * |
140 tgetstr (cap, area) | 140 tgetstr (cap, area) |
141 CONST char *cap; | 141 const char *cap; |
142 char **area; | 142 char **area; |
143 { | 143 { |
144 CONST char *ptr = find_capability (term_entry, cap); | 144 const char *ptr = find_capability (term_entry, cap); |
145 if (!ptr || (ptr[-1] != '=' && ptr[-1] != '~')) | 145 if (!ptr || (ptr[-1] != '=' && ptr[-1] != '~')) |
146 return 0; | 146 return 0; |
147 return tgetst1 (ptr, area); | 147 return tgetst1 (ptr, area); |
148 } | 148 } |
149 | 149 |
160 /* PTR points to a string value inside a termcap entry. | 160 /* PTR points to a string value inside a termcap entry. |
161 Copy that value, processing \ and ^ abbreviations, | 161 Copy that value, processing \ and ^ abbreviations, |
162 into the block that *AREA points to, | 162 into the block that *AREA points to, |
163 or to newly allocated storage if AREA is 0. */ | 163 or to newly allocated storage if AREA is 0. */ |
164 | 164 |
165 static CONST char * | 165 static const char * |
166 tgetst1 (ptr, area) | 166 tgetst1 (ptr, area) |
167 CONST char *ptr; | 167 const char *ptr; |
168 char **area; | 168 char **area; |
169 { | 169 { |
170 CONST char *p; | 170 const char *p; |
171 char *r; | 171 char *r; |
172 int c; | 172 int c; |
173 int size; | 173 int size; |
174 char *ret; | 174 char *ret; |
175 int c1; | 175 int c1; |
248 -18, -24, -48, -96, -192, -288, -384, -576, -1152 | 248 -18, -24, -48, -96, -192, -288, -384, -576, -1152 |
249 }; | 249 }; |
250 | 250 |
251 void | 251 void |
252 tputs (string, nlines, outfun) | 252 tputs (string, nlines, outfun) |
253 CONST char *string; | 253 const char *string; |
254 int nlines; | 254 int nlines; |
255 void (*outfun) (int); | 255 void (*outfun) (int); |
256 { | 256 { |
257 int padcount = 0; | 257 int padcount = 0; |
258 int speed; | 258 int speed; |
267 #endif | 267 #endif |
268 | 268 |
269 if (string == (char *) 0) | 269 if (string == (char *) 0) |
270 return; | 270 return; |
271 | 271 |
272 while (isdigit (* (CONST unsigned char *) string)) | 272 while (isdigit (* (const unsigned char *) string)) |
273 { | 273 { |
274 padcount += *string++ - '0'; | 274 padcount += *string++ - '0'; |
275 padcount *= 10; | 275 padcount *= 10; |
276 } | 276 } |
277 if (*string == '.') | 277 if (*string == '.') |
329 If BP is zero, space is dynamically allocated. */ | 329 If BP is zero, space is dynamically allocated. */ |
330 | 330 |
331 int | 331 int |
332 tgetent (bp, name) | 332 tgetent (bp, name) |
333 char *bp; | 333 char *bp; |
334 CONST char *name; | 334 const char *name; |
335 { | 335 { |
336 char *tem; | 336 char *tem; |
337 int fd; | 337 int fd; |
338 struct buffer buf; | 338 struct buffer buf; |
339 char *bp1; | 339 char *bp1; |
340 char *bp2; | 340 char *bp2; |
341 CONST char *term; | 341 const char *term; |
342 int malloc_size = 0; | 342 int malloc_size = 0; |
343 int c; | 343 int c; |
344 char *tcenv; /* TERMCAP value, if it contais :tc=. */ | 344 char *tcenv; /* TERMCAP value, if it contains :tc=. */ |
345 CONST char *indirect = 0; /* Terminal type in :tc= in TERMCAP value. */ | 345 const char *indirect = 0; /* Terminal type in :tc= in TERMCAP value. */ |
346 | 346 |
347 tem = getenv ("TERMCAP"); | 347 tem = getenv ("TERMCAP"); |
348 if (tem && *tem == 0) tem = 0; | 348 if (tem && *tem == 0) tem = 0; |
349 | 349 |
350 | 350 |
635 printf ("co: %d\n", tgetnum ("co")); | 635 printf ("co: %d\n", tgetnum ("co")); |
636 printf ("am: %d\n", tgetflag ("am")); | 636 printf ("am: %d\n", tgetflag ("am")); |
637 } | 637 } |
638 | 638 |
639 tprint (cap) | 639 tprint (cap) |
640 CONST char *cap; | 640 const char *cap; |
641 { | 641 { |
642 char *x = tgetstr (cap, 0); | 642 char *x = tgetstr (cap, 0); |
643 char *y; | 643 char *y; |
644 | 644 |
645 printf ("%s: ", cap); | 645 printf ("%s: ", cap); |