00001 /*------------------------------------------------------------------------- 00002 * 00003 * ASCII and MULE_INTERNAL 00004 * 00005 * Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group 00006 * Portions Copyright (c) 1994, Regents of the University of California 00007 * 00008 * IDENTIFICATION 00009 * src/backend/utils/mb/conversion_procs/ascii_and_mic/ascii_and_mic.c 00010 * 00011 *------------------------------------------------------------------------- 00012 */ 00013 00014 #include "postgres.h" 00015 #include "fmgr.h" 00016 #include "mb/pg_wchar.h" 00017 00018 PG_MODULE_MAGIC; 00019 00020 PG_FUNCTION_INFO_V1(ascii_to_mic); 00021 PG_FUNCTION_INFO_V1(mic_to_ascii); 00022 00023 extern Datum ascii_to_mic(PG_FUNCTION_ARGS); 00024 extern Datum mic_to_ascii(PG_FUNCTION_ARGS); 00025 00026 /* ---------- 00027 * conv_proc( 00028 * INTEGER, -- source encoding id 00029 * INTEGER, -- destination encoding id 00030 * CSTRING, -- source string (null terminated C string) 00031 * CSTRING, -- destination string (null terminated C string) 00032 * INTEGER -- source string length 00033 * ) returns VOID; 00034 * ---------- 00035 */ 00036 00037 Datum 00038 ascii_to_mic(PG_FUNCTION_ARGS) 00039 { 00040 unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2); 00041 unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3); 00042 int len = PG_GETARG_INT32(4); 00043 00044 CHECK_ENCODING_CONVERSION_ARGS(PG_SQL_ASCII, PG_MULE_INTERNAL); 00045 00046 pg_ascii2mic(src, dest, len); 00047 00048 PG_RETURN_VOID(); 00049 } 00050 00051 Datum 00052 mic_to_ascii(PG_FUNCTION_ARGS) 00053 { 00054 unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2); 00055 unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3); 00056 int len = PG_GETARG_INT32(4); 00057 00058 CHECK_ENCODING_CONVERSION_ARGS(PG_MULE_INTERNAL, PG_SQL_ASCII); 00059 00060 pg_mic2ascii(src, dest, len); 00061 00062 PG_RETURN_VOID(); 00063 }