00001 /* 00002 Copyright 2016 Otavio Rodolfo Piske 00003 00004 Licensed under the Apache License, Version 2.0 (the "License"); 00005 you may not use this file except in compliance with the License. 00006 You may obtain a copy of the License at 00007 00008 http://www.apache.org/licenses/LICENSE-2.0 00009 00010 Unless required by applicable law or agreed to in writing, software 00011 distributed under the License is distributed on an "AS IS" BASIS, 00012 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 See the License for the specific language governing permissions and 00014 limitations under the License. 00015 */ 00016 00017 #ifndef NODE_H 00018 #define NODE_H 00019 00020 #include <stdio.h> 00021 #include <stdlib.h> 00022 00023 #include "common/gru_portable.h" 00024 00025 typedef struct gru_node_t_ { 00026 struct gru_node_t_ *next; 00027 struct gru_node_t_ *previous; 00028 const void *data; 00029 } gru_node_t; 00030 00036 gru_export gru_node_t *gru_node_new(const void *ptr); 00037 00042 gru_export void gru_node_destroy(gru_node_t **node); 00043 00049 gru_export void gru_node_set_previous( 00050 gru_node_t *gru_restrict node, gru_node_t *gru_restrict previous); 00051 00057 gru_export void gru_node_set_next( 00058 gru_node_t *gru_restrict node, gru_node_t *gru_restrict next); 00059 00064 gru_export void gru_node_reset(gru_node_t *gru_restrict node); 00065 00070 gru_export void gru_node_unlink(gru_node_t *gru_restrict node); 00071 00072 #define gru_node_get_data_ptr(type, node) (type *) node->data 00073 #define gru_node_get_data(type, node) (*(gru_node_get_data_ptr(type, node))) 00074 00075 #endif