* Win32 network support by Boris Dor�s <babal@via.ecp.fr>.
[vlc.git] / src / input / input.c
blobf9cfeaa6dc774993c0dd253827ebabca76aa2088
1 /*****************************************************************************
2 * input.c: input thread
3 * Read an MPEG2 stream, demultiplex and parse it before sending it to
4 * decoders.
5 *****************************************************************************
6 * Copyright (C) 1998, 1999, 2000 VideoLAN
7 * $Id: input.c,v 1.124 2001/06/21 07:22:03 sam Exp $
9 * Authors: Christophe Massiot <massiot@via.ecp.fr>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
24 *****************************************************************************/
26 /*****************************************************************************
27 * Preamble
28 *****************************************************************************/
29 #include "defs.h"
31 #include <stdlib.h>
32 #include <sys/types.h>
33 #include <sys/stat.h>
34 #include <fcntl.h>
36 #ifdef HAVE_UNISTD_H
37 # include <unistd.h>
38 #elif defined( _MSC_VER ) && defined( _WIN32 )
39 # include <io.h>
40 #endif
42 #include <string.h>
43 #include <errno.h>
45 #ifdef STRNCASECMP_IN_STRINGS_H
46 # include <strings.h>
47 #endif
49 #ifdef WIN32
50 # include <winsock2.h>
51 #elif !defined( SYS_BEOS ) && !defined( SYS_NTO )
52 # include <netdb.h> /* hostent ... */
53 # include <sys/socket.h>
54 # include <netinet/in.h>
55 # include <arpa/inet.h>
56 # include <sys/types.h>
57 # include <sys/socket.h>
58 #endif
60 #ifdef STATS
61 # include <sys/times.h>
62 #endif
64 #include "config.h"
65 #include "common.h"
66 #include "threads.h"
67 #include "mtime.h"
68 #include "netutils.h"
69 #include "modules.h"
71 #include "intf_msg.h"
72 #include "intf_playlist.h"
74 #include "stream_control.h"
75 #include "input_ext-intf.h"
76 #include "input_ext-dec.h"
78 #include "input.h"
79 #include "interface.h"
81 #include "main.h"
83 /*****************************************************************************
84 * Local prototypes
85 *****************************************************************************/
86 static void RunThread ( input_thread_t *p_input );
87 static int InitThread ( input_thread_t *p_input );
88 static void ErrorThread ( input_thread_t *p_input );
89 static void DestroyThread ( input_thread_t *p_input );
90 static void EndThread ( input_thread_t *p_input );
92 static void FileOpen ( input_thread_t *p_input );
93 static void FileClose ( input_thread_t *p_input );
94 #if !defined( SYS_BEOS ) && !defined( SYS_NTO )
95 static void NetworkOpen ( input_thread_t *p_input );
96 static void NetworkClose ( input_thread_t *p_input );
97 #endif
99 /*****************************************************************************
100 * input_CreateThread: creates a new input thread
101 *****************************************************************************
102 * This function creates a new input, and returns a pointer
103 * to its description. On error, it returns NULL.
104 * If pi_status is NULL, then the function will block until the thread is ready.
105 * If not, it will be updated using one of the THREAD_* constants.
106 *****************************************************************************/
107 input_thread_t *input_CreateThread ( playlist_item_t *p_item, int *pi_status )
109 input_thread_t * p_input; /* thread descriptor */
110 int i_status; /* thread status */
112 /* Allocate descriptor */
113 p_input = (input_thread_t *)malloc( sizeof(input_thread_t) );
114 if( p_input == NULL )
116 intf_ErrMsg( "input error: can't allocate input thread (%s)",
117 strerror(errno) );
118 return( NULL );
121 /* Packets read once */
122 p_input->i_read_once = INPUT_READ_ONCE;
124 /* Initialize thread properties */
125 p_input->b_die = 0;
126 p_input->b_error = 0;
127 p_input->b_eof = 0;
129 /* Set target */
130 p_input->p_source = p_item->psz_name;
132 /* I have never understood that stuff --Meuuh */
133 p_input->pi_status = (pi_status != NULL) ? pi_status : &i_status;
134 *p_input->pi_status = THREAD_CREATE;
136 /* Initialize stream description */
137 p_input->stream.i_es_number = 0;
138 p_input->stream.i_selected_es_number = 0;
139 p_input->stream.i_pgrm_number = 0;
140 p_input->stream.i_new_status = p_input->stream.i_new_rate = 0;
141 p_input->stream.i_mux_rate = 0;
143 /* no stream, no area */
144 p_input->stream.i_area_nb = 0;
145 p_input->stream.pp_areas = NULL;
146 p_input->stream.p_selected_area = NULL;
147 p_input->stream.p_new_area = NULL;
149 /* By default there is one area in a stream */
150 input_AddArea( p_input );
151 p_input->stream.p_selected_area = p_input->stream.pp_areas[0];
153 /* Initialize stream control properties. */
154 p_input->stream.control.i_status = PLAYING_S;
155 p_input->stream.control.i_rate = DEFAULT_RATE;
156 p_input->stream.control.b_mute = 0;
157 p_input->stream.control.b_bw = 0;
159 /* Setup callbacks */
160 p_input->pf_file_open = FileOpen;
161 p_input->pf_file_close = FileClose;
162 #if !defined( SYS_BEOS ) && !defined( SYS_NTO )
163 p_input->pf_network_open = NetworkOpen;
164 p_input->pf_network_close = NetworkClose;
165 #endif
167 /* Create thread. */
168 if( vlc_thread_create( &p_input->thread_id, "input", (void *) RunThread,
169 (void *) p_input ) )
171 intf_ErrMsg( "input error: can't create input thread (%s)",
172 strerror(errno) );
173 free( p_input );
174 return( NULL );
177 /* If status is NULL, wait until the thread is created */
178 if( pi_status == NULL )
182 msleep( THREAD_SLEEP );
183 } while( (i_status != THREAD_READY) && (i_status != THREAD_ERROR)
184 && (i_status != THREAD_FATAL) );
185 if( i_status != THREAD_READY )
187 return( NULL );
190 return( p_input );
193 /*****************************************************************************
194 * input_DestroyThread: mark an input thread as zombie
195 *****************************************************************************
196 * This function should not return until the thread is effectively cancelled.
197 *****************************************************************************/
198 void input_DestroyThread( input_thread_t *p_input, int *pi_status )
200 int i_status; /* thread status */
202 /* Set status */
203 p_input->pi_status = (pi_status != NULL) ? pi_status : &i_status;
204 *p_input->pi_status = THREAD_DESTROY;
206 /* Request thread destruction */
207 p_input->b_die = 1;
209 /* Make the thread exit of an eventual vlc_cond_wait() */
210 vlc_mutex_lock( &p_input->stream.stream_lock );
211 vlc_cond_signal( &p_input->stream.stream_wait );
212 vlc_mutex_unlock( &p_input->stream.stream_lock );
214 /* If status is NULL, wait until thread has been destroyed */
215 if( pi_status == NULL )
219 msleep( THREAD_SLEEP );
220 } while ( (i_status != THREAD_OVER) && (i_status != THREAD_ERROR)
221 && (i_status != THREAD_FATAL) );
225 /*****************************************************************************
226 * RunThread: main thread loop
227 *****************************************************************************
228 * Thread in charge of processing the network packets and demultiplexing.
229 *****************************************************************************/
230 static void RunThread( input_thread_t *p_input )
232 int i_error, i;
233 data_packet_t ** pp_packets;
235 if( InitThread( p_input ) )
238 /* If we failed, wait before we are killed, and exit */
239 *p_input->pi_status = THREAD_ERROR;
240 p_input->b_error = 1;
241 ErrorThread( p_input );
242 DestroyThread( p_input );
243 free( p_input );
244 return;
247 /* initialization is completed */
248 vlc_mutex_lock( &p_input->stream.stream_lock );
249 p_input->stream.b_changed = 1;
250 vlc_mutex_unlock( &p_input->stream.stream_lock );
252 pp_packets = (data_packet_t **) malloc( p_input->i_read_once *
253 sizeof( data_packet_t * ) );
254 if( pp_packets == NULL )
256 intf_ErrMsg( "input error: out of memory" );
257 free( pp_packets );
258 p_input->b_error = 1;
261 while( !p_input->b_die && !p_input->b_error && !p_input->b_eof )
263 #ifdef STATS
264 p_input->c_loops++;
265 #endif
267 vlc_mutex_lock( &p_input->stream.stream_lock );
269 if( p_input->stream.p_new_area )
271 if( p_input->stream.b_seekable && p_input->pf_set_area != NULL )
274 p_input->pf_set_area( p_input, p_input->stream.p_new_area );
276 for( i = 0; i < p_input->stream.i_pgrm_number; i++ )
278 pgrm_descriptor_t * p_pgrm
279 = p_input->stream.pp_programs[i];
280 /* Escape all decoders for the stream discontinuity they
281 * will encounter. */
282 input_EscapeDiscontinuity( p_input, p_pgrm );
284 /* Reinitialize synchro. */
285 p_pgrm->i_synchro_state = SYNCHRO_REINIT;
288 p_input->stream.p_new_area = NULL;
291 if( p_input->stream.p_selected_area->i_seek != NO_SEEK )
293 if( p_input->stream.b_seekable && p_input->pf_seek != NULL )
295 p_input->pf_seek( p_input,
296 p_input->stream.p_selected_area->i_seek );
298 for( i = 0; i < p_input->stream.i_pgrm_number; i++ )
300 pgrm_descriptor_t * p_pgrm
301 = p_input->stream.pp_programs[i];
302 /* Escape all decoders for the stream discontinuity they
303 * will encounter. */
304 input_EscapeDiscontinuity( p_input, p_pgrm );
306 /* Reinitialize synchro. */
307 p_pgrm->i_synchro_state = SYNCHRO_REINIT;
310 p_input->stream.p_selected_area->i_seek = NO_SEEK;
313 if( p_input->stream.p_removed_es )
315 input_UnselectES( p_input, p_input->stream.p_removed_es );
316 p_input->stream.p_removed_es = NULL;
319 if( p_input->stream.p_newly_selected_es )
321 input_SelectES( p_input, p_input->stream.p_newly_selected_es );
322 p_input->stream.p_newly_selected_es = NULL;
325 vlc_mutex_unlock( &p_input->stream.stream_lock );
327 i_error = p_input->pf_read( p_input, pp_packets );
329 /* Demultiplex read packets. */
330 for( i = 0; i < p_input->i_read_once && pp_packets[i] != NULL; i++ )
332 p_input->pf_demux( p_input, pp_packets[i] );
335 if( i_error )
337 if( i_error == 1 )
339 /* End of file - we do not set b_die because only the
340 * interface is allowed to do so. */
341 intf_WarnMsg( 3, "input: EOF reached" );
342 p_input->b_eof = 1;
344 else
346 p_input->b_error = 1;
351 free( pp_packets );
353 if( p_input->b_error || p_input->b_eof )
355 ErrorThread( p_input );
358 EndThread( p_input );
360 DestroyThread( p_input );
362 intf_DbgMsg("input: Thread end");
365 /*****************************************************************************
366 * InitThread: init the input Thread
367 *****************************************************************************/
368 static int InitThread( input_thread_t * p_input )
371 #ifdef STATS
372 /* Initialize statistics */
373 p_input->c_loops = 0;
374 p_input->c_bytes = 0;
375 p_input->c_payload_bytes = 0;
376 p_input->c_packets_read = 0;
377 p_input->c_packets_trashed = 0;
378 #endif
380 /* Set locks. */
381 vlc_mutex_init( &p_input->stream.stream_lock );
382 vlc_cond_init( &p_input->stream.stream_wait );
383 vlc_mutex_init( &p_input->stream.control.control_lock );
385 /* Default, might get overwritten */
386 p_input->pf_open = p_input->pf_file_open;
387 p_input->pf_close = p_input->pf_file_close;
389 p_input->p_input_module = module_Need( MODULE_CAPABILITY_INPUT,
390 (probedata_t *)p_input );
392 if( p_input->p_input_module == NULL )
394 intf_ErrMsg( "input error: no suitable input module for `%s'",
395 p_input->p_source );
396 return( -1 );
399 #define f p_input->p_input_module->p_functions->input.functions.input
400 p_input->pf_init = f.pf_init;
401 if( f.pf_open != NULL )
403 p_input->pf_open = f.pf_open;
405 if( f.pf_close != NULL )
407 p_input->pf_close = f.pf_close;
409 p_input->pf_end = f.pf_end;
410 p_input->pf_read = f.pf_read;
411 p_input->pf_set_area = f.pf_set_area;
412 p_input->pf_demux = f.pf_demux;
413 p_input->pf_new_packet = f.pf_new_packet;
414 p_input->pf_new_pes = f.pf_new_pes;
415 p_input->pf_delete_packet = f.pf_delete_packet;
416 p_input->pf_delete_pes = f.pf_delete_pes;
417 p_input->pf_rewind = f.pf_rewind;
418 p_input->pf_seek = f.pf_seek;
419 #undef f
421 /* We found the appropriate plugin, open the target */
422 p_input->pf_open( p_input );
424 if( p_input->b_error )
426 /* We barfed -- exit nicely */
427 module_Unneed( p_input->p_input_module );
428 return( -1 );
431 p_input->pf_init( p_input );
433 if( p_input->b_error )
435 /* We barfed -- exit nicely */
436 p_input->pf_close( p_input );
437 module_Unneed( p_input->p_input_module );
438 return( -1 );
441 *p_input->pi_status = THREAD_READY;
443 return( 0 );
446 /*****************************************************************************
447 * ErrorThread: RunThread() error loop
448 *****************************************************************************
449 * This function is called when an error occured during thread main's loop.
450 *****************************************************************************/
451 static void ErrorThread( input_thread_t *p_input )
453 while( !p_input->b_die )
455 /* Sleep a while */
456 msleep( INPUT_IDLE_SLEEP );
460 /*****************************************************************************
461 * EndThread: end the input thread
462 *****************************************************************************/
463 static void EndThread( input_thread_t * p_input )
465 int * pi_status; /* thread status */
467 /* Store status */
468 pi_status = p_input->pi_status;
469 *pi_status = THREAD_END;
471 #ifdef STATS
473 struct tms cpu_usage;
474 times( &cpu_usage );
476 intf_Msg("input stats: cpu usage (user: %d, system: %d)",
477 cpu_usage.tms_utime, cpu_usage.tms_stime);
479 #endif
481 /* Free all ES and destroy all decoder threads */
482 input_EndStream( p_input );
484 /* Free demultiplexer's data */
485 p_input->pf_end( p_input );
487 /* Close stream */
488 p_input->pf_close( p_input );
490 /* Release modules */
491 module_Unneed( p_input->p_input_module );
495 /*****************************************************************************
496 * DestroyThread: destroy the input thread
497 *****************************************************************************/
498 static void DestroyThread( input_thread_t * p_input )
500 int * pi_status; /* thread status */
502 /* Store status */
503 pi_status = p_input->pi_status;
505 /* Destroy Mutex locks */
506 vlc_mutex_destroy( &p_input->stream.control.control_lock );
507 vlc_mutex_destroy( &p_input->stream.stream_lock );
509 /* Free input structure */
510 free( p_input );
512 /* Update status */
513 *pi_status = THREAD_OVER;
516 /*****************************************************************************
517 * FileOpen : open a file descriptor
518 *****************************************************************************/
519 static void FileOpen( input_thread_t * p_input )
521 struct stat stat_info;
522 int i_stat;
524 char *psz_name = p_input->p_source;
526 /* FIXME: this code ought to be in the plugin so that code can
527 * be shared with the *_Probe function */
528 if( ( i_stat = stat( psz_name, &stat_info ) ) == (-1) )
530 int i_size = strlen( psz_name );
532 if( ( i_size > 4 )
533 && !strncasecmp( psz_name, "dvd:", 4 ) )
535 /* get rid of the 'dvd:' stuff and try again */
536 psz_name += 4;
537 i_stat = stat( psz_name, &stat_info );
539 else if( ( i_size > 5 )
540 && !strncasecmp( psz_name, "file:", 5 ) )
542 /* get rid of the 'file:' stuff and try again */
543 psz_name += 5;
544 i_stat = stat( psz_name, &stat_info );
547 if( i_stat == (-1) )
549 intf_ErrMsg( "input error: cannot stat() file `%s' (%s)",
550 psz_name, strerror(errno));
551 p_input->b_error = 1;
552 return;
556 vlc_mutex_lock( &p_input->stream.stream_lock );
558 /* If we are here we can control the pace... */
559 p_input->stream.b_pace_control = 1;
561 if( S_ISREG(stat_info.st_mode) || S_ISCHR(stat_info.st_mode)
562 || S_ISBLK(stat_info.st_mode) )
564 p_input->stream.b_seekable = 1;
565 p_input->stream.p_selected_area->i_size = stat_info.st_size;
567 else if( S_ISFIFO(stat_info.st_mode)
568 #if !defined( SYS_BEOS ) && !defined( WIN32 )
569 || S_ISSOCK(stat_info.st_mode)
570 #endif
573 p_input->stream.b_seekable = 0;
574 p_input->stream.p_selected_area->i_size = 0;
576 else
578 vlc_mutex_unlock( &p_input->stream.stream_lock );
579 intf_ErrMsg( "input error: unknown file type for `%s'",
580 psz_name );
581 p_input->b_error = 1;
582 return;
585 p_input->stream.p_selected_area->i_tell = 0;
586 vlc_mutex_unlock( &p_input->stream.stream_lock );
588 intf_WarnMsg( 1, "input: opening file `%s'", p_input->p_source );
589 #if defined( WIN32 )
590 if( (p_input->i_handle = open( psz_name, O_BINARY ) ) == (-1) )
591 #else
592 if( (p_input->i_handle = open( psz_name,
593 /*O_NONBLOCK | O_LARGEFILE*/0 )) == (-1) )
594 #endif
596 intf_ErrMsg( "input error: cannot open file (%s)", strerror(errno) );
597 p_input->b_error = 1;
598 return;
603 /*****************************************************************************
604 * FileClose : close a file descriptor
605 *****************************************************************************/
606 static void FileClose( input_thread_t * p_input )
608 intf_WarnMsg( 1, "input: closing file `%s'", p_input->p_source );
610 close( p_input->i_handle );
612 return;
615 #if !defined( SYS_BEOS ) && !defined( SYS_NTO )
616 /*****************************************************************************
617 * NetworkOpen : open a network socket
618 *****************************************************************************/
619 static void NetworkOpen( input_thread_t * p_input )
621 char *psz_server = NULL;
622 char *psz_broadcast = NULL;
623 int i_port = 0;
624 int i_opt;
625 struct sockaddr_in sock;
626 #ifdef WIN32
627 WSADATA Data;
628 int i_err;
629 #endif
631 #ifdef WIN32
632 /* WinSock Library Init. */
633 i_err = WSAStartup( MAKEWORD( 1, 1 ), &Data );
635 if( i_err )
637 intf_ErrMsg( "input: can't initiate WinSocks, error %i", i_err );
638 return ;
640 #endif
642 /* Get the remote server */
643 if( p_input->p_source != NULL )
645 psz_server = p_input->p_source;
647 /* Skip the protocol name */
648 while( *psz_server && *psz_server != ':' )
650 psz_server++;
653 /* Skip the "://" part */
654 while( *psz_server && (*psz_server == ':' || *psz_server == '/') )
656 psz_server++;
659 /* Found a server name */
660 if( *psz_server )
662 char *psz_port = psz_server;
664 /* Skip the hostname part */
665 while( *psz_port && *psz_port != ':' )
667 psz_port++;
670 /* Found a port name */
671 if( *psz_port )
673 /* Replace ':' with '\0' */
674 *psz_port = '\0';
675 psz_port++;
677 psz_broadcast = psz_port;
678 while( *psz_broadcast && *psz_broadcast != ':' )
680 psz_broadcast++;
683 if( *psz_broadcast )
685 *psz_broadcast = '\0';
686 psz_broadcast++;
687 while( *psz_broadcast && *psz_broadcast == ':' )
689 psz_broadcast++;
692 else
694 psz_broadcast = NULL;
697 /* port before broadcast address */
698 if( *psz_port != ':' )
700 i_port = atoi( psz_port );
704 else
706 psz_server = NULL;
710 /* Check that we got a valid server */
711 if( psz_server == NULL )
713 psz_server = main_GetPszVariable( INPUT_SERVER_VAR,
714 INPUT_SERVER_DEFAULT );
717 /* Check that we got a valid port */
718 if( i_port == 0 )
720 i_port = main_GetIntVariable( INPUT_PORT_VAR, INPUT_PORT_DEFAULT );
723 if( psz_broadcast == NULL )
725 /* Are we broadcasting ? */
726 if( main_GetIntVariable( INPUT_BROADCAST_VAR,
727 INPUT_BROADCAST_DEFAULT ) )
729 psz_broadcast = main_GetPszVariable( INPUT_BCAST_ADDR_VAR,
730 INPUT_BCAST_ADDR_DEFAULT );
732 else
734 psz_broadcast = NULL;
738 intf_WarnMsg( 2, "input: server: %s port: %d broadcast: %s",
739 psz_server, i_port, psz_broadcast );
741 /* Open a SOCK_DGRAM (UDP) socket, in the AF_INET domain, automatic (0)
742 * protocol */
743 p_input->i_handle = socket( AF_INET, SOCK_DGRAM, 0 );
744 if( p_input->i_handle == -1 )
746 intf_ErrMsg("input error: can't create socket : %s", strerror(errno));
747 p_input->b_error = 1;
748 return;
751 /* We may want to reuse an already used socket */
752 i_opt = 1;
753 if( setsockopt( p_input->i_handle, SOL_SOCKET, SO_REUSEADDR,
754 (void*) &i_opt, sizeof( i_opt ) ) == -1 )
756 intf_ErrMsg( "input error: can't configure socket (SO_REUSEADDR: %s)",
757 strerror(errno));
758 close( p_input->i_handle );
759 p_input->b_error = 1;
760 return;
763 /* Increase the receive buffer size to 1/2MB (8Mb/s during 1/2s) to avoid
764 * packet loss caused by scheduling problems */
765 i_opt = 0x80000;
766 if( setsockopt( p_input->i_handle, SOL_SOCKET, SO_RCVBUF,
767 (void*) &i_opt, sizeof( i_opt ) ) == -1 )
769 intf_ErrMsg( "input error: can't configure socket (SO_RCVBUF: %s)",
770 strerror(errno));
771 close( p_input->i_handle );
772 p_input->b_error = 1;
773 return;
776 /* Build the local socket */
777 if ( network_BuildLocalAddr( &sock, i_port, psz_broadcast ) == -1 )
779 intf_ErrMsg( "input error: can't build local address" );
780 close( p_input->i_handle );
781 p_input->b_error = 1;
782 return;
785 #if defined( WIN32 )
786 if ( psz_broadcast != NULL )
788 sock.sin_addr.s_addr = INADDR_ANY;
790 #endif
792 /* Bind it */
793 if( bind( p_input->i_handle, (struct sockaddr *)&sock,
794 sizeof( sock ) ) < 0 )
796 intf_ErrMsg("input error: can't bind socket (%s)", strerror(errno));
797 close( p_input->i_handle );
798 p_input->b_error = 1;
799 return;
802 /* Build socket for remote connection */
803 if ( network_BuildRemoteAddr( &sock, psz_server ) == -1 )
805 intf_ErrMsg( "input error: can't build remote address" );
806 close( p_input->i_handle );
807 p_input->b_error = 1;
808 return;
811 /* And connect it ... should we really connect ? */
812 if( connect( p_input->i_handle, (struct sockaddr *) &sock,
813 sizeof( sock ) ) == (-1) )
815 intf_ErrMsg( "input error: can't connect socket, %s",
816 strerror(errno) );
817 close( p_input->i_handle );
818 p_input->b_error = 1;
819 return;
822 /* We can't pace control, but FIXME : bug in meuuh's code to sync PCR
823 * with the server. */
824 p_input->stream.b_pace_control = 0;
825 p_input->stream.b_seekable = 0;
827 intf_WarnMsg( 3, "input: successfully opened network mode" );
829 return;
832 /*****************************************************************************
833 * NetworkClose : close a network socket
834 *****************************************************************************/
835 static void NetworkClose( input_thread_t * p_input )
837 close( p_input->i_handle );
839 #ifdef WIN32
840 WSACleanup();
841 #endif
844 #endif