-
Notifications
You must be signed in to change notification settings - Fork 581
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Script out running of setup routine in the main process.
- Loading branch information
Showing
2 changed files
with
109 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright (C) 2023 Sippy Software, Inc., http://www.sippysoft.com | ||
* | ||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
* | ||
*/ | ||
|
||
#pragma once | ||
|
||
typedef int (*pred_cmp_f)(int, int); | ||
|
||
struct main_script { | ||
int (*hndlr)(void); | ||
int pval; | ||
int pred; | ||
const char *desc; | ||
}; | ||
|
||
static int op_neq(int r, int e) { return (r != e); } | ||
static int op_eq(int r, int e) { return (r == e); } | ||
static int op_lt(int r, int e) { return (r < e); } | ||
static int op_lte(int r, int e) { return (r <= e); } | ||
static int op_gt(int r, int e) { return (r > e); } | ||
static int op_gte(int r, int e) { return (r >= e); } | ||
|
||
#define opidx(lop) (((0 lop 0) << 2) | ((0 lop 1) << 1) | (1 lop 0)) | ||
|
||
static const pred_cmp_f cmps_ops[] = { | ||
[opidx(!=)] = op_neq, | ||
[opidx(==)] = op_eq, | ||
[opidx(<)] = op_lt, | ||
[opidx(>)] = op_gt, | ||
[opidx(<=)] = op_lte, | ||
[opidx(>=)] = op_gte | ||
}; | ||
|
||
#define FN_HNDLR(h, lop, p, d) (struct main_script){ \ | ||
.hndlr = (h), \ | ||
.pval = opidx(lop), \ | ||
.pred = (p), \ | ||
.desc = (d), \ | ||
} |