cr-enc-handler.c revision 0489e8dae1154191b4fa0931545298513034ff38
/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/*
* This file is part of The Croco Library
*
* Copyright (C) 2002-2003 Dodji Seketeli <dodji@seketeli.org>
*
* modify it under the terms of version 2.1 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*/
/*
*$Id: cr-enc-handler.c,v 1.7 2004/03/07 13:22:47 dodji Exp $
*/
/**
*@file
*The definition of the #CREncHandler class.
*/
#include "cr-enc-handler.h"
#include "cr-utils.h"
#include <string.h>
struct CREncAlias {
enum CREncoding encoding;
};
static struct CREncAlias gv_default_aliases[] = {
{"UTF-8", CR_UTF_8},
{"UTF_8", CR_UTF_8},
{"UTF8", CR_UTF_8},
{"UTF-16", CR_UTF_16},
{"UTF_16", CR_UTF_16},
{"UTF16", CR_UTF_16},
{"UCS1", CR_UCS_1},
{"UCS-1", CR_UCS_1},
{"UCS_1", CR_UCS_1},
{"ISO-8859-1", CR_UCS_1},
{"ISO_8859-1", CR_UCS_1},
{"UCS-1", CR_UCS_1},
{"UCS_1", CR_UCS_1},
{"UCS4", CR_UCS_4},
{"UCS-4", CR_UCS_4},
{"UCS_4", CR_UCS_4},
{"ASCII", CR_ASCII},
{(char *)0, (enum CREncoding)0}
};
static CREncHandler gv_default_enc_handlers[] = {
};
/**
*Gets the instance of encoding handler.
*This function implements a singleton pattern.
*@param a_enc the encoding of the Handler.
*@return the instance of #CREncHandler.
*/
{
gulong i = 0;
for (i = 0; gv_default_enc_handlers[i].encoding; i++) {
return (CREncHandler *)
}
}
return NULL;
}
/**
*Given an encoding name (called an alias name)
*the function returns the matching encoding type.
*@param a_alias_name the encoding name
*@param a_enc output param. The returned encoding type
*or 0 if the alias is not supported.
*@return CR_OK upon successfull completion, an error code otherwise.
*/
enum CRStatus
enum CREncoding *a_enc)
{
gulong i = 0;
for (i = 0; gv_default_aliases[i].name; i++) {
break;
}
}
return status;
}
/**
*Converts a raw input buffer into an utf8 buffer.
*@param a_this the current instance of #CREncHandler.
*@param a_in the input buffer to convert.
*buffer to convert. After return, contains the number of
*bytes actually consumed.
*@param @a_out output parameter. The converted output buffer.
*Must be freed by the buffer.
*@param a_out_len output parameter. The length of the output buffer.
*@return CR_OK upon successfull completion, an error code otherwise.
*/
enum CRStatus
{
return CR_OK;
if (a_this->enc_str_len_as_utf8) {
} else {
}
}
return CR_OK;
}