/src/haproxy/include/haproxy/fix.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * include/haproxy/fix.h |
3 | | * This file contains functions and macros declarations for FIX protocol decoding. |
4 | | * |
5 | | * Copyright 2020 Baptiste Assmann <bedis9@gmail.com> |
6 | | * |
7 | | * This library is free software; you can redistribute it and/or |
8 | | * modify it under the terms of the GNU Lesser General Public |
9 | | * License as published by the Free Software Foundation, version 2.1 |
10 | | * exclusively. |
11 | | * |
12 | | * This library is distributed in the hope that it will be useful, |
13 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | | * Lesser General Public License for more details. |
16 | | * |
17 | | * You should have received a copy of the GNU Lesser General Public |
18 | | * License along with this library; if not, write to the Free Software |
19 | | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
20 | | */ |
21 | | |
22 | | #ifndef _HAPROXY_FIX_H |
23 | | #define _HAPROXY_FIX_H |
24 | | |
25 | | #include <import/ist.h> |
26 | | |
27 | | #include <haproxy/fix-t.h> |
28 | | #include <haproxy/tools.h> |
29 | | |
30 | | unsigned int fix_check_id(const struct ist str, const struct ist version); |
31 | | int fix_validate_message(const struct ist msg); |
32 | | struct ist fix_tag_value(const struct ist msg, unsigned int tagid); |
33 | | |
34 | | /* |
35 | | * Return the FIX version string (one of FIX_X_Y macros) corresponding to |
36 | | * <str> or IST_NULL if not found. |
37 | | */ |
38 | | static inline struct ist fix_version(const struct ist str) |
39 | 0 | { |
40 | | /* 7 is the minimal size for the FIX version string */ |
41 | 0 | if (istlen(str) < 7) |
42 | 0 | return IST_NULL; |
43 | | |
44 | 0 | if (isteq(FIX_4_0, str)) |
45 | 0 | return FIX_4_0; |
46 | 0 | else if (isteq(FIX_4_1, str)) |
47 | 0 | return FIX_4_1; |
48 | 0 | else if (isteq(FIX_4_2, str)) |
49 | 0 | return FIX_4_2; |
50 | 0 | else if (isteq(FIX_4_3, str)) |
51 | 0 | return FIX_4_3; |
52 | 0 | else if (isteq(FIX_4_4, str)) |
53 | 0 | return FIX_4_4; |
54 | 0 | else if (isteq(FIX_5_0, str)) |
55 | 0 | return FIX_5_0; |
56 | | |
57 | 0 | return IST_NULL; |
58 | 0 | } Unexecuted instantiation: sample.c:fix_version Unexecuted instantiation: fix.c:fix_version |
59 | | |
60 | | /* |
61 | | * Return the FIX tag ID corresponding to <tag> if one found or 0 if not. |
62 | | * |
63 | | * full list of tag ID available here, just in case we need to support |
64 | | * more "string" equivalent in the future: |
65 | | * https://www.onixs.biz/fix-dictionary/4.2/fields_by_tag.html |
66 | | */ |
67 | | static inline unsigned int fix_tagid(const struct ist tag) |
68 | 0 | { |
69 | 0 | unsigned id = fix_check_id(tag, IST_NULL); |
70 | |
|
71 | 0 | if (id) |
72 | 0 | return id; |
73 | | |
74 | 0 | else if (isteqi(tag, ist("MsgType"))) |
75 | 0 | return FIX_TAG_MsgType; |
76 | 0 | else if (isteqi(tag, ist("CheckSum"))) |
77 | 0 | return FIX_TAG_CheckSum; |
78 | 0 | else if (isteqi(tag, ist("BodyLength"))) |
79 | 0 | return FIX_TAG_BodyLength; |
80 | 0 | else if (isteqi(tag, ist("TargetCompID"))) |
81 | 0 | return FIX_TAG_TargetCompID; |
82 | 0 | else if (isteqi(tag, ist("BeginString"))) |
83 | 0 | return FIX_TAG_BeginString; |
84 | 0 | else if (isteqi(tag, ist("SenderCompID"))) |
85 | 0 | return FIX_TAG_SenderCompID; |
86 | | |
87 | 0 | return 0; |
88 | 0 | } Unexecuted instantiation: sample.c:fix_tagid Unexecuted instantiation: fix.c:fix_tagid |
89 | | |
90 | | #endif /* _HAPROXY_FIX_H */ |
91 | | |
92 | | /* |
93 | | * Local variables: |
94 | | * c-indent-level: 8 |
95 | | * c-basic-offset: 8 |
96 | | * End: |
97 | | */ |