[php-i18n-commits] cvs commit: libmbfl/mbfl mbfl_wchar_device.c mbfl_wchar_device.h

Back to archive index

Moriyoshi Koizumi moriy****@users*****
2002年 12月 27日 (金) 08:41:48 JST


moriyoshi    02/12/27 08:41:48

  Added:       mbfl     mbfl_wchar_device.c mbfl_wchar_device.h
  Log:
  Forgot to add these files
  
  Revision  Changes    Path
  1.1                  libmbfl/mbfl/mbfl_wchar_device.c
  
  Index: mbfl_wchar_device.c
  ===================================================================
  /*
   * "streamable kanji code filter and converter"
   * Copyright (c) 1998-2002 HappySize, Inc. All rights reserved.
   *
   * LICENSE NOTICES
   *
   * This file is part of "streamable kanji code filter and converter",
   * which is distributed under the terms of GNU Lesser General Public 
   * License (version 2) as published by the Free Software Foundation.
   *
   * This software is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   * GNU Lesser General Public License for more details.
   *
   * You should have received a copy of the GNU Lesser General Public
   * License along with "streamable kanji code filter and converter";
   * if not, write to the Free Software Foundation, Inc., 59 Temple Place,
   * Suite 330, Boston, MA  02111-1307  USA
   *
   * The author of this file:
   *
   */
  /*
   * The source code included in this files was separated from mbfilter.c
   * by Moriyoshi Koizumi <moriy****@php*****> on 20 Dec 2002. The file
   * mbfilter.c is included in this package .
   *
   */
  
  #ifdef HAVE_CONFIG_H
  #include "config.h"
  #endif
  
  #ifdef HAVE_STDDEF_H
  #include <stddef.h>
  #endif
  
  #include "mbfl_allocators.h"
  #include "mbfl_string.h"
  #include "mbfl_wchar_device.h"
  
  void mbfl_wchar_device_ctor(mbfl_wchar_device *device)
  {
  	if (device) {
  		device->buffer = (unsigned int *)0;
  		device->length = 0;
  		device->pos= 0;
  		device->allocsz = MBFL_MEMORY_DEVICE_ALLOC_SIZE;
  	}
  }
  
  void mbfl_wchar_device_dtor(mbfl_wchar_device *device)
  {
  	if (device) {
  		if (device->buffer) {
  			mbfl_free(device->buffer);
  		}
  		device->buffer = (unsigned int*)0;
  		device->length = 0;
  		device->pos = 0;
  	}
  }
  
  int mbfl_wchar_device_output(int c, void *data)
  {
  	mbfl_wchar_device *device = (mbfl_wchar_device *)data;
  
  	if (device->pos >= device->length) {
  		/* reallocate buffer */
  		int newlen;
  		unsigned int *tmp;
  
  		newlen = device->length + device->allocsz;
  		tmp = (unsigned int *)mbfl_realloc((void *)device->buffer, newlen*sizeof(int));
  		if (tmp == NULL) {
  			return -1;
  		}
  		device->length = newlen;
  		device->buffer = tmp;
  	}
  
  	device->buffer[device->pos++] = c;
  
  	return c;
  }
  
  
  
  
  1.1                  libmbfl/mbfl/mbfl_wchar_device.h
  
  Index: mbfl_wchar_device.h
  ===================================================================
  /*
   * "streamable kanji code filter and converter"
   * Copyright (c) 1998-2002 HappySize, Inc. All rights reserved.
   *
   * LICENSE NOTICES
   *
   * This file is part of "streamable kanji code filter and converter",
   * which is distributed under the terms of GNU Lesser General Public 
   * License (version 2) as published by the Free Software Foundation.
   *
   * This software is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   * GNU Lesser General Public License for more details.
   *
   * You should have received a copy of the GNU Lesser General Public
   * License along with "streamable kanji code filter and converter";
   * if not, write to the Free Software Foundation, Inc., 59 Temple Place,
   * Suite 330, Boston, MA  02111-1307  USA
   *
   * The author of this file:
   *
   */
  /*
   * The source code included in this files was separated from mbfilter.h
   * by Moriyoshi Koizumi <moriy****@php*****> on 20 Dec 2002. The file
   * mbfilter.h is included in this package .
   *
   */
  
  #ifndef MBFL_WCHAR_DEVICE_H
  #define MBFL_WCHAR_DEVICE_H
  
  #include "mbfl_defs.h"
  #include "mbfl_consts.h"
  #include "mbfl_string.h"
  
  typedef struct _mbfl_wchar_device {
  	unsigned int *buffer;
  	int length;
  	int pos;
  	int allocsz;
  } mbfl_wchar_device;
  
  MBFLAPI void mbfl_wchar_device_ctor(mbfl_wchar_device *device);
  #define mbfl_wchar_device_ctor mbfl_wchar_device_init
  MBFLAPI void mbfl_wchar_device_dtor(mbfl_wchar_device *device);
  #define mbfl_wchar_device_clear mbfl_wchar_device_dtor
  
  MBFLAPI int mbfl_wchar_device_output(int c, void *data);
  
  #endif /* MBFL_WCHAR_DEVICE_H */
  
  
  
  



php-i18n-commits メーリングリストの案内
Back to archive index