Lines Matching +full:negative +full:- +full:reference +full:- +full:buffer

2  * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson
29 /** @file event2/buffer.h
46 - if you already know how much data you are going to add as a result
51 - evbuffer_add_buffer() adds the contents of one buffer to the other
54 - evbuffer_add() and evbuffer_add_buffer() do not mix very well:
56 buffer.
58 - For high-performance code, you may want to avoid copying data into and out
61 buffer, and evbuffer_peek() when reading.
81 #include <event2/event-config.h>
106 Used when repeatedly searching through a buffer. Calling any function
107 that modifies or re-packs the buffer contents may invalidate all
108 evbuffer_ptrs for that buffer. Do not modify or contruct these values
111 An evbuffer_ptr can represent any position from the start of a buffer up
112 to a position immediately after the end of a buffer.
128 direct-access functions.
134 /* Internal use -- defined only if we are using the native struct iovec */
171 @return 0 on success, -1 on failure.
193 * from this buffer: we'll only take bytes out of this buffer by
198 * Using this option allows the implementation to use sendfile-based
204 * output buffer.
210 * @param buffer the evbuffer that the callback is watching.
213 * @return 0 on success, -1 on failure.
219 * @param buffer the evbuffer that the callback is watching.
222 * @return 0 on success, -1 on failure.
237 Returns the number of contiguous available bytes in the first buffer chain.
246 in the first buffer chain.
259 @return 0 if successful, or -1 if an error occurred
280 It is an error to do anything that moves around the buffer's internal
294 @return the number of provided extents, or -1 on error.
310 has been added to the buffer since the space was reserved.
320 @return 0 on success, -1 on error
331 @param data pointer to the beginning of the data buffer
332 @param datlen the number of bytes to be copied from the data buffer
333 @return 0 on success, -1 on failure.
346 @param data the destination buffer to store the result
347 @param datlen the maximum size of the destination buffer
348 @return the number of bytes read, or -1 if we can't drain the buffer.
354 Read data from an evbuffer, and leave the buffer unchanged.
360 @param data_out the destination buffer to store the result
361 @param datlen the maximum size of the destination buffer
362 @return the number of bytes read, or -1 if we can't drain the buffer.
368 Read data from the middle of an evbuffer, and leave the buffer unchanged.
375 @param data_out the destination buffer to store the result
376 @param datlen the maximum size of the destination buffer
377 @return the number of bytes read, or -1 if we can't drain the buffer.
384 the bytes from the source buffer. This function avoids copy
388 buffer is drained completely.
399 /** Used to tell evbuffer_readln what kind of line-ending to look for.
407 * all in the buffer at once, but if you first read a CR from
413 * most useful for implementing text-based internet protocols. */
427 * argument. Returns a newly allocated nul-terminated string; the caller must
430 * @param buffer the evbuffer to read from
431 * @param n_read_out if non-NULL, points to a size_t that is set to the
434 * @param eol_style the style of line-ending to use.
438 char *evbuffer_readln(struct evbuffer *buffer, size_t *n_read_out,
444 This is a destructive add. The data from one buffer moves into
445 the other buffer. However, no unnecessary memory copies occur.
447 @param outbuf the output buffer
448 @param inbuf the input buffer
449 @return 0 if successful, or -1 if an error occurred
459 This is a non-destructive add. The data from one buffer is copied
460 into the other buffer. However, no unnecessary memory copies occur.
462 Note that buffers already containing buffer references can't be added
465 @param outbuf the output buffer
466 @param inbuf the input buffer
467 @return 0 if successful, or -1 if an error occurred
475 reference.
483 Reference memory into an evbuffer without copying.
486 read. This function keeps just a reference to the memory without
489 @param outbuf the output buffer
490 @param data the memory to reference
491 @param datlen how memory to reference
495 @return 0 if successful, or -1 if an error occurred
516 For more fine-grained control, use evbuffer_add_file_segment.
518 @param outbuf the output buffer
521 @param length how much data to read, or -1 to read as much as possible.
522 (-1 requires that 'fd' support fstat.)
523 @return 0 if successful, or -1 if an error occurred
531 An evbuffer_file_segment holds a reference to a range of a file --
532 possibly the whole file! -- for use in writing from an evbuffer to a
547 Flag for creating evbuffer_file_segment: Disable memory-map based
552 Flag for creating evbuffer_file_segment: Disable direct fd-to-fd
571 for reference.
593 @param length how much data to read, or -1 to read as much as possible.
594 (-1 requires that 'fd' support fstat.)
642 @param length the amount of data to add, or -1 to add it all.
643 @return 0 on success, -1 on failure.
657 @return The number of bytes added if successful, or -1 if an error occurred.
674 @return The number of bytes added if successful, or -1 if an error occurred.
688 @param len the number of bytes to drain from the beginning of the buffer
689 @return 0 on success, -1 on failure.
700 @param buffer the evbuffer to be written and drained
702 @return the number of bytes written, or -1 if an error occurred
706 int evbuffer_write(struct evbuffer *buffer, evutil_socket_t fd);
713 @param buffer the evbuffer to be written and drained
715 @param howmuch the largest allowable number of bytes to write, or -1
717 @return the number of bytes written, or -1 if an error occurred
721 int evbuffer_write_atmost(struct evbuffer *buffer, evutil_socket_t fd,
727 @param buffer the evbuffer to store the result
729 @param howmuch the number of bytes to be read. If the given number is negative
731 @return the number of bytes read, or -1 if an error occurred
735 int evbuffer_read(struct evbuffer *buffer, evutil_socket_t fd, int howmuch);
740 @param buffer the evbuffer to be searched
745 first occurrence of the string in the buffer after 'start'. The 'pos'
746 field of the result is -1 if the string was not found.
749 struct evbuffer_ptr evbuffer_search(struct evbuffer *buffer, const char *what, size_t len, const st…
754 @param buffer the evbuffer to be searched
762 first occurrence of the string in the buffer after 'start'. The 'pos'
763 field of the result is -1 if the string was not found.
766 struct evbuffer_ptr evbuffer_search_range(struct evbuffer *buffer, const char *what, size_t len, co…
781 Sets the search pointer in the buffer to position.
785 to move 'pos' to a position 'N' bytes after the start of the buffer, or
792 An evbuffer_ptr can represent any position from the start of the buffer to
793 a position immediately after the end of the buffer.
795 @param buffer the evbuffer to be search
799 @returns 0 on success or -1 otherwise
803 evbuffer_ptr_set(struct evbuffer *buffer, struct evbuffer_ptr *ptr,
807 Search for an end-of-line string within an evbuffer.
809 @param buffer the evbuffer to be searched
812 @param eol_len_out If non-NULL, the pointed-to value will be set to
813 the length of the end-of-line string.
817 first occurrence EOL in the buffer after 'start'. The 'pos'
818 field of the result is -1 if the string was not found.
821 struct evbuffer_ptr evbuffer_search_eol(struct evbuffer *buffer,
829 with pointers to one or more extents of data inside the buffer.
834 the buffer does not have as much data as you asked to see).
836 @param buffer the evbuffer to peek into,
837 @param len the number of bytes to try to peek. If len is negative, we
838 will try to fill as much of vec_out as we can. If len is negative
840 that would be needed to get all the data in the buffer.
843 buffer."
854 int evbuffer_peek(struct evbuffer *buffer, ev_ssize_t len,
880 list of callbacks, or add or remove data from the buffer. It may not
883 If a callback adds or removes data from the buffer or from another
884 buffer, this can cause a recursive invocation of your callback or
888 @param buffer the buffer whose size has changed
889 @param info a structure describing how the buffer changed.
892 typedef void (*evbuffer_cb_func)(struct evbuffer *buffer, const struct evbuffer_cb_info *info, void…
900 @param buffer the evbuffer to be monitored
907 struct evbuffer_cb_entry *evbuffer_add_cb(struct evbuffer *buffer, evbuffer_cb_func cb, void *cbarg…
914 @return 0 if a callback was removed, or -1 if no matching callback was
918 int evbuffer_remove_cb_entry(struct evbuffer *buffer,
924 @return 0 if a callback was removed, or -1 if no matching callback was
928 int evbuffer_remove_cb(struct evbuffer *buffer, evbuffer_cb_func cb, void *cbarg);
937 /** Change the flags that are set for a callback on a buffer by adding more.
939 @param buffer the evbuffer that the callback is watching.
941 @param flags EVBUFFER_CB_ENABLED to re-enable the callback.
942 @return 0 on success, -1 on failure.
945 int evbuffer_cb_set_flags(struct evbuffer *buffer,
948 /** Change the flags that are set for a callback on a buffer by removing some
950 @param buffer the evbuffer that the callback is watching.
953 @return 0 on success, -1 on failure.
956 int evbuffer_cb_clear_flags(struct evbuffer *buffer,
963 invoked later if the buffer size changes between now and when we unsuspend
966 @param the buffer that the callback is watching.
970 void evbuffer_cb_suspend(struct evbuffer *buffer, struct evbuffer_cb_entry *cb);
973 If data was added to or removed from the buffer while the callback was
976 @param the buffer that the callback is watching.
980 void evbuffer_cb_unsuspend(struct evbuffer *buffer, struct evbuffer_cb_entry *cb);
987 @param size the number of bytes to make contiguous, or -1 to make the
988 entire buffer contiguous.
990 requested more data than is present in the buffer.
1002 @return 0 if successful, or -1 otherwise
1014 @return 0 if successful, or -1 otherwise
1020 Prevent calls that modify an evbuffer from succeeding. A buffer may
1023 If the front of a buffer is frozen, operations that drain data from
1024 the front of the buffer, or that prepend data to the buffer, will
1025 fail until it is unfrozen. If the back a buffer is frozen, operations
1026 that append data from the buffer will fail until it is unfrozen.
1028 @param buf The buffer to freeze
1029 @param at_front If true, we freeze the front of the buffer. If false,
1031 @return 0 on success, -1 on failure.
1036 Re-enable calls that modify an evbuffer.
1038 @param buf The buffer to un-freeze
1039 @param at_front If true, we unfreeze the front of the buffer. If false,
1041 @return 0 on success, -1 on failure.
1055 int evbuffer_defer_callbacks(struct evbuffer *buffer, struct event_base *base);
1065 @param buffer the destination buffer
1068 @return the number of bytes successfully written to the output buffer.
1071 size_t evbuffer_add_iovec(struct evbuffer * buffer, struct evbuffer_iovec * vec, int n_vec);