- /* if a new client wants to communicate */
- fd = net_Accept( p_intf, p_sys->pi_fd, p_sys->i_clients > 0 ? 0 : -1 );
- if( fd > 0 )
- {
- telnet_client_t *cl = NULL;
-
- /* to be non blocking */
-#if defined( WIN32 ) || defined( UNDER_CE )
- {
- unsigned long i_dummy = 1;
- ioctlsocket( fd, FIONBIO, &i_dummy );
- }
-#else
- fcntl( fd, F_SETFL, O_NONBLOCK );
-#endif
- cl = malloc( sizeof( telnet_client_t ));
- if( cl )
- {
- char *psz_pwd = strdup( _("Password") );
- char *psz_tmp = NULL;
- size_t ctrl_len = strlen( ": \xff\xfb\x01" );
- size_t passwd_len = strlen( psz_pwd );
-
- memset( cl, 0, sizeof(telnet_client_t) );
- cl->i_tel_cmd = 0;
- cl->fd = fd;
- cl->buffer_write = NULL;
- cl->p_buffer_write = cl->buffer_write;
- psz_tmp = malloc( passwd_len + ctrl_len + 1 );
- if( !psz_tmp )
- {
- free( psz_pwd );
- continue;
- }
- memset( psz_tmp, 0, passwd_len + ctrl_len + 1 );
- memcpy( psz_tmp, psz_pwd, passwd_len );
- memcpy( psz_tmp + passwd_len, ": \xff\xfb\x01", ctrl_len );
- Write_message( cl, NULL, psz_tmp, WRITE_MODE_PWD );
- TAB_APPEND( p_sys->i_clients, p_sys->clients, cl );
- free( psz_pwd );
- free( psz_tmp );
- }
- }
-
- /* to do a proper select */
- FD_ZERO( &fds_read );
- FD_ZERO( &fds_write );
-
- for( i = 0 ; i < p_sys->i_clients ; i++ )