bin.h

Go to the documentation of this file.
00001 /*
00002  * $Id: bin.h 161 2007-03-01 14:06:01Z vingarzan $
00003  *
00004  * Copyright (C) 2004-2007 FhG Fokus
00005  *
00006  * This file is part of Open IMS Core - an open source IMS CSCFs & HSS
00007  * implementation
00008  *
00009  * Open IMS Core is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version.
00013  *
00014  * For a license to use the Open IMS Core software under conditions
00015  * other than those described here, or to purchase support for this
00016  * software, please contact Fraunhofer FOKUS by e-mail at the following
00017  * addresses:
00018  *     info@open-ims.org
00019  *
00020  * Open IMS Core is distributed in the hope that it will be useful,
00021  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00022  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023  * GNU General Public License for more details.
00024  *
00025  * It has to be noted that this Open Source IMS Core System is not
00026  * intended to become or act as a product in a commercial context! Its
00027  * sole purpose is to provide an IMS core reference implementation for
00028  * IMS technology testing and IMS application prototyping for research
00029  * purposes, typically performed in IMS test-beds.
00030  *
00031  * Users of the Open Source IMS Core System have to be aware that IMS
00032  * technology may be subject of patents and licence terms, as being
00033  * specified within the various IMS-related IETF, ITU-T, ETSI, and 3GPP
00034  * standards. Thus all Open IMS Core users have to take notice of this
00035  * fact and have to agree to check out carefully before installing,
00036  * using and extending the Open Source IMS Core System, if related
00037  * patents and licences may become applicable to the intended usage
00038  * context.
00039  *
00040  * You should have received a copy of the GNU General Public License
00041  * along with this program; if not, write to the Free Software
00042  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00043  *
00044  */
00045 
00102 #ifndef _BIN_H
00103 #define _BIN_H
00104 
00105 #include "mod.h"
00106 #include "../../mem/mem.h"
00107 #include "../dialog/dlg_mod.h"
00108 
00109 
00110 typedef struct _bin_data {
00111     char* s; /*string*/
00112     int len; /*string len*/
00113     int max; /*allocated size of the buffer s*/ 
00114 } bin_data;
00115 
00116 
00117 /*
00118  *      Binary encoding functions
00119  */
00120 /* memory allocation and initialization macros */
00121 #define BIN_ALLOC_METHOD    pkg_malloc
00122 #define BIN_REALLOC_METHOD  pkg_realloc
00123 #define BIN_FREE_METHOD     pkg_free
00124 
00125 inline int bin_alloc(bin_data *x, int max_len);
00126 inline int bin_realloc(bin_data *x, int delta);
00127 inline int bin_expand(bin_data *x, int delta);
00128 inline void bin_free(bin_data *x);
00129 inline void bin_print(bin_data *x);
00130 
00131 inline int bin_encode_char(bin_data *x,char k);
00132 inline int bin_decode_char(bin_data *x,char *c);
00133 
00134 inline int bin_encode_uchar(bin_data *x,unsigned char k); 
00135 inline int bin_decode_uchar(bin_data *x,unsigned char *c);
00136 
00137 inline int bin_encode_short(bin_data *x,short k);
00138 inline int bin_decode_short(bin_data *x,short *c);
00139 
00140 inline int bin_encode_ushort(bin_data *x,unsigned short k); 
00141 inline int bin_decode_ushort(bin_data *x,unsigned short *c);
00142 
00143 inline int bin_encode_int(bin_data *x,int k);
00144 inline int bin_decode_int(bin_data *x,int *c);
00145 
00146 inline int bin_encode_uint(bin_data *x,unsigned int k); 
00147 inline int bin_decode_uint(bin_data *x,unsigned int *c);
00148 
00149 inline int bin_encode_time_t(bin_data *x,time_t k);
00150 inline int bin_decode_time_t(bin_data *x,time_t *c);
00151 
00152 inline int bin_encode_str(bin_data *x,str *s);
00153 inline int bin_decode_str(bin_data *x,str *s);
00154 
00155 
00156 int bin_encode_dlg_t(bin_data *x,dlg_t *d);
00157 int bin_decode_dlg_t(bin_data *x,dlg_t **d);
00158 
00159 
00160 typedef enum {
00161     NO_PERSISTENCY=0,
00162     WITH_FILES=1,
00163     WITH_DATABASE_BULK=2,
00164     WITH_DATABASE_CACHE=3
00165 } persistency_mode_t;
00166 
00167 /* Dumping functions */
00168 
00169 
00170 int bin_dump_to_file(bin_data *x,char *location,char *prepend_fname);
00171 int bin_load_from_file(bin_data *x,char *location,char *prepend_fname);
00172 
00173 int bin_dump(bin_data *x,int mode,char *location,char* prepend_fname);
00174 int bin_load(bin_data *x,int mode,char *location,char* prepend_fname);
00175 
00176 
00177 
00178 #endif

Generated on Thu Oct 23 04:14:38 2008 for Open IMS Core CSCFs by  doxygen 1.5.2