~vcs-imports/mammoth-replicator/trunk

« back to all changes in this revision

Viewing changes to src/backend/utils/mb/conversion_procs/ascii_and_mic/ascii_and_mic.c

  • Committer: alvherre
  • Date: 2005-12-16 21:24:52 UTC
  • Revision ID: svn-v4:db760fc0-0f08-0410-9d63-cc6633f64896:trunk:1
Initial import of the REL8_0_3 sources from the Pgsql CVS repository.

Show diffs side-by-side

added added

removed removed

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