PostgreSQL Source Code  git master
latin_and_mic.c
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * LATINn and MULE_INTERNAL
4  *
5  * Portions Copyright (c) 1996-2020, 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/latin_and_mic/latin_and_mic.c
10  *
11  *-------------------------------------------------------------------------
12  */
13 
14 #include "postgres.h"
15 #include "fmgr.h"
16 #include "mb/pg_wchar.h"
17 
19 
26 
27 /* ----------
28  * conv_proc(
29  * INTEGER, -- source encoding id
30  * INTEGER, -- destination encoding id
31  * CSTRING, -- source string (null terminated C string)
32  * CSTRING, -- destination string (null terminated C string)
33  * INTEGER -- source string length
34  * ) returns VOID;
35  * ----------
36  */
37 
38 
39 Datum
41 {
42  unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
43  unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
44  int len = PG_GETARG_INT32(4);
45 
47 
48  latin2mic(src, dest, len, LC_ISO8859_1, PG_LATIN1);
49 
51 }
52 
53 Datum
55 {
56  unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
57  unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
58  int len = PG_GETARG_INT32(4);
59 
61 
62  mic2latin(src, dest, len, LC_ISO8859_1, PG_LATIN1);
63 
65 }
66 
67 Datum
69 {
70  unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
71  unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
72  int len = PG_GETARG_INT32(4);
73 
75 
76  latin2mic(src, dest, len, LC_ISO8859_3, PG_LATIN3);
77 
79 }
80 
81 Datum
83 {
84  unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
85  unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
86  int len = PG_GETARG_INT32(4);
87 
89 
90  mic2latin(src, dest, len, LC_ISO8859_3, PG_LATIN3);
91 
93 }
94 
95 Datum
97 {
98  unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
99  unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
100  int len = PG_GETARG_INT32(4);
101 
103 
104  latin2mic(src, dest, len, LC_ISO8859_4, PG_LATIN4);
105 
106  PG_RETURN_VOID();
107 }
108 
109 Datum
111 {
112  unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
113  unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
114  int len = PG_GETARG_INT32(4);
115 
117 
118  mic2latin(src, dest, len, LC_ISO8859_4, PG_LATIN4);
119 
120  PG_RETURN_VOID();
121 }
Datum latin3_to_mic(PG_FUNCTION_ARGS)
Definition: latin_and_mic.c:68
#define PG_GETARG_INT32(n)
Definition: fmgr.h:269
#define LC_ISO8859_4
Definition: pg_wchar.h:105
Datum mic_to_latin3(PG_FUNCTION_ARGS)
Definition: latin_and_mic.c:82
#define LC_ISO8859_1
Definition: pg_wchar.h:102
#define LC_ISO8859_3
Definition: pg_wchar.h:104
void latin2mic(const unsigned char *l, unsigned char *p, int len, int lc, int encoding)
Definition: conv.c:71
Datum mic_to_latin1(PG_FUNCTION_ARGS)
Definition: latin_and_mic.c:54
Datum latin1_to_mic(PG_FUNCTION_ARGS)
Definition: latin_and_mic.c:40
PG_MODULE_MAGIC
Definition: latin_and_mic.c:18
void mic2latin(const unsigned char *mic, unsigned char *p, int len, int lc, int encoding)
Definition: conv.c:99
uintptr_t Datum
Definition: postgres.h:367
#define PG_RETURN_VOID()
Definition: fmgr.h:348
#define CHECK_ENCODING_CONVERSION_ARGS(srcencoding, destencoding)
Definition: pg_wchar.h:506
Datum mic_to_latin4(PG_FUNCTION_ARGS)
Datum latin4_to_mic(PG_FUNCTION_ARGS)
Definition: latin_and_mic.c:96
#define PG_GETARG_CSTRING(n)
Definition: fmgr.h:277
#define PG_FUNCTION_ARGS
Definition: fmgr.h:193
PG_FUNCTION_INFO_V1(latin1_to_mic)