cosmos 4.4.1-java → 4.5.2-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/build_v4.yml +33 -0
- data/Dockerfile +10 -4
- data/Gemfile +1 -1
- data/Manifest.txt +26 -2
- data/README.md +4 -1
- data/Rakefile +33 -27
- data/autohotkey/tools/cmd_extractor.ahk +11 -9
- data/autohotkey/tools/cmd_sender.ahk +1 -1
- data/autohotkey/tools/cmd_sequence.ahk +1 -1
- data/autohotkey/tools/data_viewer.ahk +1 -1
- data/autohotkey/tools/limits_monitor.ahk +1 -1
- data/autohotkey/tools/packet_viewer.ahk +1 -1
- data/autohotkey/tools/script_runner.ahk +1 -1
- data/autohotkey/tools/test_runner2.ahk +1 -1
- data/autohotkey/tools/tlm_grapher.ahk +1 -1
- data/autohotkey/tools/tlm_grapher3.ahk +1 -1
- data/autohotkey/tools/tlm_viewer.ahk +1 -1
- data/autohotkey/tools/tlm_viewer2.ahk +1 -1
- data/autohotkey/tools/tlm_viewer5.ahk +1 -1
- data/bin/rubysloc +73 -28
- data/bin/xtce_converter +1 -1
- data/cosmos.gemspec +6 -12
- data/data/config/interface_modifiers.yaml +3 -2
- data/data/config/system.yaml +81 -24
- data/data/crc.txt +435 -435
- data/demo/Rakefile +4 -4
- data/demo/config/data/crc.txt +250 -250
- data/demo/config/system/system.txt +15 -7
- data/demo/config/system/system2.txt +15 -7
- data/demo/config/system/system_alt_ports.txt +15 -7
- data/demo/config/targets/INST/cmd_tlm/inst_cmds.txt +1 -1
- data/demo/config/tools/handbook_creator/default_toc.xsl +59 -59
- data/ext/cosmos/ext/buffered_file/buffered_file.c +2 -2
- data/ext/cosmos/ext/config_parser/config_parser.c +1 -2
- data/ext/cosmos/ext/line_graph/line_graph.c +53 -94
- data/ext/cosmos/ext/packet/packet.c +0 -6
- data/ext/cosmos/ext/platform/platform.c +56 -21
- data/ext/cosmos/ext/polynomial_conversion/polynomial_conversion.c +4 -8
- data/ext/cosmos/ext/structure/structure.c +12 -0
- data/extensions/vscode/.gitignore +4 -0
- data/extensions/vscode/.vscode/launch.json +32 -0
- data/extensions/vscode/.vscode/settings.json +13 -0
- data/extensions/vscode/.vscode/tasks.json +79 -0
- data/extensions/vscode/License.txt +879 -0
- data/extensions/vscode/README.md +9 -0
- data/extensions/vscode/client/License.txt +879 -0
- data/extensions/vscode/client/README.md +39 -0
- data/extensions/vscode/client/cosmos.configuration.json +23 -0
- data/extensions/vscode/client/images/icon.png +0 -0
- data/extensions/vscode/client/package-lock.json +414 -0
- data/extensions/vscode/client/package.json +105 -0
- data/extensions/vscode/client/src/extension.ts +132 -0
- data/extensions/vscode/client/src/screen_preview.rb +25 -0
- data/extensions/vscode/client/syntaxes/cosmos.tmLanguage.json +219 -0
- data/extensions/vscode/client/tsconfig.json +17 -0
- data/extensions/vscode/package-lock.json +26 -0
- data/extensions/vscode/package.json +35 -0
- data/extensions/vscode/server/License.txt +879 -0
- data/extensions/vscode/server/package-lock.json +236 -0
- data/extensions/vscode/server/package.json +29 -0
- data/extensions/vscode/server/src/server.ts +59 -0
- data/extensions/vscode/server/tsconfig.json +16 -0
- data/install/Rakefile +4 -4
- data/install/config/data/crc.txt +145 -145
- data/install/config/system/system.txt +15 -7
- data/install/config/tools/handbook_creator/default_toc.xsl +59 -59
- data/lib/cosmos/config/config_parser.rb +2 -10
- data/lib/cosmos/core_ext/class.rb +10 -0
- data/lib/cosmos/core_ext/time.rb +5 -3
- data/lib/cosmos/dart/examples/dart_decom_client.rb +1 -1
- data/lib/cosmos/dart/lib/dart_common.rb +3 -3
- data/lib/cosmos/dart/lib/dart_decommutator.rb +4 -4
- data/lib/cosmos/dart/processes/dart_decom_server.rb +1 -1
- data/lib/cosmos/dart/processes/dart_master.rb +1 -1
- data/lib/cosmos/dart/spec/dart/dart_database_cleaner_spec.rb +2 -2
- data/lib/cosmos/gui/qt.rb +10 -10
- data/lib/cosmos/gui/qt_tool.rb +17 -12
- data/lib/cosmos/gui/text/completion_text_edit.rb +2 -0
- data/lib/cosmos/gui/widgets/dart_meta_frame.rb +1 -1
- data/lib/cosmos/interfaces/dart_status_interface.rb +1 -1
- data/lib/cosmos/interfaces/linc_interface.rb +3 -3
- data/lib/cosmos/interfaces/protocols/burst_protocol.rb +1 -1
- data/lib/cosmos/interfaces/protocols/crc_protocol.rb +1 -1
- data/lib/cosmos/interfaces/protocols/template_protocol.rb +3 -3
- data/lib/cosmos/interfaces/serial_interface.rb +7 -1
- data/lib/cosmos/interfaces/stream_interface.rb +1 -1
- data/lib/cosmos/interfaces/tcpip_server_interface.rb +16 -16
- data/lib/cosmos/io/io_multiplexer.rb +6 -2
- data/lib/cosmos/io/json_drb.rb +3 -11
- data/lib/cosmos/io/json_drb_object.rb +7 -2
- data/lib/cosmos/io/json_drb_rack.rb +25 -5
- data/lib/cosmos/io/json_rpc.rb +1 -1
- data/lib/cosmos/io/posix_serial_driver.rb +60 -22
- data/lib/cosmos/io/serial_driver.rb +11 -8
- data/lib/cosmos/io/win32_serial_driver.rb +8 -1
- data/lib/cosmos/packets/packet.rb +8 -8
- data/lib/cosmos/packets/packet_config.rb +1 -1
- data/lib/cosmos/packets/packet_item_limits.rb +2 -14
- data/lib/cosmos/packets/parsers/xtce_converter.rb +10 -10
- data/lib/cosmos/packets/parsers/xtce_parser.rb +3 -0
- data/lib/cosmos/packets/structure.rb +18 -5
- data/lib/cosmos/packets/structure_item.rb +4 -21
- data/lib/cosmos/script/api_shared.rb +18 -1
- data/lib/cosmos/script/extract.rb +1 -1
- data/lib/cosmos/script/script.rb +4 -11
- data/lib/cosmos/streams/serial_stream.rb +11 -6
- data/lib/cosmos/system/system.rb +47 -13
- data/lib/cosmos/tools/cmd_sender/cmd_param_table_item_delegate.rb +15 -0
- data/lib/cosmos/tools/cmd_sender/cmd_params.rb +25 -3
- data/lib/cosmos/tools/cmd_sender/cmd_sender.rb +7 -0
- data/lib/cosmos/tools/cmd_sequence/sequence_item.rb +0 -5
- data/lib/cosmos/tools/cmd_tlm_server/api.rb +10 -8
- data/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server.rb +2 -2
- data/lib/cosmos/tools/cmd_tlm_server/gui/logging_tab.rb +1 -1
- data/lib/cosmos/tools/cmd_tlm_server/interface_thread.rb +29 -26
- data/lib/cosmos/tools/cmd_tlm_server/limits_groups_background_task.rb +1 -1
- data/lib/cosmos/tools/cmd_tlm_server/router_thread.rb +5 -0
- data/lib/cosmos/tools/config_editor/config_editor.rb +1 -1
- data/lib/cosmos/tools/handbook_creator/handbook_creator.rb +1 -1
- data/lib/cosmos/tools/handbook_creator/handbook_creator_config.rb +1 -1
- data/lib/cosmos/tools/script_runner/script_runner_frame.rb +5 -2
- data/lib/cosmos/tools/test_runner/test.rb +1 -1
- data/lib/cosmos/tools/test_runner/test_runner.rb +4 -4
- data/lib/cosmos/tools/tlm_extractor/tlm_extractor.rb +3 -3
- data/lib/cosmos/tools/tlm_extractor/tlm_extractor_config.rb +1 -4
- data/lib/cosmos/tools/tlm_extractor/tlm_extractor_processor.rb +3 -3
- data/lib/cosmos/tools/tlm_grapher/tabbed_plots_tool/tabbed_plots_dart_thread.rb +1 -1
- data/lib/cosmos/tools/tlm_viewer/tlm_viewer.rb +2 -2
- data/lib/cosmos/tools/tlm_viewer/widgets/canvasdot_widget.rb +2 -0
- data/lib/cosmos/top_level.rb +1 -1
- data/lib/cosmos/utilities/simulated_target.rb +1 -1
- data/lib/cosmos/version.rb +5 -5
- data/make_gems.sh +1 -1
- data/spec/core_ext/class_spec.rb +54 -0
- data/spec/core_ext/time_spec.rb +4 -0
- data/spec/gui/qt_spec.rb +1 -1
- data/spec/gui/utilities/script_module_gui_spec.rb +1 -1
- data/spec/interfaces/linc_interface_spec.rb +1 -1
- data/spec/interfaces/serial_interface_spec.rb +1 -5
- data/spec/io/json_drb_rack_spec.rb +166 -0
- data/spec/io/json_rpc_spec.rb +4 -5
- data/spec/io/posix_serial_driver_spec.rb +87 -0
- data/spec/io/win32_serial_driver_spec.rb +17 -1
- data/spec/packet_logs/packet_log_reader_spec.rb +34 -35
- data/spec/packets/packet_item_limits_spec.rb +6 -33
- data/spec/packets/structure_item_spec.rb +3 -21
- data/spec/script/extract_spec.rb +4 -1
- data/spec/system/system_spec.rb +109 -1
- data/spec/tools/cmd_tlm_server/api_spec.rb +12 -12
- data/spec/tools/cmd_tlm_server/background_tasks_spec.rb +2 -2
- data/spec/tools/cmd_tlm_server/interface_thread_spec.rb +4 -3
- data/spec/tools/cmd_tlm_server/router_thread_spec.rb +2 -3
- data/spec/top_level/top_level_spec.rb +2 -2
- data/spec/utilities/logger_spec.rb +3 -3
- data/test/performance/Rakefile +4 -4
- data/test/performance/config/data/crc.txt +67 -48
- metadata +53 -9
- data/.coveralls.yml +0 -1
- data/.travis.yml +0 -16
|
@@ -10,16 +10,17 @@ DECLARE_TARGET DART
|
|
|
10
10
|
DECLARE_TARGET SYSTEM
|
|
11
11
|
|
|
12
12
|
# Listen Hosts - Ip addresses or hostnames to listen on when running the tools
|
|
13
|
+
# Set these to 0.0.0.0 if you need external connections from other computers
|
|
13
14
|
LISTEN_HOST CTS_API 127.0.0.1
|
|
14
15
|
LISTEN_HOST TLMVIEWER_API 127.0.0.1
|
|
15
|
-
LISTEN_HOST CTS_PREIDENTIFIED
|
|
16
|
-
LISTEN_HOST CTS_CMD_ROUTER
|
|
16
|
+
LISTEN_HOST CTS_PREIDENTIFIED 127.0.0.1
|
|
17
|
+
LISTEN_HOST CTS_CMD_ROUTER 127.0.0.1
|
|
17
18
|
LISTEN_HOST REPLAY_API 127.0.0.1
|
|
18
|
-
LISTEN_HOST REPLAY_PREIDENTIFIED
|
|
19
|
-
LISTEN_HOST REPLAY_CMD_ROUTER
|
|
20
|
-
LISTEN_HOST DART_STREAM
|
|
21
|
-
LISTEN_HOST DART_DECOM
|
|
22
|
-
LISTEN_HOST DART_MASTER
|
|
19
|
+
LISTEN_HOST REPLAY_PREIDENTIFIED 127.0.0.1
|
|
20
|
+
LISTEN_HOST REPLAY_CMD_ROUTER 127.0.0.1
|
|
21
|
+
LISTEN_HOST DART_STREAM 127.0.0.1
|
|
22
|
+
LISTEN_HOST DART_DECOM 127.0.0.1
|
|
23
|
+
LISTEN_HOST DART_MASTER 127.0.0.1
|
|
23
24
|
|
|
24
25
|
# Connect Hosts - Ip addresses or hostnames to connect to when running the tools
|
|
25
26
|
CONNECT_HOST CTS_API 127.0.0.1
|
|
@@ -80,3 +81,10 @@ ADD_HASH_FILE lib/user_version.rb
|
|
|
80
81
|
|
|
81
82
|
# Create a banner using a RGB color values
|
|
82
83
|
# CLASSIFICATION Secret 255 114 0
|
|
84
|
+
|
|
85
|
+
# ALLOW_ROUTER_COMMANDING # Enable this to chain servers with commanding
|
|
86
|
+
# ALLOW_HOST localhost:7777 # This is provided by default. Add with HostIP:7777 for chaining
|
|
87
|
+
# ALLOW_ORIGIN 1.2.3.4:8080 # Add this if you have a webserver that should be able to access the COSMOS API
|
|
88
|
+
|
|
89
|
+
# *** IMPORTANT *** Change this value to a unique value for each project
|
|
90
|
+
X_CSRF_TOKEN SuperSecret # Secret used to secure requests - Change for each project
|
|
@@ -8,16 +8,17 @@ DECLARE_TARGET EXAMPLE
|
|
|
8
8
|
DECLARE_TARGET SYSTEM
|
|
9
9
|
|
|
10
10
|
# Listen Hosts - Ip addresses or hostnames to listen on when running the tools
|
|
11
|
+
# Set these to 0.0.0.0 if you need external connections from other computers
|
|
11
12
|
LISTEN_HOST CTS_API 127.0.0.1
|
|
12
13
|
LISTEN_HOST TLMVIEWER_API 127.0.0.1
|
|
13
|
-
LISTEN_HOST CTS_PREIDENTIFIED
|
|
14
|
-
LISTEN_HOST CTS_CMD_ROUTER
|
|
14
|
+
LISTEN_HOST CTS_PREIDENTIFIED 127.0.0.1
|
|
15
|
+
LISTEN_HOST CTS_CMD_ROUTER 127.0.0.1
|
|
15
16
|
LISTEN_HOST REPLAY_API 127.0.0.1
|
|
16
|
-
LISTEN_HOST REPLAY_PREIDENTIFIED
|
|
17
|
-
LISTEN_HOST REPLAY_CMD_ROUTER
|
|
18
|
-
LISTEN_HOST DART_STREAM
|
|
19
|
-
LISTEN_HOST DART_DECOM
|
|
20
|
-
LISTEN_HOST DART_MASTER
|
|
17
|
+
LISTEN_HOST REPLAY_PREIDENTIFIED 127.0.0.1
|
|
18
|
+
LISTEN_HOST REPLAY_CMD_ROUTER 127.0.0.1
|
|
19
|
+
LISTEN_HOST DART_STREAM 127.0.0.1
|
|
20
|
+
LISTEN_HOST DART_DECOM 127.0.0.1
|
|
21
|
+
LISTEN_HOST DART_MASTER 127.0.0.1
|
|
21
22
|
|
|
22
23
|
# Connect Hosts - Ip addresses or hostnames to connect to when running the tools
|
|
23
24
|
CONNECT_HOST CTS_API 127.0.0.1
|
|
@@ -65,3 +66,10 @@ ALLOW_ACCESS ALL
|
|
|
65
66
|
|
|
66
67
|
# Initialize the metadata dialog using values from the following file:
|
|
67
68
|
# META_INIT config/data/meta_init.txt
|
|
69
|
+
|
|
70
|
+
# ALLOW_ROUTER_COMMANDING # Enable this to chain servers with commanding
|
|
71
|
+
# ALLOW_HOST localhost:7777 # This is provided by default. Add with HostIP:7777 for chaining
|
|
72
|
+
# ALLOW_ORIGIN 1.2.3.4:8080 # Add this if you have a webserver that should be able to access the COSMOS API
|
|
73
|
+
|
|
74
|
+
# *** IMPORTANT *** Change this value to a unique value for each project
|
|
75
|
+
X_CSRF_TOKEN SuperSecret # Secret used to secure requests - Change for each project
|
|
@@ -10,16 +10,17 @@ DECLARE_TARGET DART
|
|
|
10
10
|
DECLARE_TARGET SYSTEM
|
|
11
11
|
|
|
12
12
|
# Listen Hosts - Ip addresses or hostnames to listen on when running the tools
|
|
13
|
+
# Set these to 0.0.0.0 if you need external connections from other computers
|
|
13
14
|
LISTEN_HOST CTS_API 127.0.0.1
|
|
14
15
|
LISTEN_HOST TLMVIEWER_API 127.0.0.1
|
|
15
|
-
LISTEN_HOST CTS_PREIDENTIFIED
|
|
16
|
-
LISTEN_HOST CTS_CMD_ROUTER
|
|
16
|
+
LISTEN_HOST CTS_PREIDENTIFIED 127.0.0.1
|
|
17
|
+
LISTEN_HOST CTS_CMD_ROUTER 127.0.0.1
|
|
17
18
|
LISTEN_HOST REPLAY_API 127.0.0.1
|
|
18
|
-
LISTEN_HOST REPLAY_PREIDENTIFIED
|
|
19
|
-
LISTEN_HOST REPLAY_CMD_ROUTER
|
|
20
|
-
LISTEN_HOST DART_STREAM
|
|
21
|
-
LISTEN_HOST DART_DECOM
|
|
22
|
-
LISTEN_HOST DART_MASTER
|
|
19
|
+
LISTEN_HOST REPLAY_PREIDENTIFIED 127.0.0.1
|
|
20
|
+
LISTEN_HOST REPLAY_CMD_ROUTER 127.0.0.1
|
|
21
|
+
LISTEN_HOST DART_STREAM 127.0.0.1
|
|
22
|
+
LISTEN_HOST DART_DECOM 127.0.0.1
|
|
23
|
+
LISTEN_HOST DART_MASTER 127.0.0.1
|
|
23
24
|
|
|
24
25
|
# Connect Hosts - Ip addresses or hostnames to connect to when running the tools
|
|
25
26
|
CONNECT_HOST CTS_API 127.0.0.1
|
|
@@ -70,3 +71,10 @@ ENABLE_SOUND
|
|
|
70
71
|
META_INIT config/data/meta_init.txt
|
|
71
72
|
|
|
72
73
|
ADD_HASH_FILE lib/user_version.rb
|
|
74
|
+
|
|
75
|
+
# ALLOW_ROUTER_COMMANDING # Enable this to chain servers with commanding
|
|
76
|
+
# ALLOW_HOST localhost:7777 # This is provided by default. Add with HostIP:7777 for chaining
|
|
77
|
+
# ALLOW_ORIGIN 1.2.3.4:8080 # Add this if you have a webserver that should be able to access the COSMOS API
|
|
78
|
+
|
|
79
|
+
# *** IMPORTANT *** Change this value to a unique value for each project
|
|
80
|
+
X_CSRF_TOKEN SuperSecret # Secret used to secure requests - Change for each project
|
|
@@ -36,7 +36,7 @@ COMMAND INST ASCIICMD BIG_ENDIAN "Enumerated ASCII command"
|
|
|
36
36
|
<%= render "_ccsds_cmd.txt", locals: {id: 5} %>
|
|
37
37
|
APPEND_PARAMETER STRING 2048 STRING "NOOP" "Enumerated string parameter"
|
|
38
38
|
STATE "NOOP" "NOOP"
|
|
39
|
-
STATE "ARM LASER" "ARM LASER" HAZARDOUS "Arming the laser poses an eye safety hazard."
|
|
39
|
+
STATE "ARM LASER" "ARM LASER" HAZARDOUS "Arming the laser poses an eye safety hazard so anyone without laser safety training needs to leave."
|
|
40
40
|
STATE "FIRE LASER" "FIRE LASER" HAZARDOUS "WARNING Laser will be fired!"
|
|
41
41
|
APPEND_PARAMETER BINARY 32 STRING 0xDEADBEEF "Binary string"
|
|
42
42
|
APPEND_PARAMETER ASCII 80 STRING "0xDEADBEEF" "ASCII string"
|
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<xsl:stylesheet version="
|
|
3
|
-
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
|
4
|
-
xmlns:outline="http://code.google.com/p/wkhtmltopdf/outline"
|
|
5
|
-
xmlns="http://www.w3.org/1999/xhtml">
|
|
6
|
-
<xsl:output doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
|
|
7
|
-
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
|
|
8
|
-
indent="yes" />
|
|
9
|
-
<xsl:template match="outline:outline">
|
|
10
|
-
<html>
|
|
11
|
-
<head>
|
|
12
|
-
<title>Table of Contents</title>
|
|
13
|
-
<style>
|
|
14
|
-
h1 {
|
|
15
|
-
text-align: center;
|
|
16
|
-
font-size: 20px;
|
|
17
|
-
font-family: arial;
|
|
18
|
-
}
|
|
19
|
-
div {border-bottom: 1px dashed rgb(200,200,200);}
|
|
20
|
-
span {float: right;}
|
|
21
|
-
li {list-style: none;}
|
|
22
|
-
ul {
|
|
23
|
-
font-size: 20px;
|
|
24
|
-
font-family: arial;
|
|
25
|
-
}
|
|
26
|
-
ul ul {font-size: 80%; }
|
|
27
|
-
ul {padding-left: 0em;}
|
|
28
|
-
ul ul {padding-left: 1em;}
|
|
29
|
-
a {text-decoration:none; color: black;}
|
|
30
|
-
</style>
|
|
31
|
-
</head>
|
|
32
|
-
<body>
|
|
33
|
-
<h1>Table of Contents</h1>
|
|
34
|
-
<ul><xsl:apply-templates select="outline:item/outline:item"/></ul>
|
|
35
|
-
</body>
|
|
36
|
-
</html>
|
|
37
|
-
</xsl:template>
|
|
38
|
-
<xsl:template match="outline:item">
|
|
39
|
-
<li>
|
|
40
|
-
<xsl:if test="@title!=''">
|
|
41
|
-
<div>
|
|
42
|
-
<a>
|
|
43
|
-
<xsl:if test="@link">
|
|
44
|
-
<xsl:attribute name="href"><xsl:value-of select="@link"/></xsl:attribute>
|
|
45
|
-
</xsl:if>
|
|
46
|
-
<xsl:if test="@backLink">
|
|
47
|
-
<xsl:attribute name="name"><xsl:value-of select="@backLink"/></xsl:attribute>
|
|
48
|
-
</xsl:if>
|
|
49
|
-
<xsl:value-of select="@title" />
|
|
50
|
-
</a>
|
|
51
|
-
<span> <xsl:value-of select="@page" /> </span>
|
|
52
|
-
</div>
|
|
53
|
-
</xsl:if>
|
|
54
|
-
<ul>
|
|
55
|
-
<xsl:apply-templates select="outline:item"/>
|
|
56
|
-
</ul>
|
|
57
|
-
</li>
|
|
58
|
-
</xsl:template>
|
|
59
|
-
</xsl:stylesheet>
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<xsl:stylesheet version="2.0"
|
|
3
|
+
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
|
4
|
+
xmlns:outline="http://code.google.com/p/wkhtmltopdf/outline"
|
|
5
|
+
xmlns="http://www.w3.org/1999/xhtml">
|
|
6
|
+
<xsl:output doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
|
|
7
|
+
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
|
|
8
|
+
indent="yes" />
|
|
9
|
+
<xsl:template match="outline:outline">
|
|
10
|
+
<html>
|
|
11
|
+
<head>
|
|
12
|
+
<title>Table of Contents</title>
|
|
13
|
+
<style>
|
|
14
|
+
h1 {
|
|
15
|
+
text-align: center;
|
|
16
|
+
font-size: 20px;
|
|
17
|
+
font-family: arial;
|
|
18
|
+
}
|
|
19
|
+
div {border-bottom: 1px dashed rgb(200,200,200);}
|
|
20
|
+
span {float: right;}
|
|
21
|
+
li {list-style: none;}
|
|
22
|
+
ul {
|
|
23
|
+
font-size: 20px;
|
|
24
|
+
font-family: arial;
|
|
25
|
+
}
|
|
26
|
+
ul ul {font-size: 80%; }
|
|
27
|
+
ul {padding-left: 0em;}
|
|
28
|
+
ul ul {padding-left: 1em;}
|
|
29
|
+
a {text-decoration:none; color: black;}
|
|
30
|
+
</style>
|
|
31
|
+
</head>
|
|
32
|
+
<body>
|
|
33
|
+
<h1>Table of Contents</h1>
|
|
34
|
+
<ul><xsl:apply-templates select="outline:item/outline:item"/></ul>
|
|
35
|
+
</body>
|
|
36
|
+
</html>
|
|
37
|
+
</xsl:template>
|
|
38
|
+
<xsl:template match="outline:item">
|
|
39
|
+
<li>
|
|
40
|
+
<xsl:if test="@title!=''">
|
|
41
|
+
<div>
|
|
42
|
+
<a>
|
|
43
|
+
<xsl:if test="@link">
|
|
44
|
+
<xsl:attribute name="href"><xsl:value-of select="@link"/></xsl:attribute>
|
|
45
|
+
</xsl:if>
|
|
46
|
+
<xsl:if test="@backLink">
|
|
47
|
+
<xsl:attribute name="name"><xsl:value-of select="@backLink"/></xsl:attribute>
|
|
48
|
+
</xsl:if>
|
|
49
|
+
<xsl:value-of select="@title" />
|
|
50
|
+
</a>
|
|
51
|
+
<span> <xsl:value-of select="@page" /> </span>
|
|
52
|
+
</div>
|
|
53
|
+
</xsl:if>
|
|
54
|
+
<ul>
|
|
55
|
+
<xsl:apply-templates select="outline:item"/>
|
|
56
|
+
</ul>
|
|
57
|
+
</li>
|
|
58
|
+
</xsl:template>
|
|
59
|
+
</xsl:stylesheet>
|
|
@@ -56,7 +56,7 @@ static VALUE buffered_file_read(VALUE self, VALUE arg_length) {
|
|
|
56
56
|
rb_funcall(buffer, id_method_slice_bang, 1, rb_range_new(INT2FIX(0), INT2FIX(buffer_index - 1), Qfalse));
|
|
57
57
|
buffer_length = RSTRING_LEN(buffer);
|
|
58
58
|
buffer_index = 0;
|
|
59
|
-
rb_ivar_set(self, id_ivar_buffer_index, INT2FIX(
|
|
59
|
+
rb_ivar_set(self, id_ivar_buffer_index, INT2FIX(buffer_index));
|
|
60
60
|
}
|
|
61
61
|
super_arg = INT2FIX(length - buffer_length);
|
|
62
62
|
rb_str_append(buffer, rb_funcall(rb_call_super(1, (VALUE*) &super_arg), id_method_to_s, 0));
|
|
@@ -70,7 +70,7 @@ static VALUE buffered_file_read(VALUE self, VALUE arg_length) {
|
|
|
70
70
|
rb_funcall(buffer, id_method_slice_bang, 1, rb_range_new(INT2FIX(0), INT2FIX(buffer_index - 1), Qfalse));
|
|
71
71
|
buffer_length = RSTRING_LEN(buffer);
|
|
72
72
|
buffer_index = 0;
|
|
73
|
-
rb_ivar_set(self, id_ivar_buffer_index, INT2FIX(
|
|
73
|
+
rb_ivar_set(self, id_ivar_buffer_index, INT2FIX(buffer_index));
|
|
74
74
|
}
|
|
75
75
|
super_arg = INT2FIX(BUFFER_SIZE - buffer_length);
|
|
76
76
|
rb_str_append(buffer, rb_funcall(rb_call_super(1, (VALUE*) &super_arg), id_method_to_s, 0));
|
|
@@ -74,7 +74,6 @@ static VALUE parse_loop(VALUE self, VALUE io, VALUE yield_non_keyword_lines, VAL
|
|
|
74
74
|
int result = 0;
|
|
75
75
|
long length = 0;
|
|
76
76
|
int index = 0;
|
|
77
|
-
double float_pos = 0.0;
|
|
78
77
|
double float_size = NUM2DBL(size);
|
|
79
78
|
volatile VALUE progress_callback = rb_cvar_get(cConfigParser, id_cvar_progress_callback);
|
|
80
79
|
volatile VALUE line = Qnil;
|
|
@@ -98,7 +97,7 @@ static VALUE parse_loop(VALUE self, VALUE io, VALUE yield_non_keyword_lines, VAL
|
|
|
98
97
|
|
|
99
98
|
if (RTEST(progress_callback) && ((line_number % 10) == 0)) {
|
|
100
99
|
if (float_size > 0.0) {
|
|
101
|
-
float_pos = NUM2DBL(rb_funcall(io, id_method_pos, 0));
|
|
100
|
+
double float_pos = NUM2DBL(rb_funcall(io, id_method_pos, 0));
|
|
102
101
|
rb_funcall(progress_callback, id_method_call, 1, rb_float_new(float_pos / float_size));
|
|
103
102
|
}
|
|
104
103
|
}
|
|
@@ -95,8 +95,6 @@ static VALUE line_clip_internal(double x0, double y0, double x1, double y1, doub
|
|
|
95
95
|
volatile VALUE done = Qfalse;
|
|
96
96
|
volatile VALUE clipped0 = Qfalse;
|
|
97
97
|
volatile VALUE clipped1 = Qfalse;
|
|
98
|
-
double x = 0.0;
|
|
99
|
-
double y = 0.0;
|
|
100
98
|
|
|
101
99
|
code0 = cal_code(x0, y0, xmin, ymin, xmax, ymax);
|
|
102
100
|
code1 = cal_code(x1, y1, xmin, ymin, xmax, ymax);
|
|
@@ -117,8 +115,8 @@ static VALUE line_clip_internal(double x0, double y0, double x1, double y1, doub
|
|
|
117
115
|
} else {
|
|
118
116
|
/* Part of the line is inside the viewable area. Figure out which part
|
|
119
117
|
* of the line can be drawn. */
|
|
120
|
-
x
|
|
121
|
-
y
|
|
118
|
+
double x;
|
|
119
|
+
double y;
|
|
122
120
|
|
|
123
121
|
if (code0 != 0) {
|
|
124
122
|
codeout = code0;
|
|
@@ -178,28 +176,19 @@ static VALUE line_clip(VALUE self, VALUE x0, VALUE y0, VALUE x1, VALUE y1, VALUE
|
|
|
178
176
|
volatile VALUE result_clipped0 = Qnil;
|
|
179
177
|
volatile VALUE result_clipped1 = Qnil;
|
|
180
178
|
volatile VALUE return_value = Qnil;
|
|
181
|
-
double double_x0 = 0
|
|
182
|
-
double double_y0 = 0
|
|
183
|
-
double double_x1 = 0
|
|
184
|
-
double double_y1 = 0
|
|
185
|
-
double double_xmin = 0
|
|
186
|
-
double double_ymin = 0
|
|
187
|
-
double double_xmax = 0
|
|
188
|
-
double double_ymax = 0
|
|
179
|
+
double double_x0 = RFLOAT_VALUE(rb_funcall(x0, id_method_to_f, 0));
|
|
180
|
+
double double_y0 = RFLOAT_VALUE(rb_funcall(y0, id_method_to_f, 0));
|
|
181
|
+
double double_x1 = RFLOAT_VALUE(rb_funcall(x1, id_method_to_f, 0));
|
|
182
|
+
double double_y1 = RFLOAT_VALUE(rb_funcall(y1, id_method_to_f, 0));
|
|
183
|
+
double double_xmin = RFLOAT_VALUE(rb_funcall(xmin, id_method_to_f, 0));
|
|
184
|
+
double double_ymin = RFLOAT_VALUE(rb_funcall(ymin, id_method_to_f, 0));
|
|
185
|
+
double double_xmax = RFLOAT_VALUE(rb_funcall(xmax, id_method_to_f, 0));
|
|
186
|
+
double double_ymax = RFLOAT_VALUE(rb_funcall(ymax, id_method_to_f, 0));
|
|
189
187
|
double result_x0 = 0.0;
|
|
190
188
|
double result_y0 = 0.0;
|
|
191
189
|
double result_x1 = 0.0;
|
|
192
190
|
double result_y1 = 0.0;
|
|
193
191
|
|
|
194
|
-
double_x0 = RFLOAT_VALUE(rb_funcall(x0, id_method_to_f, 0));
|
|
195
|
-
double_y0 = RFLOAT_VALUE(rb_funcall(y0, id_method_to_f, 0));
|
|
196
|
-
double_x1 = RFLOAT_VALUE(rb_funcall(x1, id_method_to_f, 0));
|
|
197
|
-
double_y1 = RFLOAT_VALUE(rb_funcall(y1, id_method_to_f, 0));
|
|
198
|
-
double_xmin = RFLOAT_VALUE(rb_funcall(xmin, id_method_to_f, 0));
|
|
199
|
-
double_ymin = RFLOAT_VALUE(rb_funcall(ymin, id_method_to_f, 0));
|
|
200
|
-
double_xmax = RFLOAT_VALUE(rb_funcall(xmax, id_method_to_f, 0));
|
|
201
|
-
double_ymax = RFLOAT_VALUE(rb_funcall(ymax, id_method_to_f, 0));
|
|
202
|
-
|
|
203
192
|
result = line_clip_internal(double_x0, double_y0, double_x1, double_y1, double_xmin, double_ymin, double_xmax, double_ymax, &result_x0, &result_y0, &result_x1, &result_y1, &result_clipped0, &result_clipped1);
|
|
204
193
|
|
|
205
194
|
if (result == Qtrue)
|
|
@@ -236,10 +225,8 @@ static long scale_value_to_graph_y_internal (double y, double y_max, double y_sc
|
|
|
236
225
|
static VALUE scale_value_to_graph_y(int argc, VALUE* argv, VALUE self) {
|
|
237
226
|
volatile VALUE y = Qnil;
|
|
238
227
|
ID id_axis = 0;
|
|
239
|
-
|
|
240
|
-
double
|
|
241
|
-
double double_y_max = 0.0;
|
|
242
|
-
double double_y_scale = 0.0;
|
|
228
|
+
double double_y_max;
|
|
229
|
+
double double_y_scale;
|
|
243
230
|
|
|
244
231
|
switch (argc) {
|
|
245
232
|
case 1:
|
|
@@ -256,8 +243,8 @@ static VALUE scale_value_to_graph_y(int argc, VALUE* argv, VALUE self) {
|
|
|
256
243
|
break;
|
|
257
244
|
};
|
|
258
245
|
|
|
259
|
-
long_graph_top_y = FIX2INT(rb_ivar_get(self, id_ivar_graph_top_y));
|
|
260
|
-
double_y = RFLOAT_VALUE(rb_funcall(y, id_method_to_f, 0));
|
|
246
|
+
long long_graph_top_y = FIX2INT(rb_ivar_get(self, id_ivar_graph_top_y));
|
|
247
|
+
double double_y = RFLOAT_VALUE(rb_funcall(y, id_method_to_f, 0));
|
|
261
248
|
|
|
262
249
|
if (id_axis == id_LEFT) {
|
|
263
250
|
double_y_max = RFLOAT_VALUE(rb_funcall(rb_ivar_get(self, id_ivar_left_y_max), id_method_to_f, 0));
|
|
@@ -281,15 +268,10 @@ static long scale_value_to_graph_x_internal (double x, double x_min, double x_sc
|
|
|
281
268
|
* This function converts an x value to an x coordinate on the graph
|
|
282
269
|
*/
|
|
283
270
|
static VALUE scale_value_to_graph_x(VALUE self, VALUE x) {
|
|
284
|
-
long long_graph_left_x =
|
|
285
|
-
double double_x = 0
|
|
286
|
-
double double_x_min = 0
|
|
287
|
-
double double_x_scale = 0
|
|
288
|
-
|
|
289
|
-
long_graph_left_x = FIX2INT(rb_ivar_get(self, id_ivar_graph_left_x));
|
|
290
|
-
double_x = RFLOAT_VALUE(rb_funcall(x, id_method_to_f, 0));
|
|
291
|
-
double_x_min = RFLOAT_VALUE(rb_funcall(rb_ivar_get(self, id_ivar_x_min), id_method_to_f, 0));
|
|
292
|
-
double_x_scale = RFLOAT_VALUE(rb_funcall(rb_ivar_get(self, id_ivar_x_scale), id_method_to_f, 0));
|
|
271
|
+
long long_graph_left_x = FIX2INT(rb_ivar_get(self, id_ivar_graph_left_x));
|
|
272
|
+
double double_x = RFLOAT_VALUE(rb_funcall(x, id_method_to_f, 0));
|
|
273
|
+
double double_x_min = RFLOAT_VALUE(rb_funcall(rb_ivar_get(self, id_ivar_x_min), id_method_to_f, 0));
|
|
274
|
+
double double_x_scale = RFLOAT_VALUE(rb_funcall(rb_ivar_get(self, id_ivar_x_scale), id_method_to_f, 0));
|
|
293
275
|
|
|
294
276
|
return INT2FIX(scale_value_to_graph_x_internal(double_x, double_x_min, double_x_scale, long_graph_left_x));
|
|
295
277
|
}
|
|
@@ -301,10 +283,6 @@ static void draw_line_internal(VALUE dc, double x1, double y1, double x2, double
|
|
|
301
283
|
volatile VALUE result = Qnil;
|
|
302
284
|
volatile VALUE clipped1 = Qnil;
|
|
303
285
|
volatile VALUE clipped2 = Qnil;
|
|
304
|
-
long x1_scaled = 0;
|
|
305
|
-
long y1_scaled = 0;
|
|
306
|
-
long x2_scaled = 0;
|
|
307
|
-
long y2_scaled = 0;
|
|
308
286
|
double clipped_x1 = 0.0;
|
|
309
287
|
double clipped_y1 = 0.0;
|
|
310
288
|
double clipped_x2 = 0.0;
|
|
@@ -315,10 +293,10 @@ static void draw_line_internal(VALUE dc, double x1, double y1, double x2, double
|
|
|
315
293
|
|
|
316
294
|
if (result == Qtrue) /* Line is visible so draw it */ {
|
|
317
295
|
/* Scale to graph coordinates */
|
|
318
|
-
x1_scaled = scale_value_to_graph_x_internal(clipped_x1, x_min, x_scale, graph_left_x);
|
|
319
|
-
y1_scaled = scale_value_to_graph_y_internal(clipped_y1, y_max, y_scale, graph_top_y);
|
|
320
|
-
x2_scaled = scale_value_to_graph_x_internal(clipped_x2, x_min, x_scale, graph_left_x);
|
|
321
|
-
y2_scaled = scale_value_to_graph_y_internal(clipped_y2, y_max, y_scale, graph_top_y);
|
|
296
|
+
double x1_scaled = scale_value_to_graph_x_internal(clipped_x1, x_min, x_scale, graph_left_x);
|
|
297
|
+
double y1_scaled = scale_value_to_graph_y_internal(clipped_y1, y_max, y_scale, graph_top_y);
|
|
298
|
+
double x2_scaled = scale_value_to_graph_x_internal(clipped_x2, x_min, x_scale, graph_left_x);
|
|
299
|
+
double y2_scaled = scale_value_to_graph_y_internal(clipped_y2, y_max, y_scale, graph_top_y);
|
|
322
300
|
|
|
323
301
|
/* Draw the line */
|
|
324
302
|
if (RTEST(show_line)) {
|
|
@@ -339,30 +317,20 @@ static void draw_line_internal(VALUE dc, double x1, double y1, double x2, double
|
|
|
339
317
|
* Draws a line between two points that is clipped to fit the visible graph if necessary
|
|
340
318
|
*/
|
|
341
319
|
static VALUE draw_line(VALUE self, VALUE dc, VALUE x1, VALUE y1, VALUE x2, VALUE y2, VALUE show_line, VALUE point_size, VALUE axis, VALUE color) {
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
double
|
|
348
|
-
double
|
|
349
|
-
double
|
|
350
|
-
double
|
|
351
|
-
double
|
|
352
|
-
double
|
|
353
|
-
double double_x_scale = 0
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
id_axis = SYM2ID(axis);
|
|
357
|
-
double_x_max = RFLOAT_VALUE(rb_funcall(rb_ivar_get(self, id_ivar_x_max), id_method_to_f, 0));
|
|
358
|
-
double_x_min = RFLOAT_VALUE(rb_funcall(rb_ivar_get(self, id_ivar_x_min), id_method_to_f, 0));
|
|
359
|
-
double_x1 = RFLOAT_VALUE(rb_funcall(x1, id_method_to_f, 0));
|
|
360
|
-
double_y1 = RFLOAT_VALUE(rb_funcall(y1, id_method_to_f, 0));
|
|
361
|
-
double_x2 = RFLOAT_VALUE(rb_funcall(x2, id_method_to_f, 0));
|
|
362
|
-
double_y2 = RFLOAT_VALUE(rb_funcall(y2, id_method_to_f, 0));
|
|
363
|
-
double_x_scale = RFLOAT_VALUE(rb_funcall(rb_ivar_get(self, id_ivar_x_scale), id_method_to_f, 0));
|
|
364
|
-
long_graph_left_x = FIX2INT(rb_ivar_get(self, id_ivar_graph_left_x));
|
|
365
|
-
long_graph_top_y = FIX2INT(rb_ivar_get(self, id_ivar_graph_top_y));
|
|
320
|
+
double double_y_min;
|
|
321
|
+
double double_y_max;
|
|
322
|
+
double double_y_scale;
|
|
323
|
+
|
|
324
|
+
ID id_axis = SYM2ID(axis);
|
|
325
|
+
double double_x_max = RFLOAT_VALUE(rb_funcall(rb_ivar_get(self, id_ivar_x_max), id_method_to_f, 0));
|
|
326
|
+
double double_x_min = RFLOAT_VALUE(rb_funcall(rb_ivar_get(self, id_ivar_x_min), id_method_to_f, 0));
|
|
327
|
+
double double_x1 = RFLOAT_VALUE(rb_funcall(x1, id_method_to_f, 0));
|
|
328
|
+
double double_y1 = RFLOAT_VALUE(rb_funcall(y1, id_method_to_f, 0));
|
|
329
|
+
double double_x2 = RFLOAT_VALUE(rb_funcall(x2, id_method_to_f, 0));
|
|
330
|
+
double double_y2 = RFLOAT_VALUE(rb_funcall(y2, id_method_to_f, 0));
|
|
331
|
+
double double_x_scale = RFLOAT_VALUE(rb_funcall(rb_ivar_get(self, id_ivar_x_scale), id_method_to_f, 0));
|
|
332
|
+
long long_graph_left_x = FIX2INT(rb_ivar_get(self, id_ivar_graph_left_x));
|
|
333
|
+
long long_graph_top_y = FIX2INT(rb_ivar_get(self, id_ivar_graph_top_y));
|
|
366
334
|
|
|
367
335
|
if (id_axis == id_LEFT) {
|
|
368
336
|
double_y_max = RFLOAT_VALUE(rb_funcall(rb_ivar_get(self, id_ivar_left_y_max), id_method_to_f, 0));
|
|
@@ -383,37 +351,28 @@ static VALUE draw_line(VALUE self, VALUE dc, VALUE x1, VALUE y1, VALUE x2, VALUE
|
|
|
383
351
|
* Draws all lines for the given axis
|
|
384
352
|
*/
|
|
385
353
|
static VALUE draw_lines (VALUE self, VALUE dc, VALUE axis) {
|
|
386
|
-
long long_graph_left_x = 0;
|
|
387
|
-
long long_graph_top_y = 0;
|
|
388
|
-
long num_lines = 0;
|
|
389
354
|
long line_index = 0;
|
|
390
355
|
long line_length = 0;
|
|
391
356
|
long point_index = 0;
|
|
392
|
-
ID id_axis = 0;
|
|
393
357
|
volatile VALUE lines = Qnil;
|
|
394
358
|
volatile VALUE line = Qnil;
|
|
395
359
|
volatile VALUE x_values = Qnil;
|
|
396
360
|
volatile VALUE y_values = Qnil;
|
|
397
361
|
volatile VALUE color = Qnil;
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
double
|
|
401
|
-
double
|
|
402
|
-
double
|
|
403
|
-
double
|
|
404
|
-
double
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
double
|
|
408
|
-
double
|
|
409
|
-
double
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
double_x_max = RFLOAT_VALUE(rb_funcall(rb_ivar_get(self, id_ivar_x_max), id_method_to_f, 0));
|
|
413
|
-
double_x_min = RFLOAT_VALUE(rb_funcall(rb_ivar_get(self, id_ivar_x_min), id_method_to_f, 0));
|
|
414
|
-
double_x_scale = RFLOAT_VALUE(rb_funcall(rb_ivar_get(self, id_ivar_x_scale), id_method_to_f, 0));
|
|
415
|
-
long_graph_left_x = FIX2INT(rb_ivar_get(self, id_ivar_graph_left_x));
|
|
416
|
-
long_graph_top_y = FIX2INT(rb_ivar_get(self, id_ivar_graph_top_y));
|
|
362
|
+
double double_x1;
|
|
363
|
+
double double_y1;
|
|
364
|
+
double double_x2;
|
|
365
|
+
double double_y2;
|
|
366
|
+
double double_y_min;
|
|
367
|
+
double double_y_max;
|
|
368
|
+
double double_y_scale;
|
|
369
|
+
|
|
370
|
+
ID id_axis = SYM2ID(axis);
|
|
371
|
+
double double_x_max = RFLOAT_VALUE(rb_funcall(rb_ivar_get(self, id_ivar_x_max), id_method_to_f, 0));
|
|
372
|
+
double double_x_min = RFLOAT_VALUE(rb_funcall(rb_ivar_get(self, id_ivar_x_min), id_method_to_f, 0));
|
|
373
|
+
double double_x_scale = RFLOAT_VALUE(rb_funcall(rb_ivar_get(self, id_ivar_x_scale), id_method_to_f, 0));
|
|
374
|
+
long long_graph_left_x = FIX2INT(rb_ivar_get(self, id_ivar_graph_left_x));
|
|
375
|
+
long long_graph_top_y = FIX2INT(rb_ivar_get(self, id_ivar_graph_top_y));
|
|
417
376
|
|
|
418
377
|
if (id_axis == id_LEFT) {
|
|
419
378
|
lines = rb_funcall(rb_ivar_get(self, id_ivar_lines), id_method_left, 0);
|
|
@@ -427,10 +386,10 @@ static VALUE draw_lines (VALUE self, VALUE dc, VALUE axis) {
|
|
|
427
386
|
double_y_scale = RFLOAT_VALUE(rb_funcall(rb_ivar_get(self, id_ivar_right_y_scale), id_method_to_f, 0));
|
|
428
387
|
}
|
|
429
388
|
|
|
430
|
-
show_lines = rb_ivar_get(self, id_ivar_show_lines);
|
|
431
|
-
point_size = rb_ivar_get(self, id_ivar_point_size);
|
|
389
|
+
volatile VALUE show_lines = rb_ivar_get(self, id_ivar_show_lines);
|
|
390
|
+
volatile VALUE point_size = rb_ivar_get(self, id_ivar_point_size);
|
|
432
391
|
|
|
433
|
-
num_lines = RARRAY_LEN(lines);
|
|
392
|
+
long num_lines = RARRAY_LEN(lines);
|
|
434
393
|
for (line_index = 0; line_index < num_lines; line_index++) {
|
|
435
394
|
line = rb_ary_entry(lines, line_index);
|
|
436
395
|
x_values = rb_ary_entry(line, 0);
|
|
@@ -118,15 +118,9 @@ static VALUE received_time_equals(VALUE self, VALUE received_time) {
|
|
|
118
118
|
* received */
|
|
119
119
|
static VALUE received_count_equals(VALUE self, VALUE received_count) {
|
|
120
120
|
volatile VALUE read_conversion_cache = rb_ivar_get(self, id_ivar_read_conversion_cache);
|
|
121
|
-
#ifdef RUBY_INTEGER_UNIFICATION /* Ruby 2.4.0 unified Fixnum and Bignum into Integer. This check allows the code to build pre- and post-2.4.0. */
|
|
122
121
|
if (rb_funcall(received_count, id_method_class, 0) != rb_cInteger) {
|
|
123
122
|
rb_raise(rb_eArgError, "received_count must be an Integer but is a %s", RSTRING_PTR(rb_funcall(rb_funcall(received_count, id_method_class, 0), id_method_to_s, 0)));
|
|
124
123
|
}
|
|
125
|
-
#else
|
|
126
|
-
if ((rb_funcall(received_count, id_method_class, 0) != rb_cFixnum) && (rb_funcall(received_count, id_method_class, 0) != rb_cBignum)) {
|
|
127
|
-
rb_raise(rb_eArgError, "received_count must be an Integer but is a %s", RSTRING_PTR(rb_funcall(rb_funcall(received_count, id_method_class, 0), id_method_to_s, 0)));
|
|
128
|
-
}
|
|
129
|
-
#endif
|
|
130
124
|
rb_ivar_set(self, id_ivar_received_count, received_count);
|
|
131
125
|
if (RTEST(read_conversion_cache)) {
|
|
132
126
|
rb_funcall(read_conversion_cache, id_method_clear, 0);
|
|
@@ -23,31 +23,64 @@ VALUE cSegFault = Qnil;
|
|
|
23
23
|
#include <signal.h>
|
|
24
24
|
#include <unistd.h>
|
|
25
25
|
#include <time.h>
|
|
26
|
+
#include <string.h>
|
|
27
|
+
#include <sys/stat.h>
|
|
26
28
|
|
|
27
29
|
static void catch_sigsegv(int sig_num) {
|
|
30
|
+
const int FILENAME_LEN = 256;
|
|
28
31
|
char *cosmos_log_dir = NULL;
|
|
29
32
|
time_t rawtime;
|
|
30
|
-
struct tm
|
|
31
|
-
|
|
33
|
+
struct tm timeinfo;
|
|
34
|
+
struct tm *timeinfo_ptr;
|
|
35
|
+
struct stat stats;
|
|
36
|
+
char filename[FILENAME_LEN];
|
|
32
37
|
FILE* file = NULL;
|
|
33
38
|
|
|
34
39
|
signal(SIGSEGV, SIG_DFL);
|
|
35
40
|
signal(SIGILL, SIG_DFL);
|
|
36
41
|
|
|
37
42
|
cosmos_log_dir = getenv("COSMOS_LOGS_DIR");
|
|
38
|
-
if
|
|
39
|
-
|
|
43
|
+
// If the COSMOS_LOGS_DIR env var isn't set or if it's too big set to "."
|
|
44
|
+
// NOTE: The filename buffer will be written to by snprintf which appends
|
|
45
|
+
// a null terminator so we have 1 less byte available minus the length
|
|
46
|
+
// of the fixed filename structure
|
|
47
|
+
if ((cosmos_log_dir == NULL) || (strlen(cosmos_log_dir) > (FILENAME_LEN - 1 - strlen("/YYYY_MM_DD_HH_MM_SS_segfault.txt"))))
|
|
48
|
+
{
|
|
49
|
+
cosmos_log_dir = (char*)".";
|
|
40
50
|
}
|
|
51
|
+
// Validate that we can write to this directory
|
|
52
|
+
if (stat(cosmos_log_dir, &stats) == 0)
|
|
53
|
+
{
|
|
54
|
+
if (!((stats.st_mode & W_OK)&& S_ISDIR(stats.st_mode)))
|
|
55
|
+
{
|
|
56
|
+
cosmos_log_dir = (char *)".";
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
else
|
|
60
|
+
{
|
|
61
|
+
cosmos_log_dir = (char *)".";
|
|
62
|
+
}
|
|
63
|
+
|
|
41
64
|
time(&rawtime);
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
65
|
+
timeinfo_ptr = localtime_r(&rawtime, &timeinfo);
|
|
66
|
+
if (timeinfo_ptr == NULL)
|
|
67
|
+
{
|
|
68
|
+
// If localtime returns NULL we set our own and set to 1919 to make it interesting
|
|
69
|
+
strptime("1919-01-01 00:00:00", "%Y-%m-%d %H:%M:%S", &timeinfo);
|
|
70
|
+
}
|
|
71
|
+
snprintf(filename, FILENAME_LEN, "%s/%04u_%02u_%02u_%02u_%02u_%02u_segfault.txt",
|
|
72
|
+
cosmos_log_dir,
|
|
73
|
+
1900 + timeinfo.tm_year,
|
|
74
|
+
1 + timeinfo.tm_mon,
|
|
75
|
+
timeinfo.tm_mday,
|
|
76
|
+
timeinfo.tm_hour,
|
|
77
|
+
timeinfo.tm_min,
|
|
78
|
+
timeinfo.tm_sec);
|
|
79
|
+
|
|
80
|
+
// Fortify warns about Path Manipulation here. We explictly allow this to let
|
|
81
|
+
// segfault files be written to a directory of their choosing.
|
|
82
|
+
// The input is validated above for length and to ensure it is a writable directory.
|
|
83
|
+
// If the checks fail the directory is set to the current directory without additional info.
|
|
51
84
|
file = freopen(filename, "a", stderr);
|
|
52
85
|
/* Using file removes a warning */
|
|
53
86
|
if (file) {
|
|
@@ -58,11 +91,12 @@ VALUE cSegFault = Qnil;
|
|
|
58
91
|
}
|
|
59
92
|
#endif
|
|
60
93
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
94
|
+
/* NOTE: Uncomment and rebuilt for testing the handler */
|
|
95
|
+
// static VALUE segfault(VALUE self) {
|
|
96
|
+
// char *a = 0;
|
|
97
|
+
// *a = 50;
|
|
98
|
+
// return Qnil;
|
|
99
|
+
// }
|
|
66
100
|
|
|
67
101
|
/*
|
|
68
102
|
* Initialize methods for Platform specific C code
|
|
@@ -95,7 +129,8 @@ void Init_platform (void) {
|
|
|
95
129
|
signal(SIGILL, catch_sigsegv);
|
|
96
130
|
#endif
|
|
97
131
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
132
|
+
/* NOTE: Uncomment and rebuilt for testing the handler */
|
|
133
|
+
// mCosmos = rb_define_module("Cosmos");
|
|
134
|
+
// cSegFault = rb_define_class_under(mCosmos, "SegFault", rb_cObject);
|
|
135
|
+
// rb_define_singleton_method(cSegFault, "segfault", segfault, 0);
|
|
101
136
|
}
|