]> diplodocus.org Git - nmh/blob - docs/historical/mh-jun-1982/Extras/libg/ttynam.c
Replaced use of snprintf() with memcpy()/memmove().
[nmh] / docs / historical / mh-jun-1982 / Extras / libg / ttynam.c
1 #ifdef COMMENT
2 Proprietary Rand Corporation, 1981.
3 Further distribution of this software
4 subject to the terms of the Rand
5 license agreement.
6 #endif
7
8 #include "libg.h"
9
10 /* this routine returns the file name within "/dev" */
11 /* corresponding to the internal tty #, which */
12 /* is in turn used by ttynum and getwho */
13 /* this routine is obviously very system dependent. */
14
15 /* ttyname is set up so that, in conjunction */
16 /* with getwho, the following simple "who" program will work: */
17 /* for (i = 0; ttnam = ttyname(i); i++) */
18 /* if (luid = getwho(i)) printf("%s %s\n",ttnam,getlogn(luid)); */
19
20 /* also, ttynum(ttyname(n)) should equal n if 0 <= n <= 31 */
21
22 char *ttyname(num)
23 {
24 register char *tty;
25 tty = "ttyx";
26 if (num < 0 || num > 31) return(NULSTR);
27 if (num == 0) return("tty8");
28 if (num < 9) {
29 tty[3] = num + ('0' - 1);
30 return(tty);
31 }
32 tty[3] = num - ('a' - 9);
33 return(tty);
34 }