int32_t s_count = s->count(ec);
for (i = 0; i < s_count; i++) {
- char buf[128] = {0};
+ char buf[CAL_STR_MIDDLE_LEN] = {0};
const UnicodeString *unicode_tzid = s->snext(ec);
unicode_tzid->extract(buf, sizeof(buf), NULL, ec);
if (CAL_STRING_EQUAL == strncmp(tzid, buf, strlen(buf))) {
gmtoffset = sec2ms(tz->tz_offset_from_gmt * 60);
if (tz->day_light_bias == 0) {
- char buf[128] = {0};
+ char buf[CAL_STR_MIDDLE_LEN] = {0};
snprintf(buf, sizeof(buf), "Etc/GMT%c%d",
gmtoffset < 0 ? '+' : '-',
tz->tz_offset_from_gmt / 60);
UCalendar *cal_time_open_ucal(int calendar_system_type, const char *tzid, int wkst)
{
- UChar utf16_timezone[64] = {0};
+ UChar utf16_timezone[CAL_STR_SHORT_LEN64] = {0};
u_uastrncpy(utf16_timezone, tzid, sizeof(utf16_timezone));
UErrorCode status = U_ZERO_ERROR;
UCalendar *cal_time_get_ucal(const char *tzid, int wkst)
{
- UChar utf16_timezone[64] = {0};
+ UChar utf16_timezone[CAL_STR_SHORT_LEN64] = {0};
u_uastrncpy(utf16_timezone, tzid, sizeof(utf16_timezone));
UErrorCode status = U_ZERO_ERROR;
char* cal_time_convert_ltos(const char *tzid, long long int lli, int is_allday)
{
int y, mon, d, h, min, s;
- char buf[32] = {0};
+ char buf[CAL_STR_SHORT_LEN32] = {0};
UCalendar *ucal;
UErrorCode status = U_ZERO_ERROR;
*/
char* cal_time_get_timezone(void)
{
- char buf[256] = {0};
+ char buf[CAL_STR_MIDDLE_LEN] = {0};
ssize_t len = readlink("/opt/etc/localtime", buf, sizeof(buf)-1);
RETVM_IF(-1 == len, NULL, "readlink() Fail");
int len = strlen(tzid);
int i, j;
for (i = 0; i < s_count; i++) {
- char buf[32] = {0};
+ char buf[CAL_STR_SHORT_LEN32] = {0};
const UnicodeString *unicode_tzid = s->snext(ec);
for (j = 0; j < unicode_tzid->length(); j++) {
buf[j] = unicode_tzid->charAt(j);
#include "cal_record.h"
#include <tzplatform_config.h>
-#define CAL_STR_SHORT_LEN 1024
+#define CAL_STR_SHORT_LEN32 32
+#define CAL_STR_SHORT_LEN64 64
+#define CAL_STR_MIDDLE_LEN 1024
+#define CAL_STR_LONG_LEN 2048
#define CAL_STRING_EQUAL 0
#define CAL_TZID_GMT "Etc/GMT"
#define CAL_SOCK_PATH "/run/user/%d"
FILE *file;
int buf_size, len;
char *stream;
- char buf[1024];
+ char buf[CAL_STR_MIDDLE_LEN];
vcalendar_foreach_s *foreach_data = NULL;
RETV_IF(NULL == vcalendar_file_path, CALENDAR_ERROR_INVALID_PARAMETER);
return CALENDAR_ERROR_NONE;
}
- char buf[256] = {0};
+ char buf[CAL_STR_MIDDLE_LEN] = {0};
int y = 0, m = 0, d = 0;
int h = 0, n = 0, s = 0;
switch (b->version) {
static const char* vl_tick(calendar_alarm_time_unit_type_e unit, int tick)
{
- static char buf[32] = {0};
+ static char buf[CAL_STR_SHORT_LEN32] = {0};
int i = 0;
if (0 < tick) {
}
else {
- char datetime[32] = {0};
+ char datetime[CAL_STR_SHORT_LEN32] = {0};
snprintf(datetime, sizeof(datetime), "%04d%02d%02dT%02d%02d%02d",
at.time.date.year, at.time.date.month, at.time.date.mday,
at.time.date.hour, at.time.date.minute, at.time.date.second);
ret = calendar_record_get_int(alarm, _calendar_alarm.tick_unit, &unit);
RETM_IF(CALENDAR_ERROR_NONE != ret, "calendar_record_get_int() Fail(%d)", ret);
- char datetime[32] = {0};
+ char datetime[CAL_STR_SHORT_LEN32] = {0};
if (CALENDAR_ALARM_TIME_UNIT_SPECIFIC == unit) {
calendar_time_s at = {0};
ret = calendar_record_get_caltime(alarm, _calendar_alarm.alarm_time, &at);
if (false == is_working) {
is_extracted = true;
is_working = true;
- char num[32] = {0};
+ char num[CAL_STR_SHORT_LEN32] = {0};
snprintf(num, digit +1, "%s%s", byday +i -digit, (-1 == sign) ? "- ": "+ ");
if (NULL == strstr(buf, num)) {
blen += snprintf(buf +blen, buf_len -blen, "%s", num);
d = caltime.time.date.mday;
break;
}
- char mday[32] = {0};
+ char mday[CAL_STR_SHORT_LEN32] = {0};
snprintf(mday, sizeof(mday), "%d", d);
_cal_vcalendar_make_rrule_append_mday(buf, sizeof(buf), mday);
}
RET_IF(NULL == record);
int ret = 0;
- char buf[1024] = {0};
+ char buf[CAL_STR_MIDDLE_LEN] = {0};
int freq = 0;
ret = calendar_record_get_int(record, _calendar_event.freq, &freq);
int ret = 0;
char *text = NULL;
- char tmp[32] = {0};
+ char tmp[CAL_STR_SHORT_LEN32] = {0};
calendar_time_s caltime = {0};
int freq = 0;
int y = 0, m = 0, d = 0;
int h = 0, n = 0, s = 0;
cal_time_get_local_datetime(NULL, value, &y, &m, &d, &h, &n, &s);
- char buf[128] = {0};
+ char buf[CAL_STR_MIDDLE_LEN] = {0};
snprintf(buf, sizeof(buf), VCAL_DATETIME_FORMAT_YYYYMMDDTHHMMSSZ, y, m, d, h, n, s);
switch (b->version) {
if ((NULL == name || '\0' == *name) && (NULL == email || '\0' == *email))
return;
- char buf[128] = {0};
+ char buf[CAL_STR_MIDDLE_LEN] = {0};
snprintf(buf, sizeof(buf), "ORGANIZER%s%s%s%s",
(name && *name) ? ";CN=" : "",
(name && *name) ? name : "",
int h = 0, n = 0, s = 0;
cal_time_get_local_datetime(NULL, value, &y, &m, &d, &h, &n, &s);
- char buf[128] = {0};
+ char buf[CAL_STR_MIDDLE_LEN] = {0};
snprintf(buf, sizeof(buf), VCAL_DATETIME_FORMAT_YYYYMMDDTHHMMSSZ, y, m, d, h, n, s);
_cal_vcalendar_make_printf(b, "LAST-MODIFIED:", buf);
}
int y = 0, m = 0, d = 0;
int h = 0, n = 0, s = 0;
cal_time_get_local_datetime(NULL, value, &y, &m, &d, &h, &n, &s);
- char buf[128] = {0};
+ char buf[CAL_STR_MIDDLE_LEN] = {0};
snprintf(buf, sizeof(buf), VCAL_DATETIME_FORMAT_YYYYMMDDTHHMMSSZ, y, m, d, h, n, s);
_cal_vcalendar_make_printf(b, "COMPLETED", buf);
}
}
break;
}
- char buf[128] = {0};
+ char buf[CAL_STR_MIDDLE_LEN] = {0};
snprintf(buf, sizeof(buf), "PRIORITY:%d", priority);
_cal_vcalendar_make_printf(b, buf, NULL);
}
int y = 0, m = 0, d = 0;
int h = 0, n = 0, s = 0;
cal_time_get_local_datetime(NULL, t, &y, &m, &d, &h, &n, &s);
- char buf[128] = {0};
+ char buf[CAL_STR_MIDDLE_LEN] = {0};
snprintf(buf, sizeof(buf), VCAL_DATETIME_FORMAT_YYYYMMDDTHHMMSSZ, y, m, d, h, n, s);
_cal_vcalendar_make_printf(b, "DTSTAMP:", buf);
}
ret = _cal_vcalendar_make_printf(b, "PRODID:vCal ID Default", NULL);
RETM_IF(CALENDAR_ERROR_NONE != ret, "_cal_vcalendar_make_printf() Fail(%d)", ret);
- char buf[32] = {0};
+ char buf[CAL_STR_SHORT_LEN32] = {0};
snprintf(buf, sizeof(buf), "VERSION:%d.0", b->version);
ret = _cal_vcalendar_make_printf(b, buf, NULL);
RETM_IF(CALENDAR_ERROR_NONE != ret, "_cal_vcalendar_make_printf() Fail(%d)", ret);
int h = (zone / 3600) + (dst / 3600);
int m = (zone % 3600) / 60 + (dst % 3600) / 60;
- char buf[32] = {0};
+ char buf[CAL_STR_SHORT_LEN32] = {0};
snprintf(buf, sizeof(buf), "TZ:%s%02d:%02d",
h == 0 ? "" : (h < 0 ? "-" : "+"),
h < 0 ? (-1 * h) : h, m < 0 ? (-1 * m) : m);
int h = 0, m = 0;
__parse_tz(value +1, &h, &m); /* +1 to skip ':' */
- char buf[32] = {0};
+ char buf[CAL_STR_SHORT_LEN32] = {0};
if (0 == m) {
snprintf(buf, sizeof(buf), "Etc/GMT%c%d", h < 0 ? '+' : '-', h);
int freq_mode = 0;
bool has_by = false;
- char bystr[1024] = {0};
+ char bystr[CAL_STR_MIDDLE_LEN] = {0};
int len_str = 0;
int week[5] = {0};
WARN_IF(CALENDAR_ERROR_NONE != ret, "cal_record_set_int() Fail(%d)", ret);
if (NULL == ud->timezone_tzid || '\0' == *ud->timezone_tzid) {
- char buf[32] = {0};
+ char buf[CAL_STR_SHORT_LEN32] = {0};
snprintf(buf, sizeof(buf), "Etc/GMT%c%d", offset < 0 ? '+' : '-', h);
ud->timezone_tzid = strdup(buf);
__adjust_tzid(ud->timezone_tzid);
#include <vasum.h>
#include "calendar_errors.h"
+#include "cal_typedef.h"
#include "cal_internal.h"
#include "cal_zone.h"
#include "cal_utils.h"
RETV_IF(NULL == path, CALENDAR_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == canonicalize_path, CALENDAR_ERROR_INVALID_PARAMETER);
- char buf[1024] = {0};
+ char buf[CAL_STR_MIDDLE_LEN] = {0};
if (zone_name) {
if ('\0' == *zone_name)
snprintf(buf, sizeof(buf), "%s", path);
index++;
if (CALENDAR_TIME_LOCALTIME == alarm->alarm.type) {
- char alarm_datetime[32] = {0};
+ char alarm_datetime[CAL_STR_SHORT_LEN32] = {0};
snprintf(alarm_datetime, sizeof(alarm_datetime), CAL_FORMAT_LOCAL_DATETIME,
alarm->alarm.time.date.year,
alarm->alarm.time.date.month,
int y = 0, m = 0, d = 0;
int h = 0, n = 0, s = 0;
- char dtstart_datetime[32] = {0};
+ char dtstart_datetime[CAL_STR_SHORT_LEN32] = {0};
long long int dtstart_utime = 0;
calendar_time_s rectime = {0};
switch (len_datetime) {
int index;
int input_ver;
char query[CAL_DB_SQL_MAX_LEN] = {0};
- char dtstart_datetime[32] = {0};
- char dtend_datetime[32] = {0};
+ char dtstart_datetime[CAL_STR_SHORT_LEN32] = {0};
+ char dtend_datetime[CAL_STR_SHORT_LEN32] = {0};
sqlite3_stmt *stmt = NULL;
cal_event_s* event = (cal_event_s*)(record);
cal_rrule_s *rrule = NULL;
int y = 0, m = 0, d = 0;
int h = 0, n = 0, s = 0;
- char buf[32] = {0};
+ char buf[CAL_STR_SHORT_LEN32] = {0};
switch (strlen(p)) {
case 8:
DBG("ALLDAY instance");
long long int lli_e = 0;
int y = 0, m = 0, d = 0;
int h = 0, n = 0, s = 0;
- char buf_s[256] = {0};
- char buf_e[256] = {0};
+ char buf_s[CAL_STR_MIDDLE_LEN] = {0};
+ char buf_e[CAL_STR_MIDDLE_LEN] = {0};
RETV_IF(NULL == ucal, CALENDAR_ERROR_INVALID_PARAMETER);
/* set until before dtstart_utime */
long long int until_utime = ms2sec(ucal_getMillis(ucal, &ec));
- int byyearday[1024] = {0};
+ int byyearday[CAL_STR_MIDDLE_LEN] = {0};
int byyearday_len = 0;
_cal_db_instance_parse_byint(event->byyearday, byyearday, &byyearday_len);
DBG("byyearday len(%d)", byyearday_len);
- int bysetpos[1024] = {0};
+ int bysetpos[CAL_STR_MIDDLE_LEN] = {0};
int bysetpos_len = 0;
_cal_db_instance_parse_byint(event->bysetpos, bysetpos, &bysetpos_len);
DBG("bysetpos len(%d)", bysetpos_len);
}
DBG("byday_len (%d) week integer(0x%x)", byday_len, week_bits);
- int byweekno[1024] = {0};
+ int byweekno[CAL_STR_MIDDLE_LEN] = {0};
int byweekno_len = 0;
_cal_db_instance_parse_byint(event->byweekno, byweekno, &byweekno_len);
DBG("byweekno len(%d)", byweekno_len);
- int bysetpos[1024] = {0};
+ int bysetpos[CAL_STR_MIDDLE_LEN] = {0};
int bysetpos_len = 0;
_cal_db_instance_parse_byint(event->bysetpos, bysetpos, &bysetpos_len);
DBG("bysetpos len(%d)", bysetpos_len);
}
/* get bymonthday into array */
- int bymonthday[1024] = {0};
+ int bymonthday[CAL_STR_MIDDLE_LEN] = {0};
int bymonthday_len = 0;
_cal_db_instance_parse_byint(event->bymonthday, bymonthday, &bymonthday_len);
DBG("bymonthday_len(%d)", bymonthday_len);
__set_time_to_ucal(event->system_type, ucal, st);
int nth = ucal_get(ucal, UCAL_DAY_OF_WEEK_IN_MONTH, &ec);
int dtstart_wday = ucal_get(ucal, UCAL_DAY_OF_WEEK, &ec);
- char buf[32] = {0};
+ char buf[CAL_STR_SHORT_LEN32] = {0};
snprintf(buf, sizeof(buf), "%d%s", nth, week_text[dtstart_wday -1]);
DBG("set byday[%s]", buf);
}
DBG("[%s] byday_len(%d)", event->byday, byday_len);
- int bysetpos[1024] = {0};
+ int bysetpos[CAL_STR_MIDDLE_LEN] = {0};
int bysetpos_len = 0;
_cal_db_instance_parse_byint(event->bysetpos, bysetpos, &bysetpos_len);
DBG("bysetpos len(%d)", bysetpos_len);
if (0 == strlen(t[j])) continue;
/* get nth, wday */
int nth = 0;
- char wday[32] = {0};
+ char wday[CAL_STR_SHORT_LEN32] = {0};
sscanf(t[j], "%d%s", &nth, wday); /* -3SU, +2SA */
DBG("nth(%d) wday[%s]", nth, wday);
DBG("bymonth_len(%d)", bymonth_len);
/* get bymonthday into array */
- int bymonthday[1024] = {0};
+ int bymonthday[CAL_STR_MIDDLE_LEN] = {0};
int bymonthday_len = 0;
_cal_db_instance_parse_byint(event->bymonthday, bymonthday, &bymonthday_len);
if (0 == bymonthday_len) {
}
DBG("bymonthday len(%d)", bymonthday_len);
- int bysetpos[1024] = {0};
+ int bysetpos[CAL_STR_MIDDLE_LEN] = {0};
int bysetpos_len = 0;
_cal_db_instance_parse_byint(event->bysetpos, bysetpos, &bysetpos_len);
DBG("bysetpos len(%d)", bysetpos_len);
long long int until_utime = ms2sec(ucal_getMillis(ucal, &ec));
/* get bymonthday into array */
- int bymonthday[1024] = {0};
+ int bymonthday[CAL_STR_MIDDLE_LEN] = {0};
int bymonthday_len = 0;
_cal_db_instance_parse_byint(event->bymonthday, bymonthday, &bymonthday_len);
__set_time_to_ucal(event->system_type, ucal, st);
int week_nth = ucal_get(ucal, UCAL_DAY_OF_WEEK_IN_MONTH, &ec);
int dtstart_wday = ucal_get(ucal, UCAL_DAY_OF_WEEK, &ec);
- char buf[32] = {0};
+ char buf[CAL_STR_SHORT_LEN32] = {0};
snprintf(buf, sizeof(buf), "%d%s", week_nth, week_text[dtstart_wday -1]);
DBG("set byday[%s]", buf);
}
DBG("[%s] byday_len(%d)", event->byday, byday_len);
- int bysetpos[1024] = {0};
+ int bysetpos[CAL_STR_MIDDLE_LEN] = {0};
int bysetpos_len = 0;
_cal_db_instance_parse_byint(event->bysetpos, bysetpos, &bysetpos_len);
DBG("bysetpos len(%d)", bysetpos_len);
continue;
/* get nth, wday */
int nth = 0;
- char wday[32] = {0};
+ char wday[CAL_STR_SHORT_LEN32] = {0};
sscanf(t[i], "%d%s", &nth, wday); /* -3SU, +2SA */
DBG("nth(%d) wday[%s]", nth, wday);
long long int until_utime = ms2sec(ucal_getMillis(ucal, &ec));
/* get bymonthday into array */
- int bymonthday[1024] = {0};
+ int bymonthday[CAL_STR_MIDDLE_LEN] = {0};
int bymonthday_len = 0;
_cal_db_instance_parse_byint(event->bymonthday, bymonthday, &bymonthday_len);
if (0 == bymonthday_len) {
}
DBG("bymonthday_len(%d) [%s]", bymonthday_len, event->bymonthday);
- int bysetpos[1024] = {0};
+ int bysetpos[CAL_STR_MIDDLE_LEN] = {0};
int bysetpos_len = 0;
_cal_db_instance_parse_byint(event->bysetpos, bysetpos, &bysetpos_len);
DBG("bysetpos_len(%d)", bysetpos_len);
}
DBG("week integer(0x%x)", week_bits);
- int bysetpos[1024] = {0};
+ int bysetpos[CAL_STR_MIDDLE_LEN] = {0};
int bysetpos_len = 0;
_cal_db_instance_parse_byint(event->bysetpos, bysetpos, &bysetpos_len);
DBG("bysetpos len(%d)", bysetpos_len);
CAL_FREE(order);
}
- char buf[32] = {0};
+ char buf[CAL_STR_SHORT_LEN32] = {0};
if (0 < limit) {
snprintf(buf, sizeof(buf), "LIMIT %d", limit);
cal_db_append_string(&query_str, buf);
CAL_FREE(order);
}
- char buf[32] = {0};
+ char buf[CAL_STR_SHORT_LEN32] = {0};
if (0 < limit) {
snprintf(buf, sizeof(buf), "LIMIT %d", limit);
cal_db_append_string(&query_str, buf);
CAL_FREE(condition);
/* limit, offset */
- char buf[32] = {0};
+ char buf[CAL_STR_SHORT_LEN32] = {0};
if (0 < limit) {
snprintf(buf, sizeof(buf), "LIMIT %d", limit);
cal_db_append_string(&query_str, buf);
tm.tm_min = n;
tm.tm_sec = s;
- char buf[32] = {0};
+ char buf[CAL_STR_SHORT_LEN32] = {0};
switch (new_type) {
case CALENDAR_TIME_UTIME:
switch (strlen(t[i])) {
{
int ret = 0;
char query[CAL_DB_SQL_MAX_LEN] = {0};
- char dtstart_datetime[32] = {0};
- char dtend_datetime[32] = {0};
+ char dtstart_datetime[CAL_STR_SHORT_LEN32] = {0};
+ char dtend_datetime[CAL_STR_SHORT_LEN32] = {0};
sqlite3_stmt *stmt = NULL;
cal_event_s* event = (cal_event_s*)(record);
cal_rrule_s *rrule = NULL;
CAL_FREE(condition);
/* limit, offset */
- char buf[32] = {0};
+ char buf[CAL_STR_SHORT_LEN32] = {0};
if (0 < limit) {
snprintf(buf, sizeof(buf), "LIMIT %d", limit);
cal_db_append_string(&query_str, buf);
{
int ret = CALENDAR_ERROR_NONE;
char query[CAL_DB_SQL_MAX_LEN] = {0};
- char dtstart_datetime[32] = {0};
- char dtend_datetime[32] = {0};
+ char dtstart_datetime[CAL_STR_SHORT_LEN32] = {0};
+ char dtend_datetime[CAL_STR_SHORT_LEN32] = {0};
sqlite3_stmt *stmt = NULL;
cal_event_s* event = (cal_event_s*)(record);
cal_rrule_s *rrule = NULL;
CAL_FREE(order);
}
- char buf[32] = {0};
+ char buf[CAL_STR_SHORT_LEN32] = {0};
if (0 < limit) {
snprintf(buf, sizeof(buf), "LIMIT %d", limit);
cal_db_append_string(&query_str, buf);
CAL_FREE(condition);
/* limit, offset */
- char buf[32] = {0};
+ char buf[CAL_STR_SHORT_LEN32] = {0};
if (0 < limit) {
snprintf(buf, sizeof(buf), "LIMIT %d", limit);
cal_db_append_string(&query_str, buf);
CAL_FREE(condition);
/* limit, offset */
- char buf[32] = {0};
+ char buf[CAL_STR_SHORT_LEN32] = {0};
if (0 < limit) {
snprintf(buf, sizeof(buf), "LIMIT %d", limit);
cal_db_append_string(&query_str, buf);
CAL_FREE(condition);
/* limit, offset */
- char buf[32] = {0};
+ char buf[CAL_STR_SHORT_LEN32] = {0};
if (0 < limit) {
snprintf(buf, sizeof(buf), "LIMIT %d", limit);
cal_db_append_string(&query_str, buf);
CAL_FREE(condition);
/* limit, offset */
- char buf[32] = {0};
+ char buf[CAL_STR_SHORT_LEN32] = {0};
if (0 < limit) {
snprintf(buf, sizeof(buf), "LIMIT %d", limit);
cal_db_append_string(&query_str, buf);
CAL_FREE(condition);
/* limit, offset */
- char buf[32] = {0};
+ char buf[CAL_STR_SHORT_LEN32] = {0};
if (0 < limit) {
snprintf(buf, sizeof(buf), "LIMIT %d", limit);
cal_db_append_string(&query_str, buf);
CAL_FREE(order);
}
- char buf[32] = {0};
+ char buf[CAL_STR_SHORT_LEN32] = {0};
if (0 < limit) {
snprintf(buf, sizeof(buf), "LIMIT %d", limit);
cal_db_append_string(&query_str, buf);
int index = -1;
int input_ver;
char query[CAL_DB_SQL_MAX_LEN] = {0};
- char dtstart_datetime[32] = {0};
- char dtend_datetime[32] = {0};
+ char dtstart_datetime[CAL_STR_SHORT_LEN32] = {0};
+ char dtend_datetime[CAL_STR_SHORT_LEN32] = {0};
sqlite3_stmt *stmt = NULL;
cal_todo_s* todo = (cal_todo_s*)(record);
cal_rrule_s *rrule = NULL;
static int _cal_db_todo_update_record(calendar_record_h record)
{
char query[CAL_DB_SQL_MAX_LEN] = {0};
- char dtstart_datetime[32] = {0};
- char dtend_datetime[32] = {0};
+ char dtstart_datetime[CAL_STR_SHORT_LEN32] = {0};
+ char dtend_datetime[CAL_STR_SHORT_LEN32] = {0};
sqlite3_stmt *stmt = NULL;
cal_todo_s* todo = (cal_todo_s*)(record);
cal_rrule_s *rrule = NULL;
{
int ret = CALENDAR_ERROR_NONE;
char query[CAL_DB_SQL_MAX_LEN] = {0};
- char dtstart_datetime[32] = {0};
- char dtend_datetime[32] = {0};
+ char dtstart_datetime[CAL_STR_SHORT_LEN32] = {0};
+ char dtend_datetime[CAL_STR_SHORT_LEN32] = {0};
sqlite3_stmt *stmt = NULL;
cal_todo_s* todo = (cal_todo_s*)(record);
cal_rrule_s *rrule = NULL;
CAL_FREE(condition);
/* limit, offset */
- char buf[32] = {0};
+ char buf[CAL_STR_SHORT_LEN32] = {0};
if (0 < limit) {
snprintf(buf, sizeof(buf), "LIMIT %d", limit);
cal_db_append_string(&query_str, buf);
}
else {
char *bind_tmp = NULL;
- char bind_datetime[32] = {0};
+ char bind_datetime[CAL_STR_SHORT_LEN32] = {0};
snprintf(bind_datetime, sizeof(bind_datetime), CAL_FORMAT_LOCAL_DATETIME,
tmp.time.date.year,
tmp.time.date.month,
}
else {
char *bind_tmp = NULL;
- char bind_datetime[32] = {0};
+ char bind_datetime[CAL_STR_SHORT_LEN32] = {0};
snprintf(bind_datetime, sizeof(bind_datetime), CAL_FORMAT_LOCAL_DATETIME,
tmp.time.date.year,
tmp.time.date.month,
}
}
else if (filter->value.caltime.type == CALENDAR_TIME_LOCALTIME) {
- char sdate[32] = {0};
+ char sdate[CAL_STR_SHORT_LEN32] = {0};
snprintf(sdate, sizeof(sdate), CAL_FORMAT_LOCAL_DATETIME,
filter->value.caltime.time.date.year, filter->value.caltime.time.date.month, filter->value.caltime.time.date.mday,
filter->value.caltime.time.date.hour, filter->value.caltime.time.date.minute, filter->value.caltime.time.date.second);
int rrule_id;
int index;
char query[CAL_DB_SQL_MAX_LEN] = {0};
- char until_datetime[32] = {0};
+ char until_datetime[CAL_STR_SHORT_LEN32] = {0};
sqlite3_stmt *stmt = NULL;
int ret = 0;
static int _cal_db_rrule_update_record(int id, cal_rrule_s *rrule)
{
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- char until_datetime[32] = {0};
int ret = 0;
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ char until_datetime[CAL_STR_SHORT_LEN32] = {0};
sqlite3_stmt *stmt = NULL;
snprintf(query, sizeof(query),
int type; /* utime, localtime */
long long int time;
int record; /* todo, event */
- char datetime[32];
+ char datetime[CAL_STR_SHORT_LEN32];
int system_type;
};
struct tm st_local = {0};
localtime_r(&utime, &st_local);
- char datetime[32] = {0};
+ char datetime[CAL_STR_SHORT_LEN32] = {0};
snprintf(datetime, sizeof(datetime), CAL_FORMAT_LOCAL_DATETIME,
st_local.tm_year +1900, st_local.tm_mon + 1, st_local.tm_mday,
st_local.tm_hour, st_local.tm_min, st_local.tm_sec);
DBG("pkg[%s] time[%lld] tick[%d] unit[%d] record_type[%d]",
package, ad->time, ad->tick, ad->unit, ad->record);
- char buf_event_id[128] = {0};
- char buf_time[128] = {0};
- char buf_tick[128] = {0};
- char buf_unit[128] = {0};
- char buf_record_type[128] = {0};
- snprintf(buf_event_id, sizeof(buf_event_id), "%d", ad->event_id);
- snprintf(buf_time, sizeof(buf_time), "%lld", ad->time);
- snprintf(buf_tick, sizeof(buf_tick), "%d", ad->tick);
- snprintf(buf_unit, sizeof(buf_unit), "%d", ad->unit);
- snprintf(buf_record_type, sizeof(buf_record_type), "%d", ad->record);
-
- char *p = NULL;
- cal_server_reminder_add_callback_data(&p, "id", buf_event_id);
- cal_server_reminder_add_callback_data(&p, "time", buf_time);
- cal_server_reminder_add_callback_data(&p, "tick", buf_tick);
- cal_server_reminder_add_callback_data(&p, "unit", buf_unit);
- cal_server_reminder_add_callback_data(&p, "type", buf_record_type);
-
- app_control_add_extra_data(b, buf_event_id, p); // key: id, value: id=4&time=123123&..
- DBG("value[%s]", p);
- free(p);
-
- // append ids
- ids[i] = strdup(buf_event_id);
+ int len = 0;
+ char extra[CAL_STR_MIDDLE_LEN] = {0};
+ len = snprintf(extra, sizeof(extra), "%s=%d", "id", ad->event_id);
+ len += snprintf(extra+len, sizeof(extra)-len, "&%s=%lld", "time", ad->time);
+ len += snprintf(extra+len, sizeof(extra)-len, "&%s=%d", "tick", ad->tick);
+ len += snprintf(extra+len, sizeof(extra)-len, "&%s=%d", "unit", ad->unit);
+ len += snprintf(extra+len, sizeof(extra)-len, "&%s=%d", "type", ad->record);
+
+ char buf_id[CAL_STR_MIDDLE_LEN] = {0};
+ snprintf(buf_id, sizeof(buf_id), "%d", ad->event_id);
+ app_control_add_extra_data(b, buf_id, extra); /* key: id, value: id=4&time=123123&.. */
+ DBG("value[%s]", extra);
+
+ /* append ids */
+ ids[i] = strdup(buf_id);
l = g_list_next(l);
}
DBG("callback time[%lld] tick[%d] unit[%d] record_type[%d]",
ad->time, ad->tick, ad->unit, ad->record);
- char buf_event_id[128] = {0};
- char buf_time[128] = {0};
- char buf_tick[128] = {0};
- char buf_unit[128] = {0};
- char buf_record_type[128] = {0};
- snprintf(buf_event_id, sizeof(buf_event_id), "%d", ad->event_id);
- snprintf(buf_time, sizeof(buf_time), "%lld", ad->time);
- snprintf(buf_tick, sizeof(buf_tick), "%d", ad->tick);
- snprintf(buf_unit, sizeof(buf_unit), "%d", ad->unit);
- snprintf(buf_record_type, sizeof(buf_record_type), "%d", ad->record);
-
- char *p = NULL;
- cal_server_reminder_add_callback_data(&p, "id", buf_event_id);
- cal_server_reminder_add_callback_data(&p, "time", buf_time);
- cal_server_reminder_add_callback_data(&p, "tick", buf_tick);
- cal_server_reminder_add_callback_data(&p, "unit", buf_unit);
- cal_server_reminder_add_callback_data(&p, "type", buf_record_type);
- cal_server_reminder_publish(p);
- free(p);
+ int len = 0;
+ char extra[CAL_STR_MIDDLE_LEN] = {0};
+ len = snprintf(extra, sizeof(extra), "%s=%d", "id", ad->event_id);
+ len += snprintf(extra+len, sizeof(extra)-len, "&%s=%lld", "time", ad->time);
+ len += snprintf(extra+len, sizeof(extra)-len, "&%s=%d", "tick", ad->tick);
+ len += snprintf(extra+len, sizeof(extra)-len, "&%s=%d", "unit", ad->unit);
+ len += snprintf(extra+len, sizeof(extra)-len, "&%s=%d", "type", ad->record);
+
+ cal_server_reminder_publish(extra, len);
l = g_list_next(l);
}
DBG("alarm_id (%ld)", alarm_id);
time_t tt_alert = 0;
- char *zone_name = data;
cal_server_alarm_get_alert_time(alarm_id, &tt_alert);
cal_server_alarm_alert(tt_alert);
_cal_server_alarm_unset_alerted_alarmmgr_id(alarm_id);
#define CAL_SUBSCRIBE_MAX_LEN 1024
-static gboolean _cal_server_reminder_publish_changes_with_data(char *data, int len)
+void cal_server_reminder_publish(char *p, int p_len)
{
- pims_ipc_data_h indata = NULL;
- if (NULL == data)
- {
- ERR("Invalid parameter: data is NULL");
- return true;
- }
+ RET_IF(NULL == p);
+ pims_ipc_data_h indata = NULL;
indata = pims_ipc_data_create(0);
- if (NULL == indata)
- {
- ERR("pims_ipc_data_create() failed");
- return false;
- }
- if (pims_ipc_data_put(indata, &len, sizeof(int)) != 0)
- {
- ERR("pims_ipc_data_put() failed");
+ RETM_IF(NULL == indata, "pims_ipc_data_create() Fail");
+
+ if (pims_ipc_data_put(indata, &p_len, sizeof(int)) != 0) {
+ ERR("pims_ipc_data_put() Fail");
pims_ipc_data_destroy(indata);
- return false;
+ return;
}
- if (pims_ipc_data_put(indata, data, strlen(data) + 1) != 0)
- {
- ERR("pims_ipc_data_put() failed");
+ if (pims_ipc_data_put(indata, p, p_len + 1) != 0) {
+ ERR("pims_ipc_data_put() Fail");
pims_ipc_data_destroy(indata);
- return false;
+ return;
}
- if (pims_ipc_svc_publish(CAL_IPC_MODULE_FOR_SUBSCRIPTION, (char *)CAL_NOTI_REMINDER_CAHNGED, indata) != 0)
- {
- ERR("pims_ipc_svc_publish() failed");
+ if (pims_ipc_svc_publish(CAL_IPC_MODULE_FOR_SUBSCRIPTION, (char *)CAL_NOTI_REMINDER_CAHNGED, indata) != 0) {
+ ERR("pims_ipc_svc_publish() Fail");
pims_ipc_data_destroy(indata);
- return false;
+ return;
}
pims_ipc_data_destroy(indata);
- return true;
-}
-
-void cal_server_reminder_publish(char *p)
-{
- RET_IF(NULL == p);
- _cal_server_reminder_publish_changes_with_data(p, strlen(p));
}
int cal_server_reminder_add_callback_data(char **p, char *key, char *value)
#ifndef __CAL_SERVER_REMINDER_H__
#define __CAL_SERVER_REMINDER_H__
-void cal_server_reminder_publish(char *p);
+void cal_server_reminder_publish(char *p, int p_len);
int cal_server_reminder_add_callback_data(char **p, char *key, char *value);
#endif /* __CAL_SERVER_REMINDER_H__ */
sqlite3 *__db;
char query[CAL_DB_SQL_MAX_LEN] = {0};
- char db_file[256] = {0};
+ char db_file[CAL_STR_MIDDLE_LEN] = {0};
snprintf(db_file, sizeof(db_file), "%s/%s", DB_PATH, CALS_DB_NAME);
ret = db_util_open(db_file, &__db, 0);
if (SQLITE_OK != ret) {
}
DBG("schema init");
- char path[1024] = {0};
+ char path[CAL_STR_MIDDLE_LEN] = {0};
int len = 0;
len = cal_zone_get_root_path(zone_name, path, sizeof(path));
snprintf(path+len, sizeof(path)-len, "%s", "/opt/usr/dbspace/");
vsm_zone_h old_zone = NULL;
int len = 0;
- char path[1024] = {0};
+ char path[CAL_STR_MIDDLE_LEN] = {0};
switch (state) {
case VSM_ZONE_STATE_STARTING:
DBG("STARTING");