LCOV - code coverage report
Current view: top level - src/backend/utils/mb/conversion_procs/latin_and_mic - latin_and_mic.c (source / functions) Hit Total Coverage
Test: PostgreSQL Lines: 49 49 100.0 %
Date: 2017-09-29 15:12:54 Functions: 13 13 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*-------------------------------------------------------------------------
       2             :  *
       3             :  *    LATINn 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/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             : 
      18           4 : PG_MODULE_MAGIC;
      19             : 
      20           6 : PG_FUNCTION_INFO_V1(latin1_to_mic);
      21           6 : PG_FUNCTION_INFO_V1(mic_to_latin1);
      22           6 : PG_FUNCTION_INFO_V1(latin3_to_mic);
      23           6 : PG_FUNCTION_INFO_V1(mic_to_latin3);
      24           6 : PG_FUNCTION_INFO_V1(latin4_to_mic);
      25           6 : PG_FUNCTION_INFO_V1(mic_to_latin4);
      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
      40           4 : latin1_to_mic(PG_FUNCTION_ARGS)
      41             : {
      42           4 :     unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
      43           4 :     unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
      44           4 :     int         len = PG_GETARG_INT32(4);
      45             : 
      46           4 :     CHECK_ENCODING_CONVERSION_ARGS(PG_LATIN1, PG_MULE_INTERNAL);
      47             : 
      48           4 :     latin2mic(src, dest, len, LC_ISO8859_1, PG_LATIN1);
      49             : 
      50           4 :     PG_RETURN_VOID();
      51             : }
      52             : 
      53             : Datum
      54           4 : mic_to_latin1(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_MULE_INTERNAL, PG_LATIN1);
      61             : 
      62           4 :     mic2latin(src, dest, len, LC_ISO8859_1, PG_LATIN1);
      63             : 
      64           4 :     PG_RETURN_VOID();
      65             : }
      66             : 
      67             : Datum
      68           4 : latin3_to_mic(PG_FUNCTION_ARGS)
      69             : {
      70           4 :     unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
      71           4 :     unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
      72           4 :     int         len = PG_GETARG_INT32(4);
      73             : 
      74           4 :     CHECK_ENCODING_CONVERSION_ARGS(PG_LATIN3, PG_MULE_INTERNAL);
      75             : 
      76           4 :     latin2mic(src, dest, len, LC_ISO8859_3, PG_LATIN3);
      77             : 
      78           4 :     PG_RETURN_VOID();
      79             : }
      80             : 
      81             : Datum
      82           4 : mic_to_latin3(PG_FUNCTION_ARGS)
      83             : {
      84           4 :     unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
      85           4 :     unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
      86           4 :     int         len = PG_GETARG_INT32(4);
      87             : 
      88           4 :     CHECK_ENCODING_CONVERSION_ARGS(PG_MULE_INTERNAL, PG_LATIN3);
      89             : 
      90           4 :     mic2latin(src, dest, len, LC_ISO8859_3, PG_LATIN3);
      91             : 
      92           4 :     PG_RETURN_VOID();
      93             : }
      94             : 
      95             : Datum
      96           4 : latin4_to_mic(PG_FUNCTION_ARGS)
      97             : {
      98           4 :     unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
      99           4 :     unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
     100           4 :     int         len = PG_GETARG_INT32(4);
     101             : 
     102           4 :     CHECK_ENCODING_CONVERSION_ARGS(PG_LATIN4, PG_MULE_INTERNAL);
     103             : 
     104           4 :     latin2mic(src, dest, len, LC_ISO8859_4, PG_LATIN4);
     105             : 
     106           4 :     PG_RETURN_VOID();
     107             : }
     108             : 
     109             : Datum
     110           4 : mic_to_latin4(PG_FUNCTION_ARGS)
     111             : {
     112           4 :     unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
     113           4 :     unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
     114           4 :     int         len = PG_GETARG_INT32(4);
     115             : 
     116           4 :     CHECK_ENCODING_CONVERSION_ARGS(PG_MULE_INTERNAL, PG_LATIN4);
     117             : 
     118           4 :     mic2latin(src, dest, len, LC_ISO8859_4, PG_LATIN4);
     119             : 
     120           4 :     PG_RETURN_VOID();
     121             : }

Generated by: LCOV version 1.11