Back to index

php5  5.3.10
mbfilter_7bit.c
Go to the documentation of this file.
00001 /*
00002  * "streamable kanji code filter and converter"
00003  * Copyright (c) 1998-2002 HappySize, Inc. All rights reserved.
00004  *
00005  * LICENSE NOTICES
00006  *
00007  * This file is part of "streamable kanji code filter and converter",
00008  * which is distributed under the terms of GNU Lesser General Public 
00009  * License (version 2) as published by the Free Software Foundation.
00010  *
00011  * This software is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with "streamable kanji code filter and converter";
00018  * if not, write to the Free Software Foundation, Inc., 59 Temple Place,
00019  * Suite 330, Boston, MA  02111-1307  USA
00020  *
00021  * The author of this file:
00022  *
00023  */
00024 /*
00025  * The source code included in this files was separated from mbfilter.c
00026  * by Moriyoshi Koizumi <moriyoshi@php.net> on 4 Dec 2002. The file
00027  * mbfilter.c is included in this package .
00028  *
00029  */
00030 
00031 #ifdef HAVE_CONFIG_H
00032 #include "config.h"
00033 #endif
00034 
00035 #include "mbfilter.h"
00036 #include "mbfilter_7bit.h"
00037 
00038 const mbfl_encoding mbfl_encoding_7bit = {
00039        mbfl_no_encoding_7bit,
00040        "7bit",
00041        "7bit",
00042        NULL,
00043        NULL,
00044        MBFL_ENCTYPE_SBCS
00045 };
00046 
00047 const struct mbfl_convert_vtbl vtbl_8bit_7bit = {
00048        mbfl_no_encoding_8bit,
00049        mbfl_no_encoding_7bit,
00050        mbfl_filt_conv_common_ctor,
00051        mbfl_filt_conv_common_dtor,
00052        mbfl_filt_conv_any_7bit,
00053        mbfl_filt_conv_common_flush
00054 };
00055 
00056 const struct mbfl_convert_vtbl vtbl_7bit_8bit = {
00057        mbfl_no_encoding_7bit,
00058        mbfl_no_encoding_8bit,
00059        mbfl_filt_conv_common_ctor,
00060        mbfl_filt_conv_common_dtor,
00061        mbfl_filt_conv_7bit_any,
00062        mbfl_filt_conv_common_flush
00063 };
00064 
00065 
00066 #define CK(statement)       do { if ((statement) < 0) return (-1); } while (0)
00067 
00068 int mbfl_filt_conv_7bit_any(int c, mbfl_convert_filter *filter)
00069 {
00070        return (*filter->output_function)(c, filter->data);
00071 }
00072 
00073 
00074 int mbfl_filt_conv_any_7bit(int c, mbfl_convert_filter *filter)
00075 {
00076        if (c >= 0 && c < 0x80) {
00077               CK((*filter->output_function)(c, filter->data));
00078        } 
00079        return c;
00080 }
00081 
00082