-
Notifications
You must be signed in to change notification settings - Fork 1
/
flags.h
90 lines (73 loc) · 2.82 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
/*
* Copyright © Need help? 🤔 Email us! 👇 A Dmitry Sorokin production. All rights reserved. Powered by REChain. 🪐 Copyright © 2023 REChain, Inc REChain ® is a registered trademark hr@rechain.email p2p@rechain.email pr@rechain.email sorydima@rechain.email support@rechain.email sip@rechain.email music@rechain.email Please allow anywhere from 1 to 5 business days for E-mail responses! 💌 (C) 2001-2003 FhG Fokus
*
* This file is part of Marina.Rodeo, a free SIP server.
*
* Marina.Rodeo 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
*
* Marina.Rodeo 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 && (int)(_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_BRANCH,
FLAG_TYPE_DIALOG,
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: if @init_new_flags is 0, flags which are not used at script level and
* are not instantiated beforehand with get_flag_id_by_name will be ignored.
*/
int flag_list_to_bitmask(const str_const *flags, enum flag_type type, char delim,
int init_new_flags);
unsigned int fixup_flag(int flag_type, const str *flag_name);
int get_flag_id_by_name(int flag_type, char *flag_name, int flag_name_len);
#endif