4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jonghyuk Choi <jhchoi.choi@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.
29 #include "mm_attrs_private.h"
32 int mm_attrs_new(MMAttrsConstructInfo *info, int count, const char *name,
33 mm_attrs_commit_callback callback, void *user_param, MMHandleType *attrs)
37 return_val_if_fail(attrs, MM_ERROR_COMMON_INVALID_ARGUMENT);
39 _attrs = mmf_attrs_new_from_data(name, (mmf_attrs_construct_info_t *) info, count, (mmf_attrs_commit_func_t) callback, user_param);
41 return MM_ERROR_COMMON_INTERNAL;
49 void mm_attrs_free(MMHandleType attrs)
51 mmf_attrs_free(attrs);
55 int mm_attrs_commit_all(MMHandleType attrs)
57 return mmf_attrs_commit(attrs);
60 int mm_attrs_commit(MMHandleType attrs, int index)
62 mmf_attrs_t *h = (mmf_attrs_t *) attrs;
63 mmf_attribute_t *item;
65 return_val_if_fail(attrs, MM_ERROR_COMMON_INVALID_ARGUMENT);
66 return_val_if_fail(index >= 0, MM_ERROR_COMMON_INVALID_ARGUMENT);
68 item = &h->items[index];
70 MM_ATTR_ITEM_WRITE_LOCK(item);
72 mmf_attribute_commit(item);
74 MM_ATTR_ITEM_WRITE_UNLOCK(item);
79 int mm_attrs_get_type(MMHandleType attrs, int index, MMAttrsType *attrtype)
81 mmf_attrs_t *h = (mmf_attrs_t *) attrs;
83 return_val_if_fail(h && index >= 0 && index < h->count && attrtype, MM_ERROR_COMMON_INVALID_ARGUMENT);
85 *attrtype = h->items[index].value.type;
90 int mm_attrs_get_flags(MMHandleType attrs, int index, int *flags)
92 mmf_attrs_t *h = (mmf_attrs_t *) attrs;
94 return_val_if_fail(h && index >= 0 && index < h->count && flags, MM_ERROR_COMMON_INVALID_ARGUMENT);
96 *flags = h->items[index].flags;
101 int mm_attrs_get_valid_type(MMHandleType attrs, int index, MMAttrsValidType *type)
103 mmf_attrs_t *h = (mmf_attrs_t *) attrs;
105 return_val_if_fail(h && index >= 0 && index < h->count && type, MM_ERROR_COMMON_INVALID_ARGUMENT);
107 *type = h->items[index].value_spec.type;
108 return MM_ERROR_NONE;
112 int mm_attrs_get_valid_range(MMHandleType attrs, int index, int *min, int *max)
114 mmf_attrs_t *h = (mmf_attrs_t *) attrs;
116 return_val_if_fail(h && index >= 0 && index < h->count && min && max, MM_ERROR_COMMON_INVALID_ARGUMENT);
119 *min = h->items[index].value_spec.spec.int_spec.range.min;
122 *max = h->items[index].value_spec.spec.int_spec.range.max;
124 return MM_ERROR_NONE;
128 int mm_attrs_get_valid_array(MMHandleType attrs, int index, int *count, int **array)
130 mmf_attrs_t *h = (mmf_attrs_t *) attrs;
135 return_val_if_fail(h && count && index >= 0 && index < h->count && array, MM_ERROR_COMMON_INVALID_ARGUMENT);
138 *count = h->items[index].value_spec.spec.int_spec.array.count;
139 *array = h->items[index].value_spec.spec.int_spec.array.array;
140 return MM_ERROR_NONE;
144 int mm_attrs_get_size(MMHandleType attrs, int *size)
146 mmf_attrs_t *h = (mmf_attrs_t *) attrs;
148 return_val_if_fail(h && size, MM_ERROR_COMMON_INVALID_ARGUMENT);
151 return MM_ERROR_NONE;
155 int mm_attrs_get_name(MMHandleType attrs, int index, char **name)
157 mmf_attrs_t *h = (mmf_attrs_t *) attrs;
159 return_val_if_fail(h && index >= 0 && index < h->count && name, MM_ERROR_COMMON_INVALID_ARGUMENT);
161 *name = h->items[index].name;
162 return MM_ERROR_NONE;
166 int mm_attrs_get_index(MMHandleType attrs, const char *attrname, int *index)
168 mmf_attrs_t *h = (mmf_attrs_t *) attrs;
171 return_val_if_fail(h && attrname && index, MM_ERROR_COMMON_INVALID_ARGUMENT);
173 for (i = 0; i < h->count; i++) {
174 if (0 == strcmp(h->items[i].name, attrname)) {
176 return MM_ERROR_NONE;
180 debug_error("failed to get index for [%s]", attrname);
182 return MM_ERROR_COMMON_OUT_OF_ARRAY;
186 int mm_attrs_set_int(MMHandleType attrs, int index, int val)
188 mmf_attrs_t *h = (mmf_attrs_t *) attrs;
189 mmf_attribute_t *item;
191 return_val_if_fail(h && index >= 0 && index < h->count, MM_ERROR_COMMON_INVALID_ARGUMENT);
193 item = &h->items[index];
194 return_val_if_fail(item, MM_ERROR_COMMON_INVALID_ARGUMENT);
196 if (!mmf_attribute_check_flags(item, MM_ATTRS_FLAG_WRITABLE)) {
197 return MM_ERROR_COMMON_INVALID_PERMISSION;
200 if (mmf_attribute_validate_int(item, val)) {
202 ret = mmf_attribute_set_int(item, val);
205 return MM_ERROR_NONE;
207 return MM_ERROR_COMMON_INVALID_ATTRTYPE;
210 if (item->value_spec.type == MMF_VALUE_SPEC_INT_RANGE)
211 return MM_ERROR_COMMON_OUT_OF_RANGE;
212 else if (item->value_spec.type == MMF_VALUE_SPEC_INT_ARRAY)
213 return MM_ERROR_COMMON_OUT_OF_ARRAY;
215 return MM_ERROR_COMMON_INVALID_ARGUMENT;
219 int mm_attrs_get_int(MMHandleType attrs, int index, int *val)
221 mmf_attrs_t *h = (mmf_attrs_t *) attrs;
222 mmf_attribute_t *item;
224 return_val_if_fail(h && index >= 0 && index < h->count && val, MM_ERROR_COMMON_INVALID_ARGUMENT);
226 item = &h->items[index];
227 return_val_if_fail(item, MM_ERROR_COMMON_INVALID_ARGUMENT);
229 if (mmf_attribute_check_flags(item, MM_ATTRS_FLAG_READABLE)) {
230 *val = mmf_value_get_int(&h->items[index].value);
231 return MM_ERROR_NONE;
234 return MM_ERROR_COMMON_INVALID_PERMISSION;
238 int mm_attrs_set_double(MMHandleType attrs, int index, double val)
240 mmf_attrs_t *h = (mmf_attrs_t *) attrs;
241 mmf_attribute_t *item;
243 return_val_if_fail(h && index >= 0 && index < h->count, MM_ERROR_COMMON_INVALID_ARGUMENT);
245 item = &h->items[index];
246 return_val_if_fail(item, MM_ERROR_COMMON_INVALID_ARGUMENT);
248 if (!mmf_attribute_check_flags(item, MM_ATTRS_FLAG_WRITABLE))
249 return MM_ERROR_COMMON_INVALID_PERMISSION;
251 if (mmf_attribute_validate_double(item, val)) {
253 ret = mmf_attribute_set_double(item, val);
256 return MM_ERROR_NONE;
258 return MM_ERROR_COMMON_INVALID_ATTRTYPE;
261 if (item->value_spec.type == MMF_VALUE_SPEC_DOUBLE_RANGE)
262 return MM_ERROR_COMMON_OUT_OF_RANGE;
263 else if (item->value_spec.type == MMF_VALUE_SPEC_DOUBLE_ARRAY)
264 return MM_ERROR_COMMON_OUT_OF_ARRAY;
266 return MM_ERROR_COMMON_INVALID_ARGUMENT;
270 int mm_attrs_get_double(MMHandleType attrs, int index, double *val)
272 mmf_attrs_t *h = (mmf_attrs_t *) attrs;
273 mmf_attribute_t *item;
275 return_val_if_fail(h && index >= 0 && index < h->count && val, MM_ERROR_COMMON_INVALID_ARGUMENT);
277 item = &h->items[index];
278 return_val_if_fail(item, MM_ERROR_COMMON_INVALID_ARGUMENT);
280 if (mmf_attribute_check_flags(item, MM_ATTRS_FLAG_READABLE)) {
281 *val = mmf_value_get_double(&h->items[index].value);
282 return MM_ERROR_NONE;
285 return MM_ERROR_COMMON_INVALID_PERMISSION;
289 int mm_attrs_set_string(MMHandleType attrs, int index, const char *string, int size)
291 mmf_attrs_t *h = (mmf_attrs_t *) attrs;
292 mmf_attribute_t *item;
294 return_val_if_fail(h && index >= 0 && index < h->count, MM_ERROR_COMMON_INVALID_ARGUMENT);
296 item = &h->items[index];
297 return_val_if_fail(item, MM_ERROR_COMMON_INVALID_ARGUMENT);
299 MM_ATTR_ITEM_WRITE_LOCK(item);
301 if (mmf_attribute_check_flags(item, MM_ATTRS_FLAG_WRITABLE)) {
303 ret = mmf_attribute_set_string(item, string, size);
305 MM_ATTR_ITEM_WRITE_UNLOCK(item);
308 return MM_ERROR_NONE;
310 return MM_ERROR_COMMON_INVALID_ARGUMENT;
313 MM_ATTR_ITEM_WRITE_UNLOCK(item);
315 return MM_ERROR_COMMON_INVALID_PERMISSION;
319 int mm_attrs_get_string(MMHandleType attrs, int index, char **sval, int *size)
321 mmf_attrs_t *h = (mmf_attrs_t *) attrs;
322 mmf_attribute_t *item;
324 return_val_if_fail(h && index >= 0 && index < h->count && sval, MM_ERROR_COMMON_INVALID_ARGUMENT);
326 item = &h->items[index];
328 MM_ATTR_ITEM_WRITE_LOCK(item);
330 if (!(item->flags & MM_ATTRS_FLAG_READABLE)) {
331 //mmf_debug(MMF_DEBUG_LOG, "Access denied.\n");
332 MM_ATTR_ITEM_WRITE_UNLOCK(item);
333 return MM_ERROR_COMMON_INVALID_PERMISSION;
336 *sval = mmf_value_get_string(&item->value, size);
338 MM_ATTR_ITEM_WRITE_UNLOCK(item);
340 return MM_ERROR_NONE;
344 int mm_attrs_set_data(MMHandleType attrs, int index, void *data, int size)
346 mmf_attrs_t *h = (mmf_attrs_t *) attrs;
347 mmf_attribute_t *item;
349 return_val_if_fail(h && index >= 0 && index < h->count, MM_ERROR_COMMON_INVALID_ARGUMENT);
351 item = &h->items[index];
352 return_val_if_fail(item, MM_ERROR_COMMON_INVALID_ARGUMENT);
354 if (mmf_attribute_check_flags(item, MM_ATTRS_FLAG_WRITABLE)) {
356 ret = mmf_attribute_set_data(item, data, size);
359 return MM_ERROR_NONE;
361 return MM_ERROR_COMMON_INVALID_ARGUMENT;
364 return MM_ERROR_COMMON_INVALID_ARGUMENT;
368 int mm_attrs_get_data(MMHandleType attrs, int index, void **data, int *size)
370 mmf_attrs_t *h = (mmf_attrs_t *) attrs;
372 return_val_if_fail(h && index >= 0 && index < h->count && data, MM_ERROR_COMMON_INVALID_ARGUMENT);
374 if (!(h->items[index].flags & MM_ATTRS_FLAG_READABLE)) {
375 //mmf_debug(MMF_DEBUG_LOG, "Access denied.\n");
376 return MM_ERROR_COMMON_INVALID_PERMISSION;
378 *data = mmf_value_get_data(&h->items[index].value, size);
379 return MM_ERROR_NONE;
383 int mm_attrs_set_int_by_name(MMHandleType attrs, const char *name, int val)
387 return_val_if_fail(attrs && name, -1);
389 mm_attrs_get_index(attrs, name, &index);
391 return mm_attrs_set_int(attrs, index, val);
397 int mm_attrs_get_int_by_name(MMHandleType attrs, const char *name, int *val)
401 return_val_if_fail(attrs && name && val, MM_ERROR_COMMON_INVALID_ARGUMENT);
403 mm_attrs_get_index(attrs, name, &index);
405 return mm_attrs_get_int(attrs, index, val);
407 return MM_ERROR_COMMON_INVALID_ATTRTYPE;
411 int mm_attrs_set_string_by_name(MMHandleType attrs, const char *name, const char *string)
416 return_val_if_fail(attrs && name, -1);
418 mm_attrs_get_index(attrs, name, &index);
421 size = strlen(string);
427 return mm_attrs_set_string(attrs, index, string, size);
433 int mm_attrs_get_string_by_name(MMHandleType attrs, const char *name, char **string)
438 return_val_if_fail(attrs && name && string, MM_ERROR_COMMON_INVALID_ARGUMENT);
440 mm_attrs_get_index(attrs, name, &index);
442 return mm_attrs_get_string(attrs, index, string, &len);
444 return MM_ERROR_COMMON_INVALID_ATTRTYPE;
448 int mm_attrs_set_data_by_name(MMHandleType attrs, const char *name, void *data, int size)
452 return_val_if_fail(attrs && name, -1);
454 mm_attrs_get_index(attrs, name, &index);
456 return mm_attrs_set_data(attrs, index, data, size);
462 int mm_attrs_get_data_by_name(MMHandleType attrs, const char *name, void **data)
467 return_val_if_fail(attrs && name, MM_ERROR_COMMON_INVALID_ARGUMENT);
469 mm_attrs_get_index(attrs, name, &index);
471 return mm_attrs_get_data(attrs, index, data, &len);
473 return MM_ERROR_COMMON_INVALID_ATTRTYPE;
477 int mm_attrs_set_double_by_name(MMHandleType attrs, const char *name, double val)
481 return_val_if_fail(attrs && name, MM_ERROR_COMMON_INVALID_ARGUMENT);
483 mm_attrs_get_index(attrs, name, &index);
485 return mm_attrs_set_double(attrs, index, val);
487 return MM_ERROR_COMMON_INVALID_ATTRTYPE;
491 int mm_attrs_get_double_by_name(MMHandleType attrs, const char *name, double *val)
495 return_val_if_fail(attrs && name && val, MM_ERROR_COMMON_INVALID_ARGUMENT);
497 mm_attrs_get_index(attrs, name, &index);
499 *val = mm_attrs_get_double(attrs, index, val);
502 return MM_ERROR_COMMON_INVALID_ATTRTYPE;
506 int mm_attrs_set_valist(MMHandleType attrs, char **err_attr_name, const char *attribute_name, va_list var_args)
508 const char *name = NULL;
509 int ret = MM_ERROR_NONE;
511 return_val_if_fail(attrs, MM_ERROR_COMMON_INVALID_ARGUMENT);
512 // return_val_if_fail(err_attr_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
513 return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
516 *err_attr_name = NULL;
517 name = attribute_name;
521 MMAttrsType attr_type = MM_ATTRS_TYPE_INVALID;
524 if ((ret = mm_attrs_get_index(attrs, name, &index)) != MM_ERROR_NONE) {
527 *err_attr_name = strdup(name);
529 if (ret == (int)MM_ERROR_COMMON_OUT_OF_ARRAY) { //to avoid confusing
530 //mmf_debug(MMF_DEBUG_ERROR, "result of mm_attrs_get_index is MM_ERROR_COMMON_OUT_OF_ARRAY so return(ret = %x, name:%s)",ret, name);
531 return MM_ERROR_COMMON_ATTR_NOT_EXIST;
533 //mmf_debug(MMF_DEBUG_ERROR, "result of mm_attrs_get_index is %x so return(name:%s)",ret, name);
539 if ((ret = mm_attrs_get_type(attrs, index, &attr_type)) != MM_ERROR_NONE)
544 case MM_ATTRS_TYPE_INT:
546 int val = va_arg((var_args), int);
547 // mmf_debug(MMF_DEBUG_LOG, "(%s: %d)\n", name, val);
548 ret = mm_attrs_set_int(attrs, index, val);
551 case MM_ATTRS_TYPE_DOUBLE:
553 double val = va_arg((var_args), double);
554 // mmf_debug(MMF_DEBUG_LOG, "(%s: %f)\n", name, val);
555 ret = mm_attrs_set_double(attrs, index, val);
558 case MM_ATTRS_TYPE_STRING:
560 char * val = va_arg((var_args), char*);
561 int size = va_arg((var_args), int);
562 // mmf_debug(MMF_DEBUG_LOG, "(%s: \'%s\', size: %d)\n", name, val, size);
563 ret = mm_attrs_set_string(attrs, index, (const char*)val, size);
566 case MM_ATTRS_TYPE_DATA:
568 void * val = va_arg((var_args), void*);
569 int size = va_arg((var_args), int);
570 // mmf_debug(MMF_DEBUG_LOG, "(%s: %p, size: %d)\n", name, val, size);
571 ret = mm_attrs_set_data(attrs, index, val, size);
574 case MM_ATTRS_TYPE_INVALID:
576 //mmf_debug(MMF_DEBUG_ERROR, "This function doesn't support attribute type(%d, name:%s)\n", attr_type, name);
577 return MM_ERROR_COMMON_INVALID_ARGUMENT;
581 if (ret != MM_ERROR_NONE) {
583 *err_attr_name = strdup(name);
584 //mmf_debug(MMF_DEBUG_ERROR, "Setting failure.(name:%s)\n", name);
589 name = va_arg(var_args, char*);
592 if (mmf_attrs_commit_err(attrs, err_attr_name) == -1) {
593 //mmf_debug(MMF_DEBUG_ERROR, "result of mmf_attrs_commit_err is -1 (name:%s)", name);
594 return MM_ERROR_COMMON_UNKNOWN;
596 return MM_ERROR_NONE;
603 int mm_attrs_get_valist(MMHandleType attrs, char **err_attr_name, const char *attribute_name, va_list var_args)
605 const char *name = NULL;
606 int ret = MM_ERROR_NONE;
608 return_val_if_fail(attrs, MM_ERROR_COMMON_INVALID_ARGUMENT);
609 // return_val_if_fail(err_attr_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
610 return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
613 *err_attr_name = NULL;
614 name = attribute_name;
618 MMAttrsType attr_type = MM_ATTRS_TYPE_INVALID;
621 if ((ret = mm_attrs_get_index(attrs, name, &index)) != MM_ERROR_NONE) {
623 *err_attr_name = strdup(name);
625 if (ret == (int)MM_ERROR_COMMON_OUT_OF_ARRAY) //to avoid confusing
626 return MM_ERROR_COMMON_ATTR_NOT_EXIST;
632 if ((ret = mm_attrs_get_type(attrs, index, &attr_type)) != MM_ERROR_NONE)
637 case MM_ATTRS_TYPE_INT:
639 int * val = va_arg((var_args), int*);
640 // mmf_debug(MMF_DEBUG_LOG, "(%s: %p)\n", name, val);
641 ret = mm_attrs_get_int(attrs, index, val);
644 case MM_ATTRS_TYPE_DOUBLE:
646 double * val = va_arg((var_args), double*);
647 // mmf_debug(MMF_DEBUG_LOG, "(%s: %p)\n", name, val);
648 ret = mm_attrs_get_double(attrs, index, val);
651 case MM_ATTRS_TYPE_STRING:
653 char ** val = va_arg((var_args), char**);
654 int * size = va_arg((var_args), int*);
655 // mmf_debug(MMF_DEBUG_LOG, "(%s: %p, size: %p)\n", name, val, size);
656 ret = mm_attrs_get_string(attrs, index, (char**)val, size);
659 case MM_ATTRS_TYPE_DATA:
661 void ** val = va_arg((var_args), void**);
662 int * size = va_arg((var_args), int*);
663 // mmf_debug(MMF_DEBUG_LOG, "(%s: %p, size: %p)\n", name, val, size);
664 ret = mm_attrs_get_data(attrs, index, val, size);
667 case MM_ATTRS_TYPE_INVALID:
669 // mmf_debug(MMF_DEBUG_ERROR, "This function doesn't support attribute type(%d, name:%s)\n", attr_type, name);
671 // *err_attr_name = strdup(name);
672 ret = MM_ERROR_COMMON_INVALID_ARGUMENT;
676 if (ret != MM_ERROR_NONE) {
678 *err_attr_name = strdup(name);
679 //mmf_debug(MMF_DEBUG_ERROR, "Setting failure.(name:%s)\n", name);
684 name = va_arg(var_args, char*);
691 int mm_attrs_multiple_set(MMHandleType attrs, char **err_attr_name, const char *attribute_name, ...)
694 int ret = MM_ERROR_NONE;
696 return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
698 va_start(var_args, attribute_name);
699 ret = mm_attrs_set_valist(attrs, err_attr_name, attribute_name, var_args);
706 int mm_attrs_multiple_get(MMHandleType attrs, char **err_attr_name, const char *attribute_name, ...)
709 int ret = MM_ERROR_NONE;
711 return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
713 va_start(var_args, attribute_name);
714 ret = mm_attrs_get_valist(attrs, err_attr_name, attribute_name, var_args);
721 int mm_attrs_get_info(MMHandleType attrs, int index, MMAttrsInfo *info)
723 mmf_attrs_t *h = (mmf_attrs_t *) attrs;
725 return_val_if_fail(attrs, MM_ERROR_COMMON_INVALID_ARGUMENT);
726 return_val_if_fail(info, MM_ERROR_COMMON_INVALID_ARGUMENT);
727 return_val_if_fail(0 <= index && index < h->count, MM_ERROR_COMMON_INVALID_ARGUMENT);
729 memset(info, 0x00, sizeof(MMAttrsInfo));
731 info->type = h->items[index].value.type;
732 info->flag = h->items[index].flags;
733 info->validity_type = h->items[index].value_spec.type;
735 switch (info->validity_type) {
736 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
737 info->int_array.array = h->items[index].value_spec.spec.int_spec.array.array;
738 info->int_array.count = h->items[index].value_spec.spec.int_spec.array.count;
739 info->int_array.dval = h->items[index].value_spec.spec.int_spec.array.dval;
741 case MM_ATTRS_VALID_TYPE_INT_RANGE:
742 info->int_range.min = h->items[index].value_spec.spec.int_spec.range.min;
743 info->int_range.max = h->items[index].value_spec.spec.int_spec.range.max;
744 info->int_range.dval = h->items[index].value_spec.spec.int_spec.range.dval;
746 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
747 info->double_array.array = h->items[index].value_spec.spec.double_spec.array.array;
748 info->double_array.count = h->items[index].value_spec.spec.double_spec.array.count;
749 info->double_array.dval = h->items[index].value_spec.spec.double_spec.array.dval;
751 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
752 info->double_range.min = h->items[index].value_spec.spec.double_spec.range.min;
753 info->double_range.max = h->items[index].value_spec.spec.double_spec.range.max;
754 info->double_range.dval = h->items[index].value_spec.spec.double_spec.range.dval;
756 case MM_ATTRS_VALID_TYPE_NONE:
757 //mmf_debug(MMF_DEBUG_LOG, "Valid type none.\n");
759 case MM_ATTRS_VALID_TYPE_INVALID:
764 return MM_ERROR_NONE;
768 int mm_attrs_get_info_by_name(MMHandleType attrs, const char *attr_name, MMAttrsInfo *info)
771 int ret = MM_ERROR_NONE;
773 return_val_if_fail(attrs, MM_ERROR_COMMON_INVALID_ARGUMENT);
774 return_val_if_fail(info, MM_ERROR_COMMON_INVALID_ARGUMENT);
776 //mmf_debug(MMF_DEBUG_LOG, "(attr_name:%s)\n", attr_name);
778 mm_attrs_get_index(attrs, attr_name, &index);
780 return_val_if_fail(index >= 0, MM_ERROR_COMMON_INVALID_ARGUMENT);
782 ret = mm_attrs_get_info(attrs, index, info);
788 int mm_attrs_set_valid_type(MMHandleType attrs, int index, MMAttrsValidType type)
790 return_val_if_fail(type > MM_ATTRS_VALID_TYPE_INVALID, MM_ERROR_COMMON_INVALID_ARGUMENT);
791 return_val_if_fail(type <= MM_ATTRS_VALID_TYPE_DOUBLE_RANGE, MM_ERROR_COMMON_INVALID_ARGUMENT);
793 return mmf_attrs_set_valid_type(attrs, index, (int)type);
797 int mm_attrs_set_valid_range(MMHandleType attrs, int index, int min, int max, int dval)
799 return mmf_attrs_set_valid_range(attrs, index, min, max, dval);
803 int mm_attrs_set_valid_array(MMHandleType attrs, int index, const int *array, int count, int dval)
805 return mmf_attrs_set_valid_array(attrs, index, array, count, dval);
809 int mm_attrs_set_valid_double_range(MMHandleType attrs, int index, double min, double max, double dval)
811 return mmf_attrs_set_valid_double_range(attrs, index, min, max, dval);
815 int mm_attrs_set_valid_double_array(MMHandleType attrs, int index, const double *array, int count, double dval)
817 return mmf_attrs_set_valid_double_array(attrs, index, array, count, dval);
821 int mm_attrs_is_modified(MMHandleType attrs, int index, bool *modified)
823 mmf_attrs_t *h = (mmf_attrs_t *) attrs;
824 mmf_attribute_t *item;
826 return_val_if_fail(attrs, MM_ERROR_COMMON_INVALID_ARGUMENT);
827 return_val_if_fail(index >= 0, MM_ERROR_COMMON_INVALID_ARGUMENT);
829 item = &h->items[index];
831 MM_ATTR_ITEM_WRITE_LOCK(item);
833 *modified = mmf_attribute_is_modified(item);
835 MM_ATTR_ITEM_WRITE_UNLOCK(item);
837 return MM_ERROR_NONE;
841 int mm_attrs_set_modified(MMHandleType attrs, int index)
843 mmf_attrs_t *h = (mmf_attrs_t *) attrs;
844 mmf_attribute_t *item;
846 return_val_if_fail(attrs, MM_ERROR_COMMON_INVALID_ARGUMENT);
847 return_val_if_fail(index >= 0, MM_ERROR_COMMON_INVALID_ARGUMENT);
849 item = &h->items[index];
851 MM_ATTR_ITEM_WRITE_LOCK(item);
853 mmf_attribute_set_modified(item);
855 MM_ATTR_ITEM_WRITE_UNLOCK(item);
857 return MM_ERROR_NONE;
861 int mm_attrs_set_readonly(MMHandleType attrs, int index)
863 mmf_attrs_t *h = (mmf_attrs_t *) attrs;
864 mmf_attribute_t *item;
866 return_val_if_fail(attrs, MM_ERROR_COMMON_INVALID_ARGUMENT);
867 return_val_if_fail(index >= 0, MM_ERROR_COMMON_INVALID_ARGUMENT);
869 item = &h->items[index];
871 MM_ATTR_ITEM_WRITE_LOCK(item);
873 mmf_attribute_set_readonly(item);
875 MM_ATTR_ITEM_WRITE_UNLOCK(item);
877 return MM_ERROR_NONE;
881 int mm_attrs_set_disabled(MMHandleType attrs, int index)
883 mmf_attrs_t *h = (mmf_attrs_t *) attrs;
884 mmf_attribute_t *item;
886 return_val_if_fail(attrs, MM_ERROR_COMMON_INVALID_ARGUMENT);
887 return_val_if_fail(index >= 0, MM_ERROR_COMMON_INVALID_ARGUMENT);
889 item = &h->items[index];
891 MM_ATTR_ITEM_WRITE_LOCK(item);
893 mmf_attribute_set_disabled(item);
895 MM_ATTR_ITEM_WRITE_UNLOCK(item);
897 return MM_ERROR_NONE;