1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
|
.TH "event2/buffer.h" 3 "Tue Jan 27 2015" "libevent" \" -*- nroff -*-
.ad l
.nh
.SH NAME
event2/buffer.h \-
Functions for buffering data for network sending or receiving\&.
.SH SYNOPSIS
.br
.PP
\fC#include <event2/event-config\&.h>\fP
.br
\fC#include <stdarg\&.h>\fP
.br
\fC#include <event2/util\&.h>\fP
.br
.SS "Data Structures"
.in +1c
.ti -1c
.RI "struct \fBevbuffer\fP"
.br
.RI "\fIAn evbuffer is an opaque data type for efficiently buffering data to be sent or received on the network\&. \fP"
.ti -1c
.RI "struct \fBevbuffer_cb_info\fP"
.br
.RI "\fIStructure passed to an evbuffer_cb_func evbuffer callback\&. \fP"
.ti -1c
.RI "struct \fBevbuffer_iovec\fP"
.br
.RI "\fIDescribes a single extent of memory inside an evbuffer\&. \fP"
.ti -1c
.RI "struct \fBevbuffer_ptr\fP"
.br
.RI "\fIPointer to a position within an evbuffer\&. \fP"
.in -1c
.SS "Macros"
.in +1c
.ti -1c
.RI "#define \fBEVBUFFER_CB_ENABLED\fP 1"
.br
.RI "\fIIf this flag is not set, then a callback is temporarily disabled, and should not be invoked\&. \fP"
.ti -1c
.RI "#define \fBEVBUFFER_FLAG_DRAINS_TO_FD\fP 1"
.br
.RI "\fIIf this flag is set, then we will not use \fBevbuffer_peek()\fP, \fBevbuffer_remove()\fP, \fBevbuffer_remove_buffer()\fP, and so on to read bytes from this buffer: we'll only take bytes out of this buffer by writing them to the network (as with evbuffer_write_atmost), by removing them without observing them (as with evbuffer_drain), or by copying them all out at once (as with evbuffer_add_buffer)\&. \fP"
.in -1c
.SS "Typedefs"
.in +1c
.ti -1c
.RI "typedef void(* \fBevbuffer_cb_func\fP )(struct \fBevbuffer\fP *buffer, const struct \fBevbuffer_cb_info\fP *info, void *arg)"
.br
.RI "\fIType definition for a callback that is invoked whenever data is added or removed from an evbuffer\&. \fP"
.ti -1c
.RI "typedef void(* \fBevbuffer_ref_cleanup_cb\fP )(const void *data, size_t datalen, void *extra)"
.br
.RI "\fIA cleanup function for a piece of memory added to an evbuffer by reference\&. \fP"
.in -1c
.SS "Enumerations"
.in +1c
.ti -1c
.RI "enum \fBevbuffer_eol_style\fP { \fBEVBUFFER_EOL_ANY\fP, \fBEVBUFFER_EOL_CRLF\fP, \fBEVBUFFER_EOL_CRLF_STRICT\fP, \fBEVBUFFER_EOL_LF\fP }"
.br
.RI "\fIUsed to tell evbuffer_readln what kind of line-ending to look for\&. \fP"
.ti -1c
.RI "enum \fBevbuffer_ptr_how\fP { \fBEVBUFFER_PTR_SET\fP, \fBEVBUFFER_PTR_ADD\fP }"
.br
.RI "\fIDefines how to adjust an \fBevbuffer_ptr\fP by \fBevbuffer_ptr_set()\fP \fP"
.in -1c
.SS "Functions"
.in +1c
.ti -1c
.RI "int \fBevbuffer_add\fP (struct \fBevbuffer\fP *buf, const void *data, size_t datlen)"
.br
.RI "\fIAppend data to the end of an evbuffer\&. \fP"
.ti -1c
.RI "int \fBevbuffer_add_buffer\fP (struct \fBevbuffer\fP *outbuf, struct \fBevbuffer\fP *inbuf)"
.br
.RI "\fIMove all data from one evbuffer into another evbuffer\&. \fP"
.ti -1c
.RI "struct evbuffer_cb_entry * \fBevbuffer_add_cb\fP (struct \fBevbuffer\fP *buffer, \fBevbuffer_cb_func\fP cb, void *cbarg)"
.br
.RI "\fIAdd a new callback to an evbuffer\&. \fP"
.ti -1c
.RI "int \fBevbuffer_add_file\fP (struct \fBevbuffer\fP *outbuf, int fd, ev_off_t offset, ev_off_t length)"
.br
.RI "\fICopy data from a file into the evbuffer for writing to a socket\&. \fP"
.ti -1c
.RI "int \fBevbuffer_add_printf\fP (struct \fBevbuffer\fP *buf, const char *fmt,\&.\&.\&.)"
.br
.RI "\fIAppend a formatted string to the end of an evbuffer\&. \fP"
.ti -1c
.RI "int \fBevbuffer_add_reference\fP (struct \fBevbuffer\fP *outbuf, const void *data, size_t datlen, \fBevbuffer_ref_cleanup_cb\fP cleanupfn, void *cleanupfn_arg)"
.br
.RI "\fIReference memory into an evbuffer without copying\&. \fP"
.ti -1c
.RI "int \fBevbuffer_add_vprintf\fP (struct \fBevbuffer\fP *buf, const char *fmt, va_list ap)"
.br
.RI "\fIAppend a va_list formatted string to the end of an evbuffer\&. \fP"
.ti -1c
.RI "int \fBevbuffer_cb_clear_flags\fP (struct \fBevbuffer\fP *buffer, struct evbuffer_cb_entry *cb, ev_uint32_t flags)"
.br
.RI "\fIChange the flags that are set for a callback on a buffer by removing some\&. \fP"
.ti -1c
.RI "int \fBevbuffer_cb_set_flags\fP (struct \fBevbuffer\fP *buffer, struct evbuffer_cb_entry *cb, ev_uint32_t flags)"
.br
.RI "\fIChange the flags that are set for a callback on a buffer by adding more\&. \fP"
.ti -1c
.RI "int \fBevbuffer_clear_flags\fP (struct \fBevbuffer\fP *buf, ev_uint64_t flags)"
.br
.RI "\fIChange the flags that are set for an evbuffer by removing some\&. \fP"
.ti -1c
.RI "int \fBevbuffer_commit_space\fP (struct \fBevbuffer\fP *buf, struct \fBevbuffer_iovec\fP *vec, int n_vecs)"
.br
.RI "\fICommits previously reserved space\&. \fP"
.ti -1c
.RI "ev_ssize_t \fBevbuffer_copyout\fP (struct \fBevbuffer\fP *buf, void *data_out, size_t datlen)"
.br
.RI "\fIRead data from an evbuffer, and leave the buffer unchanged\&. \fP"
.ti -1c
.RI "int \fBevbuffer_defer_callbacks\fP (struct \fBevbuffer\fP *buffer, struct \fBevent_base\fP *base)"
.br
.RI "\fIForce all the callbacks on an evbuffer to be run, not immediately after the evbuffer is altered, but instead from inside the event loop\&. \fP"
.ti -1c
.RI "int \fBevbuffer_drain\fP (struct \fBevbuffer\fP *buf, size_t len)"
.br
.RI "\fIRemove a specified number of bytes data from the beginning of an evbuffer\&. \fP"
.ti -1c
.RI "int \fBevbuffer_enable_locking\fP (struct \fBevbuffer\fP *buf, void *lock)"
.br
.RI "\fIEnable locking on an evbuffer so that it can safely be used by multiple threads at the same time\&. \fP"
.ti -1c
.RI "int \fBevbuffer_expand\fP (struct \fBevbuffer\fP *buf, size_t datlen)"
.br
.RI "\fIExpands the available space in an evbuffer\&. \fP"
.ti -1c
.RI "void \fBevbuffer_free\fP (struct \fBevbuffer\fP *buf)"
.br
.RI "\fIDeallocate storage for an evbuffer\&. \fP"
.ti -1c
.RI "int \fBevbuffer_freeze\fP (struct \fBevbuffer\fP *buf, int at_front)"
.br
.RI "\fIPrevent calls that modify an evbuffer from succeeding\&. \fP"
.ti -1c
.RI "size_t \fBevbuffer_get_contiguous_space\fP (const struct \fBevbuffer\fP *buf)"
.br
.RI "\fIReturns the number of contiguous available bytes in the first buffer chain\&. \fP"
.ti -1c
.RI "size_t \fBevbuffer_get_length\fP (const struct \fBevbuffer\fP *buf)"
.br
.RI "\fIReturns the total number of bytes stored in the evbuffer\&. \fP"
.ti -1c
.RI "void \fBevbuffer_lock\fP (struct \fBevbuffer\fP *buf)"
.br
.RI "\fIAcquire the lock on an evbuffer\&. \fP"
.ti -1c
.RI "struct \fBevbuffer\fP * \fBevbuffer_new\fP (void)"
.br
.RI "\fIAllocate storage for a new evbuffer\&. \fP"
.ti -1c
.RI "int \fBevbuffer_peek\fP (struct \fBevbuffer\fP *buffer, ev_ssize_t len, struct \fBevbuffer_ptr\fP *start_at, struct \fBevbuffer_iovec\fP *vec_out, int n_vec)"
.br
.RI "\fIFunction to peek at data inside an evbuffer without removing it or copying it out\&. \fP"
.ti -1c
.RI "int \fBevbuffer_prepend\fP (struct \fBevbuffer\fP *buf, const void *data, size_t size)"
.br
.RI "\fIPrepends data to the beginning of the evbuffer\&. \fP"
.ti -1c
.RI "int \fBevbuffer_prepend_buffer\fP (struct \fBevbuffer\fP *dst, struct \fBevbuffer\fP *src)"
.br
.RI "\fIPrepends all data from the src evbuffer to the beginning of the dst evbuffer\&. \fP"
.ti -1c
.RI "int \fBevbuffer_ptr_set\fP (struct \fBevbuffer\fP *buffer, struct \fBevbuffer_ptr\fP *ptr, size_t position, enum \fBevbuffer_ptr_how\fP how)"
.br
.RI "\fISets the search pointer in the buffer to position\&. \fP"
.ti -1c
.RI "unsigned char * \fBevbuffer_pullup\fP (struct \fBevbuffer\fP *buf, ev_ssize_t size)"
.br
.RI "\fIMakes the data at the beginning of an evbuffer contiguous\&. \fP"
.ti -1c
.RI "int \fBevbuffer_read\fP (struct \fBevbuffer\fP *buffer, \fBevutil_socket_t\fP fd, int howmuch)"
.br
.RI "\fIRead from a file descriptor and store the result in an evbuffer\&. \fP"
.ti -1c
.RI "char * \fBevbuffer_readln\fP (struct \fBevbuffer\fP *buffer, size_t *n_read_out, enum \fBevbuffer_eol_style\fP eol_style)"
.br
.RI "\fIRead a single line from an evbuffer\&. \fP"
.ti -1c
.RI "int \fBevbuffer_remove\fP (struct \fBevbuffer\fP *buf, void *data, size_t datlen)"
.br
.RI "\fIRead data from an evbuffer and drain the bytes read\&. \fP"
.ti -1c
.RI "int \fBevbuffer_remove_buffer\fP (struct \fBevbuffer\fP *src, struct \fBevbuffer\fP *dst, size_t datlen)"
.br
.RI "\fIRead data from an evbuffer into another evbuffer, draining the bytes from the source buffer\&. \fP"
.ti -1c
.RI "int \fBevbuffer_remove_cb\fP (struct \fBevbuffer\fP *buffer, \fBevbuffer_cb_func\fP cb, void *cbarg)"
.br
.RI "\fIRemove a callback from an evbuffer, given the function and argument used to add it\&. \fP"
.ti -1c
.RI "int \fBevbuffer_remove_cb_entry\fP (struct \fBevbuffer\fP *buffer, struct evbuffer_cb_entry *ent)"
.br
.RI "\fIRemove a callback from an evbuffer, given a handle returned from evbuffer_add_cb\&. \fP"
.ti -1c
.RI "int \fBevbuffer_reserve_space\fP (struct \fBevbuffer\fP *buf, ev_ssize_t size, struct \fBevbuffer_iovec\fP *vec, int n_vec)"
.br
.RI "\fIReserves space in the last chain or chains of an evbuffer\&. \fP"
.ti -1c
.RI "struct \fBevbuffer_ptr\fP \fBevbuffer_search\fP (struct \fBevbuffer\fP *buffer, const char *what, size_t len, const struct \fBevbuffer_ptr\fP *start)"
.br
.RI "\fISearch for a string within an evbuffer\&. \fP"
.ti -1c
.RI "struct \fBevbuffer_ptr\fP \fBevbuffer_search_eol\fP (struct \fBevbuffer\fP *buffer, struct \fBevbuffer_ptr\fP *start, size_t *eol_len_out, enum \fBevbuffer_eol_style\fP eol_style)"
.br
.RI "\fISearch for an end-of-line string within an evbuffer\&. \fP"
.ti -1c
.RI "struct \fBevbuffer_ptr\fP \fBevbuffer_search_range\fP (struct \fBevbuffer\fP *buffer, const char *what, size_t len, const struct \fBevbuffer_ptr\fP *start, const struct \fBevbuffer_ptr\fP *end)"
.br
.RI "\fISearch for a string within part of an evbuffer\&. \fP"
.ti -1c
.RI "int \fBevbuffer_set_flags\fP (struct \fBevbuffer\fP *buf, ev_uint64_t flags)"
.br
.RI "\fIChange the flags that are set for an evbuffer by adding more\&. \fP"
.ti -1c
.RI "int \fBevbuffer_unfreeze\fP (struct \fBevbuffer\fP *buf, int at_front)"
.br
.RI "\fIRe-enable calls that modify an evbuffer\&. \fP"
.ti -1c
.RI "void \fBevbuffer_unlock\fP (struct \fBevbuffer\fP *buf)"
.br
.RI "\fIRelease the lock on an evbuffer\&. \fP"
.ti -1c
.RI "int \fBevbuffer_write\fP (struct \fBevbuffer\fP *buffer, \fBevutil_socket_t\fP fd)"
.br
.RI "\fIWrite the contents of an evbuffer to a file descriptor\&. \fP"
.ti -1c
.RI "int \fBevbuffer_write_atmost\fP (struct \fBevbuffer\fP *buffer, \fBevutil_socket_t\fP fd, ev_ssize_t howmuch)"
.br
.RI "\fIWrite some of the contents of an evbuffer to a file descriptor\&. \fP"
.in -1c
.SH "Detailed Description"
.PP
Functions for buffering data for network sending or receiving\&.
An evbuffer can be used for preparing data before sending it to the network or conversely for reading data from the network\&. Evbuffers try to avoid memory copies as much as possible\&. As a result, evbuffers can be used to pass data around without actually incurring the overhead of copying the data\&.
.PP
A new evbuffer can be allocated with \fBevbuffer_new()\fP, and can be freed with \fBevbuffer_free()\fP\&. Most users will be using evbuffers via the bufferevent interface\&. To access a bufferevent's evbuffers, use \fBbufferevent_get_input()\fP and \fBbufferevent_get_output()\fP\&.
.PP
There are several guidelines for using evbuffers\&.
.PP
.IP "\(bu" 2
if you already know how much data you are going to add as a result of calling \fBevbuffer_add()\fP multiple times, it makes sense to use \fBevbuffer_expand()\fP first to make sure that enough memory is allocated before hand\&.
.IP "\(bu" 2
\fBevbuffer_add_buffer()\fP adds the contents of one buffer to the other without incurring any unnecessary memory copies\&.
.IP "\(bu" 2
\fBevbuffer_add()\fP and \fBevbuffer_add_buffer()\fP do not mix very well: if you use them, you will wind up with fragmented memory in your buffer\&.
.IP "\(bu" 2
For high-performance code, you may want to avoid copying data into and out of buffers\&. You can skip the copy step by using \fBevbuffer_reserve_space()\fP/evbuffer_commit_space() when writing into a buffer, and \fBevbuffer_peek()\fP when reading\&.
.PP
.PP
In Libevent 2\&.0 and later, evbuffers are represented using a linked list of memory chunks, with pointers to the first and last chunk in the chain\&.
.PP
As the contents of an evbuffer can be stored in multiple different memory blocks, it cannot be accessed directly\&. Instead, \fBevbuffer_pullup()\fP can be used to force a specified number of bytes to be contiguous\&. This will cause memory reallocation and memory copies if the data is split across multiple blocks\&. It is more efficient, however, to use \fBevbuffer_peek()\fP if you don't require that the memory to be contiguous\&.
.SH "Macro Definition Documentation"
.PP
.SS "#define EVBUFFER_CB_ENABLED 1"
.PP
If this flag is not set, then a callback is temporarily disabled, and should not be invoked\&.
.PP
\fBSee also:\fP
.RS 4
\fBevbuffer_cb_set_flags()\fP, \fBevbuffer_cb_clear_flags()\fP
.RE
.PP
.SS "#define EVBUFFER_FLAG_DRAINS_TO_FD 1"
.PP
If this flag is set, then we will not use \fBevbuffer_peek()\fP, \fBevbuffer_remove()\fP, \fBevbuffer_remove_buffer()\fP, and so on to read bytes from this buffer: we'll only take bytes out of this buffer by writing them to the network (as with evbuffer_write_atmost), by removing them without observing them (as with evbuffer_drain), or by copying them all out at once (as with evbuffer_add_buffer)\&. Using this option allows the implementation to use sendfile-based operations for \fBevbuffer_add_file()\fP; see that function for more information\&.
.PP
This flag is on by default for bufferevents that can take advantage of it; you should never actually need to set it on a bufferevent's output buffer\&.
.SH "Typedef Documentation"
.PP
.SS "typedef void(* evbuffer_cb_func)(struct \fBevbuffer\fP *buffer, const struct \fBevbuffer_cb_info\fP *info, void *arg)"
.PP
Type definition for a callback that is invoked whenever data is added or removed from an evbuffer\&. An evbuffer may have one or more callbacks set at a time\&. The order in which they are executed is undefined\&.
.PP
A callback function may add more callbacks, or remove itself from the list of callbacks, or add or remove data from the buffer\&. It may not remove another callback from the list\&.
.PP
If a callback adds or removes data from the buffer or from another buffer, this can cause a recursive invocation of your callback or other callbacks\&. If you ask for an infinite loop, you might just get one: watch out!
.PP
\fBParameters:\fP
.RS 4
\fIbuffer\fP the buffer whose size has changed
.br
\fIinfo\fP a structure describing how the buffer changed\&.
.br
\fIarg\fP a pointer to user data
.RE
.PP
.SS "typedef void(* evbuffer_ref_cleanup_cb)(const void *data, size_t datalen, void *extra)"
.PP
A cleanup function for a piece of memory added to an evbuffer by reference\&.
.PP
\fBSee also:\fP
.RS 4
\fBevbuffer_add_reference()\fP
.RE
.PP
.SH "Enumeration Type Documentation"
.PP
.SS "enum \fBevbuffer_eol_style\fP"
.PP
Used to tell evbuffer_readln what kind of line-ending to look for\&.
.PP
\fBEnumerator\fP
.in +1c
.TP
\fB\fIEVBUFFER_EOL_ANY \fP\fP
Any sequence of CR and LF characters is acceptable as an EOL\&. Note that this style can produce ambiguous results: the sequence 'CRLF' will be treated as a single EOL if it is all in the buffer at once, but if you first read a CR from the network and later read an LF from the network, it will be treated as two EOLs\&.
.TP
\fB\fIEVBUFFER_EOL_CRLF \fP\fP
An EOL is an LF, optionally preceded by a CR\&. This style is most useful for implementing text-based internet protocols\&.
.TP
\fB\fIEVBUFFER_EOL_CRLF_STRICT \fP\fP
An EOL is a CR followed by an LF\&.
.TP
\fB\fIEVBUFFER_EOL_LF \fP\fP
An EOL is a LF\&.
.SS "enum \fBevbuffer_ptr_how\fP"
.PP
Defines how to adjust an \fBevbuffer_ptr\fP by \fBevbuffer_ptr_set()\fP
.PP
\fBSee also:\fP
.RS 4
\fBevbuffer_ptr_set()\fP
.RE
.PP
.PP
\fBEnumerator\fP
.in +1c
.TP
\fB\fIEVBUFFER_PTR_SET \fP\fP
Sets the pointer to the position; can be called on with an uninitialized \fBevbuffer_ptr\fP\&.
.TP
\fB\fIEVBUFFER_PTR_ADD \fP\fP
Advances the pointer by adding to the current position\&.
.SH "Function Documentation"
.PP
.SS "int evbuffer_add (struct \fBevbuffer\fP *buf, const void *data, size_tdatlen)"
.PP
Append data to the end of an evbuffer\&.
.PP
\fBParameters:\fP
.RS 4
\fIbuf\fP the evbuffer to be appended to
.br
\fIdata\fP pointer to the beginning of the data buffer
.br
\fIdatlen\fP the number of bytes to be copied from the data buffer
.RE
.PP
\fBReturns:\fP
.RS 4
0 on success, -1 on failure\&.
.RE
.PP
.SS "int evbuffer_add_buffer (struct \fBevbuffer\fP *outbuf, struct \fBevbuffer\fP *inbuf)"
.PP
Move all data from one evbuffer into another evbuffer\&. This is a destructive add\&. The data from one buffer moves into the other buffer\&. However, no unnecessary memory copies occur\&.
.PP
\fBParameters:\fP
.RS 4
\fIoutbuf\fP the output buffer
.br
\fIinbuf\fP the input buffer
.RE
.PP
\fBReturns:\fP
.RS 4
0 if successful, or -1 if an error occurred
.RE
.PP
\fBSee also:\fP
.RS 4
\fBevbuffer_remove_buffer()\fP
.RE
.PP
.SS "struct evbuffer_cb_entry* evbuffer_add_cb (struct \fBevbuffer\fP *buffer, \fBevbuffer_cb_func\fPcb, void *cbarg)"
.PP
Add a new callback to an evbuffer\&. Subsequent calls to \fBevbuffer_add_cb()\fP add new callbacks\&. To remove this callback, call evbuffer_remove_cb or evbuffer_remove_cb_entry\&.
.PP
\fBParameters:\fP
.RS 4
\fIbuffer\fP the evbuffer to be monitored
.br
\fIcb\fP the callback function to invoke when the evbuffer is modified, or NULL to remove all callbacks\&.
.br
\fIcbarg\fP an argument to be provided to the callback function
.RE
.PP
\fBReturns:\fP
.RS 4
a handle to the callback on success, or NULL on failure\&.
.RE
.PP
.SS "int evbuffer_add_file (struct \fBevbuffer\fP *outbuf, intfd, ev_off_toffset, ev_off_tlength)"
.PP
Copy data from a file into the evbuffer for writing to a socket\&. This function avoids unnecessary data copies between userland and kernel\&. If sendfile is available and the EVBUFFER_FLAG_DRAINS_TO_FD flag is set, it uses those functions\&. Otherwise, it tries to use mmap (or CreateFileMapping on Windows)\&.
.PP
The function owns the resulting file descriptor and will close it when finished transferring data\&.
.PP
The results of using \fBevbuffer_remove()\fP or \fBevbuffer_pullup()\fP on evbuffers whose data was added using this function are undefined\&.
.PP
\fBParameters:\fP
.RS 4
\fIoutbuf\fP the output buffer
.br
\fIfd\fP the file descriptor
.br
\fIoffset\fP the offset from which to read data
.br
\fIlength\fP how much data to read
.RE
.PP
\fBReturns:\fP
.RS 4
0 if successful, or -1 if an error occurred
.RE
.PP
.SS "int evbuffer_add_printf (struct \fBevbuffer\fP *buf, const char *fmt, \&.\&.\&.)"
.PP
Append a formatted string to the end of an evbuffer\&. The string is formated as printf\&.
.PP
\fBParameters:\fP
.RS 4
\fIbuf\fP the evbuffer that will be appended to
.br
\fIfmt\fP a format string
.br
\fI\&.\&.\&.\fP arguments that will be passed to printf(3)
.RE
.PP
\fBReturns:\fP
.RS 4
The number of bytes added if successful, or -1 if an error occurred\&.
.RE
.PP
\fBSee also:\fP
.RS 4
evutil_printf(), \fBevbuffer_add_vprintf()\fP
.RE
.PP
.SS "int evbuffer_add_reference (struct \fBevbuffer\fP *outbuf, const void *data, size_tdatlen, \fBevbuffer_ref_cleanup_cb\fPcleanupfn, void *cleanupfn_arg)"
.PP
Reference memory into an evbuffer without copying\&. The memory needs to remain valid until all the added data has been read\&. This function keeps just a reference to the memory without actually incurring the overhead of a copy\&.
.PP
\fBParameters:\fP
.RS 4
\fIoutbuf\fP the output buffer
.br
\fIdata\fP the memory to reference
.br
\fIdatlen\fP how memory to reference
.br
\fIcleanupfn\fP callback to be invoked when the memory is no longer referenced by this evbuffer\&.
.br
\fIcleanupfn_arg\fP optional argument to the cleanup callback
.RE
.PP
\fBReturns:\fP
.RS 4
0 if successful, or -1 if an error occurred
.RE
.PP
.SS "int evbuffer_add_vprintf (struct \fBevbuffer\fP *buf, const char *fmt, va_listap)"
.PP
Append a va_list formatted string to the end of an evbuffer\&.
.PP
\fBParameters:\fP
.RS 4
\fIbuf\fP the evbuffer that will be appended to
.br
\fIfmt\fP a format string
.br
\fIap\fP a varargs va_list argument array that will be passed to vprintf(3)
.RE
.PP
\fBReturns:\fP
.RS 4
The number of bytes added if successful, or -1 if an error occurred\&.
.RE
.PP
.SS "int evbuffer_cb_clear_flags (struct \fBevbuffer\fP *buffer, struct evbuffer_cb_entry *cb, ev_uint32_tflags)"
.PP
Change the flags that are set for a callback on a buffer by removing some\&.
.PP
\fBParameters:\fP
.RS 4
\fIbuffer\fP the evbuffer that the callback is watching\&.
.br
\fIcb\fP the callback whose status we want to change\&.
.br
\fIflags\fP EVBUFFER_CB_ENABLED to disable the callback\&.
.RE
.PP
\fBReturns:\fP
.RS 4
0 on success, -1 on failure\&.
.RE
.PP
.SS "int evbuffer_cb_set_flags (struct \fBevbuffer\fP *buffer, struct evbuffer_cb_entry *cb, ev_uint32_tflags)"
.PP
Change the flags that are set for a callback on a buffer by adding more\&.
.PP
\fBParameters:\fP
.RS 4
\fIbuffer\fP the evbuffer that the callback is watching\&.
.br
\fIcb\fP the callback whose status we want to change\&.
.br
\fIflags\fP EVBUFFER_CB_ENABLED to re-enable the callback\&.
.RE
.PP
\fBReturns:\fP
.RS 4
0 on success, -1 on failure\&.
.RE
.PP
.SS "int evbuffer_clear_flags (struct \fBevbuffer\fP *buf, ev_uint64_tflags)"
.PP
Change the flags that are set for an evbuffer by removing some\&.
.PP
\fBParameters:\fP
.RS 4
\fIbuffer\fP the evbuffer that the callback is watching\&.
.br
\fIcb\fP the callback whose status we want to change\&.
.br
\fIflags\fP One or more EVBUFFER_FLAG_* options
.RE
.PP
\fBReturns:\fP
.RS 4
0 on success, -1 on failure\&.
.RE
.PP
.SS "int evbuffer_commit_space (struct \fBevbuffer\fP *buf, struct \fBevbuffer_iovec\fP *vec, intn_vecs)"
.PP
Commits previously reserved space\&. Commits some of the space previously reserved with \fBevbuffer_reserve_space()\fP\&. It then becomes available for reading\&.
.PP
This function may return an error if the pointer in the extents do not match those returned from evbuffer_reserve_space, or if data has been added to the buffer since the space was reserved\&.
.PP
If you want to commit less data than you got reserved space for, modify the iov_len pointer of the appropriate extent to a smaller value\&. Note that you may have received more space than you requested if it was available!
.PP
\fBParameters:\fP
.RS 4
\fIbuf\fP the evbuffer in which to reserve space\&.
.br
\fIvec\fP one or two extents returned by evbuffer_reserve_space\&.
.br
\fIn_vecs\fP the number of extents\&.
.RE
.PP
\fBReturns:\fP
.RS 4
0 on success, -1 on error
.RE
.PP
\fBSee also:\fP
.RS 4
\fBevbuffer_reserve_space()\fP
.RE
.PP
.SS "ev_ssize_t evbuffer_copyout (struct \fBevbuffer\fP *buf, void *data_out, size_tdatlen)"
.PP
Read data from an evbuffer, and leave the buffer unchanged\&. If more bytes are requested than are available in the evbuffer, we only extract as many bytes as were available\&.
.PP
\fBParameters:\fP
.RS 4
\fIbuf\fP the evbuffer to be read from
.br
\fIdata_out\fP the destination buffer to store the result
.br
\fIdatlen\fP the maximum size of the destination buffer
.RE
.PP
\fBReturns:\fP
.RS 4
the number of bytes read, or -1 if we can't drain the buffer\&.
.RE
.PP
.SS "int evbuffer_defer_callbacks (struct \fBevbuffer\fP *buffer, struct \fBevent_base\fP *base)"
.PP
Force all the callbacks on an evbuffer to be run, not immediately after the evbuffer is altered, but instead from inside the event loop\&. This can be used to serialize all the callbacks to a single thread of execution\&.
.SS "int evbuffer_drain (struct \fBevbuffer\fP *buf, size_tlen)"
.PP
Remove a specified number of bytes data from the beginning of an evbuffer\&.
.PP
\fBParameters:\fP
.RS 4
\fIbuf\fP the evbuffer to be drained
.br
\fIlen\fP the number of bytes to drain from the beginning of the buffer
.RE
.PP
\fBReturns:\fP
.RS 4
0 on success, -1 on failure\&.
.RE
.PP
.SS "int evbuffer_enable_locking (struct \fBevbuffer\fP *buf, void *lock)"
.PP
Enable locking on an evbuffer so that it can safely be used by multiple threads at the same time\&. NOTE: when locking is enabled, the lock will be held when callbacks are invoked\&. This could result in deadlock if you aren't careful\&. Plan accordingly!
.PP
\fBParameters:\fP
.RS 4
\fIbuf\fP An evbuffer to make lockable\&.
.br
\fIlock\fP A lock object, or NULL if we should allocate our own\&.
.RE
.PP
\fBReturns:\fP
.RS 4
0 on success, -1 on failure\&.
.RE
.PP
.SS "int evbuffer_expand (struct \fBevbuffer\fP *buf, size_tdatlen)"
.PP
Expands the available space in an evbuffer\&. Expands the available space in the evbuffer to at least datlen, so that appending datlen additional bytes will not require any new allocations\&.
.PP
\fBParameters:\fP
.RS 4
\fIbuf\fP the evbuffer to be expanded
.br
\fIdatlen\fP the new minimum length requirement
.RE
.PP
\fBReturns:\fP
.RS 4
0 if successful, or -1 if an error occurred
.RE
.PP
.SS "void evbuffer_free (struct \fBevbuffer\fP *buf)"
.PP
Deallocate storage for an evbuffer\&.
.PP
\fBParameters:\fP
.RS 4
\fIbuf\fP pointer to the evbuffer to be freed
.RE
.PP
.SS "int evbuffer_freeze (struct \fBevbuffer\fP *buf, intat_front)"
.PP
Prevent calls that modify an evbuffer from succeeding\&. A buffer may frozen at the front, at the back, or at both the front and the back\&.
.PP
If the front of a buffer is frozen, operations that drain data from the front of the buffer, or that prepend data to the buffer, will fail until it is unfrozen\&. If the back a buffer is frozen, operations that append data from the buffer will fail until it is unfrozen\&.
.PP
\fBParameters:\fP
.RS 4
\fIbuf\fP The buffer to freeze
.br
\fIat_front\fP If true, we freeze the front of the buffer\&. If false, we freeze the back\&.
.RE
.PP
\fBReturns:\fP
.RS 4
0 on success, -1 on failure\&.
.RE
.PP
.SS "size_t evbuffer_get_contiguous_space (const struct \fBevbuffer\fP *buf)"
.PP
Returns the number of contiguous available bytes in the first buffer chain\&. This is useful when processing data that might be split into multiple chains, or that might all be in the first chain\&. Calls to \fBevbuffer_pullup()\fP that cause reallocation and copying of data can thus be avoided\&.
.PP
\fBParameters:\fP
.RS 4
\fIbuf\fP pointer to the evbuffer
.RE
.PP
\fBReturns:\fP
.RS 4
0 if no data is available, otherwise the number of available bytes in the first buffer chain\&.
.RE
.PP
.SS "size_t evbuffer_get_length (const struct \fBevbuffer\fP *buf)"
.PP
Returns the total number of bytes stored in the evbuffer\&.
.PP
\fBParameters:\fP
.RS 4
\fIbuf\fP pointer to the evbuffer
.RE
.PP
\fBReturns:\fP
.RS 4
the number of bytes stored in the evbuffer
.RE
.PP
.SS "void evbuffer_lock (struct \fBevbuffer\fP *buf)"
.PP
Acquire the lock on an evbuffer\&. Has no effect if locking was not enabled with evbuffer_enable_locking\&.
.SS "struct \fBevbuffer\fP* evbuffer_new (void)"
.PP
Allocate storage for a new evbuffer\&.
.PP
\fBReturns:\fP
.RS 4
a pointer to a newly allocated evbuffer struct, or NULL if an error occurred
.RE
.PP
.SS "int evbuffer_peek (struct \fBevbuffer\fP *buffer, ev_ssize_tlen, struct \fBevbuffer_ptr\fP *start_at, struct \fBevbuffer_iovec\fP *vec_out, intn_vec)"
.PP
Function to peek at data inside an evbuffer without removing it or copying it out\&. Pointers to the data are returned by filling the 'vec_out' array with pointers to one or more extents of data inside the buffer\&.
.PP
The total data in the extents that you get back may be more than you requested (if there is more data last extent than you asked for), or less (if you do not provide enough evbuffer_iovecs, or if the buffer does not have as much data as you asked to see)\&.
.PP
\fBParameters:\fP
.RS 4
\fIbuffer\fP the evbuffer to peek into,
.br
\fIlen\fP the number of bytes to try to peek\&. If len is negative, we will try to fill as much of vec_out as we can\&. If len is negative and vec_out is not provided, we return the number of evbuffer_iovecs that would be needed to get all the data in the buffer\&.
.br
\fIstart_at\fP an \fBevbuffer_ptr\fP indicating the point at which we should start looking for data\&. NULL means, 'At the start of the
buffer\&.'
.br
\fIvec_out\fP an array of \fBevbuffer_iovec\fP
.br
\fIn_vec\fP the length of vec_out\&. If 0, we only count how many extents would be necessary to point to the requested amount of data\&.
.RE
.PP
\fBReturns:\fP
.RS 4
The number of extents needed\&. This may be less than n_vec if we didn't need all the evbuffer_iovecs we were given, or more than n_vec if we would need more to return all the data that was requested\&.
.RE
.PP
.SS "int evbuffer_prepend (struct \fBevbuffer\fP *buf, const void *data, size_tsize)"
.PP
Prepends data to the beginning of the evbuffer\&.
.PP
\fBParameters:\fP
.RS 4
\fIbuf\fP the evbuffer to which to prepend data
.br
\fIdata\fP a pointer to the memory to prepend
.br
\fIsize\fP the number of bytes to prepend
.RE
.PP
\fBReturns:\fP
.RS 4
0 if successful, or -1 otherwise
.RE
.PP
.SS "int evbuffer_prepend_buffer (struct \fBevbuffer\fP *dst, struct \fBevbuffer\fP *src)"
.PP
Prepends all data from the src evbuffer to the beginning of the dst evbuffer\&.
.PP
\fBParameters:\fP
.RS 4
\fIdst\fP the evbuffer to which to prepend data
.br
\fIsrc\fP the evbuffer to prepend; it will be emptied as a result
.RE
.PP
\fBReturns:\fP
.RS 4
0 if successful, or -1 otherwise
.RE
.PP
.SS "int evbuffer_ptr_set (struct \fBevbuffer\fP *buffer, struct \fBevbuffer_ptr\fP *ptr, size_tposition, enum \fBevbuffer_ptr_how\fPhow)"
.PP
Sets the search pointer in the buffer to position\&. If \fBevbuffer_ptr\fP is not initialized\&. This function can only be called with EVBUFFER_PTR_SET\&.
.PP
\fBParameters:\fP
.RS 4
\fIbuffer\fP the evbuffer to be search
.br
\fIptr\fP a pointer to a struct \fBevbuffer_ptr\fP
.br
\fIposition\fP the position at which to start the next search
.br
\fIhow\fP determines how the pointer should be manipulated\&.
.RE
.PP
\fBReturns:\fP
.RS 4
0 on success or -1 otherwise
.RE
.PP
.SS "unsigned char* evbuffer_pullup (struct \fBevbuffer\fP *buf, ev_ssize_tsize)"
.PP
Makes the data at the beginning of an evbuffer contiguous\&.
.PP
\fBParameters:\fP
.RS 4
\fIbuf\fP the evbuffer to make contiguous
.br
\fIsize\fP the number of bytes to make contiguous, or -1 to make the entire buffer contiguous\&.
.RE
.PP
\fBReturns:\fP
.RS 4
a pointer to the contiguous memory array
.RE
.PP
.SS "int evbuffer_read (struct \fBevbuffer\fP *buffer, \fBevutil_socket_t\fPfd, inthowmuch)"
.PP
Read from a file descriptor and store the result in an evbuffer\&.
.PP
\fBParameters:\fP
.RS 4
\fIbuffer\fP the evbuffer to store the result
.br
\fIfd\fP the file descriptor to read from
.br
\fIhowmuch\fP the number of bytes to be read
.RE
.PP
\fBReturns:\fP
.RS 4
the number of bytes read, or -1 if an error occurred
.RE
.PP
\fBSee also:\fP
.RS 4
\fBevbuffer_write()\fP
.RE
.PP
.SS "char* evbuffer_readln (struct \fBevbuffer\fP *buffer, size_t *n_read_out, enum \fBevbuffer_eol_style\fPeol_style)"
.PP
Read a single line from an evbuffer\&. Reads a line terminated by an EOL as determined by the evbuffer_eol_style argument\&. Returns a newly allocated nul-terminated string; the caller must free the returned value\&. The EOL is not included in the returned string\&.
.PP
\fBParameters:\fP
.RS 4
\fIbuffer\fP the evbuffer to read from
.br
\fIn_read_out\fP if non-NULL, points to a size_t that is set to the number of characters in the returned string\&. This is useful for strings that can contain NUL characters\&.
.br
\fIeol_style\fP the style of line-ending to use\&.
.RE
.PP
\fBReturns:\fP
.RS 4
pointer to a single line, or NULL if an error occurred
.RE
.PP
.SS "int evbuffer_remove (struct \fBevbuffer\fP *buf, void *data, size_tdatlen)"
.PP
Read data from an evbuffer and drain the bytes read\&. If more bytes are requested than are available in the evbuffer, we only extract as many bytes as were available\&.
.PP
\fBParameters:\fP
.RS 4
\fIbuf\fP the evbuffer to be read from
.br
\fIdata\fP the destination buffer to store the result
.br
\fIdatlen\fP the maximum size of the destination buffer
.RE
.PP
\fBReturns:\fP
.RS 4
the number of bytes read, or -1 if we can't drain the buffer\&.
.RE
.PP
.SS "int evbuffer_remove_buffer (struct \fBevbuffer\fP *src, struct \fBevbuffer\fP *dst, size_tdatlen)"
.PP
Read data from an evbuffer into another evbuffer, draining the bytes from the source buffer\&. This function avoids copy operations to the extent possible\&.
.PP
If more bytes are requested than are available in src, the src buffer is drained completely\&.
.PP
\fBParameters:\fP
.RS 4
\fIsrc\fP the evbuffer to be read from
.br
\fIdst\fP the destination evbuffer to store the result into
.br
\fIdatlen\fP the maximum numbers of bytes to transfer
.RE
.PP
\fBReturns:\fP
.RS 4
the number of bytes read
.RE
.PP
.SS "int evbuffer_remove_cb (struct \fBevbuffer\fP *buffer, \fBevbuffer_cb_func\fPcb, void *cbarg)"
.PP
Remove a callback from an evbuffer, given the function and argument used to add it\&.
.PP
\fBReturns:\fP
.RS 4
0 if a callback was removed, or -1 if no matching callback was found\&.
.RE
.PP
.SS "int evbuffer_remove_cb_entry (struct \fBevbuffer\fP *buffer, struct evbuffer_cb_entry *ent)"
.PP
Remove a callback from an evbuffer, given a handle returned from evbuffer_add_cb\&. Calling this function invalidates the handle\&.
.PP
\fBReturns:\fP
.RS 4
0 if a callback was removed, or -1 if no matching callback was found\&.
.RE
.PP
.SS "int evbuffer_reserve_space (struct \fBevbuffer\fP *buf, ev_ssize_tsize, struct \fBevbuffer_iovec\fP *vec, intn_vec)"
.PP
Reserves space in the last chain or chains of an evbuffer\&. Makes space available in the last chain or chains of an evbuffer that can be arbitrarily written to by a user\&. The space does not become available for reading until it has been committed with \fBevbuffer_commit_space()\fP\&.
.PP
The space is made available as one or more extents, represented by an initial pointer and a length\&. You can force the memory to be available as only one extent\&. Allowing more extents, however, makes the function more efficient\&.
.PP
Multiple subsequent calls to this function will make the same space available until \fBevbuffer_commit_space()\fP has been called\&.
.PP
It is an error to do anything that moves around the buffer's internal memory structures before committing the space\&.
.PP
NOTE: The code currently does not ever use more than two extents\&. This may change in future versions\&.
.PP
\fBParameters:\fP
.RS 4
\fIbuf\fP the evbuffer in which to reserve space\&.
.br
\fIsize\fP how much space to make available, at minimum\&. The total length of the extents may be greater than the requested length\&.
.br
\fIvec\fP an array of one or more \fBevbuffer_iovec\fP structures to hold pointers to the reserved extents of memory\&.
.br
\fIn_vec\fP The length of the vec array\&. Must be at least 1; 2 is more efficient\&.
.RE
.PP
\fBReturns:\fP
.RS 4
the number of provided extents, or -1 on error\&.
.RE
.PP
\fBSee also:\fP
.RS 4
\fBevbuffer_commit_space()\fP
.RE
.PP
.SS "struct \fBevbuffer_ptr\fP evbuffer_search (struct \fBevbuffer\fP *buffer, const char *what, size_tlen, const struct \fBevbuffer_ptr\fP *start)"
.PP
Search for a string within an evbuffer\&.
.PP
\fBParameters:\fP
.RS 4
\fIbuffer\fP the evbuffer to be searched
.br
\fIwhat\fP the string to be searched for
.br
\fIlen\fP the length of the search string
.br
\fIstart\fP NULL or a pointer to a valid struct \fBevbuffer_ptr\fP\&.
.RE
.PP
\fBReturns:\fP
.RS 4
a struct \fBevbuffer_ptr\fP whose 'pos' field has the offset of the first occurrence of the string in the buffer after 'start'\&. The 'pos' field of the result is -1 if the string was not found\&.
.RE
.PP
.SS "struct \fBevbuffer_ptr\fP evbuffer_search_eol (struct \fBevbuffer\fP *buffer, struct \fBevbuffer_ptr\fP *start, size_t *eol_len_out, enum \fBevbuffer_eol_style\fPeol_style)"
.PP
Search for an end-of-line string within an evbuffer\&.
.PP
\fBParameters:\fP
.RS 4
\fIbuffer\fP the evbuffer to be searched
.br
\fIstart\fP NULL or a pointer to a valid struct \fBevbuffer_ptr\fP to start searching at\&.
.br
\fIeol_len_out\fP If non-NULL, the pointed-to value will be set to the length of the end-of-line string\&.
.br
\fIeol_style\fP The kind of EOL to look for; see \fBevbuffer_readln()\fP for more information
.RE
.PP
\fBReturns:\fP
.RS 4
a struct \fBevbuffer_ptr\fP whose 'pos' field has the offset of the first occurrence EOL in the buffer after 'start'\&. The 'pos' field of the result is -1 if the string was not found\&.
.RE
.PP
.SS "struct \fBevbuffer_ptr\fP evbuffer_search_range (struct \fBevbuffer\fP *buffer, const char *what, size_tlen, const struct \fBevbuffer_ptr\fP *start, const struct \fBevbuffer_ptr\fP *end)"
.PP
Search for a string within part of an evbuffer\&.
.PP
\fBParameters:\fP
.RS 4
\fIbuffer\fP the evbuffer to be searched
.br
\fIwhat\fP the string to be searched for
.br
\fIlen\fP the length of the search string
.br
\fIstart\fP NULL or a pointer to a valid struct \fBevbuffer_ptr\fP that indicates where we should start searching\&.
.br
\fIend\fP NULL or a pointer to a valid struct \fBevbuffer_ptr\fP that indicates where we should stop searching\&.
.RE
.PP
\fBReturns:\fP
.RS 4
a struct \fBevbuffer_ptr\fP whose 'pos' field has the offset of the first occurrence of the string in the buffer after 'start'\&. The 'pos' field of the result is -1 if the string was not found\&.
.RE
.PP
.SS "int evbuffer_set_flags (struct \fBevbuffer\fP *buf, ev_uint64_tflags)"
.PP
Change the flags that are set for an evbuffer by adding more\&.
.PP
\fBParameters:\fP
.RS 4
\fIbuffer\fP the evbuffer that the callback is watching\&.
.br
\fIcb\fP the callback whose status we want to change\&.
.br
\fIflags\fP One or more EVBUFFER_FLAG_* options
.RE
.PP
\fBReturns:\fP
.RS 4
0 on success, -1 on failure\&.
.RE
.PP
.SS "int evbuffer_unfreeze (struct \fBevbuffer\fP *buf, intat_front)"
.PP
Re-enable calls that modify an evbuffer\&.
.PP
\fBParameters:\fP
.RS 4
\fIbuf\fP The buffer to un-freeze
.br
\fIat_front\fP If true, we unfreeze the front of the buffer\&. If false, we unfreeze the back\&.
.RE
.PP
\fBReturns:\fP
.RS 4
0 on success, -1 on failure\&.
.RE
.PP
.SS "void evbuffer_unlock (struct \fBevbuffer\fP *buf)"
.PP
Release the lock on an evbuffer\&. Has no effect if locking was not enabled with evbuffer_enable_locking\&.
.SS "int evbuffer_write (struct \fBevbuffer\fP *buffer, \fBevutil_socket_t\fPfd)"
.PP
Write the contents of an evbuffer to a file descriptor\&. The evbuffer will be drained after the bytes have been successfully written\&.
.PP
\fBParameters:\fP
.RS 4
\fIbuffer\fP the evbuffer to be written and drained
.br
\fIfd\fP the file descriptor to be written to
.RE
.PP
\fBReturns:\fP
.RS 4
the number of bytes written, or -1 if an error occurred
.RE
.PP
\fBSee also:\fP
.RS 4
\fBevbuffer_read()\fP
.RE
.PP
.SS "int evbuffer_write_atmost (struct \fBevbuffer\fP *buffer, \fBevutil_socket_t\fPfd, ev_ssize_thowmuch)"
.PP
Write some of the contents of an evbuffer to a file descriptor\&. The evbuffer will be drained after the bytes have been successfully written\&.
.PP
\fBParameters:\fP
.RS 4
\fIbuffer\fP the evbuffer to be written and drained
.br
\fIfd\fP the file descriptor to be written to
.br
\fIhowmuch\fP the largest allowable number of bytes to write, or -1 to write as many bytes as we can\&.
.RE
.PP
\fBReturns:\fP
.RS 4
the number of bytes written, or -1 if an error occurred
.RE
.PP
\fBSee also:\fP
.RS 4
\fBevbuffer_read()\fP
.RE
.PP
.SH "Author"
.PP
Generated automatically by Doxygen for libevent from the source code\&.
|