803849677e86d3b6c7809c791c3e7c3335b17561
[framework/telephony/libtcore.git] / include / util.h
1 /*
2  * libtcore
3  *
4  * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Ja-young Gu <jygu@samsung.com>
7  *
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
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
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.
19  */
20
21 #ifndef __TCORE_UTIL_H__
22 #define __TCORE_UTIL_H__
23
24 #include <glib-object.h>
25
26 __BEGIN_DECLS
27
28
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,
37 };
38
39
40 union tcore_ip4_type {
41         uint32_t i;
42         unsigned char s[4];
43 };
44
45 enum tcore_dcs_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,
51 };
52
53 TReturn     tcore_util_netif_up(const char *name);
54 TReturn     tcore_util_netif_down(const char *name);
55 TReturn     tcore_util_netif_set(const char *name, const char *ipaddr,
56                 const char *gateway, const char *netmask);
57
58 char*       tcore_util_get_string_by_ip4type(union tcore_ip4_type ip);
59
60 GHashTable* tcore_util_marshal_create();
61 void        tcore_util_marshal_destory(GHashTable *ht);
62
63 GHashTable* tcore_util_marshal_deserialize_string(const gchar *serialized_string);
64 gchar*      tcore_util_marshal_serialize(GHashTable *ht);
65
66 gboolean    tcore_util_marshal_add_data(GHashTable *ht, const gchar *key,
67                 const void *data, enum tcore_util_marshal_data_type type);
68 gboolean    tcore_util_marshal_get_data(GHashTable *ht, const gchar *key,
69                 void **data, enum tcore_util_marshal_data_type type);
70
71 gint        tcore_util_marshal_get_int(GHashTable *ht, const gchar *key);
72 gchar*      tcore_util_marshal_get_string(GHashTable *ht, const gchar *key);
73 GHashTable* tcore_util_marshal_get_object(GHashTable *ht, const gchar *key);
74
75 enum tcore_dcs_type
76             tcore_util_get_cbs_coding_scheme(unsigned char encode);
77
78 unsigned char* tcore_util_decode_hex(const char *src, int len);
79
80 unsigned char* tcore_util_unpack_gsm7bit(const unsigned char *src, unsigned int src_len);
81 unsigned char* tcore_util_pack_gsm7bit(const unsigned char *src, unsigned int src_len);
82 char*       tcore_util_convert_bcd2ascii(const char *src, int src_len, int max_len);
83
84 __END_DECLS
85
86 #endif