Line data Source code
1 : /*-------------------------------------------------------------------------
2 : *
3 : * ASCII and MULE_INTERNAL
4 : *
5 : * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
6 : * Portions Copyright (c) 1994, Regents of the University of California
7 : *
8 : * IDENTIFICATION
9 : * src/backend/utils/mb/conversion_procs/ascii_and_mic/ascii_and_mic.c
10 : *
11 : *-------------------------------------------------------------------------
12 : */
13 :
14 : #include "postgres.h"
15 : #include "fmgr.h"
16 : #include "mb/pg_wchar.h"
17 :
18 2 : PG_MODULE_MAGIC;
19 :
20 4 : PG_FUNCTION_INFO_V1(ascii_to_mic);
21 4 : PG_FUNCTION_INFO_V1(mic_to_ascii);
22 :
23 : /* ----------
24 : * conv_proc(
25 : * INTEGER, -- source encoding id
26 : * INTEGER, -- destination encoding id
27 : * CSTRING, -- source string (null terminated C string)
28 : * CSTRING, -- destination string (null terminated C string)
29 : * INTEGER -- source string length
30 : * ) returns VOID;
31 : * ----------
32 : */
33 :
34 : Datum
35 2 : ascii_to_mic(PG_FUNCTION_ARGS)
36 : {
37 2 : unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
38 2 : unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
39 2 : int len = PG_GETARG_INT32(4);
40 :
41 2 : CHECK_ENCODING_CONVERSION_ARGS(PG_SQL_ASCII, PG_MULE_INTERNAL);
42 :
43 2 : pg_ascii2mic(src, dest, len);
44 :
45 2 : PG_RETURN_VOID();
46 : }
47 :
48 : Datum
49 2 : mic_to_ascii(PG_FUNCTION_ARGS)
50 : {
51 2 : unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
52 2 : unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
53 2 : int len = PG_GETARG_INT32(4);
54 :
55 2 : CHECK_ENCODING_CONVERSION_ARGS(PG_MULE_INTERNAL, PG_SQL_ASCII);
56 :
57 2 : pg_mic2ascii(src, dest, len);
58 :
59 2 : PG_RETURN_VOID();
60 : }
|