diff options
author | Wez Furlong <wez@php.net> | 2003-01-01 11:04:44 +0000 |
---|---|---|
committer | Wez Furlong <wez@php.net> | 2003-01-01 11:04:44 +0000 |
commit | f58628ca4d100480b2ab45cf16e368c20af31417 (patch) | |
tree | b56ca65fabf6e991c927203f8e65901800aacb1c /ext/standard/string.c | |
parent | 30dafe2f42adfa081e39c9287aa0708598736561 (diff) | |
download | php-git-f58628ca4d100480b2ab45cf16e368c20af31417.tar.gz |
Move rot13 filter into a new filters.c source file.
Tidy up some other filter related code.
# win32 -> someone please add user_filters.c and filters.c to the .dsp
Diffstat (limited to 'ext/standard/string.c')
-rw-r--r-- | ext/standard/string.c | 76 |
1 files changed, 0 insertions, 76 deletions
diff --git a/ext/standard/string.c b/ext/standard/string.c index 8842b24145..722812c56e 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -4167,82 +4167,6 @@ PHP_FUNCTION(money_format) { /* }}} */ #endif -/* {{{ rot13 stream filter implementation */ -static size_t strfilter_rot13_write(php_stream *stream, php_stream_filter *thisfilter, - const char *buf, size_t count TSRMLS_DC) -{ - char rotbuf[1024]; - size_t chunk; - size_t wrote = 0; - - while (count > 0) { - chunk = count; - if (chunk > sizeof(rotbuf)) - chunk = sizeof(rotbuf); - - PHP_STRLCPY(rotbuf, buf, sizeof(rotbuf), chunk); - buf += chunk; - count -= chunk; - - php_strtr(rotbuf, chunk, rot13_from, rot13_to, 52); - wrote += php_stream_filter_write_next(stream, thisfilter, rotbuf, chunk); - } - - return wrote; -} - -static size_t strfilter_rot13_read(php_stream *stream, php_stream_filter *thisfilter, - char *buf, size_t count TSRMLS_DC) -{ - size_t read; - - read = php_stream_filter_read_next(stream, thisfilter, buf, count); - php_strtr(buf, read, rot13_from, rot13_to, 52); - - return read; -} - -static int strfilter_rot13_flush(php_stream *stream, php_stream_filter *thisfilter, int closing TSRMLS_DC) -{ - return php_stream_filter_flush_next(stream, thisfilter, closing); -} - -static int strfilter_rot13_eof(php_stream *stream, php_stream_filter *thisfilter TSRMLS_DC) -{ - return php_stream_filter_eof_next(stream, thisfilter); -} - - -static php_stream_filter_ops strfilter_rot13_ops = { - strfilter_rot13_write, - strfilter_rot13_read, - strfilter_rot13_flush, - strfilter_rot13_eof, - NULL, - "string.rot13" -}; - -static php_stream_filter *strfilter_rot13_create(const char *filtername, const char *filterparams, - int filterparamslen, int persistent TSRMLS_DC) -{ - return php_stream_filter_alloc(&strfilter_rot13_ops, NULL, persistent); -} - -static php_stream_filter_factory strfilter_rot13_factory = { - strfilter_rot13_create -}; - -PHP_MINIT_FUNCTION(string_filters) -{ - return php_stream_filter_register_factory("string.rot13", &strfilter_rot13_factory TSRMLS_CC); -} - -PHP_MSHUTDOWN_FUNCTION(string_filters) -{ - return php_stream_filter_unregister_factory("string.rot13" TSRMLS_CC); -} -/* }}} */ - /* * Local variables: * tab-width: 4 |