[FEATURE] Implement kernel -> user connection
[platform/core/system/swap-manager.git] / daemon / device_camera.c
1 /*
2  *  DA manager
3  *
4  * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact:
7  *
8  * Jaewon Lim           <jaewon81.lim@samsung.com>
9  * Woojin Jung          <woojin2.jung@samsung.com>
10  * Juyoung Kim          <j0.kim@samsung.com>
11  * Nikita Kalyazin      <n.kalyazin@samsung.com>
12  *
13  * Licensed under the Apache License, Version 2.0 (the "License");
14  * you may not use this file except in compliance with the License.
15  * You may obtain a copy of the License at
16  *
17  * http://www.apache.org/licenses/LICENSE-2.0
18  *
19  * Unless required by applicable law or agreed to in writing, software
20  * distributed under the License is distributed on an "AS IS" BASIS,
21  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22  * See the License for the specific language governing permissions and
23  * limitations under the License.
24  *
25  * Contributors:
26  * - S-Core Co., Ltd
27  * - Samsung RnD Institute Russia
28  *
29  */
30
31
32 #include <stdio.h>
33 #include <string.h>
34 #include "device_camera.h"
35
36 #define CAMCORDER_FILE "/usr/etc/mmfw_camcorder.ini"
37 #define CAMERA_COUNT_STR "DeviceCount"
38 #define BUFFER_MAX 1024
39
40 int get_camera_count(void)
41 {
42         FILE* fp;
43         int count = 0;
44         int size;
45         char buf[BUFFER_MAX];
46
47         fp = fopen(CAMCORDER_FILE, "r");
48         if (fp == NULL)
49                 return 0;
50
51         size = strlen(CAMERA_COUNT_STR);
52         while (fgets(buf, BUFFER_MAX, fp) != NULL) {
53                 if (strncmp(buf, CAMERA_COUNT_STR, size) == 0) {
54                         sscanf(buf, CAMERA_COUNT_STR " = %d", &count);
55                         break;
56                 }
57         }
58
59         fclose(fp);
60
61         return count;
62 }