char path[PATH_MAX]; register char *sp;
char pathbuf[PATH_MAX]; register char *path_open, *path_lock;
tty_open(char *name, const char *speed){  char path[PATH_MAX];  register char *sp;  int fd;  /* Try opening the TTY device. */  if (name != NULL) {	if ((sp = strrchr(name, '/')) != (char *)NULL) *sp++ = '\0';	  else sp = name;	sprintf(path, "/dev/%s", sp);	if (opt_d) printf("slattach: tty_open: looking for lock\n");	if (tty_lock(sp, 1)) return(-1); /* can we lock the device? */	if (opt_d) printf("slattach: tty_open: trying to open %s\n", path);	if ((fd = open(path, O_RDWR|O_NDELAY)) < 0) {		if (opt_q == 0) fprintf(stderr,			"slattach: tty_open(%s, RW): %s\n",					path, strerror(errno));		return(-errno);	}	tty_fd = fd;	if (opt_d) printf("slattach: tty_open: %s (fd=%d) ", path, fd);  } else {	tty_fd = 0;	sp = (char *)NULL;  }  /* Fetch the current state of the terminal. */  if (tty_get_state(&tty_saved) < 0) {	if (opt_q == 0) fprintf(stderr, _("slattach: tty_open: cannot get current state!\n"));	return(-errno);  }  tty_current = tty_saved;  /* Fetch the current line discipline of this terminal. */  if (tty_get_disc(&tty_sdisc) < 0) {	if (opt_q == 0) fprintf(stderr, _("slattach: tty_open: cannot get current line disc!\n"));	return(-errno);  }   tty_ldisc = tty_sdisc;  /* Put this terminal line in a 8-bit transparent mode. */  if (opt_m == 0) {	if (tty_set_raw(&tty_current) < 0) {		if (opt_q == 0) fprintf(stderr, _("slattach: tty_open: cannot set RAW mode!\n"));		return(-errno);	}	/* Set the default speed if we need to. */	if (speed != NULL) {		if (tty_set_speed(&tty_current, speed) != 0) {			if (opt_q == 0) fprintf(stderr, _("slattach: tty_open: cannot set %s bps!\n"),						speed);			return(-errno);		}	}	/* Set up a completely 8-bit clean line. */	if (tty_set_databits(&tty_current, "8") ||	    tty_set_stopbits(&tty_current, "1") ||	    tty_set_parity(&tty_current, "N")) {		if (opt_q == 0) fprintf(stderr, _("slattach: tty_open: cannot set 8N1 mode!\n"));		return(-errno);  	}	/* Set the new line mode. */	if ((fd = tty_set_state(&tty_current)) < 0) return(fd);  }  /* OK, line is open.  Do we need to "silence" it? */  (void) tty_nomesg(tty_fd);  return(0);}