[6cdc32]: src / core / config / params.h Maximize Restore History

Download this file

params.h    117 lines (92 with data), 3.0 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*
* Copyright (C) 2010 OpenSIPS Project
*
* This file is part of opensips, a free SIP server.
*
* opensips is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* opensips 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*
* history:
* ---------
* 2010-01-xx created (adragus)
*
*/
#include "../str.h"
#ifndef _OPENSIPS_PARAMS_H
#define _OPENSIPS_PARAMS_H
#define PARAM_TYPE_INT (1<<0)
#define PARAM_TYPE_DOUBLE (1<<1)
#define PARAM_TYPE_STR (1<<2)
#define PARAM_TYPE_STRING (1<<3)
#define PARAM_TYPE_FUNC (1<<7)
/*
* Structure that describes a parameter
*
*/
typedef struct config_param
{
char* name;
/* Destination where the information will be put.
* May be param_*_func in which case it will not be set,
* it will be called with the corresponding value
* */
void * dest;
/*
* Types of data accepted.
* It is a mask of PARAM_TYPE_* values
*/
int flags;
/*
* Function to verify a parameter.
* May be NULL.
*/
int (*verify) (struct config_param *);
} config_param_t;
/* type of function used to verify parameters*/
typedef int (*param_func)(config_param_t *);
/* type of function called if you don't wish to overwrite parameters */
typedef int (*param_int_func)( int );
typedef int (*param_double_func)( double );
typedef int (*param_string_func)( char* );
typedef struct param_section
{
char* name;
/* zero terminated array of parameters */
config_param_t * params;
} param_section_t;
typedef struct param_list
{
param_section_t* section;
struct param_list * next;
} param_list_t;
/*
* Function that adds sections of parameters to the global list
*/
void global_append_section(param_section_t* section);
void global_destroy_sections(void);
/*
* Function that gets sections of parameters from the global list
*/
param_section_t* global_get_section(char* name);
int set_int_param(param_section_t* section, char * name, int val);
int set_double_param(param_section_t* section, char * name, double val);
int set_string_param(param_section_t* section, char * name, char * val);
/*
* Functions that are not on global values
*/
void append_section(param_list_t ** list, param_section_t* section);
param_section_t* get_section(param_list_t * list, char* name);
config_param_t* get_param(param_section_t* section, char* name);
#endif