have a question about something I saw in some large code. The author
checks for the user tty using the following
Code:
while ((err = getopt(argc, argv, "t:s:wrp:")) != -1)
switch (err) {
case 't':
tflg = 1;
strncpy(tsk[0].u.ut_line, optarg, sizeof (tsk[0].u.ut_line));
break;
And then later on,
Code:
int check_in(tty, in)
char *tty;
int in;
{
int i;
for (i = 0; i < in; i++) {
if (!strncmp(tty, uinfo[i].ut_line, strlen(tty))) {
return 1;
}
}
return 0;
}
The question is why would this person copy the tty arg into
tsk[0].u.ut_line? Ie why not just do something
./name cda -t ttyp4
Then in the program, just check if the arg ttyp4 (via check_in())
passed on the command line was a vaild tty.