comparison src/curl/curl.c @ 521:72515e5313cf trunk

[svn] - refinements for getc/ungetc in curl
author giacomo
date Mon, 22 Jan 2007 12:21:31 -0800
parents bbc597d9875d
children c00fd2a0736f
comparison
equal deleted inserted replaced
520:8f1785471613 521:72515e5313cf
586 while ( (ret < sz) && (handle->stream_stack != NULL) ) 586 while ( (ret < sz) && (handle->stream_stack != NULL) )
587 { 587 {
588 uc = GPOINTER_TO_INT(handle->stream_stack->data); 588 uc = GPOINTER_TO_INT(handle->stream_stack->data);
589 handle->stream_stack = g_slist_delete_link( handle->stream_stack , handle->stream_stack ); 589 handle->stream_stack = g_slist_delete_link( handle->stream_stack , handle->stream_stack );
590 memcpy( ptr + ret , &uc , 1 ); 590 memcpy( ptr + ret , &uc , 1 );
591 handle->rd_abs++;
591 ret++; 592 ret++;
592 } 593 }
593 } 594 }
594 595
595 curl_req_xfer(handle); 596 curl_req_xfer(handle);
647 648
648 if ( handle->stream_stack != NULL ) /* check if some char was ungetc'ed before */ 649 if ( handle->stream_stack != NULL ) /* check if some char was ungetc'ed before */
649 { 650 {
650 uc = GPOINTER_TO_INT(handle->stream_stack->data); 651 uc = GPOINTER_TO_INT(handle->stream_stack->data);
651 handle->stream_stack = g_slist_delete_link( handle->stream_stack , handle->stream_stack ); 652 handle->stream_stack = g_slist_delete_link( handle->stream_stack , handle->stream_stack );
653 handle->rd_abs++;
652 return uc; 654 return uc;
653 } 655 }
654 else if (curl_vfs_fread_impl(&uc, 1, 1, stream) != 1) 656 else if (curl_vfs_fread_impl(&uc, 1, 1, stream) != 1)
655 return EOF; 657 return EOF;
656 return uc; 658 return uc;
663 665
664 g_return_val_if_fail(handle != NULL, EOF); 666 g_return_val_if_fail(handle != NULL, EOF);
665 667
666 handle->stream_stack = g_slist_prepend( handle->stream_stack , GINT_TO_POINTER(c) ); 668 handle->stream_stack = g_slist_prepend( handle->stream_stack , GINT_TO_POINTER(c) );
667 if ( handle->stream_stack != NULL ) 669 if ( handle->stream_stack != NULL )
670 {
671 handle->rd_abs--;
668 return c; 672 return c;
673 }
669 else 674 else
670 return EOF; 675 return EOF;
671 } 676 }
672 677
673 gint 678 gint
757 762
758 glong 763 glong
759 curl_vfs_ftell_impl(VFSFile * file) 764 curl_vfs_ftell_impl(VFSFile * file)
760 { 765 {
761 CurlHandle *handle = file->handle; 766 CurlHandle *handle = file->handle;
762 if ( handle->stream_stack != NULL ) 767 return handle->rd_abs;
763 return handle->rd_abs - g_slist_length( handle->stream_stack );
764 else
765 return handle->rd_abs;
766 } 768 }
767 769
768 gboolean 770 gboolean
769 curl_vfs_feof_impl(VFSFile * file) 771 curl_vfs_feof_impl(VFSFile * file)
770 { 772 {
771 CurlHandle *handle = file->handle; 773 CurlHandle *handle = file->handle;
772 if ( handle->stream_stack != NULL ) 774 return handle->rd_abs == handle->length;
773 return (handle->rd_abs - g_slist_length( handle->stream_stack )) == handle->length;
774 else
775 return handle->rd_abs == handle->length;
776 } 775 }
777 776
778 gint 777 gint
779 curl_vfs_truncate_impl(VFSFile * file, glong size) 778 curl_vfs_truncate_impl(VFSFile * file, glong size)
780 { 779 {