Logo Search packages:      
Sourcecode: g2ipmsg version File versions  Download package

int convert_string_internal ( const char *  string,
const gchar **  to_string 
)

文字コードを内部形式に変換する

Parameters:
[in] string 変換対象の文字列
[out] to_string 変換後の文字列を指すポインタ変数のアドレス
Return values:
0 正常終了(string, to_stringのいずれかがNULL).
-EINVAL 引数異常
-ENOMEM メモリ不足

Definition at line 292 of file codeset.c.

References convert_mutex, IPMSG_INTERNAL_CODE, and IPMSG_PROTO_CODE.

Referenced by info_message_window(), and ipmsg_convert_string_internal().

                                                                     {
      int                      rc = 0;
      gsize              read_len = 0;
      gsize             write_len = 0;
      GError          *error_info = NULL;
      gchar     *converted_string = NULL;
      const char *external_encode = NULL;

      if ( (string == NULL) || (to_string == NULL) )
            return -EINVAL;
      
      external_encode = hostinfo_refer_encoding(); /* 外部エンコード取得 */

      g_static_mutex_lock(&convert_mutex);
      converted_string = g_convert((const gchar *)string,
          -1, /* ヌルターミネート */
          IPMSG_INTERNAL_CODE,
          (external_encode != NULL) ? (external_encode) : (IPMSG_PROTO_CODE),
          &read_len,
          &write_len,
          &error_info);

      rc = -EINVAL;
      if (converted_string == NULL) {
            if (error_info != NULL) {
                  dbg_out("%s\n",error_info->message);
                  rc = error_info->code;
                  g_error_free(error_info);
            }
            if (rc > 0)
                  rc = -rc;
            g_static_mutex_unlock(&convert_mutex);
            goto error_out;
      }
      
      *to_string = converted_string;
      rc = 0; /* 正常終了  */

      g_static_mutex_unlock(&convert_mutex);

error_out:
      return rc;
}


Generated by  Doxygen 1.6.0   Back to index