else
return TRUE;
}
- if (ret > ie.len)
+ if (ie.len < ret)
{
ie.len = 0;
}
cal_mutex_lock(CAL_MUTEX_INOTIFY);
calendar_inoti_count++;
- if (calendar_inoti_count > 1)
+ if (1 < calendar_inoti_count)
{
DBG("inotify count =%d",calendar_inoti_count);
cal_mutex_unlock(CAL_MUTEX_INOTIFY);
cal_mutex_lock(CAL_MUTEX_INOTIFY);
calendar_inoti_count--;
- if (calendar_inoti_count > 0)
+ if (0 < calendar_inoti_count)
{
DBG("inotify count =%d",calendar_inoti_count);
cal_mutex_unlock(CAL_MUTEX_INOTIFY);
noti_list = NULL;
}
- if (inoti_fd >= 0)
+ if (0 <= inoti_fd)
{
close(inoti_fd);
inoti_fd = -1;
return CALENDAR_ERROR_NONE;
}
- ERR("Check index(%d) > count(%d)", index, list_s->count);
+ ERR("Check count(%d) < index(%d)", list_s->count, index);
return CALENDAR_ERROR_NO_DATA;
}
cal_filter_clone((calendar_filter_h)que->filter,(calendar_filter_h*)&out_filter);
}
- if (que->projection_count > 0)
+ if (0 < que->projection_count)
{
out_que->projection = calloc(que->projection_count, sizeof(unsigned int));
RETVM_IF(NULL == out_que->projection, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc() Fail");
int count = 0;
cal_view_get_property_info(_record->view_uri,&count);
- if (count > 0)
+ if (0 < count)
{
_record->properties_flags = calloc(count, sizeof(char));
_record->properties_max_count = count;
(cal_rec->visibility) = value;
break;
case CAL_PROPERTY_CALENDAR_ACCOUNT_ID:
- RETVM_IF(cal_rec->index > 0, CALENDAR_ERROR_INVALID_PARAMETER, "property_id(%d) is a write-once value (calendar)", property_id);
+ RETVM_IF(0 < cal_rec->index, CALENDAR_ERROR_INVALID_PARAMETER, "property_id(%d) is a write-once value (calendar)", property_id);
(cal_rec->account_id) = value;
break;
case CAL_PROPERTY_CALENDAR_STORE_TYPE:
(rec->id) = value;
break;
case CAL_PROPERTY_EXTENDED_RECORD_ID:
- RETVM_IF(rec->id > 0, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter : property_id(%d) is a write-once value (calendar)", property_id);
+ RETVM_IF(0 < rec->id, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter : property_id(%d) is a write-once value (calendar)", property_id);
(rec->record_id) = value;
break;
case CAL_PROPERTY_EXTENDED_RECORD_TYPE:
return NULL;
}
- if (wkst >= CALENDAR_SUNDAY && wkst <= CALENDAR_SATURDAY)
+ if (CALENDAR_SUNDAY <= wkst && wkst <= CALENDAR_SATURDAY)
{
DBG("set wkst(%d)", wkst);
ucal_setAttribute(ucal, UCAL_FIRST_DAY_OF_WEEK, wkst);
return NULL;
}
- if (wkst >= CALENDAR_SUNDAY && wkst <= CALENDAR_SATURDAY)
+ if (CALENDAR_SUNDAY <= wkst && wkst <= CALENDAR_SATURDAY)
{
ucal_setAttribute(ucal, UCAL_FIRST_DAY_OF_WEEK, wkst);
}
static char buf[32] = {0};
int i = 0;
- if (tick > 0) {
+ if (0 < tick) {
*buf = '-';
i++;
p = t[i];
num = atoi(p);
- len += snprintf(buf +len, buf_len -len, "%d%s ", num, num > 0 ? "" : "-");
+ len += snprintf(buf +len, buf_len -len, "%d%s ", num, 0 < num? "": "-");
}
g_strfreev(t);
int sign = 0;
while (i <= len) {
// extract -1, 1 from 1SU,-1SU
- if ((byday[i] >= '1' && byday[i] <= '9')) {
+ if ('1' <= byday[i] && byday[i] <= '9') {
is_working = false;
digit++;
} else if ('+' == byday[i]) {
p++;
j = 0;
- while (p[j] == '+' || p[j] == '-' || (p[j] >= '1' && p[j] <= '9')) // get number length
+ while (p[j] == '+' || p[j] == '-' || ('1' <= p[j] && p[j] <= '9')) // get number length
j++;
if (strstr(buf, p +j)) // already appended
continue;
const char wday[7][3] = {"SU", "MO", "TU", "WE", "TH", "FR", "SA"};
int wkst = 0;
calendar_record_get_int(record, _calendar_event.wkst, &wkst);
- if (wkst < CALENDAR_SUNDAY || wkst > CALENDAR_SATURDAY)
+ if (wkst < CALENDAR_SUNDAY || CALENDAR_SATURDAY < wkst)
return;
DBG("wkst(%d) [%s]", wkst, wday[wkst - 1]);
p = t[i];
j = 0; // get number
- while (p[j] == '+' || p[j] == '-' || (p[j] >= '1' && p[j] <= '9'))
+ while (p[j] == '+' || p[j] == '-' || ('1' <= p[j] && p[j] <= '9'))
j++;
- if (j > 0)
+ if (0 < j)
{
if (CALENDAR_RECURRENCE_WEEKLY == rrule_type)
{
int interval = 1;
ret = calendar_record_get_int(record, _calendar_event.interval, &interval);
RETM_IF(CALENDAR_ERROR_NONE != ret, "calendar_record_get_int() Fail(%d)", ret);
- interval = interval > 0 ? interval : 1;
+ interval = 0 < interval ? interval : 1;
char *byyearday = NULL;
ret = calendar_record_get_str_p(record, _calendar_event.byyearday, &byyearday);
int interval = 1;
ret = calendar_record_get_int(record, _calendar_event.interval, &interval);
WARN_IF(CALENDAR_ERROR_NONE != ret, "calendar_record_get_int() Fail(%d)", ret);
- interval = interval > 0 ? interval : 1;
+ interval = 0 < interval ? interval : 1;
snprintf(tmp, sizeof(tmp), ";INTERVAL=%d", interval);
_cal_vcalendar_make_set_str(b, tmp);
int wkst = 0;
ret = calendar_record_get_int(record, _calendar_event.wkst, &wkst);
WARN_IF(CALENDAR_ERROR_NONE != ret, "calendar_record_get_int() Fail(%d)", ret);
- if (wkst >= CALENDAR_SUNDAY && wkst <= CALENDAR_SATURDAY) {
+ if (CALENDAR_SUNDAY <= wkst && wkst <= CALENDAR_SATURDAY) {
_cal_vcalendar_make_set_str(b, ";WKST=");
switch (wkst) {
case CALENDAR_SUNDAY:
int i = 0;
while (*(p +i)) {
if ('-' == *(p +i)) {
- if ('1' <= *(p +i +1) && '9' >= *(p +i +1)) {
+ if ('1' <= *(p +i +1) && *(p +i +1) <= '9') {
i++;
} else {
*(p +i) = '/';
RET_IF('\0' == *value);
RET_IF(NULL == record);
RET_IF(NULL == ud);
- RETM_IF(*value < '0' || *value > '9', "out of range[%s]", value);
+ RETM_IF(*value < '0' || '9' < *value, "out of range[%s]", value);
int ret = 0;
int modified_priority = __decode_priority(value, ud);
if (index) index++;
if (NULL == t[i] || '\0' == *t[i]) continue;
- if ('0' <= *t[i] && *t[i] <= '9' && strlen(t[i]) > strlen("PTM")) { // runTime
+ if ('0' <= *t[i] && *t[i] <= '9' && strlen("PTM") < strlen(t[i])) { // runTime
index = 1;
calendar_time_s caltime = {0};
__get_caltime(t[i], &caltime, ud);
if (index) index++;
if (NULL == t[i] || '\0' == *t[i]) continue;
- if ('0' <= *t[i] && *t[i] <= '9' && strlen(t[i]) > strlen("PTM")) { // runTime
+ if ('0' <= *t[i] && *t[i] <= '9' && strlen("PTM") < strlen(t[i])) { // runTime
index = 1;
calendar_time_s caltime = {0};
__get_caltime(t[i], &caltime, ud);
if (index) index++;
if (NULL == t[i] || '\0' == *t[i]) continue;
- if ('0' <= *t[i] && *t[i] <= '9' && strlen(t[i]) > strlen("PTM")) { // runTime
+ if ('0' <= *t[i] && *t[i] <= '9' && strlen("PTM") < strlen(t[i])) { // runTime
index = 1;
calendar_time_s caltime = {0};
__get_caltime(t[i], &caltime, ud);
} else if (!strncmp(t[i], "VALUE", strlen("VALUE"))) {
// do nothing
} else {
- if ('0' <= *t[i] && *t[i] <= '9' && strlen(t[i]) >= strlen("YYYYDDMM")) {
+ if ('0' <= *t[i] && *t[i] <= '9' && strlen("YYYYDDMM") <= strlen(t[i])) {
calendar_time_s caltime = {0};
__get_caltime(t[i], &caltime, ud);
ret = cal_record_set_caltime(alarm, _calendar_alarm.alarm_time, caltime);
int unit = 0;
int tick = 0;
__decode_duration(t[i], strlen(t[i]), &tick, &unit);
- if (CALENDAR_ALARM_TIME_UNIT_SPECIFIC == unit || tick > 0) {
- if (CALENDAR_ALARM_TIME_UNIT_SPECIFIC == unit) DBG("alarm tick is second, changed as specific.");
- if (tick > 0) DBG("alarm is set after start/end time(%d).", tick);
+ if (CALENDAR_ALARM_TIME_UNIT_SPECIFIC == unit || 0 < tick) {
+ if (CALENDAR_ALARM_TIME_UNIT_SPECIFIC == unit)
+ DBG("alarm tick is second, changed as specific.");
+ if (0 < tick)
+ DBG("alarm is set after start/end time(%d).", tick);
calendar_time_s caltime = {0};
if (VCAL_RELATED_NONE == related) {
return CALENDAR_ERROR_NO_DATA;
}
common->properties_max_count = *(unsigned int*)ret_pims;
- if (common->properties_max_count > 0) {
+ if (0 < common->properties_max_count) {
unsigned char *tmp_properties_flags;
ret_pims = pims_ipc_data_get(ipc_data,&size);
if (NULL == ret_pims) {
return CALENDAR_ERROR_NO_DATA;
}
- if (common->properties_max_count > 0) {
+ if (0 < common->properties_max_count) {
if(pims_ipc_data_put(ipc_data,(void*)common->properties_flags,sizeof(char)*common->properties_max_count) < 0) {
ERR("cal_ipc_marshal fail");
return CALENDAR_ERROR_NO_DATA;
goto ERROR_RETURN;
}
- if (que->projection_count > 0) {
+ if (0 < que->projection_count) {
que->projection = (unsigned int*)calloc(que->projection_count, sizeof(int));
if (que->projection == NULL) {
ERR("calloc() Fail");
#ifndef __CALENDAR_SVC_CALENDAR_H__
#define __CALENDAR_SVC_CALENDAR_H__
-void cal_calendar_internal_disconnect(const char *zone_name);
-int cal_connect(const char *zone_name);
-int cal_disconnect(const char *zone_name);
+void cal_calendar_internal_disconnect(void);
+int cal_connect(void);
+int cal_disconnect(void);
#endif // __CALENDAR_SVC_CALENDAR_H__
}
/* delete event table */
- len = snprintf(query, sizeof(query), "DELETE FROM %s "
- "WHERE is_deleted = 1 AND calendar_id = %d",
- CAL_TABLE_SCHEDULE,
- calendar_book_id);
- if (calendar_db_version > 0)
- {
+ len = snprintf(query, sizeof(query), "DELETE FROM %s WHERE is_deleted = 1 AND calendar_id = %d",
+ CAL_TABLE_SCHEDULE, calendar_book_id);
+ if (0 < calendar_db_version)
len = snprintf(query+len, sizeof(query)-len, " AND changed_ver <= %d", calendar_db_version);
- }
dbret = cal_db_util_query_exec(query);
DBG("%s",query);
DBG("insert with id(%d)", _ids[i]);
calendar_list_next(list);
- if (i > bulk)
+ if (bulk < i)
{
bulk += (_count / div + 1);
cal_db_util_end_trans(true);
DBG("update record");
calendar_list_next(list);
- if (i > bulk)
+ if (bulk < i)
{
bulk += (count / div + 1);
cal_db_util_end_trans(true);
}
calendar_list_next(list);
- if (i > bulk)
+ if (bulk < i)
{
bulk += (count / div + 1);
cal_db_util_end_trans(true);
ret = plugin_cb->replace_record(record, record_id);
if (CALENDAR_ERROR_NONE == ret)
- {
ret = cal_db_util_end_trans(true);
- }
else
- {
cal_db_util_end_trans(false);
- }
return ret;
}
cal_db_util_error_e dbret = CAL_DB_OK;
DBG("original_event(%d) changed_ver updated", original_event_id);
- if (original_event_id > 0) {
- snprintf(query, sizeof(query), "UPDATE %s SET "
- "changed_ver = %d, has_exception = 1 WHERE id = %d ",
+ if (0 < original_event_id) {
+ snprintf(query, sizeof(query), "UPDATE %s SET changed_ver=%d, has_exception = 1 WHERE id=%d ",
CAL_TABLE_SCHEDULE, version, original_event_id);
dbret = cal_db_util_query_exec(query);
switch (event->start.type) {
case CALENDAR_TIME_UTIME:
- if (event->start.time.utime > event->end.time.utime) {
- ERR("normal start(%lld) > end(%lld)",
- event->start.time.utime, event->end.time.utime);
+ if (event->end.time.utime < event->start.time.utime) {
+ ERR("normal end(%lld) < start(%lld)",
+ event->end.time.utime, event->start.time.utime);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
break;
case CALENDAR_TIME_LOCALTIME:
// check invalid value
- if (event->start.time.date.month < 1 || event->start.time.date.month > 12) {
+ if (event->start.time.date.month < 1 || 12 < event->start.time.date.month) {
ERR("check start month(input:%d)", event->start.time.date.month);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
- else if (event->start.time.date.mday < 1 || event->start.time.date.mday > 31) {
+ else if (event->start.time.date.mday < 1 || 31 < event->start.time.date.mday) {
ERR("check start mday(input:%d)", event->start.time.date.mday);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
- else if (event->end.time.date.month < 1 || event->end.time.date.month > 12) {
+ else if (event->end.time.date.month < 1 || 12 < event->end.time.date.month) {
ERR("check end month(input:%d)", event->end.time.date.month);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
- else if (event->end.time.date.mday < 1 || event->end.time.date.mday > 31) {
+ else if (event->end.time.date.mday < 1 || 31 < event->end.time.date.mday) {
ERR("check end mday(input:%d)", event->end.time.date.mday);
return CALENDAR_ERROR_INVALID_PARAMETER;
} else { // handle hour, minute, second
- if (event->start.time.date.hour < 0 || event->start.time.date.hour > 24) event->start.time.date.hour = 0;
- if (event->start.time.date.minute < 0 || event->start.time.date.minute > 60) event->start.time.date.minute = 0;
- if (event->start.time.date.second < 0 || event->start.time.date.second > 60) event->start.time.date.second = 0;
- if (event->end.time.date.hour < 0 || event->end.time.date.hour > 24) event->end.time.date.hour = 0;
- if (event->end.time.date.minute < 0 || event->end.time.date.minute > 60) event->end.time.date.minute = 0;
- if (event->end.time.date.second < 0 || event->end.time.date.second > 60) event->end.time.date.second = 0;
+ if (event->start.time.date.hour < 0 || 24 < event->start.time.date.hour)
+ event->start.time.date.hour = 0;
+ if (event->start.time.date.minute < 0 || 60 < event->start.time.date.minute)
+ event->start.time.date.minute = 0;
+ if (event->start.time.date.second < 0 || 60 < event->start.time.date.second)
+ event->start.time.date.second = 0;
+ if (event->end.time.date.hour < 0 || 24 < event->end.time.date.hour)
+ event->end.time.date.hour = 0;
+ if (event->end.time.date.minute < 0 || 60 < event->end.time.date.minute)
+ event->end.time.date.minute = 0;
+ if (event->end.time.date.second < 0 || 60 < event->end.time.date.second)
+ event->end.time.date.second = 0;
}
- // check start > end; convert long long int.
+ // check end < start; convert long long int.
slli = cal_time_convert_itol(NULL,
event->start.time.date.year, event->start.time.date.month, event->start.time.date.mday,
event->start.time.date.hour, event->start.time.date.minute, event->start.time.date.second);
event->end.time.date.year, event->end.time.date.month, event->end.time.date.mday,
event->end.time.date.hour, event->end.time.date.minute, event->end.time.date.second);
- if (slli - elli > 1) { // 1 is to ignore milliseconds
- ERR("allday start(%lld) > end(%lld)", slli, elli);
+ if (1 < slli - elli) { // 1 is to ignore milliseconds
+ ERR("allday end(%lld) < start(%lld)", elli, slli);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
break;
(long long int)0, 0, //event->completed_time, event->progress,
event->start.type, event->start.type == CALENDAR_TIME_UTIME ? event->start.time.utime : 0,
event->end.type, event->end.type == CALENDAR_TIME_UTIME ? event->end.time.utime : 0,
- event->freq > 0 ? 1 : 0,
+ 0 < event->freq ? 1 : 0,
(0 < event->attendee_list->count) ? 1 : 0,
has_alarm,
event->system_type,
cal_db_rrule_insert_record(event_id, rrule);
CAL_FREE(rrule);
}
- if (original_event_id > 0) {
+ if (0 < original_event_id) {
cal_record_set_int(record, _calendar_event.original_event_id, original_event_id);
}
cal_db_instance_publish_record(record);
static inline int __cal_db_instance_has_after(calendar_time_s *t1, calendar_time_s *t2)
{
- if (t1->type == CALENDAR_TIME_UTIME) {
- if (t1->time.utime > t2->time.utime)
- return 1;
- else
- return 0;
- }
+ if (t1->type == CALENDAR_TIME_UTIME)
+ return t1->time.utime < t2->time.utime ? 0 : 1;
DBG("%d %d %d /%d %d %d", t1->time.date.year, t1->time.date.month, t1->time.date.mday,
t2->time.date.year, t2->time.date.month, t2->time.date.mday);
- if (t1->time.date.year > t2->time.date.year) {
- DBG("exit year");
- return 1;
- } else if (t1->time.date.year < t2->time.date.year) {
- return 0;
- } else {
- if (t1->time.date.month > t2->time.date.month) {
- return 1;
- } else if (t1->time.date.month < t2->time.date.month) {
- return 0;
- } else {
- if (t1->time.date.mday > t2->time.date.mday) {
- return 1;
- } else {
- return 0;
- }
+
+ if (t1->time.date.year == t2->time.date.year) {
+ if (t1->time.date.month == t2->time.date.month) {
+ return t1->time.date.mday < t2->time.date.mday ? 0 : 1;
}
+ return t1->time.date.month < t2->time.date.month ? 0 : 1;
}
+ return t1->time.date.year < t2->time.date.year ? 0 : 1;
}
static inline int _cal_db_instance_convert_mday(const char *str, int *mday)
RETV_IF(*str, CALENDAR_ERROR_INVALID_PARAMETER);
d = atoi(str);
- RETVM_IF(d < 1 || d > 31, CALENDAR_ERROR_INVALID_PARAMETER, "day(%d)", d);
+ RETVM_IF(d < 1 || 31 < d, CALENDAR_ERROR_INVALID_PARAMETER, "day(%d)", d);
DBG("get mday[%s] and convert to int(%d)", str, d);
*mday = d;
switch (st->type) {
case CALENDAR_TIME_UTIME:
- if (st->time.utime > et->time.utime) {
- ERR("check time: start(%lld) > end(%lld)", st->time.utime, et->time.utime);
+ if ( et->time.utime < st->time.utime) {
+ ERR("check time: end(%lld < start(%lld)", et->time.utime, st->time.utime);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
_duration = et->time.utime - st->time.utime;
__get_allday_date(event, ucal, &y, &m, &d, &h, &n, &s);
snprintf(buf_s, sizeof(buf_s), CAL_FORMAT_LOCAL_DATETIME, y, m, d, h, n, s);
- if (duration > 0) {
+ if (0 < duration) {
UCalendar *ucal2 = NULL;
ucal2 = ucal_clone(ucal, &ec);
ucal_add(ucal2, UCAL_SECOND, duration, &ec);
case CALENDAR_TIME_UTIME:
range = cal_time_convert_itol(NULL, CAL_ENDLESS_LIMIT_YEAR,
CAL_ENDLESS_LIMIT_MONTH, CAL_ENDLESS_LIMIT_MDAY, 0, 0, 0);
- if (event->until.time.utime > range) {
- DBG("until time(%lld) > max, so set max(%lld)", event->until.time.utime, range);
+ if (range < event->until.time.utime) {
+ DBG("range max < until time(%lld), so set max(%lld)", event->until.time.utime, range);
until->time.utime = range;
} else {
until->time.utime = event->until.time.utime;
break;
case CALENDAR_TIME_LOCALTIME:
- until->time.date.year = event->until.time.date.year > CAL_ENDLESS_LIMIT_YEAR ?
+ until->time.date.year = CAL_ENDLESS_LIMIT_YEAR < event->until.time.date.year ?
CAL_ENDLESS_LIMIT_YEAR : event->until.time.date.year;
until->time.date.month = event->until.time.date.month;
until->time.date.mday = event->until.time.date.mday;
return false;
for (i = 0; i < bysetpos_len; i++) {
- if (bysetpos[i] > 0) {
+ if (0 < bysetpos[i]) {
if (bysetpos[i] == (index + 1)) {
return false;
}
{
case CALENDAR_RANGE_UNTIL:
case CALENDAR_RANGE_NONE:
- if (current_utime > until_utime) {
+ if (until_utime < current_utime) {
DBG("(%lld) (%lld)", current_utime, until_utime);
return true;
}
case CALENDAR_RANGE_COUNT:
(*count)++;
- if (*count > event->count) {
+ if (event->count < *count) {
DBG("(%d) (%d)", *count, event->count);
return true;
}
- if (current_utime > CAL_ENDLESS_LIMIT_UTIME) { // event count is remained, it should not go over LIMIT
- DBG("stopped because dtstart(%lld) > LIMIT UTIME(%lld)", current_utime, (long long int)CAL_ENDLESS_LIMIT_UTIME);
+ if (CAL_ENDLESS_LIMIT_UTIME < current_utime) { // event count is remained, it should not go over LIMIT
+ DBG("stopped because LIMIT UTIME(%lld) < dtstart(%lld)", (long long int)CAL_ENDLESS_LIMIT_UTIME, current_utime);
return true;
}
break;
ucal_set(ucal, UCAL_DATE, 1);
int wkst = ucal_getAttribute(ucal, UCAL_FIRST_DAY_OF_WEEK);
int first_wday = ucal_get(ucal, UCAL_DAY_OF_WEEK, &ec);
- extra_weekno = ((first_wday+7-wkst)%7) > 3 ? 1 : 0;
+ extra_weekno = 3 < ((first_wday+7-wkst)%7) ? 1 : 0;
ucal_setMillis(ucal, ms2sec(start_point), &ec); // set start point
int i, j, k;
for (i = 0; i < bymonth_len; i++) {
- if (strlen(t[0]) > 2) { // -3SU, +2SA
+ if (2 < strlen(t[0])) { // -3SU, +2SA
for (j = 0; j < byday_len; j++) {
if (0 == strlen(t[j])) continue;
// get nth, wday
int wday_int = __convert_wday_to_int(wday);
// set nth, wday
- if (nth > 0) {
+ if (0 < nth) {
ucal_set(ucal, UCAL_DAY_OF_WEEK, wday_int);
ucal_set(ucal, UCAL_DAY_OF_WEEK_IN_MONTH, 1);
ucal_set(ucal, UCAL_MONTH, false == has_bymonth ? 0 : (bymonth[i] - 1));
int i, j;
for (j = 0; j < bymonth_len; j++) {
for (i = 0 ; i < bymonthday_len; i++) {
- if (bymonthday[i] > 0) {
+ if (0 < bymonthday[i]) {
ucal_set(ucal, UCAL_MONTH, bymonth[j] - 1);
ucal_set(ucal, UCAL_DATE, bymonthday[i]);
int get_mday = ucal_get(ucal, UCAL_DATE, &ec);
RETV_IF(NULL == ucal, CALENDAR_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == event, CALENDAR_ERROR_INVALID_PARAMETER);
- if (event->byyearday && strlen(event->byyearday) > 0) {
+ if (event->byyearday && 0 < strlen(event->byyearday)) {
_cal_db_instance_publish_yearly_yday(ucal, event, duration);
- } else if (event->byweekno && strlen(event->byweekno) > 0) {
+ } else if (event->byweekno && 0 < strlen(event->byweekno)) {
_cal_db_instance_publish_yearly_weekno(ucal, event, duration);
} else {
ucal_setMillis(ucal, ucal_getMillis(ucal, &ec), &ec); // set start point
int i, j, k;
- if (strlen(t[0]) > 2) { // -3SU, +2SA
+ if (2 < strlen(t[0])) { // -3SU, +2SA
for (i = 0; i < byday_len; i++) {
if (0 == strlen(t[i])) continue;
// get nth, wday
int wday_int = __convert_wday_to_int(wday);
// set nth, wday
- if (nth > 0) {
- if (nth > 4) {
+ if (0 < nth) {
+ if (4 < nth) {
ucal_set(ucal, UCAL_DAY_OF_WEEK, wday_int);
ucal_set(ucal, UCAL_DAY_OF_WEEK_IN_MONTH, -1);
int i;
for (i = 0 ; i < bymonthday_len; i++) {
- if (bymonthday[i] > 0) {
+ if (0 < bymonthday[i]) {
ucal_set(ucal, UCAL_MONTH, ucal_get(ucal, UCAL_MONTH, &ec));
ucal_set(ucal, UCAL_DATE, bymonthday[i]);
int get_mday = ucal_get(ucal, UCAL_DATE, &ec);
RETV_IF(NULL == ucal, CALENDAR_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == event, CALENDAR_ERROR_INVALID_PARAMETER);
- if (event->byday && strlen(event->byday) > 0) {
+ if (event->byday && 0 < strlen(event->byday))
_cal_db_instance_publish_monthly_wday(ucal, event, duration);
-
- } else {
+ else
_cal_db_instance_publish_monthly_mday(ucal, event, duration);
- }
+
return CALENDAR_ERROR_NONE;
}
_cal_db_instance_get_duration(ucal, &event->start, &event->end, &duration);
WARN_IF(duration < 0, "Invalid duration (%lld)", duration);
- if (event->original_event_id > 0)
+ if (0 < event->original_event_id)
{
DBG("this is exception event so publish only one instance");
exception_freq = event->freq;
break;
}
- if (event->original_event_id > 0)
+ if (0 < event->original_event_id)
{
DBG("return freq for exception event");
event->freq = exception_freq;
ret = calendar_list_create(out_list);
RETVM_IF(CALENDAR_ERROR_NONE != ret, ret, "calendar_list_create() Fail(%d)", ret);
- if (offset > 0) {
+ if (0 < offset) {
snprintf(offsetquery, sizeof(offsetquery), "OFFSET %d", offset);
}
- if (limit > 0) {
+ if (0 < limit) {
snprintf(limitquery, sizeof(limitquery), "LIMIT %d", limit);
}
snprintf(query, sizeof(query), "SELECT *, rowid FROM %s %s %s",
sqlite3_finalize(stmt);
return ret;
}
- if (que->projection_count > 0) {
+ if (0 < que->projection_count) {
cal_record_set_projection(record,
que->projection, que->projection_count, que->property_count);
ret = calendar_list_create(out_list);
RETVM_IF(CALENDAR_ERROR_NONE != ret, ret, "calendar_list_create() Fail(%d)", ret);
- if (limit > 0) {
+ if (0 < limit) {
snprintf(limitquery, sizeof(limitquery), "LIMIT %d ", limit);
}
- if (offset > 0) {
+ if (0 < offset) {
snprintf(offsetquery, sizeof(offsetquery), "OFFSET %d ", offset);
}
snprintf(query, sizeof(query), "SELECT *, rowid FROM %s %s %s ",
sqlite3_finalize(stmt);
return ret;
}
- if (que->projection_count > 0) {
+ if (0 < que->projection_count) {
cal_record_set_projection(record,
que->projection, que->projection_count, que->property_count);
count += count2;
- if(count > 1000)
+ if(1000 < count)
{
snprintf(query, sizeof(query), "UPDATE %s SET deleted = 1 WHERE id = %d",
CAL_TABLE_CALENDAR, id);
ret = calendar_list_create(out_list);
RETVM_IF(CALENDAR_ERROR_NONE != ret, ret, "calendar_list_create() Fail(%d)", ret);
- if (offset > 0)
+ if (0 < offset)
snprintf(offsetquery, sizeof(offsetquery), "OFFSET %d", offset);
- if (limit > 0)
+ if (0 < limit)
snprintf(limitquery, sizeof(limitquery), "LIMIT %d", limit);
char *query_str = NULL;
// limit, offset
char buf[32] = {0};
- if (limit > 0) {
+ if (0 < limit) {
snprintf(buf, sizeof(buf), "LIMIT %d", limit);
cal_db_append_string(&query_str, buf);
- if (offset > 0) {
+ if (0 < offset) {
snprintf(buf, sizeof(buf), "OFFSET %d", offset);
cal_db_append_string(&query_str, buf);
}
return ret;
}
- if (que->projection_count > 0) {
+ if (0 < que->projection_count) {
cal_record_set_projection(record,
que->projection, que->projection_count, que->property_count);
event->start.type == CALENDAR_TIME_UTIME ? event->start.time.utime : 0,
event->end.type,
event->end.type == CALENDAR_TIME_UTIME ? event->end.time.utime : 0,
- event->freq > 0 ? 1 : 0,
+ 0 < event->freq ? 1 : 0,
(event->attendee_list && 0 < event->attendee_list->count)? 1: 0,
has_alarm,
event->system_type,
return CALENDAR_ERROR_PERMISSION_DENIED;
}
- if (original_event_id > 0)
+ if (0 < original_event_id)
{
// start:add record to exdate if this record is exception mod.
_cal_db_event_add_exdate(original_event_id, recurrence_id);
ret = calendar_list_create(out_list);
RETVM_IF(CALENDAR_ERROR_NONE != ret, ret, "calendar_list_create() Fail(%d)", ret);
- if (offset > 0)
+ if (0 < offset)
{
snprintf(offsetquery, sizeof(offsetquery), "OFFSET %d", offset);
}
- if (limit > 0)
+ if (0 < limit)
{
snprintf(limitquery, sizeof(limitquery), "LIMIT %d", limit);
}
// limit, offset
char buf[32] = {0};
- if (limit > 0)
+ if (0 < limit)
{
snprintf(buf, sizeof(buf), "LIMIT %d", limit);
cal_db_append_string(&query_str, buf);
- if (offset > 0)
+ if (0 < offset)
{
snprintf(buf, sizeof(buf), "OFFSET %d", offset);
cal_db_append_string(&query_str, buf);
CAL_FREE(query_str);
return ret;
}
- if (que->projection_count > 0)
- {
- cal_record_set_projection(record,
- que->projection, que->projection_count, que->property_count);
-
- _cal_db_event_get_projection_stmt(stmt,
- que->projection, que->projection_count,
- record);
- }
- else
- {
+ if (0 < que->projection_count) {
+ cal_record_set_projection(record, que->projection, que->projection_count, que->property_count);
+ _cal_db_event_get_projection_stmt(stmt, que->projection, que->projection_count, record);
+ } else {
cal_event_s *event = NULL;
_cal_db_event_get_stmt(stmt,true,record, &exception, &extended);
event = (cal_event_s*)(record);
event->start.type == CALENDAR_TIME_UTIME ? event->start.time.utime : 0,
event->end.type,
event->end.type == CALENDAR_TIME_UTIME ? event->end.time.utime : 0,
- event->freq > 0 ? 1 : 0,
+ 0 < event->freq ? 1 : 0,
(event->attendee_list && 0 < event->attendee_list->count) ? 1 : 0,
has_alarm,
event->system_type,
int exception_id = 0;
ret = calendar_record_get_int(exception,_calendar_event.id, &exception_id);
DBG("exception(%d)", exception_id);
- if (exception_id > 0 && exception_id != original_id) { // update
+ if (0 < exception_id && exception_id != original_id) { // update
bool bchanged = false;
cal_record_s *_record = NULL;
const cal_property_info_s* property_info = NULL;
int len1 = 0, len2 = 0, i = 0, j = 0;
int input_ver = cal_db_util_get_next_ver();
- if (exdate != NULL && strlen(exdate) > 0)
+ if (exdate != NULL && 0 < strlen(exdate))
{
patterns1 = g_strsplit_set(exdate, " ,", -1);
len1 = g_strv_length(patterns1);
}
- if (original_exdate != NULL && strlen(original_exdate) > 0)
+ if (original_exdate != NULL && 0 < strlen(original_exdate))
{
patterns2 = g_strsplit_set(original_exdate, " ,", -1);
len2 = g_strv_length(patterns2);
char query[CAL_DB_SQL_MAX_LEN] = {0};
long long int start_utime = 0;
char datetime[16] = {0};
- if (strlen(patterns1[i]) > strlen("YYYYMMDD"))
+ if (strlen("YYYYMMDD") < strlen(patterns1[i]))
{
//DBG("NORMAL instance");
int y, mon, d, h, min, s;
ret = calendar_list_create(out_list);
RETVM_IF(CALENDAR_ERROR_NONE != ret, ret, "calendar_list_create() Fail(%d)", ret);
- if (offset > 0)
+ if (0 < offset)
{
snprintf(offsetquery, sizeof(offsetquery), "OFFSET %d", offset);
}
- if (limit > 0)
+ if (0 < limit)
{
snprintf(limitquery, sizeof(limitquery), "LIMIT %d", limit);
}
sqlite3_finalize(stmt);
return ret;
}
- if (que->projection_count > 0)
+ if (0 < que->projection_count)
{
cal_record_set_projection(record,
que->projection, que->projection_count, que->property_count);
ret = calendar_list_create(out_list);
RETVM_IF(CALENDAR_ERROR_NONE != ret, ret, "calendar_list_create() Fail(%d)", ret);
- if (offset > 0)
+ if (0 < offset)
snprintf(offsetquery, sizeof(offsetquery), "OFFSET %d", offset);
- if (limit > 0)
+ if (0 < limit)
snprintf(limitquery, sizeof(limitquery), "LIMIT %d", limit);
char *query_str = NULL;
// limit, offset
char buf[32] = {0};
- if (limit > 0)
+ if (0 < limit)
{
snprintf(buf, sizeof(buf), "LIMIT %d", limit);
cal_db_append_string(&query_str, buf);
- if (offset > 0)
+ if (0 < offset)
{
snprintf(buf, sizeof(buf), "OFFSET %d", offset);
cal_db_append_string(&query_str, buf);
CAL_FREE(query_str);
return ret;
}
- if (que->projection_count > 0)
+ if (0 < que->projection_count)
{
cal_record_set_projection(record,
que->projection, que->projection_count, que->property_count);
instance->sensitivity = sqlite3_column_int(stmt, count++);
instance->has_rrule = sqlite3_column_int(stmt, count++);
- if (instance->has_rrule > 0)
+ if (0 < instance->has_rrule)
{
instance->has_rrule = 1;
}
break;
case CAL_PROPERTY_INSTANCE_ALLDAY_HAS_RRULE:
instance->has_rrule = sqlite3_column_int(stmt, *stmt_count);
- if (instance->has_rrule > 0)
+ if (0 < instance->has_rrule)
{
instance->has_rrule = 1;
}
ret = calendar_list_create(out_list);
RETVM_IF(CALENDAR_ERROR_NONE != ret, ret, "calendar_list_create() Fail(%d)", ret);
- if (offset > 0)
- {
+ if (0 < offset)
snprintf(offsetquery, sizeof(offsetquery), "OFFSET %d", offset);
- }
- if (limit > 0)
- {
+ if (0 < limit)
snprintf(limitquery, sizeof(limitquery), "LIMIT %d", limit);
- }
char *query_str = NULL;
cal_db_append_string(&query_str, "SELECT * FROM");
// limit, offset
char buf[32] = {0};
- if (limit > 0)
+ if (0 < limit)
{
snprintf(buf, sizeof(buf), "LIMIT %d", limit);
cal_db_append_string(&query_str, buf);
- if (offset > 0)
+ if (0 < offset)
{
snprintf(buf, sizeof(buf), "OFFSET %d", offset);
cal_db_append_string(&query_str, buf);
CAL_FREE(query_str);
return ret;
}
- if (que->projection_count > 0)
- {
- cal_record_set_projection(record,
- que->projection, que->projection_count, que->property_count);
-
- _cal_db_instance_allday_extended_get_projection_stmt(stmt,
- que->projection, que->projection_count,
- record);
- }
- else
- {
+ if (0 < que->projection_count) {
+ cal_record_set_projection(record, que->projection, que->projection_count, que->property_count);
+ _cal_db_instance_allday_extended_get_projection_stmt(stmt, que->projection, que->projection_count, record);
+ } else {
_cal_db_instance_allday_extended_get_stmt(stmt,record);
}
instance->sensitivity = sqlite3_column_int(stmt, count++);
instance->has_rrule = sqlite3_column_int(stmt, count++);
- if (instance->has_rrule > 0)
+ if (0 < instance->has_rrule)
{
instance->has_rrule = 1;
}
break;
case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_HAS_RRULE:
instance->has_rrule = sqlite3_column_int(stmt, *stmt_count);
- if (instance->has_rrule > 0)
+ if (0 < instance->has_rrule)
{
instance->has_rrule = 1;
}
ret = calendar_list_create(out_list);
RETVM_IF(CALENDAR_ERROR_NONE != ret, ret, "calendar_list_create() Fail(%d)", ret);
- if (offset > 0)
+ if (0 < offset)
snprintf(offsetquery, sizeof(offsetquery), "OFFSET %d", offset);
- if (limit > 0)
+ if (0 < limit)
snprintf(limitquery, sizeof(limitquery), "LIMIT %d", limit);
char *query_str = NULL;
// limit, offset
char buf[32] = {0};
- if (limit > 0)
+ if (0 < limit)
{
snprintf(buf, sizeof(buf), "LIMIT %d", limit);
cal_db_append_string(&query_str, buf);
- if (offset > 0)
+ if (0 < offset)
{
snprintf(buf, sizeof(buf), "OFFSET %d", offset);
cal_db_append_string(&query_str, buf);
sqlite3_finalize(stmt);
return ret;
}
- if (que->projection_count > 0)
+ if (0 < que->projection_count)
{
cal_record_set_projection(record,
que->projection, que->projection_count, que->property_count);
instance->sensitivity = sqlite3_column_int(stmt, count++);
instance->has_rrule = sqlite3_column_int(stmt, count++);
- if (instance->has_rrule > 0)
+ if (0 < instance->has_rrule)
{
instance->has_rrule = 1;
}
break;
case CAL_PROPERTY_INSTANCE_NORMAL_HAS_RRULE:
instance->has_rrule = sqlite3_column_int(stmt, *stmt_count);
- if (instance->has_rrule > 0)
+ if (0 < instance->has_rrule)
{
instance->has_rrule = 1;
}
ret = calendar_list_create(out_list);
RETVM_IF(CALENDAR_ERROR_NONE != ret, ret, "calendar_list_create() Fail(%d)", ret);
- if (offset > 0)
+ if (0 < offset)
snprintf(offsetquery, sizeof(offsetquery), "OFFSET %d", offset);
- if (limit > 0)
+ if (0 < limit)
snprintf(limitquery, sizeof(limitquery), "LIMIT %d", limit);
char *query_str = NULL;
// limit, offset
char buf[32] = {0};
- if (limit > 0)
+ if (0 < limit)
{
snprintf(buf, sizeof(buf), "LIMIT %d", limit);
cal_db_append_string(&query_str, buf);
- if (offset > 0)
+ if (0 < offset)
{
snprintf(buf, sizeof(buf), "OFFSET %d", offset);
cal_db_append_string(&query_str, buf);
return ret;
}
- if (que->projection_count > 0)
+ if (0 < que->projection_count)
{
cal_record_set_projection(record,
que->projection, que->projection_count, que->property_count);
instance->sensitivity = sqlite3_column_int(stmt, count++);
instance->has_rrule = sqlite3_column_int(stmt, count++);
- if (instance->has_rrule > 0)
+ if (0 < instance->has_rrule)
{
instance->has_rrule = 1;
}
break;
case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_HAS_RRULE:
instance->has_rrule = sqlite3_column_int(stmt, *stmt_count);
- if (instance->has_rrule > 0)
+ if (0 < instance->has_rrule)
{
instance->has_rrule = 1;
}
}
// make projection
- if (que->projection_count > 0)
+ if (0 < que->projection_count)
{
ret = cal_db_query_create_projection(query, &projection);
}
// limit, offset
char buf[32] = {0};
- if (limit > 0)
+ if (0 < limit)
{
snprintf(buf, sizeof(buf), "LIMIT %d", limit);
cal_db_append_string(&query_str, buf);
- if (offset > 0)
+ if (0 < offset)
{
snprintf(buf, sizeof(buf), "OFFSET %d", offset);
cal_db_append_string(&query_str, buf);
CAL_FREE(query_str);
return ret;
}
- if (que->projection_count > 0)
+ if (0 < que->projection_count)
{
_cal_db_search_get_projection_stmt(stmt,que->projection,que->projection_count,
record);
if (field_name)
len += snprintf(out_projection+len, sizeof(out_projection)-len, "%s", field_name);
- if (len >= sizeof(out_projection))
+ if (sizeof(out_projection) <= len)
{
ERR("buf len max");
return CALENDAR_ERROR_SYSTEM;
if (field_name)
{
len += snprintf(out_projection+len, sizeof(out_projection)-len, ", %s", field_name);
- if (len >= sizeof(out_projection))
+ if (sizeof(out_projection) <= len)
{
ERR("buf len max");
return CALENDAR_ERROR_SYSTEM;
int timezone_id = sqlite3_column_int(stmt, index++);
sqlite3_finalize(stmt);
- if (count > 0)
+ if (0 < count)
{
DBG("Already exist which tzid name[%s] id(%d)", timezone->standard_name, timezone_id);
*id = timezone_id;
ret = calendar_list_create(out_list);
RETVM_IF(CALENDAR_ERROR_NONE != ret, ret, "calendar_list_create() Fail(%d)", ret);
- if (offset > 0)
+ if (0 < offset)
{
snprintf(offsetquery, sizeof(offsetquery), "OFFSET %d", offset);
}
- if (limit > 0)
+ if (0 < limit)
{
snprintf(limitquery, sizeof(limitquery), "LIMIT %d", limit);
}
sqlite3_finalize(stmt);
return ret;
}
- if (que->projection_count > 0)
+ if (0 < que->projection_count)
{
cal_record_set_projection(record,
que->projection, que->projection_count, que->property_count);
todo->completed_time, todo->progress,
todo->start.type, todo->start.type == CALENDAR_TIME_UTIME ? todo->start.time.utime : 0,
todo->due.type, todo->due.type == CALENDAR_TIME_UTIME ? todo->due.time.utime : 0,
- todo->freq > 0 ? 1 : 0,
+ 0 < todo->freq ? 1 : 0,
has_alarm,
todo->system_type,
todo->updated,
ret = calendar_list_create(out_list);
RETVM_IF(CALENDAR_ERROR_NONE != ret, ret, "calendar_list_create() Fail(%d)", ret);
- if (offset > 0)
+ if (0 < offset)
{
snprintf(offsetquery, sizeof(offsetquery), "OFFSET %d", offset);
}
- if (limit > 0)
+ if (0 < limit)
{
snprintf(limitquery, sizeof(limitquery), "LIMIT %d", limit);
}
// limit, offset
char buf[32] = {0};
- if (limit > 0)
+ if (0 < limit)
{
snprintf(buf, sizeof(buf), "LIMIT %d", limit);
cal_db_append_string(&query_str, buf);
- if (offset > 0)
+ if (0 < offset)
{
snprintf(buf, sizeof(buf), "OFFSET %d", offset);
cal_db_append_string(&query_str, buf);
CAL_FREE(query_str);
return ret;
}
- if (que->projection_count > 0)
+ if (0 < que->projection_count)
{
cal_record_set_projection(record,
que->projection, que->projection_count, que->property_count);
case CALENDAR_RECURRENCE_DAILY:
break;
case CALENDAR_RECURRENCE_WEEKLY:
- if (event->byday && strlen(event->byday) > 0)
+ if (event->byday && 0 < strlen(event->byday))
{
break;
}
break;
case CALENDAR_RECURRENCE_MONTHLY:
- if (event->bymonthday && strlen(event->bymonthday) > 0) {
+ if (event->bymonthday && 0 < strlen(event->bymonthday)) {
break;
}
- else if (event->byday && strlen(event->byday) > 0) {
+ else if (event->byday && 0 < strlen(event->byday)) {
break;
}
break;
case CALENDAR_RECURRENCE_YEARLY:
- if (event->bymonth && strlen(event->bymonth) > 0) {
+ if (event->bymonth && 0 < strlen(event->bymonth)) {
break;
}
- else if (event->byyearday && strlen(event->byyearday) > 0) {
+ else if (event->byyearday && 0 < strlen(event->byyearday)) {
break;
}
- else if (event->byweekno && strlen(event->byweekno) > 0) {
+ else if (event->byweekno && 0 < strlen(event->byweekno)) {
break;
}
return ret;
}
- *has_record = count > 0 ? 1 : 0;
+ *has_record = 0 < count ? 1 : 0;
return CALENDAR_ERROR_NONE;
}
#include "cal_db.h"
#include "cal_db_util.h"
-void cal_db_timezone_search_with_tzid(const char *zone_name, char *tzid, int *timezone_id)
+void cal_db_timezone_search_with_tzid(char *tzid, int *timezone_id)
{
- RET_IF(NULL == zone_name);
RET_IF(NULL == tzid);
RET_IF('\0' == *tzid);
RET_IF(NULL == timezone_id);
char query[CAL_DB_SQL_MAX_LEN] = {0};
snprintf(query, sizeof(query), "SELECT id FROM %s WHERE standard_name='%s'", CAL_TABLE_TIMEZONE, tzid);
- cal_db_util_query_get_first_int_result(zone_name, query, NULL, timezone_id);
+ cal_db_util_query_get_first_int_result(query, NULL, timezone_id);
}
struct _alarm_data_s *p2 = (struct _alarm_data_s *)b;
DBG("%lld) > (%lld)",p1->alert_utime, p2->alert_utime);
- return p1->alert_utime > p2->alert_utime ? 1 : -1;
+ return p1->alert_utime < p2->alert_utime ? -1 : 1;
}
static GFunc _cal_server_alarm_print_cb(gpointer data, gpointer user_data)
return ret;
}
- if (account_id > 0) {
+ if (0 < account_id) {
snprintf(buf, sizeof(buf), "%d", account_id);
ret = calendar_record_set_str(event, _calendar_event.sync_data4, buf);
if (CALENDAR_ERROR_NONE != ret) {
contacts_record_destroy(contact, true);
return CALENDAR_ERROR_SYSTEM;
}
- if (address_book_id > 0) { // default phone addressbook is 0
+ if (0 < address_book_id) { // default phone addressbook is 0
DBG("address_book_id(%d)", address_book_id);
contacts_record_h address_book = NULL;
ret = contacts_db_get_record(_contacts_address_book._uri, address_book_id, &address_book);
}
DBG("event count(%d)\n", count);
- if (count > 0) {
+ if (0 < count) {
record_id_array = (int *)calloc(count, sizeof(int));
if (NULL == record_id_array) {
ERR("calloc() Fail");