data_control_h provider, bundle *insert_map)
{
int index;
- char *data_id = NULL;
int sql_len;
char *sql;
int row_count = bundle_get_count(insert_map);
- int ret;
- if (provider == NULL || row_count == 0) {
+ if (provider == NULL || provider->data_id == NULL || row_count == 0) {
set_last_result(DATA_CONTROL_ERROR_INVALID_PARAMETER);
return NULL;
}
index = 0;
bundle_foreach(insert_map, bundle_foreach_cb, (void *)(cols));
- ret = _get_data_id(provider, &data_id);
- if (ret != DATA_CONTROL_ERROR_NONE) {
- free(cols->keys);
- free(cols->vals);
- free(cols);
- set_last_result(ret);
- return NULL;
- }
-
- sql_len = INSERT_STMT_CONST_LEN + strlen(data_id) +
+ sql_len = INSERT_STMT_CONST_LEN + strlen(provider->data_id) +
(row_count - 1) * 4 + (cols->length) + 1;
_LOGI("SQL statement length: %d", sql_len);
sql = (char *)calloc(sql_len, sizeof(char));
if (sql == NULL) {
- free(data_id);
free(cols->keys);
free(cols->vals);
free(cols);
return NULL;
}
- snprintf(sql, sql_len, "INSERT INTO %s (", data_id);
- free(data_id);
+ snprintf(sql, sql_len, "INSERT INTO %s (", provider->data_id);
for (index = 0; index < row_count - 1; index++) {
strncat(sql, cols->keys[index], sql_len - (strlen(sql) + 1));
EXPORT_API char *data_control_provider_create_delete_statement(
data_control_h provider, const char *where)
{
- char *data_id = NULL;
int cond_len;
int sql_len;
char *sql;
- int ret;
- if (provider == NULL) {
+ if (provider == NULL || provider->data_id == NULL) {
set_last_result(DATA_CONTROL_ERROR_INVALID_PARAMETER);
return NULL;
}
- ret = _get_data_id(provider, &data_id);
- if (ret != DATA_CONTROL_ERROR_NONE) {
- set_last_result(ret);
- return NULL;
- }
-
cond_len = (where != NULL) ? (WHERE_COND_CONST_LEN + strlen(where)) : 0;
- sql_len = DELETE_STMT_CONST_LEN + strlen(data_id) + cond_len + 1;
+ sql_len = DELETE_STMT_CONST_LEN + strlen(provider->data_id) + cond_len + 1;
_LOGI("SQL statement length: %d", sql_len);
sql = (char *)calloc(sql_len, sizeof(char));
if (sql == NULL) {
- free(data_id);
set_last_result(DATA_CONTROL_ERROR_OUT_OF_MEMORY);
return NULL;
}
- snprintf(sql, sql_len, "DELETE FROM %s", data_id);
+ snprintf(sql, sql_len, "DELETE FROM %s", provider->data_id);
if (where) {
strncat(sql, " WHERE ", sql_len - (strlen(sql) + 1));
strncat(sql, where, sql_len - (strlen(sql) + 1));
_LOGD("SQL statement is: %s", sql);
- free(data_id);
return sql;
}
data_control_h provider, bundle *update_map, const char *where)
{
int index;
- char *data_id = NULL;
int cond_len;
int sql_len;
char *sql;
int row_count = bundle_get_count(update_map);
- int ret;
- if (provider == NULL || row_count == 0) {
+ if (provider == NULL || provider->data_id == NULL || row_count == 0) {
set_last_result(DATA_CONTROL_ERROR_INVALID_PARAMETER);
return NULL;
}
index = 0;
bundle_foreach(update_map, bundle_foreach_cb, (void *)(cols));
- ret = _get_data_id(provider, &data_id);
- if (ret != DATA_CONTROL_ERROR_NONE) {
- free(cols->keys);
- free(cols->vals);
- free(cols);
- set_last_result(ret);
- return NULL;
- }
-
cond_len = (where != NULL) ? (WHERE_COND_CONST_LEN + strlen(where)) : 0;
- sql_len = UPDATE_STMT_CONST_LEN + strlen(data_id) + (cols->length) +
+ sql_len = UPDATE_STMT_CONST_LEN + strlen(provider->data_id) + (cols->length) +
(row_count - 1) * 5 + cond_len + 1;
_LOGI("SQL statement length: %d", sql_len);
sql = (char *) calloc(sql_len, sizeof(char));
if (sql == NULL) {
- free(data_id);
free(cols->keys);
free(cols->vals);
free(cols);
return NULL;
}
- snprintf(sql, sql_len, "UPDATE %s SET ", data_id);
- free(data_id);
+ snprintf(sql, sql_len, "UPDATE %s SET ", provider->data_id);
for (index = 0; index < row_count - 1; index++) {
strncat(sql, cols->keys[index], sql_len - (strlen(sql) + 1));
{
int index = 0;
int col_name_length = 0;
- char *data_id = NULL;
int cond_len;
int order_len;
int sql_len;
char *sql;
- int ret;
- if (provider == NULL) {
+ if (provider == NULL || provider->data_id == NULL) {
set_last_result(DATA_CONTROL_ERROR_INVALID_PARAMETER);
return NULL;
}
col_name_length = 1;
}
- ret = _get_data_id(provider, &data_id);
- if (ret != DATA_CONTROL_ERROR_NONE) {
- set_last_result(ret);
- return NULL;
- }
-
cond_len = (where != NULL) ? (WHERE_COND_CONST_LEN + strlen(where)) : 0;
order_len = (order != NULL) ? (ORDER_CLS_CONST_LEN + strlen(order)) : 0;
- sql_len = SELECT_STMT_CONST_LEN + col_name_length + strlen(data_id) +
+ sql_len = SELECT_STMT_CONST_LEN + col_name_length + strlen(provider->data_id) +
cond_len + order_len + 1;
_LOGI("SQL statement length: %d", sql_len);
sql = (char *) calloc(sql_len, sizeof(char));
if (sql == NULL) {
- free(data_id);
set_last_result(DATA_CONTROL_ERROR_OUT_OF_MEMORY);
return NULL;
}
}
strncat(sql, " FROM ", sql_len - (strlen(sql) + 1));
- strncat(sql, data_id, sql_len - (strlen(sql) + 1));
+ strncat(sql, provider->data_id, sql_len - (strlen(sql) + 1));
if (where) {
strncat(sql, " WHERE ", sql_len - (strlen(sql) + 1));
_LOGD("SQL statement is: %s", sql);
- free(data_id);
return sql;
}
EXPORT_API bool data_control_provider_match_data_id(
data_control_h provider, const char *data_id)
{
- int ret = DATA_CONTROL_ERROR_NONE;
- char *data = NULL;
-
if (provider == NULL || data_id == NULL) {
set_last_result(DATA_CONTROL_ERROR_INVALID_PARAMETER);
return false;
}
- ret = _get_data_id(provider, &data);
- set_last_result(ret);
- if (ret != DATA_CONTROL_ERROR_NONE)
- return false;
-
- if (strcmp(data, data_id) == 0) {
- free(data);
+ if (strcmp(provider->data_id, data_id) == 0)
return true;
- } else {
- free(data);
+ else
return false;
- }
+
}
EXPORT_API int data_control_provider_send_map_bulk_add_result(