aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-stream-buffer.c
Commit message (Collapse)AuthorAgeFilesLines
* Removed. (stream_write): Keep looping (non-blocking case) if errno isJeffrey Stedfast2001-10-301-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 2001-10-29 Jeffrey Stedfast <fejj@ximian.com> * camel-tcp-stream-openssl.c (my_SSL_write): Removed. (stream_write): Keep looping (non-blocking case) if errno is EAGAIN, EINTR or EWOULDBLOCK. For NONBLOCKing I/O, sync up with CamelTcpStreamRaw. As with CamelTcpStreamRaw/SSL - make sure to write out everything before returning. (my_SSL_read): Removed. (stream_read): Just call ssl_error_to_errno() and check the errno values that we care about so we can keep the general look of all this stream code the same. Also when checking the return value of SSL_read, check for <0 instead of ==-1 since the man page for SSL_read doesn't say it will return -1 on fail, it just says <0. (stream_flush): Don't fsync() since syncing on a socket is a Bad Thing (tm). * camel-tcp-stream-ssl.c (stream_write): Make sure we write out everything just like in camel-tcp-stream-raw.c. * camel-stream-buffer.c (camel_stream_buffer_gets): If camel_stream_read() returns -1, don't necessarily return -1 to our caller since it's possible that we did actually "read" some data (ie, we copied some pre-buffered data into the out buffer). * camel-stream-buffer.h: Removed CAMEL_STREAM_BUFFER_NEWLINE since it never got used anywhere and it isn't supported anyway. svn path=/trunk/; revision=14409
* Make sure we've actually read data before checking if p[-] is '\r' or not.Jeffrey Stedfast2001-10-281-1/+1
| | | | | | | | | 2001-10-28 Jeffrey Stedfast <fejj@ximian.com> * camel-stream-buffer.c (camel_stream_buffer_read_line): Make sure we've actually read data before checking if p[-] is '\r' or not. svn path=/trunk/; revision=14288
* Fixing the license text.Ettore Perazzoli2001-10-281-1/+0
| | | | svn path=/trunk/; revision=14212
* Update the licensing information to require version 2 of the GPLEttore Perazzoli2001-10-271-2/+2
| | | | | | (instead of version 2 or any later version). svn path=/trunk/; revision=14190
* A "safe write" function that always writes out all data asked of it, till52001-09-261-31/+42
| | | | | | | | | | | | 2001-09-25 <NotZed@Ximian.com> * camel-stream-buffer.c (stream_write_all): A "safe write" function that always writes out all data asked of it, till finished. (stream_write): Rewritten. What was i on when i wrote that originally, how did it ever work with tcp streams ... svn path=/trunk/; revision=13115
* Update the copyrights, replacing Helix Code with Ximian andEttore Perazzoli2001-06-231-2/+2
| | | | | | helixcode.com with ximian.com all over the place. svn path=/trunk/; revision=10440
* Big header cleanups and nntp compile fixKjartan Maraas2001-03-301-2/+5
| | | | svn path=/trunk/; revision=9024
* Update the doc comment: since it always NUL-terminates the buffer, itDan Winship2000-12-221-1/+1
| | | | | | | | | | | | | * camel-stream-buffer.c (camel_stream_buffer_gets): Update the doc comment: since it always NUL-terminates the buffer, it reads at most @max-1 bytes, not @max. * camel-remote-store.c (remote_recv_line): Fix the "did camel_stream_buffer_gets fill the whole buffer" check. Fixes a bug when reading lines longer than 1024 characters (eg, IMAP SEARCH responses in very large folders). svn path=/trunk/; revision=7117
* Fix some off-by-one-ness.Dan Winship2000-11-301-1/+1
| | | | | | | | | | * providers/imap/camel-imap-command.c (imap_read_untagged): Fix some off-by-one-ness. * camel-stream-buffer.c (stream_read): Fix another bug found in previously-unused code here. svn path=/trunk/; revision=6718
* Make this gratuitously more complicated. No wait, I mean, fix bugs. NowDan Winship2000-11-281-4/+5
| | | | | | | | | | | | | * providers/imap/camel-imap-command.c (imap_read_untagged): Make this gratuitously more complicated. No wait, I mean, fix bugs. Now fully handles NULs in the data stream (which "can't happen" but do) and also handles responses containing multiple literals. Also does less copying than the original code. * camel-stream-buffer.c (stream_read): Fix a bug that could make it lose sync and/or overrun buffers. svn path=/trunk/; revision=6688
* We should always terminate the string. No need to check outptr is inNot Zed2000-11-171-2/+1
| | | | | | | | | | | | | | | | | | 2000-11-17 Not Zed <NotZed@HelixCode.com> * camel-stream-buffer.c (camel_stream_buffer_gets): We should always terminate the string. No need to check outptr is in range, its already been checked. * providers/local/camel-mbox-summary.c (mbox_summary_sync): When we update the summary, do it from mbox_summary->folder_size, not the content info endpos (which isn't any good anymore anyway). * providers/local/camel-mbox-folder.c (mbox_append_message): Set the frompos from the current folder size, since summary_add wont have initialised it to anything useful. svn path=/trunk/; revision=6597
* Merge with camel-async.Peter Williams2000-08-111-57/+29
| | | | svn path=/trunk/; revision=4687
* Changed the read and write method prototypes to return an ssize_t typeJeffrey Stedfast2000-06-071-16/+22
| | | | | | | | | | | | | | | | | | | 2000-06-06 Jeffrey Stedfast <fejj@helixcode.com> * camel-stream.[c,h]: Changed the read and write method prototypes to return an ssize_t type rather than an int and also changed the 'number of bytes' to read or write to a size_t type * camel-stream-fs.c: same as above * camel-stream-mem.c: again, same as above * camel-stream-buffer.c: same * camel-imap-stream.[c,h]: Added this new stream, cache's previously read data so each successive call will instead read from the cache svn path=/trunk/; revision=3450
* > searchpart = strchr(namepart, '?');NotZed2000-05-201-64/+72
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 2000-05-19 NotZed <NotZed@HelixCode.com> * camel-simple-data-wrapper.c (construct_from_stream): If we already have been constructed, unref our content. (write_to_stream): Check we've been constructued, and change for stream api changes. * camel-mime-parser.c: Removed exception stuff. * md5-utils.c (md5_get_digest_from_stream): repaired. * camel-mime-message.c: Remove exception from write_to_stream, and fix, and fix formatting. * providers/sendmail/camel-sendmail-transport.c (_send_internal): Fix for stream changes. * providers/pop3/camel-pop3-store.c (camel_pop3_command): Fixes for stream changes. * providers/mbox/camel-mbox-folder.c, and elsewhere, fix all stream api changes. (mbox_append_message): Use stream_close() now its back. (mbox_append_message): unref the from filter. * camel-stream-mem.c: And here. * camel-stream-fs.[ch]: Here too. * camel-stream-filter.c: Likewise. This is getting tedious. * camel-stream-buffer.c (stream_write): Fix a few little problems. (stream_close): Reimplmeent. (camel_stream_buffer_read_line): Slightly more efficient version, that also only allocates the right amount of memory for strings. * camel-seekable-substream.c: Likewise. * camel-seekable-stream.[ch]: Remove exceptions, fix formatting, changes for stream (re)fixes. set_bounds returns an error. * camel-stream.[ch]: Remove exceptions. Make flush and reset return an error code, repair all the screwed up formatting, and put back close. * camel-mime-part-utils.c (camel_mime_part_construct_content_from_parser): And here. * camel-mime-part.c (camel_mime_part_set_content): And this too. (write_to_stream): Fixed for stream changes. * camel.h: Fixed. * providers/vee/camel-vee-folder.c (vee_search_by_expression): Implement. Performs an intersection of the two searches. (camel_vee_folder_finalise): Unref search folders. (vee_append_message): Implement append. svn path=/trunk/; revision=3142
* Use CamelException to signal failure. (camel_stream_write_strings):Dan Winship2000-05-091-61/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * camel-stream.c (camel_stream_read, camel_stream_write, camel_stream_flush, camel_stream_reset, camel_stream_printf, camel_stream_write_to_stream): Use CamelException to signal failure. (camel_stream_write_strings): Remove. camel_stream_printf is more useful in most of the places that used this. (camel_stream_write_string): Change from macro to function to prevent problems with double-evaluation. * camel-seekable-stream.c (camel_seekable_stream_seek, camel_seekable_stream_set_bounds): Use CamelException. (reset): Update. * camel-seekable-substream.c, camel-stream-buffer.c, camel-stream-filter.c, camel-stream-fs.c, camel-stream-mem.c: Update. * camel-stream-fs.c: Remove the virtual init functions and move the code into the creator functions. Add CamelExceptions to creation functions that could fail. * camel-data-wrapper.c (camel_data_wrapper_write_to_stream): Use CamelException. * camel-mime-message.c, camel-mime-part.c, camel-multipart.c (write_to_stream): Update. * camel-mime-parser.c: add an exception to the mime parser private data and pass that to stream functions as needed. * gmime-content-field.c, md5-utils.c: Update (badly) for stream changes. * camel-exception.h (camel_exception_is_set): convenience macro. * providers/Makefile.am: disable SMTP for now * providers/mbox/camel-mbox-folder.c (mbox_append_message): Pass CamelException to the functions that now need it. Check the exception after calling camel_stream_flush, and fail if it fails. (mbox_get_message_by_uid): More updates. * providers/pop/camel-pop3-folder.c, providers/pop/camel-pop3-store.c, providers/sendmail/camel-sendmail/transport.c: Update. svn path=/trunk/; revision=2924
* Make camel not leak like a sieve.Dan Winship2000-05-081-11/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * camel-object.c: New subclass of GtkObject which is now the base of the Camel object hierarchy. Currently the only difference between CamelObject and GtkObject is that CamelObjects don't start out floating. * *.h: Move a bunch of typedefs to camel-types.h. Standardize on using <camel/foo.h> in header files rather than <foo.h>, "foo.h", or "camel/foo.h". Remove some unneeded includes. * camel-address.c, camel-data-wrapper.c, camel-folder-search.c, camel-folder-summary.c, camel-folder.c, camel-mime-filter.c, camel-mime-parser.c, camel-service.c, camel-session.c, camel-stream.c: These are now subclasses of CamelObject. * camel-data-wrapper.c (set_output_stream): * camel-medium.c (set_content_object): * camel-seekable-substream.c (init_with_seekable_stream_and_bounds): * providers/mbox/camel-mbox-folder.c (mbox_get_message_by_uid): remove gtk_object_sink calls. * camel-stream-buffer.c (init_vbuf): * camel-stream-filter.c (camel_stream_filter_new_with_stream): ref the original stream. * camel-folder-summary.c (camel_folder_summary_finalise): unref the filters when finalizing. * camel-mime-part-utils.c (simple_data_wrapper_construct_from_parser, camel_mime_part_construct_content_from_parser): * camel-mime-part.c (camel_mime_part_set_content): Unref objects that are created only to be handed off to other objects. If they're going to be needed later, they will have been additionally ref'ed by the object that needs them. * providers/pop3/camel-pop3-folder.c (get_message_by_number): unref the message stream after creating the data from it. * camel-stream.c, camel-stream-buffer.c, camel-stream-filter.c, camel-stream-fs.c, camel-stream-mem.c: Remove camel_stream_close, since its semantics are dubious (what happens when you close a stream other people still have references on?). * providers/nntp/camel-nntp-store.c: * providers/smtp/camel-smtp-transport.c: * providers/pop3/camel-pop3-store.c: replace camel_stream_close calls with gtk_object_unref. * providers/mbox/camel-mbox-folder.c: * providers/nntp/camel-nntp-folder.c: * providers/sendmail/camel-sendmail-transport.c: replace camel_stream_close with camel_stream_flush + gtk_object_unref svn path=/trunk/; revision=2882
* Big cleanup of camel-stream-*, got rid of 3 classes, improved the interfaces,NotZed2000-04-261-48/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | and fixed at least one problem (end of stream never happening in certain cases). Things that can fail now have a way of saying they failed too. So much for taking ANZAC day off to get drunk! 2000-04-26 NotZed <NotZed@HelixCode.com> * camel-seekable-substream.c (stream_seek): Changed to have absolute seek semantics, not relative to the bounds. * camel-seekable-stream.c (reset): When we reset, seek to the start of the bound, if there is one. (stream_tell): Make tell virtual. * camel-stream-filter.c (do_available): Removed. * camel-stream-buffer.c: Remove leading _'s from static functions. (stream_read): Renamed from read(). Fancy that conflicting! (my boo!) Others too. * providers/pop3/camel-pop3-folder.c (get_message_by_number): Changed to stream_mem interface. * providers/mbox/camel-mbox-folder.c (_get_message_by_uid): Fixed for streamfs interface changes, and implement a failure case. (_append_message): Changed for fs stream interface change. * camel-multipart.c (print_part): Iterate rahter than callback. I hate glists's interface (hence, move this to write_to_stream). (write_to_stream): Return an error (yuck, this is a royal PITA to do with the stream write interface). * camel-mime-message.c: Removed leading _ from static names. * camel-mime-part.h: construct_from_parser() now returns an error code. * camel-mime-part-utils.c (camel_mime_part_construct_content_from_parser): Changed to use a camel-data-wrapper instead of a camel-simple-data-wrapper (no change needed elsewhere?). (simple_data_wrapper_construct_from_parser): Fixes for stream-mem interface changes. * camel-simple-data-wrapper.[ch], camel-simple-data-wrapper-stream.[ch], camel-stream-data-wrapper.[ch], removed. Fixed including of these files. * camel-mime-part.c (camel_mime_part_set_text): Remove the use of the camel-simple-data-wrapper-stream, just use a mem stream. (write_to_stream): Renamed from my_* (construct_from_stream): Return an error on error. * camel-stream-mem.c (camel_stream_mem_new*): Remove mode parameter. * camel-stream-mem.h (enum CamelStreamMemMode): Removed. It wasn't used at all. * camel-data-wrapper.h: Add camel_data_wrapper_new() to create these. (write_to_stream, construct_from_stream): Return an error indicator for success. Fixed all methods to match (ICK). * Makefile.am (libcamel_la_SOURCES): Remove camel-simple-data-wrapper.c, camel-simple-data-wrapper-stream.c, camel-stream-data-wrapper.c. Obsoleted by code re-use! * camel-data-wrapper.c (construct_from_stream): Change the default implementation to just set the output stream == construction stream. Well, this lets me get rid of both simple-data-wrapper and stream-data-wrapper (unused anyway), and simple-data-wrapper-stream in one hit. CamelDataWrapper is now also a concrete class. (write_to_stream): Use camel_stream_write_to_stream() to calculate/return values (and save code). Include <errno.h> for obvious reasons. * camel-stream.c (eos): Provide a default implementation of .eos(). (camel_stream_write_to_stream): Make it return an error code on error. (camel_stream_printf): Changed to return the number of bytes written/error. (camel_stream_available): Removed. * camel-stream-fs.h (enum CamelStreamFsMode): Removed. Changed to use unix modes and so forth (wasn't used for anything but new file creation and didn't work well either). * camel-stream-fs.c: Removed leading _'s for names. And removed some virtual method 'documentation'. (destroy): Dont try and close a closed/error fd. Only report error if close returns -1. Moved all the code to finalise(), and killed this function. (init_with_fd): Properly setup the seek offset, if it is a valid and seekable file descriptor. (init_with_fd_and_bounds): Use off_t for bounds, set bounds on the seekable stream. (init_with_name): Return error codes. (init_with_name_and_bounds): Ditto. (camel_stream_fs_new_with_name): REturn NULL object if it failed. (camel_stream_fs_new_with_name_and_bounds): Return NULL object on failure. Changed with_name* api's to take unix open style args and flags. (read): The bounded stream bounds checking seemed off, simplified code a bit. (write): Implement bounds checking for writing, the comment was wrong, it could make sense to bound writing. Cleaned up a little. (available): Gone. (eos): Removed. Use CamelStream's implementation now. (close): Reset the fd to -1, provide a warning for bad usage. (seek): Cleaned up. Changed the behaviour a little, the returned offset is the absolute position in the file, even in bounded streams. (seek): Seek from end mirrors lseek() behaviour (reverse seeking). 2000-04-25 NotZed <NotZed@HelixCode.com> * camel-stream-fs.h (struct _CamelStreamFs): Moved bounds and eof indicator to other parent classes. * camel-stream.c (camel_stream_printf): New utility function. Obvious use. * camel-stream-mem.c: Removed leading _'s from static func's. (camel_stream_mem_new_with_byte_array): Fixed for api changes, set the owner for the byte array to us. : Removed A bunch of gtk doc stuff for static (implementation) functions. (available): Removed. (write): Fixed the write implementation so that seek() works on a seekable memory stream, as expected. Seeking past the end of the buffer has unix semantics (filling with 0). (available): Removed. (write): Implement seekable stream bounded stream. (read): Implement seekable stream bounded stream. (close): Dont free the stream_mem if we're not the owner. (seek): Allow to seek beyond the end of memory area, implement bounds checking. (seek): Set errno on bad policy. * camel-stream-mem.h (struct _CamelStreamMem): Changed position to off_t. (new_with_buffer): Changed len to be a size_t. (set_buffer, set_byte_array): New interface functions. (struct _CamelStreamMem): Removed position, it is stored in the superclass. * camel-stream.h: Removed some of the seemingly random whitespace. Removed the available method (its not impelemented/useful enough). * camel-seekable-substream.c (init_with_seekable_stream_and_bounds): Remove the data_available stuff, it hasn't been properly implemented/finished, and may never work (unfortunately *sigh). (reemit_parent_signal): Removed part of the above change. (set_bounds): Removed (moved to seekable-stream). : Fixed up some of the generally unreadable indenting (sorry, wrapping at 80 characters with camels_really_long_function_names() just_doesnt_work_very_well_does_it(). (available): Removed. (stream_seek): Fixup for object changes. Make sure we return -1 if the parent stream can't seek. * camel-seekable-stream.c (ccamel_seekable_stream_set_bounds): New function to bound any seekable stream. : Removed _'s. (camel_seekable_stream_class_init): Implement an init function, to setup the stream bounds to unbound. * camel-seekable-stream.h (CamelSeekableStreamClass): New virtual method set_bounds for seekable streams. (CAMEL_STREAM_UNBOUND): New define for no bound. * camel-seekable-substream.h (struct _CamelSeekableSubstream): Removed sup_bound and inf_bound, moved to CamelSeekableStream (and renamed, and changed to off_t's). (new_with_seekable_stream_and_bounds): Use off_t as the bounds. (CamelSeekableSubstreamClass): Uh, why was the intialiser virtual? Removed. * camel-seekable-stream.[ch] (CamelSeekableStreamClass): Changed seek to accept an off_t as the offset. (struct _CamelSeekableStream): Renamed cur_pos to position and changed it to an off_t type. (enum CamelStreamSeekPolicy): Set to match the SEEK_* constants from lseek(). (get_current_position): Renamed to tell(). * camel-stream-buffer.h: Commented out set_vbuf - never implemented. svn path=/trunk/; revision=2624
* only return TRUE if the parent is at eos AND the buffer has been exhaustedDan Winship2000-04-261-1/+1
| | | | | | | * camel-stream-buffer.c (_eos): only return TRUE if the parent is at eos AND the buffer has been exhausted svn path=/trunk/; revision=2621
* kill camel-logDan Winship2000-04-191-10/+0
| | | | svn path=/trunk/; revision=2487
* Function to read one line of any size from a stream and return it inDan Winship2000-03-241-0/+43
| | | | | | | | | | | * camel-stream-buffer.c (camel_stream_buffer_read_line): Function to read one line of any size from a stream and return it in allocated memory. Also add camel-stream-buffer.h to camel.h and CamelStreamBuffer to camel-types.h. svn path=/trunk/; revision=2152
* fix the name of "Helix Code, Inc." in all the copyrightsDan Winship2000-03-101-1/+1
| | | | svn path=/trunk/; revision=2091
* Added camel-stream-buffer to build.NotZed2000-03-011-0/+454
2000-02-29 NotZed <NotZed@HelixCode.com> * Makefile.am (libcamelinclude_HEADERS): Added camel-stream-buffer to build. * camel-stream-buffer.[ch]: Generic buffer which can be applied to any stream. svn path=/trunk/; revision=1995