home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-perl-addon-1.4.9-installer.exe / Brigade.pm < prev    next >
Encoding:
Perl POD Document  |  2004-09-23  |  10.1 KB  |  599 lines

  1. # /*
  2. #  * *********** WARNING **************
  3. #  * This file generated by ModPerl::WrapXS/0.01
  4. #  * Any changes made here will be lost
  5. #  * ***********************************
  6. #  * 01: lib/ModPerl/Code.pm:701
  7. #  * 02: O:\147xampp\sources\mod_perl-1.99_16\blib\lib/ModPerl/WrapXS.pm:584
  8. #  * 03: O:\147xampp\sources\mod_perl-1.99_16\blib\lib/ModPerl/WrapXS.pm:1100
  9. #  * 04: Makefile.PL:335
  10. #  * 05: Makefile.PL:283
  11. #  * 06: Makefile.PL:51
  12. #  */
  13.  
  14.  
  15. package APR::Brigade;
  16.  
  17. use strict;
  18. use warnings FATAL => 'all';
  19.  
  20.  
  21. use APR ();
  22. use APR::XSLoader ();
  23. our $VERSION = '0.01';
  24. APR::XSLoader::load __PACKAGE__;
  25.  
  26.  
  27.  
  28. 1;
  29. __END__
  30.  
  31. =head1 NAME
  32.  
  33. APR::Brigade - Perl API for manipulating APR Bucket Brigades
  34.  
  35.  
  36.  
  37.  
  38. =head1 Synopsis
  39.  
  40.   use APR::Brigade ();
  41.   
  42.   $bb = APR::Brigade->new($r->pool, $c->bucket_alloc);
  43.   $pool = $bb->pool;
  44.   
  45.   $bb->insert_head($b);
  46.   $bb->insert_tail($b);
  47.   
  48.   $b_first = $bb->first;
  49.   $b_last  = $bb->last;
  50.   
  51.   $b_prev = $bb->prev($b_last);
  52.   $b_next = $bb->next($b);
  53.   
  54.   $bb2 = APR::Brigade->new($r->pool, $c->bucket_alloc);
  55.   $bb1->concat($bb2);
  56.   
  57.   $len = $bb->flatten($data);
  58.   $len = $bb2->flatten($data, $wanted);
  59.   
  60.   $len = $bb->length;
  61.   $bb3 = $bb->split($b_last);
  62.   
  63.   last if $bb->is_empty();
  64.   $bb->cleanup();
  65.   $bb->destroy();
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75. =head1 Description
  76.  
  77. C<APR::Brigade> allows you to create, manipulate and delete APR bucket
  78. brigades.
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85. =head1 API
  86.  
  87. C<APR::Brigade> provides the following functions and/or methods:
  88.  
  89.  
  90. =head2 C<cleanup>
  91.  
  92. Empty out an entire bucket brigade:
  93.  
  94.   $bb->cleanup;
  95.  
  96. =over 4
  97.  
  98. =item obj: C<$bb>
  99. ( C<L<APR::Brigade object|docs::2.0::api::APR::Brigade>> )
  100.  
  101. The brigade to cleanup
  102.  
  103. =item ret: no return value
  104.  
  105. =item since: 1.99_15
  106.  
  107. =back
  108.  
  109. This method destroys all of the buckets within the bucket brigade's
  110. bucket list.  This is similar to C<L<destroy()|/C_destroy_>>, except
  111. that it does not deregister the brigade's C<L<pool()|/C_pool_>>
  112. cleanup function.
  113.  
  114. Generally, you should use C<L<destroy()|/C_destroy_>>.  This function
  115. can be useful in situations where you have a single brigade that you
  116. wish to reuse many times by destroying all of the buckets in the
  117. brigade and putting new buckets into it later.
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127. =head2 C<concat>
  128.  
  129. Concatenate brigade C<$bb2> onto the end of brigade C<$bb1>, leaving
  130. brigade C<$bb2> empty:
  131.  
  132.   $bb1->concat($bb2);
  133.  
  134. =over 4
  135.  
  136. =item obj: C<$bb1>
  137. ( C<L<APR::Brigade object|docs::2.0::api::APR::Brigade>> )
  138.  
  139. The brigade to concatenate to.
  140.  
  141. =item arg1: C<$bb2>
  142. ( C<L<APR::Brigade object|docs::2.0::api::APR::Brigade>> )
  143.  
  144. The brigade to concatenate and empty afterwards.
  145.  
  146. =item ret: no return value
  147.  
  148. =item since: 1.99_10
  149.  
  150. =back
  151.  
  152.  
  153.  
  154.  
  155. =head2 C<destroy>
  156.  
  157. destroy an entire bucket brigade, includes all of the buckets within
  158. the bucket brigade's bucket list.
  159.  
  160.   $bb->destroy();
  161.  
  162. =over 4
  163.  
  164. =item obj: C<$bb>
  165. ( C<L<APR::Brigade object|docs::2.0::api::APR::Brigade>> )
  166.  
  167. The bucket brigade to destroy.
  168.  
  169. =item ret: no return value
  170.  
  171. =item excpt: C<L<APR::Error|docs::2.0::api::APR::Error>>
  172.  
  173. =item since: 1.99_15
  174.  
  175. =back
  176.  
  177.  
  178.  
  179.  
  180.  
  181. =head2 C<is_empty>
  182.  
  183. Test whether the bucket brigade is empty
  184.  
  185.   $ret = $bb->is_empty();
  186.  
  187. =over 4
  188.  
  189. =item obj: C<$bb>
  190. ( C<L<APR::Brigade object|docs::2.0::api::APR::Brigade>> )
  191.  
  192. =item ret: C<$ret> ( boolean )
  193.  
  194. =item since: 1.99_15
  195.  
  196. =back
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205. =head2 C<first>
  206.  
  207. Return the first bucket in a brigade
  208.  
  209.   $b_first = $bb->first;
  210.  
  211. =over 4
  212.  
  213. =item obj: C<$bb>
  214. ( C<L<APR::Brigade object|docs::2.0::api::APR::Brigade>> )
  215.  
  216. =item ret: C<$b_first>
  217. ( C<L<APR::Bucket object|docs::2.0::api::APR::Bucket>> )
  218.  
  219. The first bucket in the bucket brigade C<$bb>.
  220.  
  221. C<undef> is returned if there are no buckets in C<$bb>.
  222.  
  223. =item since: 1.99_10
  224.  
  225. =back
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233. =head2 C<flatten>
  234.  
  235. Get the data from buckets in the bucket brigade as one string
  236.  
  237.   $len = $bb->flatten($buffer);
  238.   $len = $bb->flatten($buffer, $wanted);
  239.  
  240. =over 4
  241.  
  242. =item obj: C<$bb>
  243. ( C<L<APR::Brigade object|docs::2.0::api::APR::Brigade>> )
  244.  
  245. =item arg1: C<$buffer> ( SCALAR )
  246.  
  247. The buffer to fill. All previous data will be lost.
  248.  
  249. =item opt arg2: C<$wanted> ( number )
  250.  
  251. If no argument is passed then all data will be returned. If C<$wanted>
  252. is specified -- that number or less bytes will be returned.
  253.  
  254. =item ret: C<$len> ( number )
  255.  
  256. How many bytes were actually read.
  257.  
  258. C<$buffer> gets populated with the string that is read. It will
  259. contain an empty string if there was nothing to read.
  260.  
  261.  
  262. =item since: 1.99_15
  263.  
  264. =item excpt: C<L<APR::Error|docs::2.0::api::APR::Error>>
  265.  
  266. =back
  267.  
  268.  
  269.  
  270.  
  271.  
  272.  
  273.  
  274. =head2 C<insert_head>
  275.  
  276. Insert a list of buckets at the front of a brigade
  277.  
  278.   $bb->insert_head($b);
  279.  
  280. =over 4
  281.  
  282. =item obj: C<$bb>
  283. ( C<L<APR::Brigade object|docs::2.0::api::APR::Brigade>> )
  284.  
  285. Brigade to insert into
  286.  
  287. =item arg1: C<$b>
  288. ( C<L<APR::Bucket object|docs::2.0::api::APR::Bucket>> )
  289.  
  290. the bucket to insert. More buckets could be attached to that bucket.
  291.  
  292. =item ret: no return value
  293.  
  294. =item since: 1.99_10
  295.  
  296. =back
  297.  
  298.  
  299.  
  300.  
  301.  
  302. =head2 C<insert_tail>
  303.  
  304. Insert a list of buckets at the end of a brigade
  305.  
  306.   $bb->insert_tail($b);
  307.  
  308. =over 4
  309.  
  310. =item obj: C<$bb>
  311. ( C<L<APR::Brigade object|docs::2.0::api::APR::Brigade>> )
  312.  
  313. Brigade to insert into
  314.  
  315. =item arg1: C<$b>
  316. ( C<L<APR::Bucket object|docs::2.0::api::APR::Bucket>> )
  317.  
  318. the bucket to insert. More buckets could be attached to that bucket.
  319.  
  320. =item ret: no return value
  321.  
  322. =item since: 1.99_10
  323.  
  324. =back
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332. =head2 C<last>
  333.  
  334. Return the last bucket in the brigade
  335.  
  336.   $b_last = $bb->last;
  337.  
  338. =over 4
  339.  
  340. =item obj: C<$bb>
  341. ( C<L<APR::Brigade object|docs::2.0::api::APR::Brigade>> )
  342.  
  343. =item ret: C<$b_last>
  344. ( C<L<APR::Bucket object|docs::2.0::api::APR::Bucket>> )
  345.  
  346. The last bucket in the bucket brigade C<$bb>.
  347.  
  348. C<undef> is returned if there are no buckets in C<$bb>.
  349.  
  350. =item since: 1.99_10
  351.  
  352. =back
  353.  
  354.  
  355.  
  356.  
  357.  
  358.  
  359. =head2 C<length>
  360.  
  361. Return the total length of the data in the brigade (not the number of
  362. buckets)
  363.  
  364.   $len = $bb->length;
  365.  
  366. =over 4
  367.  
  368. =item obj: C<$bb>
  369. ( C<L<APR::Brigade object|docs::2.0::api::APR::Brigade>> )
  370.  
  371. =item ret: C<$len> ( number )
  372.  
  373. =item since: 1.99_10
  374.  
  375. =back
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383. =head2 C<new>
  384.  
  385.   my $nbb = APR::Brigade->new($p, $bucket_alloc);
  386.   my $nbb =          $bb->new($p, $bucket_alloc);
  387.  
  388. =over 4
  389.  
  390. =item obj: C<$bb>
  391. ( C<L<APR::Brigade object or class|docs::2.0::api::APR::Brigade>> )
  392.  
  393. =item arg1: C<$p>
  394. ( C<L<APR::Pool object|docs::2.0::api::APR::Pool>> )
  395.  
  396. =item arg2: C<$bucket_alloc>
  397. ( C<L<APR::BucketAlloc object|docs::2.0::api::APR::BucketAlloc>> )
  398.  
  399. =item ret: C<$nbb>
  400. ( C<L<APR::Brigade object|docs::2.0::api::APR::Brigade>> )
  401.  
  402. a newly created bucket brigade object
  403.  
  404. =item since: 1.99_10
  405.  
  406. =back
  407.  
  408. Example:
  409.  
  410. Create a new bucket brigade, using the request object's pool:
  411.  
  412.   use Apache::Connection ();
  413.   use Apache::RequestRec ();
  414.   use APR::Brigade ();
  415.   my $bb = APR::Brigade->new($r->pool, $r->connection->bucket_alloc);
  416.  
  417.  
  418.  
  419.  
  420.  
  421.  
  422. =head2 C<next>
  423.  
  424. Return the next bucket in a brigade
  425.  
  426.   $b_next = $bb->next($b);
  427.  
  428. =over 4
  429.  
  430. =item obj: C<$bb>
  431. ( C<L<APR::Brigade object|docs::2.0::api::APR::Brigade>> )
  432.  
  433. =item arg1: C<$b>
  434. ( C<L<APR::Bucket object|docs::2.0::api::APR::Bucket>> )
  435.  
  436. The bucket after which the next bucket C<$b_next> is located
  437.  
  438. =item ret: C<$b_next>
  439. ( C<L<APR::Bucket object|docs::2.0::api::APR::Bucket>> )
  440.  
  441. The next bucket after bucket C<$b>.
  442.  
  443. C<undef> is returned if there is no next bucket (i.e. C<$b> is the
  444. last bucket).
  445.  
  446. =item since: 1.99_10
  447.  
  448. =back
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456. =head2 C<pool>
  457.  
  458. The pool the brigade is associated with.
  459.  
  460.   $pool = $bb->pool;
  461.  
  462. =over 4
  463.  
  464. =item obj: C<$bb>
  465. ( C<L<APR::Brigade object|docs::2.0::api::APR::Brigade>> )
  466.  
  467. =item ret: C<$pool>
  468. ( C<L<APR::Pool object|docs::2.0::api::APR::Pool>> )
  469.  
  470. =item since: 1.99_10
  471.  
  472. =back
  473.  
  474. The data is not allocated out of the pool, but a cleanup is registered
  475. with this pool.  If the brigade is destroyed by some mechanism other
  476. than pool destruction, the destroying function is responsible for
  477. killing the registered cleanup.
  478.  
  479.  
  480.  
  481.  
  482.  
  483.  
  484.  
  485.  
  486. =head2 C<prev>
  487.  
  488. Return the previous bucket in the brigade
  489.  
  490.   $b_prev = $bb->prev($b);
  491.  
  492. =over 4
  493.  
  494. =item obj: C<$bb>
  495. ( C<L<APR::Brigade object|docs::2.0::api::APR::Brigade>> )
  496.  
  497. =item arg1: C<$b>
  498. ( C<L<APR::Bucket object|docs::2.0::api::APR::Bucket>> )
  499.  
  500. The bucket located after bucket C<$b_prev>
  501.  
  502. =item ret: C<$b_prev>
  503. ( C<L<APR::Bucket object|docs::2.0::api::APR::Bucket>> )
  504.  
  505. The bucket located before bucket C<$b>.
  506.  
  507. C<undef> is returned if there is no previous bucket (i.e. C<$b> is the
  508. first bucket).
  509.  
  510. =item since: 1.99_10
  511.  
  512. =back
  513.  
  514.  
  515.  
  516.  
  517.  
  518.  
  519.  
  520.  
  521. =head2 C<split>
  522.  
  523. Split a bucket brigade into two, such that the given bucket is the
  524. first in the new bucket brigade.
  525.  
  526.   $bb2 = $bb->split($b);
  527.  
  528. =over 4
  529.  
  530. =item obj: C<$bb>
  531. ( C<L<APR::Brigade object|docs::2.0::api::APR::Brigade>> )
  532.  
  533. The brigade to split
  534.  
  535. =item arg1: C<$b>
  536. ( C<L<APR::Bucket object|docs::2.0::api::APR::Bucket>> )
  537.  
  538. The first bucket of the new brigade
  539.  
  540. =item ret: C<$bb2>
  541. ( C<L<APR::Brigade object|docs::2.0::api::APR::Brigade>> )
  542.  
  543. The new brigade.
  544.  
  545. =item since: 1.99_10
  546.  
  547. =back
  548.  
  549. This function is useful when a filter wants to pass only the initial
  550. part of a brigade to the next filter.
  551.  
  552. Example:
  553.  
  554. Create a bucket brigade with three buckets, and split it into two
  555. brigade such that the second brigade will have the last two buckets.
  556.  
  557.   my $bb1 = APR::Brigade->new($r->pool, $c->bucket_alloc);
  558.   $bb1->insert_tail(APR::Bucket->new("1"));
  559.   $bb1->insert_tail(APR::Bucket->new("2"));
  560.   $bb1->insert_tail(APR::Bucket->new("3"));
  561.  
  562. C<$bb1> now contains buckets "1", "2", "3". Now do the split at the
  563. second bucket:
  564.  
  565.   my $b = $bb1->first; # 1
  566.   $b = $bb1->next($b); # 2
  567.   my $bb2 = $bb1->split($b);
  568.  
  569. Now C<$bb1> contains bucket "1".  C<$bb2> contains buckets: "2", "3"
  570.  
  571.  
  572.  
  573.  
  574.  
  575. =head1 See Also
  576.  
  577. L<mod_perl 2.0 documentation|docs::2.0::index>.
  578.  
  579.  
  580.  
  581.  
  582. =head1 Copyright
  583.  
  584. mod_perl 2.0 and its core modules are copyrighted under
  585. The Apache Software License, Version 2.0.
  586.  
  587.  
  588.  
  589.  
  590. =head1 Authors
  591.  
  592. L<The mod_perl development team and numerous
  593. contributors|about::contributors::people>.
  594.  
  595. =cut
  596.  
  597.