LCOV - code coverage report
Current view: top level - src/backend/utils/mb/conversion_procs/utf8_and_big5 - utf8_and_big5.c (source / functions) Hit Total Coverage
Test: PostgreSQL 13devel Lines: 17 17 100.0 %
Date: 2019-09-22 07:07:17 Functions: 5 5 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*-------------------------------------------------------------------------
       2             :  *
       3             :  *    BIG5 <--> UTF8
       4             :  *
       5             :  * Portions Copyright (c) 1996-2019, 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/utf8_and_big5/utf8_and_big5.c
      10             :  *
      11             :  *-------------------------------------------------------------------------
      12             :  */
      13             : 
      14             : #include "postgres.h"
      15             : #include "fmgr.h"
      16             : #include "mb/pg_wchar.h"
      17             : #include "../../Unicode/big5_to_utf8.map"
      18             : #include "../../Unicode/utf8_to_big5.map"
      19             : 
      20           4 : PG_MODULE_MAGIC;
      21             : 
      22           4 : PG_FUNCTION_INFO_V1(big5_to_utf8);
      23           4 : PG_FUNCTION_INFO_V1(utf8_to_big5);
      24             : 
      25             : /* ----------
      26             :  * conv_proc(
      27             :  *      INTEGER,    -- source encoding id
      28             :  *      INTEGER,    -- destination encoding id
      29             :  *      CSTRING,    -- source string (null terminated C string)
      30             :  *      CSTRING,    -- destination string (null terminated C string)
      31             :  *      INTEGER     -- source string length
      32             :  * ) returns VOID;
      33             :  * ----------
      34             :  */
      35             : Datum
      36           4 : big5_to_utf8(PG_FUNCTION_ARGS)
      37             : {
      38           4 :     unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
      39           4 :     unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
      40           4 :     int         len = PG_GETARG_INT32(4);
      41             : 
      42           4 :     CHECK_ENCODING_CONVERSION_ARGS(PG_BIG5, PG_UTF8);
      43             : 
      44           4 :     LocalToUtf(src, len, dest,
      45             :                &big5_to_unicode_tree,
      46             :                NULL, 0,
      47             :                NULL,
      48             :                PG_BIG5);
      49             : 
      50           4 :     PG_RETURN_VOID();
      51             : }
      52             : 
      53             : Datum
      54           4 : utf8_to_big5(PG_FUNCTION_ARGS)
      55             : {
      56           4 :     unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
      57           4 :     unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
      58           4 :     int         len = PG_GETARG_INT32(4);
      59             : 
      60           4 :     CHECK_ENCODING_CONVERSION_ARGS(PG_UTF8, PG_BIG5);
      61             : 
      62           4 :     UtfToLocal(src, len, dest,
      63             :                &big5_from_unicode_tree,
      64             :                NULL, 0,
      65             :                NULL,
      66             :                PG_BIG5);
      67             : 
      68           4 :     PG_RETURN_VOID();
      69             : }

Generated by: LCOV version 1.13