2 * device-manager-plugin-maru
4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: DongGi Jang <dg0402.jang@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
23 * 2012-03-05 Dohyung Hong <don.hong@samsung.com> Changed package name for the maru board of emulator
30 #include <devman_plugin_intf.h>
32 #include <sys/types.h>
35 #define EXPORT_API __attribute__((visibility("default")))
41 int sys_get_node(char *path, char *node)
43 if (0 >= snprintf(node, strlen(path) + 1, "%s", path))
49 int sys_get_int_wo_convert(char *path, int *value)
53 fd = open(path, O_RDONLY);
58 if (0 > read(fd, value, sizeof(int))) {
67 int sys_set_int_wo_convert(char *path, int value)
71 fd = open(path, O_WRONLY);
76 if (0 > write(fd, &value, sizeof(int))) {
85 static int sys_read_buf(char *file, char *buf)
90 fd = open(file, O_RDONLY);
95 r = read(fd, buf, BUFF_MAX);
96 if ((r >= 0) && (r < BUFF_MAX))
107 static int sys_write_buf(char *file, char *buf)
112 fd = open(file, O_WRONLY);
117 r = write(fd, buf, strlen(buf));
126 int sys_get_int(char *fname, int *val)
130 if (sys_read_buf(fname, buf) == 0) {
139 int sys_get_str(char *fname, char* str)
141 char buf[BUFF_MAX] = {0};
143 if (sys_read_buf(fname, buf) == 0) {
144 strncpy(str, buf, strlen(buf));
151 int sys_set_int(char *fname, int val)
155 snprintf(buf, sizeof(buf), "%d", val);
157 if (sys_write_buf(fname, buf) == 0)
163 int sys_set_str(char *fname, char *val)
168 if (sys_write_buf(fname, val) == 0)