4 * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Ja-young Gu <jygu@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
21 #ifndef __TCORE_UTIL_H__
22 #define __TCORE_UTIL_H__
24 #include <glib-object.h>
29 enum tcore_util_marshal_data_type {
30 TCORE_UTIL_MARSHAL_DATA_CHAR_TYPE = G_TYPE_CHAR,
31 TCORE_UTIL_MARSHAL_DATA_BOOLEAN_TYPE = G_TYPE_BOOLEAN,
32 TCORE_UTIL_MARSHAL_DATA_INT_TYPE = G_TYPE_INT,
33 TCORE_UTIL_MARSHAL_DATA_DOUBLE_TYPE = G_TYPE_DOUBLE,
34 TCORE_UTIL_MARSHAL_DATA_STRING_TYPE = G_TYPE_STRING,
35 TCORE_UTIL_MARSHAL_DATA_OBJECT_TYPE = G_TYPE_BOXED,
36 TCORE_UTIL_MARSHAL_DATA_STRING_MAX = 0xFF,
40 union tcore_ip4_type {
46 TCORE_DCS_TYPE_NONE = 0xff,
47 TCORE_DCS_TYPE_7_BIT = 0x00,
48 TCORE_DCS_TYPE_8_BIT = 0x04,
49 TCORE_DCS_TYPE_UCS2 = 0x08,
50 TCORE_DCS_TYPE_UNSPECIFIED = 0x0F,
53 TReturn tcore_util_netif(const char *name, gboolean enabled);
54 TReturn tcore_util_netif_set(const char *name, const char *ipaddr,
55 const char *gateway, const char *netmask);
57 char* tcore_util_get_string_by_ip4type(union tcore_ip4_type ip);
59 GHashTable* tcore_util_marshal_create();
60 void tcore_util_marshal_destory(GHashTable *ht);
62 GHashTable* tcore_util_marshal_deserialize_string(const gchar *serialized_string);
63 gchar* tcore_util_marshal_serialize(GHashTable *ht);
65 gboolean tcore_util_marshal_add_data(GHashTable *ht, const gchar *key,
66 const void *data, enum tcore_util_marshal_data_type type);
67 gboolean tcore_util_marshal_get_data(GHashTable *ht, const gchar *key,
68 void **data, enum tcore_util_marshal_data_type type);
70 gint tcore_util_marshal_get_int(GHashTable *ht, const gchar *key);
71 gchar* tcore_util_marshal_get_string(GHashTable *ht, const gchar *key);
72 GHashTable* tcore_util_marshal_get_object(GHashTable *ht, const gchar *key);
75 tcore_util_get_cbs_coding_scheme(unsigned char encode);
77 unsigned char* tcore_util_decode_hex(const char *src, int len);
78 long tcore_util_encode_hex(const unsigned char *src, long num_bytes,
81 int tcore_util_pdu_encode(const unsigned char *sca, const unsigned char *tpdu,
82 int tpdu_len, char *pdu);
84 unsigned char* tcore_util_unpack_gsm7bit(const unsigned char *src, unsigned int src_len);
85 unsigned char* tcore_util_pack_gsm7bit(const unsigned char *src, unsigned int src_len);
86 char* tcore_util_convert_bcd2ascii(const char *src, int src_len, int max_len);
87 gboolean tcore_util_convert_utf8_to_gsm(unsigned char *dest, int *dest_len, unsigned char* src, int src_len);
88 gboolean tcore_util_convert_utf8_to_ucs2(unsigned char* dest, int* dest_len, unsigned char* src, int src_len);
89 gboolean tcore_util_convert_string_to_utf8(unsigned char *dest, unsigned short *dest_len,
90 enum alphabet_format dcs, const unsigned char *src, unsigned short src_len);
91 void tcore_util_swap_byte_order(unsigned short* dest, const unsigned short* src, int src_len);
93 char* tcore_util_get_version(void);