4 * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
27 #include "cals-db-info.h"
28 #include "cals-internal.h"
29 #include "calendar-svc-errors.h"
32 static inline int remake_db_file()
38 ret = db_util_open(CALS_DB_PATH, &db, 0);
39 retvm_if(SQLITE_OK != ret, CAL_ERR_DB_NOT_OPENED, "db_util_open() Failed(%d)", ret);
41 ret = sqlite3_exec(db, schema_query, NULL, 0, &errmsg);
42 if (SQLITE_OK != ret) {
43 ERR("remake calendar DB file is Failed : %s", errmsg);
49 fd = open(CALS_DB_PATH, O_CREAT | O_RDWR, 0660);
50 retvm_if(-1 == fd, CAL_ERR_FAIL, "open Failed");
52 fchown(fd, getuid(), CALS_SECURITY_FILE_GROUP);
53 fchmod(fd, CALS_SECURITY_DEFAULT_PERMISSION);
56 fd = open(CALS_DB_JOURNAL_PATH, O_CREAT | O_RDWR, 0660);
57 retvm_if(-1 == fd, CAL_ERR_FAIL, "open Failed");
59 fchown(fd, getuid(), CALS_SECURITY_FILE_GROUP);
60 fchmod(fd, CALS_SECURITY_DEFAULT_PERMISSION);
66 static inline int check_db_file(void)
68 int fd = open(CALS_DB_PATH, O_RDONLY);
69 retvm_if(-1 == fd, -1,
70 "DB file(%s) is not exist", CALS_DB_PATH);
76 static inline int check_schema(void)
84 int main(int argc, char **argv)
86 return check_schema();