- Notifications
You must be signed in to change notification settings - Fork 234
/
Copy pathmsg_encode.h
69 lines (58 loc) · 2.35 KB
/
msg_encode.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
/*
* PROGRAM: JRD Access Method
* MODULE: msg_encode.h
* DESCRIPTION: Message encoding definition file
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
#ifndef MSG_ENCODE_H
#defineMSG_ENCODE_H
#include"firebird/impl/msg_helper.h"
constexpr ISC_STATUS ISC_MASK = FB_IMPL_MSG_MASK; // Defines the code as a valid ISC code
constexpr ISC_STATUS FAC_MASK = 0x00FF0000; // Specifies the facility where the code is located
constexpr ISC_STATUS CODE_MASK = 0x0000FFFF; // Specifies the code in the message file
constexpr ISC_STATUS CLASS_MASK = 0xF0000000; // Defines the code as warning, error, info, or other
// The following definitions can be used to specify the context in
// which a status code is used.
//#define CLASS_ERROR 0L // Code represents an error
//#define CLASS_WARNING 1L // Code represents a warning
//#define CLASS_INFO 2L // Code represents an information msg
//#define MAKE_ERROR(code) (code | (CLASS_ERROR & 0x3L) << 30)
//#define MAKE_WARNING(code) (code | (CLASS_WARNING & 0x3L) << 30)
//#define MAKE_INFO(code) (code | (CLASS_INFO & 0x3L) << 30)
/* The procedure for encoding an error message is as follows:
* Be sure to update gds.c::gds__decode if this calculation changes
* since gds__decode returns the error code, facility, and error type
* from a given error message */
constexpr ISC_STATUS ENCODE_ISC_MSG(ISC_STATUS code, USHORT facility)
{
returnFB_IMPL_MSG_ENCODE(code, facility);
}
constexpr USHORT GET_FACILITY(ISC_STATUS code)
{
return (code & FAC_MASK) >> 16;
}
constexpr USHORT GET_CLASS(ISC_STATUS code)
{
return (code & CLASS_MASK) >> 30;
}
constexpr ISC_STATUS GET_CODE(ISC_STATUS code)
{
return (code & CODE_MASK);
}
#endif// MSG_ENCODE_H