summaryrefslogtreecommitdiff
path: root/common/include/email-utils.h
blob: cf2324e6e95ae67c6aa9806d847eec3b0e987ecc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
 * Copyright 2012  Samsung Electronics Co., Ltd
 *
 * Licensed under the Flora License, Version 1.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.tizenopensource.org/license
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef _EMAIL_UTILS_H_
#define _EMAIL_UTILS_H_

#include "email-common-types.h"
#include "email-debug.h"

#include <errno.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>

#include <unicode/uloc.h>
#include <unicode/ucal.h>
#include <unicode/udat.h>
#include <unicode/udatpg.h>
#include <unicode/ustring.h>

G_BEGIN_DECLS

/*
 * String utility.
 */
#undef STR_VALID
#define STR_VALID(str) \
	((str != NULL && strlen(str) > 0) ? TRUE : FALSE)
#undef STR_INVALID
#define STR_INVALID(str) \
	((str == NULL || strlen(str) == 0) ? TRUE : FALSE)
#undef STR_LEN
#define STR_LEN(str) \
	({ const char *s = (const char *)str; (s) ? strlen(s) : 0; })

/*
 * Exported fuctions.
 */
char *email_get_current_theme_name(void);

gboolean email_check_dir_exist(const gchar *path);
gboolean email_check_file_exist(const gchar *path);

gchar *email_parse_get_filename_from_path(const gchar *path);	/* g_free(). */
void email_parse_get_filename_n_ext_from_path(const gchar *path, gchar **ret_file_name, gchar **ret_ext);

void email_save_file(const gchar *path, const gchar *buf, gsize len);
gchar *email_get_buff_from_file(const gchar *path, guint max_kbyte);	/* g_free(). */
gchar *email_get_file_size_string(guint64 size);	/* g_free(). */
guint64 email_get_file_size(const gchar *path);

char *email_get_date_text(const char *locale, char *skeleton, void *time);

int email_open_icu_pattern_generator(void);
int email_close_icu_pattern_generator(void);

gboolean email_drm_file_is_right(const gchar *path);
gboolean email_drm_file_forward_lock_check(const gchar *path);

G_END_DECLS
#endif	/* _EMAIL_UTILS_H_ */

/* EOF */