2 +--------------------------------------------------------------------+
4 +--------------------------------------------------------------------+
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted provided that the conditions mentioned |
7 | in the accompanying LICENSE file are met. |
8 +--------------------------------------------------------------------+
9 | Copyright (c) 2004-2011, Michael Wallner <mike@php.net> |
10 +--------------------------------------------------------------------+
13 #include "php_http_api.h"
15 PHP_HTTP_API php_http_strlist_iterator_t
*php_http_strlist_iterator_init(php_http_strlist_iterator_t
*iter
, const char list
[], unsigned factor
)
18 iter
= emalloc(sizeof(*iter
));
20 memset(iter
, 0, sizeof(*iter
));
23 iter
->factor
= factor
;
28 PHP_HTTP_API
const char *php_http_strlist_iterator_this(php_http_strlist_iterator_t
*iter
, unsigned *id
)
31 *id
= iter
->major
* iter
->factor
+ iter
->minor
;
37 PHP_HTTP_API
const char *php_http_strlist_iterator_next(php_http_strlist_iterator_t
*iter
)
55 PHP_HTTP_API
void php_http_strlist_iterator_dtor(php_http_strlist_iterator_t
*iter
)
60 PHP_HTTP_API
void php_http_strlist_iterator_free(php_http_strlist_iterator_t
**iter
)
68 PHP_HTTP_API
const char *php_http_strlist_find(const char list
[], unsigned factor
, unsigned item
)
70 unsigned M
= 0, m
= 0, major
, minor
;
71 const char *p
= &list
[0];
74 major
= (item
/ factor
) - 1;
75 minor
= item
% factor
;
80 while (*p
&& major
!= M
++) {
90 while (*p
&& minor
!= m
++) {
105 * vim600: noet sw=4 ts=4 fdm=marker
106 * vim<600: noet sw=4 ts=4