libdballe 4.0.18
msg.h
Go to the documentation of this file.
00001 /*
00002  * DB-ALLe - Archive for punctual meteorological data
00003  *
00004  * Copyright (C) 2005--2008  ARPA-SIM <urpsim@smr.arpa.emr.it>
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00018  *
00019  * Author: Enrico Zini <enrico@enricozini.com>
00020  */
00021 
00022 #ifndef DBALLE_BUFREX_MSG_H
00023 #define DBALLE_BUFREX_MSG_H
00024 
00025 #ifdef  __cplusplus
00026 extern "C" {
00027 #endif
00028 
00035 #include <dballe/core/var.h>
00036 #include <dballe/core/rawmsg.h>
00037 #include <dballe/bufrex/dtable.h>
00038 #include <dballe/bufrex/subset.h>
00039 
00043 enum _bufrex_type {
00045     BUFREX_BUFR,
00047     BUFREX_CREX
00048 };
00050 typedef enum _bufrex_type bufrex_type;
00051 
00052 struct _bufrex_opcode;
00053 
00055 struct _bufrex_bufr_info {
00057     int centre;
00059     int subcentre;
00061     int master_table;
00063     int local_table;
00064 
00066     int compression;
00069     int optional_section_length;
00071     char* optional_section;
00073     int subsets;
00074 };
00076 struct _bufrex_crex_info {
00078     int master_table;
00080     int table;
00082     int has_check_digit;
00083 };
00084 
00088 struct _bufrex_msg
00089 {
00095     int _refcount;
00096 
00098     bufrex_type encoding_type;
00099 
00101     union {
00102         struct _bufrex_crex_info crex;
00103         struct _bufrex_bufr_info bufr;
00104     } opt;
00105 
00107     int type;
00109     int subtype;
00111     int localsubtype;
00112 
00114     int edition;
00115 
00118     int rep_year;   
00119     int rep_month;  
00120     int rep_day;    
00121     int rep_hour;   
00122     int rep_minute; 
00123     int rep_second; 
00127     dba_vartable btable;
00129     bufrex_dtable dtable;
00130 
00132     bufrex_subset* subsets;
00134     size_t subsets_count;
00136     size_t subsets_alloclen;
00137 
00139     bufrex_opcode datadesc;
00144     bufrex_opcode* datadesc_last;
00145 };
00147 typedef struct _bufrex_msg* bufrex_msg;
00148 
00159 dba_err bufrex_msg_create(bufrex_type type, bufrex_msg* msg);
00160 
00167 void bufrex_msg_delete(bufrex_msg msg);
00168 
00178 void bufrex_msg_reset(bufrex_msg msg);
00179 
00196 dba_err bufrex_msg_get_subset(bufrex_msg msg, int subsection, bufrex_subset* vars);
00197 
00207 dba_err bufrex_msg_get_table_id(bufrex_msg msg, const char** id);
00208 
00212 dba_err bufrex_msg_load_tables(bufrex_msg msg);
00213 
00227 dba_err bufrex_msg_query_btable(bufrex_msg msg, dba_varcode code, dba_varinfo* info);
00228 
00242 dba_err bufrex_msg_query_dtable(bufrex_msg msg, dba_varcode code, struct _bufrex_opcode** res);
00243 
00250 void bufrex_msg_reset_datadesc(bufrex_msg msg);
00251 
00260 void bufrex_msg_reset_sections(bufrex_msg msg);
00261 
00274 dba_err bufrex_msg_get_datadesc(bufrex_msg msg, struct _bufrex_opcode** res);
00275 
00286 dba_err bufrex_msg_append_datadesc(bufrex_msg msg, dba_varcode varcode);
00287 
00297 dba_err bufrex_msg_generate_datadesc(bufrex_msg msg);
00298 
00302 dba_err bufrex_msg_decode_header(bufrex_msg msg, dba_rawmsg raw);
00303 
00307 dba_err bufrex_msg_decode(bufrex_msg msg, dba_rawmsg raw);
00308 
00312 dba_err bufrex_msg_encode(bufrex_msg msg, dba_rawmsg* raw);
00313 
00314 
00325 dba_err bufr_encoder_encode(bufrex_msg in, dba_rawmsg out);
00326 
00337 dba_err bufr_decoder_decode_header(dba_rawmsg in, bufrex_msg out);
00338 
00349 dba_err bufr_decoder_decode(dba_rawmsg in, bufrex_msg out);
00350 
00361 dba_err crex_encoder_encode(bufrex_msg in, dba_rawmsg out);
00362 
00373 dba_err crex_decoder_decode(dba_rawmsg in, bufrex_msg out);
00374 
00385 dba_err crex_decoder_decode_header(dba_rawmsg in, bufrex_msg out);
00386 
00390 void bufrex_msg_print(bufrex_msg msg, FILE* out);
00391 
00395 void bufrex_msg_diff(bufrex_msg msg1, bufrex_msg msg2, int* diffs, FILE* out);
00396 
00414 dba_err bufrex_msg_parse_template(const char* str, int* cat, int* subcat, int* localsubcat);
00415 
00416 #ifdef  __cplusplus
00417 }
00418 #endif
00419 
00420 /* vim:set ts=4 sw=4: */
00421 #endif