forked from Vocalocity/opensips
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flags.h
97 lines (79 loc) · 2.67 KB
/
flags.h
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
/*
* $Id$
*
* Copyright (C) 2001-2003 FhG Fokus
*
* 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
*/
/*!
* \file
* \brief Flag management
*/
#ifndef _FLAGS_H
#define _FLAGS_H
#include <limits.h>
typedef unsigned int flag_t;
#define MAX_FLAG ((unsigned int)( sizeof(flag_t) * CHAR_BIT - 1 ))
#define PRINT_BUFFER_SIZE 2048
#define NAMED_FLAG_ERROR 33
#define FLAG_DELIM ' '
#define fix_flag_name(_s, _flag) \
do { \
if (!*_s && _flag > 0) { \
LM_WARN("Integer flags are now deprecated! " \
"Use unique quoted strings!\n"); \
*_s = int2str(_flag, NULL); \
} \
} while (0)
enum flag_type {
FLAG_TYPE_MSG=0,
FLAG_TYPE_SCRIPT,
FLAG_TYPE_BRANCH,
FLAG_LIST_COUNT,
};
struct sip_msg;
struct flag_entry {
str name;
int bit; /* 0 .. 31 */
struct flag_entry *next;
};
int flag_in_range( flag_t flag );
int setflag( struct sip_msg* msg, flag_t flag );
int resetflag( struct sip_msg* msg, flag_t flag );
int isflagset( struct sip_msg* msg, flag_t flag );
int flag_idx2mask(int *flag);
/**
* returns a string representation of the named flags set in the bitmask
*
* Note: prints data in a static buffer, flags are delimited by FLAG_DELIM
*/
str bitmask_to_flag_list(enum flag_type type, int bitmask);
/**
* parses a list of named flags and returns the corresponding bitmask
*
* Note: flags which are not used at script level and are not instantiated with
* get_flag_id_by_name will be ignored
*/
int flag_list_to_bitmask(str *flags, enum flag_type type, char delim);
unsigned int fixup_flag(int flag_type, str *flag_name);
int get_flag_id_by_name(int flag_type, char *flag_name);
int setsflagsval( unsigned int val );
int setsflag( unsigned int mask );
int resetsflag( unsigned int mask );
int issflagset( unsigned int mask );
unsigned int getsflags();
#endif