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 GRU_PAYLOAD_H 00018 #define GRU_PAYLOAD_H 00019 00020 #include <stdio.h> 00021 #include <stdlib.h> 00022 00023 #if !defined(_WIN32) && !defined(_WIN64) 00024 #include <strings.h> 00025 #endif 00026 00027 #include "common/gru_portable.h" 00028 #include "common/gru_status.h" 00029 #include "io/gru_ioutils.h" 00030 #include "io/gru_path.h" 00031 00032 #ifdef __cplusplus 00033 extern "C" { 00034 #endif 00035 00036 typedef void (*gru_payload_data_init_t)(void *); 00037 typedef void (*gru_payload_data_save_t)(FILE *, void *); 00038 typedef void (*gru_payload_data_read_t)(FILE *, void *); 00039 00040 typedef struct gru_payload_t_ { 00041 gru_payload_data_init_t init; 00042 gru_payload_data_save_t save; 00043 gru_payload_data_read_t read; 00044 00045 void *data; 00046 } gru_payload_t; 00047 00048 gru_export gru_payload_t *gru_payload_init(gru_payload_data_init_t init, 00049 gru_payload_data_save_t save, gru_payload_data_read_t read, void *data, 00050 gru_status_t *status); 00051 00052 gru_export void gru_payload_destroy(gru_payload_t **payload); 00053 00054 gru_export FILE *gru_payload_init_data( 00055 gru_payload_t *payload, const char *dir, const char *name, gru_status_t *status); 00056 00057 #ifdef __cplusplus 00058 } 00059 #endif 00060 00061 #endif /* GRU_PAYLOAD_H */