blob: 1c27a0dc48990d86fcf6a4a98d820afe42de4b30 (
plain)
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
|
/*-------------------------------------------------------------------------
*
* enbl.c--
* POSTGRES module enable and disable support code.
*
* Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/init/Attic/enbl.c,v 1.3 1998/08/25 21:04:40 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
#include "utils/module.h" /* where the declarations go */
/*
* BypassEnable --
* False iff enable/disable processing is required given on and "*countP."
*
* Note:
* As a side-effect, *countP is modified. It should be 0 initially.
*
* Exceptions:
* BadState if called with pointer to value 0 and false.
* BadArg if "countP" is invalid pointer.
* BadArg if on is invalid.
*/
bool
BypassEnable(int *enableCountInOutP, bool on)
{
AssertArg(PointerIsValid(enableCountInOutP));
AssertArg(BoolIsValid(on));
if (on)
{
*enableCountInOutP += 1;
return ((bool) (*enableCountInOutP >= 2));
}
AssertState(*enableCountInOutP >= 1);
*enableCountInOutP -= 1;
return ((bool) (*enableCountInOutP >= 1));
}
|