Lines 66-76
Link Here
|
66 |
* also flush the pty input buffer (by dropping its data) if it becomes |
66 |
* also flush the pty input buffer (by dropping its data) if it becomes |
67 |
* too full. |
67 |
* too full. |
68 |
*/ |
68 |
*/ |
69 |
|
69 |
void |
70 |
void |
70 |
ttloop(void) |
71 |
ttloop() |
|
|
72 |
{ |
71 |
{ |
73 |
|
|
|
74 |
DIAG(TD_REPORT, output_data("td: ttloop\r\n")); |
72 |
DIAG(TD_REPORT, output_data("td: ttloop\r\n")); |
75 |
if (nfrontp - nbackp > 0) { |
73 |
if (nfrontp - nbackp > 0) { |
76 |
netflush(); |
74 |
netflush(); |
Lines 393-414
Link Here
|
393 |
editedhost[sizeof editedhost - 1] = '\0'; |
391 |
editedhost[sizeof editedhost - 1] = '\0'; |
394 |
} |
392 |
} |
395 |
|
393 |
|
396 |
static char *putlocation; |
|
|
397 |
|
398 |
static void |
399 |
putstr(const char *s) |
400 |
{ |
401 |
|
402 |
while (*s) |
403 |
putchr(*s++); |
404 |
} |
405 |
|
406 |
void |
407 |
putchr(int cc) |
408 |
{ |
409 |
*putlocation++ = cc; |
410 |
} |
411 |
|
412 |
#ifdef __FreeBSD__ |
394 |
#ifdef __FreeBSD__ |
413 |
static char fmtstr[] = { "%+" }; |
395 |
static char fmtstr[] = { "%+" }; |
414 |
#else |
396 |
#else |
Lines 416-426
Link Here
|
416 |
#endif |
398 |
#endif |
417 |
|
399 |
|
418 |
void |
400 |
void |
419 |
putf(char *cp, char *where) |
401 |
putf(char *cp, char *where, size_t where_size) |
420 |
{ |
402 |
{ |
421 |
char *slash; |
403 |
char *slash; |
422 |
time_t t; |
404 |
time_t t; |
423 |
char db[100]; |
405 |
char db[100]; |
|
|
406 |
char ch_str[2] = {0, 0}; |
424 |
#ifdef __FreeBSD__ |
407 |
#ifdef __FreeBSD__ |
425 |
static struct utsname kerninfo; |
408 |
static struct utsname kerninfo; |
426 |
|
409 |
|
Lines 428-446
Link Here
|
428 |
uname(&kerninfo); |
411 |
uname(&kerninfo); |
429 |
#endif |
412 |
#endif |
430 |
|
413 |
|
431 |
putlocation = where; |
414 |
while (*cp != 0) { |
432 |
|
415 |
if (*cp == '\n') { |
433 |
while (*cp) { |
416 |
strlcat(where, "\r\n", where_size); |
434 |
if (*cp =='\n') { |
|
|
435 |
putstr("\r\n"); |
436 |
cp++; |
437 |
continue; |
438 |
} else if (*cp != '%') { |
417 |
} else if (*cp != '%') { |
439 |
putchr(*cp++); |
418 |
*ch_str = *cp; |
440 |
continue; |
419 |
strlcat(where, ch_str, where_size); |
441 |
} |
420 |
} else switch (*++cp) { |
442 |
switch (*++cp) { |
|
|
443 |
|
444 |
case 't': |
421 |
case 't': |
445 |
#ifdef STREAMSPTY |
422 |
#ifdef STREAMSPTY |
446 |
/* names are like /dev/pts/2 -- we want pts/2 */ |
423 |
/* names are like /dev/pts/2 -- we want pts/2 */ |
Lines 448-493
Link Here
|
448 |
#else |
425 |
#else |
449 |
slash = strrchr(line, '/'); |
426 |
slash = strrchr(line, '/'); |
450 |
#endif |
427 |
#endif |
451 |
if (slash == (char *) 0) |
428 |
if (slash == NULL) |
452 |
putstr(line); |
429 |
strlcat(where, line, where_size); |
453 |
else |
430 |
else |
454 |
putstr(&slash[1]); |
431 |
strlcat(where, &slash[1], where_size); |
455 |
break; |
432 |
break; |
456 |
|
|
|
457 |
case 'h': |
433 |
case 'h': |
458 |
putstr(editedhost); |
434 |
strlcat(where, editedhost, where_size); |
459 |
break; |
435 |
break; |
460 |
|
|
|
461 |
case 'd': |
436 |
case 'd': |
462 |
#ifdef __FreeBSD__ |
437 |
#ifdef __FreeBSD__ |
463 |
setlocale(LC_TIME, ""); |
438 |
setlocale(LC_TIME, ""); |
464 |
#endif |
439 |
#endif |
465 |
(void)time(&t); |
440 |
(void)time(&t); |
466 |
(void)strftime(db, sizeof(db), fmtstr, localtime(&t)); |
441 |
(void)strftime(db, sizeof(db), fmtstr, localtime(&t)); |
467 |
putstr(db); |
442 |
strlcat(where, db, where_size); |
468 |
break; |
443 |
break; |
469 |
|
|
|
470 |
#ifdef __FreeBSD__ |
444 |
#ifdef __FreeBSD__ |
471 |
case 's': |
445 |
case 's': |
472 |
putstr(kerninfo.sysname); |
446 |
strlcat(where, kerninfo.sysname, where_size); |
473 |
break; |
447 |
break; |
474 |
|
|
|
475 |
case 'm': |
448 |
case 'm': |
476 |
putstr(kerninfo.machine); |
449 |
strlcat(where, kerninfo.machine, where_size); |
477 |
break; |
450 |
break; |
478 |
|
|
|
479 |
case 'r': |
451 |
case 'r': |
480 |
putstr(kerninfo.release); |
452 |
strlcat(where, kerninfo.release, where_size); |
481 |
break; |
453 |
break; |
482 |
|
|
|
483 |
case 'v': |
454 |
case 'v': |
484 |
putstr(kerninfo.version); |
455 |
strlcat(where, kerninfo.version, where_size); |
485 |
break; |
456 |
break; |
486 |
#endif |
457 |
#endif |
487 |
|
|
|
488 |
case '%': |
458 |
case '%': |
489 |
putchr('%'); |
459 |
*ch_str = '%'; |
|
|
460 |
strlcat(where, ch_str, where_size); |
490 |
break; |
461 |
break; |
|
|
462 |
case 0: |
463 |
return; |
491 |
} |
464 |
} |
492 |
cp++; |
465 |
cp++; |
493 |
} |
466 |
} |