diff -rpN mgetty-1.1.21.org/conf_mg.c mgetty-1.1.21/conf_mg.c
*** mgetty-1.1.21.org/conf_mg.c	Mon Mar  1 04:17:55 1999
--- mgetty-1.1.21/conf_mg.c	Tue Jul 25 07:01:36 2000
*************** conf_data c_a[2];
*** 193,202 ****
  	conf_set_bool( &c.direct_line, TRUE );
      }
  
!     while ((opt = getopt(argc, argv, "c:x:s:rp:n:R:i:DC:FS:k:m:I:baV")) != EOF)
      {
  	switch (opt)
  	{
  	  case 'c':			/* check */
  #ifdef USE_GETTYDEFS
  	    verbose = TRUE;
--- 193,210 ----
  	conf_set_bool( &c.direct_line, TRUE );
      }
  
!     while ((opt = getopt(argc, argv, "l:c:x:s:rp:n:R:i:DC:FS:k:m:I:baV")) != EOF)
      {
  	switch (opt)
  	{
+           case 'l':			/* login_config_file select */
+             {
+               char *wk;
+ 
+               ((wk = strrchr(optarg,'/')) == NULL) ? wk = optarg : wk++;
+               conf_set_string( &c.login_config, wk );
+             }
+             break;
  	  case 'c':			/* check */
  #ifdef USE_GETTYDEFS
  	    verbose = TRUE;
diff -rpN mgetty-1.1.21.org/mgetty.c mgetty-1.1.21/mgetty.c
*** mgetty-1.1.21.org/mgetty.c	Wed Jun 16 05:39:55 1999
--- mgetty-1.1.21/mgetty.c	Tue Jul 25 07:01:36 2000
*************** int main _P2((argc, argv), int argc, cha
*** 698,703 ****
--- 698,707 ----
  	       
  	    if ( c_bool(direct_line) )			/* no RING needed */
  	    {
+ 	      wait_for_ATD( STDIN, 10, &what_action );
+ 	      if ( what_action != A_CONN )
+ 		exit(20);
+ 
  		mg_get_ctty( STDIN, devname );		/* get controll.tty */
  		mgetty_state = St_get_login;
  		break;
diff -rpN mgetty-1.1.21.org/ring.c mgetty-1.1.21/ring.c
*** mgetty-1.1.21.org/ring.c	Fri Jul 23 05:32:56 1999
--- mgetty-1.1.21/ring.c	Tue Jul 25 07:20:22 2000
*************** boolean	got_dle;		/* for <DLE><char> eve
*** 304,306 ****
--- 304,437 ----
      lprintf( L_NOISE, "wfr: rc=%d, drn=%d", rc, *dist_ring_number );
      return rc;
  }
+ 
+ 
+ /*
+ 	wait_for_ATD() is tiny modem emulater.
+ 		(IrModem or CE-PA1 only)
+ */
+ int wait_for_ATD _P3( (fd, timeout, action), int fd, int timeout, action_t *action )
+ {
+ #define BUFSIZE 500
+ char	buf[BUFSIZE], ch, *p;
+ int	i, w, r, atrc;
+ int	rc = SUCCESS;
+ int	Waiting = TRUE;
+ char	*rstr;
+ static char	*ati_res[10] = {
+ 	"\r\n504853\r\n", "\r\nPHS\r\n", "\r\nSharp\r\n", "\r\nXN-CD1\r\n",
+ 	"\r\n1.00\r\n", NULL, NULL, NULL, NULL, NULL
+ 	};
+ 
+     lprintf( L_MESG, "wfATD: waiting for ``ATD''" );
+     lprintf( L_NOISE, "got: ");
+ 
+     w=0;
+ 
+     signal( SIGALRM, chat_timeout );
+     alarm( timeout );
+     chat_has_timeout = FALSE;
+ 
+     while( Waiting )
+     {
+ 	r = mdm_read_byte( fd, &ch );
+ 
+ 	if ( r <= 0 )				/* unsuccessful */
+ 	{
+ 	    if ( chat_has_timeout )		/* timeout */
+ 		lprintf( L_WARN, "wfATD: timeout waiting for ATD" );
+ 	    else
+ 		lprintf( L_ERROR, "wfATD: error in read()" );
+ 
+ 	    if ( action != NULL ) *action = A_TIMOUT;
+ 	    rc = FAIL; break;
+ 	}
+ 
+ 	lputc( L_NOISE, ch );
+ 
+         /* line termination character? no -> add to buffer and go on */
+ 	if ( ch != '\r' && ch != '\n' )
+ 	{
+ 	    /* add character to buffer */
+ 	    if( w < BUFSIZ-2 )
+ 		buf[w++] = ch;
+ 
+ 	    continue;
+ 	}
+ 
+ 	if ( w == 0 ) { continue; }		/* $B6u9T$J$i7QB3(B */
+ 	buf[w] = '\0';
+ 
+ 	lprintf( L_NOISE, "AT command = [%s]", buf );
+ 
+ 	if ( strncmp( buf, "AT", 2 ) != 0 ) {
+ 		w = 0;
+ 		lprintf( L_NOISE, "Not AT" );
+ 		continue;
+ 	}
+ 
+ 	atrc = 0;
+ 
+ 	for( i = 2; i < w; i++ ) {
+ 		if ( ! isalpha( buf[i] ) )	/* $B1QJ8;z$N$_8+$k(B */
+ 			continue;
+ 
+ 		switch( toupper(buf[i]) ) {
+ 			case 'D':		/* $B%@%$%"%k(B */
+ 				atrc = 1;
+ 				i = w;		/* loop out */
+ 				break;
+ 			case 'H':		/* $B@ZCG(B */
+ 				atrc = 2;
+ 				i = w;		/* loop out */
+ 				break;
+ 			case 'I':		/* $B%b%G%`>pJs(B */
+ 				rstr = ati_res[0];
+ 
+ 				if ( isdigit(buf[i+1]) ) {
+ 					rstr = ati_res[buf[i+1]-'0'];
+ 					i++;
+ 				}
+ 
+ 				if ( rstr != NULL ) {
+ 					printf( "%s", rstr );
+ 				}else{
+ 					atrc = 3;
+ 					i = w;	/* loop out */
+ 				}
+ 				break;
+ 			default:
+ 				break;
+ 		}
+ 	}
+ 
+ 	/* AT$B%3%^%s%I$KBP$9$kA4BNE*$JJVEz$rJV$9(B */
+ 	switch( atrc ) {
+ 		case 1:
+ 			if ( action != NULL ) *action = A_CONN;
+ 			Waiting = FALSE;
+ 			rstr = "\r\nCONNECT\r\n";
+ 			break;
+ 		case 2:
+ 			if ( action != NULL ) *action = A_FAIL;
+ 			Waiting = FALSE;
+ 			rstr = "\r\nOK\r\n";
+ 			break;
+ 		case 3:
+ 			rstr = "\r\nERROR\r\n";
+ 			break;
+ 		default:
+ 			rstr = "\r\nOK\r\n";
+ 			break;
+ 	}
+ 
+ 	lprintf( L_NOISE, "RESULT code = [%s]", rstr );
+ 	printf( "%s" , rstr );
+ 
+ 	w = 0;
+     }
+ 
+     alarm(0);
+     lprintf( L_NOISE, "wfATD: rc=%d, atrc=%d", rc, atrc );
+     return rc;
+ }
