1 /* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef _NS_CONFIG_H 17 #define _NS_CONFIG_H 18 19 #ifdef __cplusplus 20 extern "C" { 21 #endif 22 23 #include <stdio.h> 24 #include <stdlib.h> 25 #include <string.h> 26 #include <stdbool.h> 27 #include "strops.h" 28 /* 29 * The following #include is necessary on many Unixes but not Linux. 30 * It is not needed for Windows platforms. 31 * Uncomment it if needed. 32 */ 33 /* #include <unistd.h> */ 34 35 typedef struct _kv_list_ { 36 size_t num; /** Number of entries in list */ 37 size_t size; /** Storage size */ 38 char **key; /** List of string keys */ 39 char **val; /** List of string values */ 40 } kvlist; 41 42 typedef struct _section_list_ { 43 size_t num; 44 size_t size; 45 char **names; 46 kvlist **kvs; 47 } section_list; 48 49 typedef struct _ns_configor_ { 50 char *file_path; 51 char *exe_path; 52 char *config_sys_path; 53 char *config_asan_sys_path; 54 section_list *sections; 55 kvlist *kvs; 56 57 void (*set_error_callback)(int (*errback)(const char *, ...)); 58 int (*parse)(const char *file_path, const char *exe_path); 59 strlist *(*get_namespaces)(void); 60 char *(*get_lib_paths)(const char *ns_name); 61 char *(*get_asan_lib_paths)(const char *ns_name); 62 char *(*get_permitted_paths)(const char *ns_name); 63 char *(*get_asan_permitted_paths)(const char *ns_name); 64 bool (*get_separated)(const char *ns_name); 65 strlist *(*get_inherits)(const char *ns_name); 66 char *(*get_allowed_libs)(const char *ns_name); 67 char *(*get_inherit_shared_libs)(const char *ns_name, const char *inherited_ns_name); 68 char *(*get_sys_paths)(void); 69 char *(*get_asan_sys_paths)(void); 70 } ns_configor; 71 72 ns_configor *configor_init(); 73 void configor_free(); 74 75 76 #ifdef __cplusplus 77 } 78 #endif 79 80 #endif 81