Initialize Tizen 2.3
[framework/uifw/elementary.git] / src / lib / elm_util.c
1 #ifdef HAVE_CONFIG_H
2 # include "elementary_config.h"
3 #endif
4 #include <Elementary.h>
5 #include "elm_priv.h"
6
7 char *
8 _str_ncpy(char *dest, const char *src, size_t count)
9 {
10    if ((!dest) || (!src)) return NULL;
11    return strncpy(dest, src, count);
12 }
13
14 char *
15 _str_append(char *str, const char *txt, int *len, int *alloc)
16 {
17    int txt_len = strlen(txt);
18
19    if (txt_len <= 0) return str;
20    if ((*len + txt_len) >= *alloc)
21      {
22         char *str2;
23         int alloc2;
24
25         alloc2 = *alloc + txt_len + 128;
26         str2 = realloc(str, alloc2);
27         if (!str2) return str;
28         *alloc = alloc2;
29         str = str2;
30      }
31    strcpy(str + *len, txt);
32    *len += txt_len;
33    return str;
34 }
35
36 char *
37 _elm_util_mkup_to_text(const char *mkup)
38 {
39    return evas_textblock_text_markup_to_utf8(NULL, mkup);
40 }
41
42 char *
43 _elm_util_text_to_mkup(const char *text)
44 {
45    return evas_textblock_text_utf8_to_markup(NULL, text);
46 }
47
48 double
49 _elm_atof(const char *s)
50 {
51    char *cradix, *buf, *p;
52    
53    if ((!s) || (!s[0])) return 0.0;
54    cradix = nl_langinfo(RADIXCHAR);
55    if (!cradix) return atof(s);
56    buf = alloca(strlen(s) + 1);
57    strcpy(buf, s);
58    for (p = buf; *p; p++)
59      {
60         if (*p == '.') *p = *cradix;
61      }
62    return atof(buf);
63 }
64
65 Eina_Bool
66 _elm_util_freeze_events_get(const Evas_Object *obj)
67 {
68    Evas_Object *parent = (Evas_Object *) obj;
69    while (parent)
70      {
71         if (evas_object_freeze_events_get(parent)) return EINA_TRUE;
72         parent = evas_object_smart_parent_get(parent);
73      }
74    return EINA_FALSE;
75 }