/* * object.h * * Copyright (C) 2013 Aleksandar Andrejevic * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ #ifndef _OBJECT_H_ #define _OBJECT_H_ #include #include #include #include #include typedef struct { list_entry_t link; dword_t uid; access_flags_t access_mask; } access_control_entry_t; typedef struct { list_entry_t by_name_list; list_entry_t by_type_list; char *name; qword_t ref_count; dword_t open_count; object_type_t type; uid_t owner; lock_t acl_lock; list_entry_t acl; } object_t; static inline void init_object(object_t *object, const char *name, object_type_t type) { object->name = name ? strdup(name) : NULL; object->type = type; } dword_t create_object(object_t *object); void reference(object_t *object); void dereference(object_t *object); bool_t reference_by_name(const char *name, object_type_t type, object_t **object); bool_t reference_by_handle(handle_t handle, object_type_t type, object_t **object); dword_t open_object(object_t *obj, access_flags_t access_flags, handle_t *handle); dword_t open_object_by_name(const char *name, object_type_t type, access_flags_t access_flags, handle_t *handle); void close_object_internal(object_t *obj); dword_t enum_objects_by_type(object_type_t type, object_t **object); void object_init(void); #endif