4 PHP_HTTP_API php_http_strlist_iterator_t
*php_http_strlist_iterator_init(php_http_strlist_iterator_t
*iter
, const char list
[], unsigned factor
)
7 iter
= emalloc(sizeof(*iter
));
9 memset(iter
, 0, sizeof(*iter
));
12 iter
->factor
= factor
;
17 PHP_HTTP_API
const char *php_http_strlist_iterator_this(php_http_strlist_iterator_t
*iter
, unsigned *id
)
20 *id
= iter
->major
* iter
->factor
+ iter
->minor
;
26 PHP_HTTP_API
const char *php_http_strlist_iterator_next(php_http_strlist_iterator_t
*iter
)
44 PHP_HTTP_API
void php_http_strlist_iterator_dtor(php_http_strlist_iterator_t
*iter
)
49 PHP_HTTP_API
void php_http_strlist_iterator_free(php_http_strlist_iterator_t
**iter
)
57 PHP_HTTP_API
const char *php_http_strlist_find(const char list
[], unsigned factor
, unsigned item
)
59 unsigned M
= 0, m
= 0, major
, minor
;
60 const char *p
= &list
[0];
63 major
= (item
/ factor
) - 1;
64 minor
= item
% factor
;
69 while (*p
&& major
!= M
++) {
79 while (*p
&& minor
!= m
++) {