elonmusk 1.0.72 → 1.0.79
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CYCLE_OF_ETHICAL_BEHAVIOR +7 -0
- data/EXAMPLES_OF_OPERATION.html +6132 -0
- data/PP.rb +4 -4
- data/README.md +77 -69
- data/VERSION_NUMBER +1 -1
- data/bin/big_num +3 -0
- data/bin/chat_rb +6 -18
- data/bin/close +1 -1
- data/bin/find_housing +1 -1
- data/bin/left_right +0 -0
- data/bin/left_right.exe +0 -0
- data/bin/quot +1 -1
- data/documentation/DISCOURSE_GENERATOR.exe +1 -1
- data/documentation/ULTIMATE_CHAT_APPLICATION.exe +1 -1
- data/documentation/abs +3 -11
- data/documentation/add +1 -5
- data/documentation/append +1 -3
- data/documentation/black +0 -1
- data/documentation/black_bold +0 -1
- data/documentation/black_bold_underline +0 -1
- data/documentation/black_underline +0 -1
- data/documentation/blue +0 -1
- data/documentation/blue_bold +0 -1
- data/documentation/blue_bold_underline +0 -1
- data/documentation/blue_underline +0 -1
- data/documentation/bold +1 -1
- data/documentation/chat_rb +1 -9
- data/documentation/clock +1 -16
- data/documentation/close +2 -2
- data/documentation/cyan +0 -1
- data/documentation/cyan_bold +0 -1
- data/documentation/cyan_bold_underline +0 -1
- data/documentation/cyan_underline +0 -1
- data/documentation/dictate +1 -2
- data/documentation/div +1 -7
- data/documentation/doc.rb +2 -0
- data/documentation/dump +1 -2
- data/documentation/email +2 -20
- data/documentation/emerald-browser +1 -2
- data/documentation/emeraldc +22 -47
- data/documentation/emoji +1 -4
- data/documentation/exp +1 -1
- data/documentation/find_housing +1 -1
- data/documentation/floor +1 -1
- data/documentation/g+ +1 -3
- data/documentation/google_speak +2 -2
- data/documentation/green +0 -1
- data/documentation/green_bold +0 -1
- data/documentation/green_bold_underline +0 -1
- data/documentation/green_underline +0 -1
- data/documentation/gsub +3 -7
- data/documentation/gsubip +1 -1
- data/documentation/last_nth +1 -1
- data/documentation/left_right.exe +9 -0
- data/documentation/lines +1 -3
- data/documentation/magenta +0 -1
- data/documentation/magenta_bold +0 -1
- data/documentation/magenta_bold_underline +0 -1
- data/documentation/magenta_underline +0 -1
- data/documentation/mul +2 -4
- data/documentation/nth +1 -1
- data/documentation/open +4 -23
- data/documentation/page +1 -1
- data/documentation/prepend +2 -20
- data/documentation/processes +1 -5
- data/documentation/red +0 -1
- data/documentation/red_bold +0 -1
- data/documentation/red_bold_underline +0 -1
- data/documentation/red_underline +0 -1
- data/documentation/rgsub +8 -13
- data/documentation/rhyme +5 -12
- data/documentation/rip +1 -2
- data/documentation/rnip +1 -1
- data/documentation/selectlines +1 -7
- data/documentation/speakcat +2 -2
- data/documentation/squeeze +0 -1
- data/documentation/sub +2 -3
- data/documentation/swap +0 -2
- data/documentation/t +3 -12
- data/documentation/underline +1 -1
- data/documentation/undump +1 -5
- data/documentation/white +0 -1
- data/documentation/white_bold +0 -1
- data/documentation/white_bold_underline +0 -1
- data/documentation/white_underline +0 -1
- data/documentation/yellow +0 -1
- data/documentation/yellow_bold +0 -1
- data/documentation/yellow_bold_underline +0 -1
- data/documentation/yellow_underline +0 -1
- data/gem_data/VERSION_NUMBER +1 -1
- data/gem_data/version_increment +1 -0
- data/images/12.png +0 -0
- data/index.html +78 -75
- data/non_compiled_programs/big_num +3 -0
- data/non_compiled_programs/chat_rb +6 -18
- data/non_compiled_programs/close +1 -1
- data/non_compiled_programs/find_housing +1 -1
- data/non_compiled_programs/quot +1 -1
- data/other/rub +35 -0
- data/other/stories/1 +15 -0
- data/other/stories/10 +17 -0
- data/other/stories/100 +17 -0
- data/other/stories/1000 +17 -0
- data/other/stories/1001 +17 -0
- data/other/stories/101 +15 -0
- data/other/stories/102 +15 -0
- data/other/stories/103 +13 -0
- data/other/stories/104 +17 -0
- data/other/stories/105 +11 -0
- data/other/stories/106 +13 -0
- data/other/stories/107 +15 -0
- data/other/stories/108 +15 -0
- data/other/stories/109 +13 -0
- data/other/stories/11 +13 -0
- data/other/stories/110 +17 -0
- data/other/stories/111 +11 -0
- data/other/stories/112 +13 -0
- data/other/stories/113 +11 -0
- data/other/stories/114 +15 -0
- data/other/stories/115 +15 -0
- data/other/stories/116 +13 -0
- data/other/stories/117 +17 -0
- data/other/stories/118 +19 -0
- data/other/stories/119 +15 -0
- data/other/stories/12 +19 -0
- data/other/stories/120 +15 -0
- data/other/stories/121 +15 -0
- data/other/stories/122 +11 -0
- data/other/stories/123 +23 -0
- data/other/stories/124 +17 -0
- data/other/stories/125 +19 -0
- data/other/stories/126 +15 -0
- data/other/stories/127 +17 -0
- data/other/stories/128 +17 -0
- data/other/stories/129 +15 -0
- data/other/stories/13 +13 -0
- data/other/stories/130 +19 -0
- data/other/stories/131 +17 -0
- data/other/stories/132 +11 -0
- data/other/stories/133 +13 -0
- data/other/stories/134 +17 -0
- data/other/stories/135 +15 -0
- data/other/stories/136 +15 -0
- data/other/stories/137 +15 -0
- data/other/stories/138 +17 -0
- data/other/stories/139 +9 -0
- data/other/stories/14 +11 -0
- data/other/stories/140 +13 -0
- data/other/stories/141 +15 -0
- data/other/stories/142 +11 -0
- data/other/stories/143 +13 -0
- data/other/stories/144 +21 -0
- data/other/stories/145 +11 -0
- data/other/stories/146 +11 -0
- data/other/stories/147 +13 -0
- data/other/stories/148 +17 -0
- data/other/stories/149 +15 -0
- data/other/stories/15 +15 -0
- data/other/stories/150 +17 -0
- data/other/stories/151 +13 -0
- data/other/stories/152 +13 -0
- data/other/stories/153 +17 -0
- data/other/stories/154 +15 -0
- data/other/stories/155 +15 -0
- data/other/stories/156 +17 -0
- data/other/stories/157 +13 -0
- data/other/stories/158 +21 -0
- data/other/stories/159 +15 -0
- data/other/stories/16 +17 -0
- data/other/stories/160 +17 -0
- data/other/stories/161 +15 -0
- data/other/stories/162 +19 -0
- data/other/stories/163 +15 -0
- data/other/stories/164 +13 -0
- data/other/stories/165 +11 -0
- data/other/stories/166 +19 -0
- data/other/stories/167 +19 -0
- data/other/stories/168 +21 -0
- data/other/stories/169 +13 -0
- data/other/stories/17 +19 -0
- data/other/stories/170 +13 -0
- data/other/stories/171 +13 -0
- data/other/stories/172 +15 -0
- data/other/stories/173 +13 -0
- data/other/stories/174 +11 -0
- data/other/stories/175 +15 -0
- data/other/stories/176 +15 -0
- data/other/stories/177 +15 -0
- data/other/stories/178 +15 -0
- data/other/stories/179 +17 -0
- data/other/stories/18 +23 -0
- data/other/stories/180 +19 -0
- data/other/stories/181 +15 -0
- data/other/stories/182 +15 -0
- data/other/stories/183 +17 -0
- data/other/stories/184 +15 -0
- data/other/stories/185 +15 -0
- data/other/stories/186 +15 -0
- data/other/stories/187 +15 -0
- data/other/stories/188 +15 -0
- data/other/stories/189 +17 -0
- data/other/stories/19 +17 -0
- data/other/stories/190 +13 -0
- data/other/stories/191 +17 -0
- data/other/stories/192 +17 -0
- data/other/stories/193 +11 -0
- data/other/stories/194 +17 -0
- data/other/stories/195 +13 -0
- data/other/stories/196 +13 -0
- data/other/stories/197 +15 -0
- data/other/stories/198 +15 -0
- data/other/stories/199 +15 -0
- data/other/stories/2 +13 -0
- data/other/stories/20 +15 -0
- data/other/stories/200 +17 -0
- data/other/stories/201 +21 -0
- data/other/stories/202 +13 -0
- data/other/stories/203 +15 -0
- data/other/stories/204 +17 -0
- data/other/stories/205 +13 -0
- data/other/stories/206 +15 -0
- data/other/stories/207 +13 -0
- data/other/stories/208 +11 -0
- data/other/stories/209 +15 -0
- data/other/stories/21 +19 -0
- data/other/stories/210 +11 -0
- data/other/stories/211 +19 -0
- data/other/stories/212 +17 -0
- data/other/stories/213 +13 -0
- data/other/stories/214 +13 -0
- data/other/stories/215 +15 -0
- data/other/stories/216 +13 -0
- data/other/stories/217 +23 -0
- data/other/stories/218 +17 -0
- data/other/stories/219 +15 -0
- data/other/stories/22 +13 -0
- data/other/stories/220 +15 -0
- data/other/stories/221 +19 -0
- data/other/stories/222 +15 -0
- data/other/stories/223 +19 -0
- data/other/stories/224 +15 -0
- data/other/stories/225 +13 -0
- data/other/stories/226 +15 -0
- data/other/stories/227 +15 -0
- data/other/stories/228 +13 -0
- data/other/stories/229 +15 -0
- data/other/stories/23 +17 -0
- data/other/stories/230 +15 -0
- data/other/stories/231 +17 -0
- data/other/stories/232 +17 -0
- data/other/stories/233 +17 -0
- data/other/stories/234 +19 -0
- data/other/stories/235 +17 -0
- data/other/stories/236 +15 -0
- data/other/stories/237 +15 -0
- data/other/stories/238 +17 -0
- data/other/stories/239 +19 -0
- data/other/stories/24 +15 -0
- data/other/stories/240 +15 -0
- data/other/stories/241 +13 -0
- data/other/stories/242 +23 -0
- data/other/stories/243 +11 -0
- data/other/stories/244 +19 -0
- data/other/stories/245 +19 -0
- data/other/stories/246 +17 -0
- data/other/stories/247 +15 -0
- data/other/stories/248 +17 -0
- data/other/stories/249 +13 -0
- data/other/stories/25 +15 -0
- data/other/stories/250 +15 -0
- data/other/stories/251 +21 -0
- data/other/stories/252 +17 -0
- data/other/stories/253 +15 -0
- data/other/stories/254 +13 -0
- data/other/stories/255 +15 -0
- data/other/stories/256 +13 -0
- data/other/stories/257 +15 -0
- data/other/stories/258 +13 -0
- data/other/stories/259 +15 -0
- data/other/stories/26 +15 -0
- data/other/stories/260 +15 -0
- data/other/stories/261 +11 -0
- data/other/stories/262 +13 -0
- data/other/stories/263 +17 -0
- data/other/stories/264 +13 -0
- data/other/stories/265 +19 -0
- data/other/stories/266 +23 -0
- data/other/stories/267 +13 -0
- data/other/stories/268 +15 -0
- data/other/stories/269 +19 -0
- data/other/stories/27 +13 -0
- data/other/stories/270 +15 -0
- data/other/stories/271 +17 -0
- data/other/stories/272 +11 -0
- data/other/stories/273 +13 -0
- data/other/stories/274 +15 -0
- data/other/stories/275 +13 -0
- data/other/stories/276 +15 -0
- data/other/stories/277 +13 -0
- data/other/stories/278 +15 -0
- data/other/stories/279 +15 -0
- data/other/stories/28 +19 -0
- data/other/stories/280 +15 -0
- data/other/stories/281 +19 -0
- data/other/stories/282 +15 -0
- data/other/stories/283 +17 -0
- data/other/stories/284 +13 -0
- data/other/stories/285 +15 -0
- data/other/stories/286 +15 -0
- data/other/stories/287 +17 -0
- data/other/stories/288 +11 -0
- data/other/stories/289 +15 -0
- data/other/stories/29 +23 -0
- data/other/stories/290 +19 -0
- data/other/stories/291 +19 -0
- data/other/stories/292 +17 -0
- data/other/stories/293 +13 -0
- data/other/stories/294 +15 -0
- data/other/stories/295 +15 -0
- data/other/stories/296 +15 -0
- data/other/stories/297 +15 -0
- data/other/stories/298 +23 -0
- data/other/stories/299 +11 -0
- data/other/stories/3 +15 -0
- data/other/stories/30 +13 -0
- data/other/stories/300 +15 -0
- data/other/stories/301 +15 -0
- data/other/stories/302 +19 -0
- data/other/stories/303 +15 -0
- data/other/stories/304 +17 -0
- data/other/stories/305 +15 -0
- data/other/stories/306 +21 -0
- data/other/stories/307 +11 -0
- data/other/stories/308 +15 -0
- data/other/stories/309 +15 -0
- data/other/stories/31 +19 -0
- data/other/stories/310 +17 -0
- data/other/stories/311 +15 -0
- data/other/stories/312 +15 -0
- data/other/stories/313 +13 -0
- data/other/stories/314 +15 -0
- data/other/stories/315 +13 -0
- data/other/stories/316 +17 -0
- data/other/stories/317 +17 -0
- data/other/stories/318 +15 -0
- data/other/stories/319 +13 -0
- data/other/stories/32 +17 -0
- data/other/stories/320 +13 -0
- data/other/stories/321 +15 -0
- data/other/stories/322 +11 -0
- data/other/stories/323 +15 -0
- data/other/stories/324 +19 -0
- data/other/stories/325 +19 -0
- data/other/stories/326 +21 -0
- data/other/stories/327 +15 -0
- data/other/stories/328 +15 -0
- data/other/stories/329 +15 -0
- data/other/stories/33 +13 -0
- data/other/stories/330 +15 -0
- data/other/stories/331 +17 -0
- data/other/stories/332 +20 -0
- data/other/stories/333 +17 -0
- data/other/stories/334 +11 -0
- data/other/stories/335 +15 -0
- data/other/stories/336 +15 -0
- data/other/stories/337 +19 -0
- data/other/stories/338 +19 -0
- data/other/stories/339 +13 -0
- data/other/stories/34 +13 -0
- data/other/stories/340 +17 -0
- data/other/stories/341 +15 -0
- data/other/stories/342 +17 -0
- data/other/stories/343 +15 -0
- data/other/stories/344 +17 -0
- data/other/stories/345 +15 -0
- data/other/stories/346 +17 -0
- data/other/stories/347 +17 -0
- data/other/stories/348 +11 -0
- data/other/stories/349 +15 -0
- data/other/stories/35 +13 -0
- data/other/stories/350 +21 -0
- data/other/stories/351 +15 -0
- data/other/stories/352 +17 -0
- data/other/stories/353 +15 -0
- data/other/stories/354 +17 -0
- data/other/stories/355 +15 -0
- data/other/stories/356 +15 -0
- data/other/stories/357 +11 -0
- data/other/stories/358 +13 -0
- data/other/stories/359 +11 -0
- data/other/stories/36 +11 -0
- data/other/stories/360 +13 -0
- data/other/stories/361 +13 -0
- data/other/stories/362 +13 -0
- data/other/stories/363 +21 -0
- data/other/stories/364 +17 -0
- data/other/stories/365 +11 -0
- data/other/stories/37 +13 -0
- data/other/stories/38 +17 -0
- data/other/stories/39 +17 -0
- data/other/stories/4 +15 -0
- data/other/stories/40 +11 -0
- data/other/stories/4000 +15 -0
- data/other/stories/4001 +21 -0
- data/other/stories/4002 +15 -0
- data/other/stories/4003 +15 -0
- data/other/stories/4004 +15 -0
- data/other/stories/4005 +15 -0
- data/other/stories/4006 +21 -0
- data/other/stories/4007 +15 -0
- data/other/stories/4008 +15 -0
- data/other/stories/4009 +13 -0
- data/other/stories/4010 +15 -0
- data/other/stories/4011 +15 -0
- data/other/stories/4012 +17 -0
- data/other/stories/4013 +15 -0
- data/other/stories/4014 +13 -0
- data/other/stories/4015 +15 -0
- data/other/stories/4016 +17 -0
- data/other/stories/4017 +13 -0
- data/other/stories/4018 +17 -0
- data/other/stories/4019 +15 -0
- data/other/stories/4020 +19 -0
- data/other/stories/4021 +21 -0
- data/other/stories/4022 +15 -0
- data/other/stories/4023 +13 -0
- data/other/stories/4024 +13 -0
- data/other/stories/4025 +23 -0
- data/other/stories/4026 +17 -0
- data/other/stories/4027 +15 -0
- data/other/stories/4028 +13 -0
- data/other/stories/4029 +11 -0
- data/other/stories/4030 +13 -0
- data/other/stories/4031 +13 -0
- data/other/stories/4032 +13 -0
- data/other/stories/4033 +15 -0
- data/other/stories/4034 +17 -0
- data/other/stories/4035 +13 -0
- data/other/stories/41 +15 -0
- data/other/stories/42 +17 -0
- data/other/stories/43 +15 -0
- data/other/stories/44 +15 -0
- data/other/stories/45 +17 -0
- data/other/stories/46 +17 -0
- data/other/stories/47 +13 -0
- data/other/stories/48 +13 -0
- data/other/stories/49 +17 -0
- data/other/stories/5 +11 -0
- data/other/stories/50 +13 -0
- data/other/stories/51 +15 -0
- data/other/stories/52 +17 -0
- data/other/stories/53 +15 -0
- data/other/stories/54 +11 -0
- data/other/stories/55 +21 -0
- data/other/stories/56 +19 -0
- data/other/stories/57 +13 -0
- data/other/stories/58 +15 -0
- data/other/stories/59 +13 -0
- data/other/stories/6 +11 -0
- data/other/stories/60 +13 -0
- data/other/stories/61 +13 -0
- data/other/stories/62 +13 -0
- data/other/stories/63 +15 -0
- data/other/stories/64 +15 -0
- data/other/stories/65 +17 -0
- data/other/stories/66 +15 -0
- data/other/stories/67 +15 -0
- data/other/stories/68 +15 -0
- data/other/stories/69 +17 -0
- data/other/stories/7 +15 -0
- data/other/stories/70 +21 -0
- data/other/stories/71 +13 -0
- data/other/stories/72 +13 -0
- data/other/stories/73 +15 -0
- data/other/stories/74 +17 -0
- data/other/stories/75 +11 -0
- data/other/stories/76 +19 -0
- data/other/stories/77 +21 -0
- data/other/stories/78 +19 -0
- data/other/stories/79 +11 -0
- data/other/stories/8 +17 -0
- data/other/stories/80 +21 -0
- data/other/stories/81 +23 -0
- data/other/stories/82 +15 -0
- data/other/stories/83 +11 -0
- data/other/stories/84 +13 -0
- data/other/stories/85 +17 -0
- data/other/stories/86 +17 -0
- data/other/stories/87 +25 -0
- data/other/stories/88 +19 -0
- data/other/stories/89 +17 -0
- data/other/stories/9 +15 -0
- data/other/stories/90 +15 -0
- data/other/stories/91 +15 -0
- data/other/stories/92 +17 -0
- data/other/stories/93 +17 -0
- data/other/stories/94 +19 -0
- data/other/stories/95 +13 -0
- data/other/stories/96 +17 -0
- data/other/stories/97 +15 -0
- data/other/stories/98 +11 -0
- data/other/stories/99 +13 -0
- data/other/upload.rb +8 -2
- data/src/compilation/abs +1 -1
- data/src/compilation/add +1 -1
- data/src/compilation/append +1 -1
- data/src/compilation/div +1 -1
- data/src/compilation/dump +1 -1
- data/src/compilation/exp +1 -1
- data/src/compilation/gsub +1 -1
- data/src/compilation/lines +1 -1
- data/src/compilation/mul +1 -1
- data/src/compilation/prepend +1 -1
- data/src/compilation/rip +1 -1
- data/src/compilation/rnip +1 -1
- data/src/compilation/selectlines +1 -1
- data/src/compilation/sub +1 -1
- data/src/compilation/swap +1 -1
- data/src/compilation/undump +1 -1
- data/src/compile_all +5 -2
- data/src/left_right +0 -0
- data/src/left_right.cc +87 -0
- data/src/left_right.exe +0 -0
- data/version_increment +1 -0
- metadata +417 -5
- data/non_compiled_programs/make_server +0 -784
- data/src/- +0 -1
- data/src/--file +0 -0
@@ -1,784 +0,0 @@
|
|
1
|
-
#!/usr/bin/env node
|
2
|
-
|
3
|
-
/*
|
4
|
-
|
5
|
-
# BSD 2-Clause License
|
6
|
-
#
|
7
|
-
# Copyright (c) 2023, Gregory Cohen
|
8
|
-
# All rights reserved.
|
9
|
-
#
|
10
|
-
# Redistribution and use in source and binary forms, with or without
|
11
|
-
# modification, are permitted provided that the following conditions are met:
|
12
|
-
#
|
13
|
-
# 1. Redistributions of source code must retain the above copyright notice, this
|
14
|
-
# list of conditions and the following disclaimer.
|
15
|
-
#
|
16
|
-
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
17
|
-
# this list of conditions and the following disclaimer in the documentation
|
18
|
-
# and/or other materials provided with the distribution.
|
19
|
-
#
|
20
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
21
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
22
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
23
|
-
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
24
|
-
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
25
|
-
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
26
|
-
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
27
|
-
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
28
|
-
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
29
|
-
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
30
|
-
|
31
|
-
# Get rid of the "ca"s if you want to make it work for the US.
|
32
|
-
# This program is for personal, non-commerical use.
|
33
|
-
# Any sites this program downloads from are being used for personal, non-commerical use.
|
34
|
-
# If any legal problems do arise, feel free to contact me at my
|
35
|
-
# email and I can modify this program to use some ohter site.
|
36
|
-
|
37
|
-
|
38
|
-
*/
|
39
|
-
|
40
|
-
|
41
|
-
function m() {
|
42
|
-
main_func = "";
|
43
|
-
decl = "const";
|
44
|
-
all_code = "";
|
45
|
-
VERBOSE_DEBUG = this.global && process.env["DEBUG"] == "true";
|
46
|
-
function get_all_declarations() {
|
47
|
-
return ((this.global && process.env["DECLS"]) || "").split(/,,/);
|
48
|
-
}
|
49
|
-
g = 0;
|
50
|
-
const javascript = process["mode"] === "js";
|
51
|
-
const cpp = process["mode"] === "cpp";
|
52
|
-
javascript || cpp || alert("Error, no mode selected");
|
53
|
-
if (cpp) {
|
54
|
-
decl = "const";
|
55
|
-
decl_int = "size_t";
|
56
|
-
array_decl = "Array";
|
57
|
-
precode = `
|
58
|
-
|
59
|
-
#define function static inline void*
|
60
|
-
#define var auto
|
61
|
-
#define let auto
|
62
|
-
#define const const auto
|
63
|
-
`;
|
64
|
-
} else {
|
65
|
-
array_decl = decl = decl_int = "";
|
66
|
-
precode = `
|
67
|
-
function set_globals() {
|
68
|
-
nesting=0;VERBOSE_DEBUG=${VERBOSE_DEBUG};function puts() { eval("return con" + "sole" + ".warn"); }
|
69
|
-
} ; set_globals(); `;
|
70
|
-
} /*
|
71
|
-
if (javascript)*/
|
72
|
-
if (cpp) {
|
73
|
-
len = "array.size()";
|
74
|
-
} else {
|
75
|
-
len = "array.length";
|
76
|
-
}
|
77
|
-
const m = (func, array, cond, one, i = [0, len]) => {
|
78
|
-
func = func.split(".").join("_");
|
79
|
-
c = "";
|
80
|
-
if (cpp) {
|
81
|
-
c += `#ifndef ${func}_macro
|
82
|
-
#define ${func}_macro
|
83
|
-
#undef ${func}
|
84
|
-
#undef ${func}_otherwise
|
85
|
-
#ifndef nop_func_macro
|
86
|
-
#define nop_func_macro
|
87
|
-
static double* nop_func(...) { return nullptr; }
|
88
|
-
#endif
|
89
|
-
#define ${func}_otherwise nop_func`;
|
90
|
-
}
|
91
|
-
var new_one = [];
|
92
|
-
|
93
|
-
one = one.split(/\s*;\s*/);
|
94
|
-
for (const i of one) {
|
95
|
-
if (i.length) {
|
96
|
-
new_one.push(i + ";");
|
97
|
-
}
|
98
|
-
}
|
99
|
-
one = new_one;
|
100
|
-
c += precode + `function ${func}(${array_decl} array, ${decl_int} i) {`;
|
101
|
-
c += `${cpp ? "double * " : "var"} rvalue`;
|
102
|
-
// }}`;
|
103
|
-
c += `
|
104
|
-
${
|
105
|
-
this.global &&
|
106
|
-
get_all_declarations().map((i) => {
|
107
|
-
if (!i.trim()) return "";
|
108
|
-
return "/* DECL */ const " + i;
|
109
|
-
})
|
110
|
-
}
|
111
|
-
${VERBOSE_DEBUG ? ++nesting : ""};
|
112
|
-
const max = ${i[1]};
|
113
|
-
while (i < max) {
|
114
|
-
Object element = array[i];
|
115
|
-
`;
|
116
|
-
if (javascript) {
|
117
|
-
c += `const style = element.style`;
|
118
|
-
}
|
119
|
-
c += ` ${
|
120
|
-
VERBOSE_DEBUG
|
121
|
-
? 'puts(" ".repeat((nesting - 1) * 4) + `....Iteration ${i} i=` + [i, "/", max, " (", Math.round(i/max*100, 2), "%", ") +", 1.0/max*100, "%", " of loop completed"].join(""))'
|
122
|
-
: ""
|
123
|
-
}
|
124
|
-
const condition = ${cond};
|
125
|
-
if (condition) {
|
126
|
-
using namespace std;
|
127
|
-
${one.slice(0, one.length - 1).join("\n\t\t\t\t")}
|
128
|
-
//{one.slice(one.length - 1)
|
129
|
-
rvalue = ${
|
130
|
-
cpp ? "*(double**)(size_t)(size_t*)&(" : ""
|
131
|
-
}${(last = one[one.length - 1]).substr(
|
132
|
-
0,
|
133
|
-
last.length - 1
|
134
|
-
)}${cpp ? ")" : ""};
|
135
|
-
} else {`;
|
136
|
-
if (javascript) {
|
137
|
-
c += "try { ";
|
138
|
-
}
|
139
|
-
c += `
|
140
|
-
rvalue = ${func}_otherwise(${cpp ? "&(" : "["}element${
|
141
|
-
cpp ? ")" : "]"
|
142
|
-
}, 0);
|
143
|
-
`;
|
144
|
-
if (javascript)
|
145
|
-
c += `
|
146
|
-
} catch (e) {}`;
|
147
|
-
c;
|
148
|
-
c += ` } ++i; } `;
|
149
|
-
if (VERBOSE_DEBUG && javascript)
|
150
|
-
c += `
|
151
|
-
puts("Loop comp");
|
152
|
-
--nesting;`;
|
153
|
-
c += `
|
154
|
-
return rvalue;
|
155
|
-
}
|
156
|
-
`;
|
157
|
-
if (cpp) {
|
158
|
-
c += `#endif` + "\n";
|
159
|
-
}
|
160
|
-
{
|
161
|
-
}
|
162
|
-
function remove_sides(a, first, last) {
|
163
|
-
if (a.startsWith(first)) a = a.slice(first.length, a.length);
|
164
|
-
if (a.endsWith(last)) {
|
165
|
-
a = a.slice(0, a.length - last.length);
|
166
|
-
}
|
167
|
-
return a;
|
168
|
-
}
|
169
|
-
|
170
|
-
/* String.prototype.gsub = function*/
|
171
|
-
|
172
|
-
if (!func.endsWith("otherwise")) {
|
173
|
-
d = main_func;
|
174
|
-
if (cpp) {
|
175
|
-
try {
|
176
|
-
array = mod(JSON.parse(array));
|
177
|
-
} catch (e) {
|
178
|
-
console.warn(e);
|
179
|
-
process.exit();
|
180
|
-
}
|
181
|
-
d += "return \n";
|
182
|
-
|
183
|
-
d += `${func}(\n${array},\n${i[0]}\n);`;
|
184
|
-
}
|
185
|
-
main_func = d;
|
186
|
-
}
|
187
|
-
function to_s(e) {
|
188
|
-
return e;
|
189
|
-
}
|
190
|
-
};
|
191
|
-
args = "";
|
192
|
-
try {
|
193
|
-
args = process.argv.slice(2).join(",,");
|
194
|
-
} catch (_) {
|
195
|
-
args = [...arguments].join(",,");
|
196
|
-
}
|
197
|
-
if (!args) {
|
198
|
-
puts("Added m function and env function");
|
199
|
-
return;
|
200
|
-
}
|
201
|
-
args = args.split(",,");
|
202
|
-
for (var i = 0; i < args.length; ) {
|
203
|
-
s = args.slice(i, i + 4);
|
204
|
-
if (s[0].match(/otherwise$/)) {
|
205
|
-
s = [s[0], [true], true, s[1]];
|
206
|
-
i += 2;
|
207
|
-
} else {
|
208
|
-
i += 4;
|
209
|
-
}
|
210
|
-
m(...s);
|
211
|
-
foo(s[0], c);
|
212
|
-
all_code += c;
|
213
|
-
}
|
214
|
-
all_code += `
|
215
|
-
function ${(prog_name = "e" + Date.now())}_main() {
|
216
|
-
${main_func}
|
217
|
-
}`;
|
218
|
-
if (cpp)
|
219
|
-
all_code = cpp_pre_code() + all_code + `\n\n\nint main(int argc, char ** argv , char ** envp) { main_( argc, argv, envp); }`;
|
220
|
-
else all_code += "\n" + prog_name + "_main();";
|
221
|
-
foo("all_code", all_code);
|
222
|
-
if (javascript) {
|
223
|
-
try {
|
224
|
-
eval(all_code);
|
225
|
-
} catch (e) {
|
226
|
-
console.warn(e);
|
227
|
-
}
|
228
|
-
}
|
229
|
-
function foo(func, code) {
|
230
|
-
const out = `${func}.${process.mode}`;
|
231
|
-
try {
|
232
|
-
require("fs").writeFileSync(out, code);
|
233
|
-
} catch (_) {
|
234
|
-
console.log(_);
|
235
|
-
var saveData = (function () {
|
236
|
-
var a = document.createElement("a");
|
237
|
-
document.body.appendChild(a);
|
238
|
-
a.style = "display: none";
|
239
|
-
return function (data, fileName) {
|
240
|
-
var json = data,
|
241
|
-
blob = new Blob([json], { type: "octet/stream" }),
|
242
|
-
url = window.URL.createObjectURL(blob);
|
243
|
-
a.href = url;
|
244
|
-
a.download = fileName;
|
245
|
-
a.click();
|
246
|
-
window.URL.revokeObjectURL(url);
|
247
|
-
};
|
248
|
-
})();
|
249
|
-
saveData(code, out);
|
250
|
-
}
|
251
|
-
}
|
252
|
-
return true;
|
253
|
-
}
|
254
|
-
|
255
|
-
env("mode", "js", 1) && m() && env("mode", "cpp", 1) && m();
|
256
|
-
function env(a, b, mode) {
|
257
|
-
var n = this.global || window;
|
258
|
-
n.process = n.process || { env: { DEBUG: "true", DECLS: "" } };
|
259
|
-
|
260
|
-
if (!mode) {
|
261
|
-
process.env.DECLS += `${a}=${b},,`;
|
262
|
-
} else {
|
263
|
-
process[a] = b;
|
264
|
-
}
|
265
|
-
return true;
|
266
|
-
}
|
267
|
-
function help() {
|
268
|
-
console.table(`m() (Browser console and node) -> generates a list of all arguments (or strings separted by double commas)
|
269
|
-
Functions are run sequentially. Otherwise functions are not run.
|
270
|
-
All functions loop over something
|
271
|
-
All functions have a conditional.
|
272
|
-
func_name iterable (such as a list or a DOMElement) condition expression
|
273
|
-
The resultant function returns the last expression in the function
|
274
|
-
This isn't a DSL, it's extremely broad.
|
275
|
-
Any algorithm can be expressed this way.
|
276
|
-
This makes writing algorithms much, much easier.
|
277
|
-
It works in Node.js and in the browser.
|
278
|
-
After generating all functions, the resultant code gets downloaded.
|
279
|
-
`);
|
280
|
-
}
|
281
|
-
|
282
|
-
//functin cpp
|
283
|
-
|
284
|
-
function cpp_code() {
|
285
|
-
return (cpp_code =
|
286
|
-
`
|
287
|
-
#include <cstddef>
|
288
|
-
#include <iostream>
|
289
|
-
#include <vector>
|
290
|
-
#include <sstream>
|
291
|
-
#include <cstring>
|
292
|
-
#include <map>
|
293
|
-
|
294
|
-
//namespace {
|
295
|
-
enum {
|
296
|
-
INT,
|
297
|
-
DOUBLE,
|
298
|
-
STRING,
|
299
|
-
VECTOR,
|
300
|
-
MAP,
|
301
|
-
|
302
|
-
NEEDS_FREEING,
|
303
|
-
NEEDS_DELETING,
|
304
|
-
NEEDS_DELETING_ARRAY
|
305
|
-
};
|
306
|
-
|
307
|
-
//#define c construct
|
308
|
-
|
309
|
-
class Object {
|
310
|
-
public:
|
311
|
-
double type;
|
312
|
-
double value;
|
313
|
-
|
314
|
-
|
315
|
-
~Object() {
|
316
|
-
union { char* v;
|
317
|
-
double d;
|
318
|
-
} un;
|
319
|
-
un.d = value;
|
320
|
-
|
321
|
-
switch ((size_t)type) {
|
322
|
-
case NEEDS_FREEING:
|
323
|
-
std::cout << "Freeing " << (std::string)(*this) << "\\n";
|
324
|
-
free(*un.v);
|
325
|
-
delete un.v;
|
326
|
-
break;
|
327
|
-
case NEEDS_DELETING_ARRAY:
|
328
|
-
delete [] un.v;
|
329
|
-
delete ptr;
|
330
|
-
break;
|
331
|
-
case NEEDS_DELETING:
|
332
|
-
delete *un.v;
|
333
|
-
delete un.v;
|
334
|
-
break;
|
335
|
-
}
|
336
|
-
};
|
337
|
-
|
338
|
-
operator const std::string() const;
|
339
|
-
|
340
|
-
|
341
|
-
const Object& print() const;
|
342
|
-
|
343
|
-
|
344
|
-
bool operator < (Object a) const {
|
345
|
-
return (const std::string)(*this) < (const std::string)(a);
|
346
|
-
};
|
347
|
-
|
348
|
-
};
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
template <class A>
|
355
|
-
class Array_sub : public std::vector<A>
|
356
|
-
{
|
357
|
-
public:
|
358
|
-
Array_sub(std::initializer_list<A> a) : std::vector<A>{a}
|
359
|
-
{}
|
360
|
-
|
361
|
-
inline void push(const A value) {
|
362
|
-
std::vector<A>::emplace_back(value);
|
363
|
-
}
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
inline Array_sub<A>& operator<< (A v) {
|
369
|
-
push(v);
|
370
|
-
return *this;
|
371
|
-
}
|
372
|
-
|
373
|
-
inline const auto surround(const char* first, const char* second) const {
|
374
|
-
|
375
|
-
typedef Array_sub<A> Array;
|
376
|
-
Array b{};
|
377
|
-
std::cout << "Start of loops\\n";
|
378
|
-
for (size_t i = 0; i < this->size(); ++i) {
|
379
|
-
std::string s{first};
|
380
|
-
s+= (std::string)((*this)[i]);
|
381
|
-
s += second;
|
382
|
-
|
383
|
-
b.emplace_back(construct_needs_freeing(strdup(s.c_str())));
|
384
|
-
std::cout << "Loop number " << i << std::endl;
|
385
|
-
}
|
386
|
-
std::cout << "End of loops\\n";
|
387
|
-
return b;
|
388
|
-
}
|
389
|
-
|
390
|
-
inline auto js() {
|
391
|
-
return surround("<script type='text/javascript'>", "</script>");
|
392
|
-
}
|
393
|
-
|
394
|
-
inline const auto construct_needs_freeing(const char* const a) const {
|
395
|
-
union {
|
396
|
-
const char* c;
|
397
|
-
double d;
|
398
|
-
} u;
|
399
|
-
|
400
|
-
u.c = a;
|
401
|
-
|
402
|
-
return *new Object{NEEDS_FREEING, u.d};
|
403
|
-
}
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
operator const std::string() const {
|
409
|
-
return to_s();
|
410
|
-
}
|
411
|
-
|
412
|
-
inline auto append(const char* arg1) const {
|
413
|
-
return surround(nullptr, arg1);
|
414
|
-
}
|
415
|
-
|
416
|
-
|
417
|
-
inline auto prepend(const char* arg1) const {
|
418
|
-
return surround(nullptr, arg1);
|
419
|
-
}
|
420
|
-
|
421
|
-
inline auto quote() const {
|
422
|
-
return surround("'", "'");
|
423
|
-
}
|
424
|
-
|
425
|
-
inline auto join(const char* delim) const {
|
426
|
-
std::string result;
|
427
|
-
const auto length=this->size();
|
428
|
-
for (size_t i = 0; i < length; ++i) {
|
429
|
-
result += (*this)[i];
|
430
|
-
if (i==length-1) {
|
431
|
-
} else {
|
432
|
-
result += delim;
|
433
|
-
}
|
434
|
-
}
|
435
|
-
|
436
|
-
return result;
|
437
|
-
}
|
438
|
-
|
439
|
-
inline auto html(const char* title) const {
|
440
|
-
std::string site_content;
|
441
|
-
site_content += "Content-type: text/html\\r\\n\\r\\n<!DOCTYPE html><html><head><title>";
|
442
|
-
site_content += title;
|
443
|
-
site_content += "</title></head>";
|
444
|
-
site_content += "<body>";
|
445
|
-
//this->surround("<p>", "</p>");
|
446
|
-
site_content += this->surround("<p>", "</p>");
|
447
|
-
site_content += "</body></html>";
|
448
|
-
return site_content;
|
449
|
-
}
|
450
|
-
|
451
|
-
inline auto p() const {
|
452
|
-
return surround("<p>", "</p>");
|
453
|
-
}
|
454
|
-
|
455
|
-
inline auto div() const {
|
456
|
-
return surround("<div>", "</div>");
|
457
|
-
}
|
458
|
-
|
459
|
-
inline auto nls() const {
|
460
|
-
return surround(nullptr, "\\n");
|
461
|
-
}
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
const std::string to_s() const {
|
466
|
-
std::ostringstream str;
|
467
|
-
str << '[';
|
468
|
-
for (size_t i = 0; i < this->size(); ++i) {
|
469
|
-
str << (std::string)((*this)[i]);
|
470
|
-
|
471
|
-
if (i == this->size() - 1) {
|
472
|
-
} else {
|
473
|
-
str << ", ";
|
474
|
-
}
|
475
|
-
}
|
476
|
-
str << ']';
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
return str.str();
|
481
|
-
|
482
|
-
}
|
483
|
-
};
|
484
|
-
typedef Array_sub<Object> Array;
|
485
|
-
|
486
|
-
|
487
|
-
union Object_v {
|
488
|
-
double d;
|
489
|
-
const void* v;
|
490
|
-
long long int long_long;
|
491
|
-
|
492
|
-
const std::map<Object, Object>* map;
|
493
|
-
//const char* string;
|
494
|
-
const Array* array; /*/const ch
|
495
|
-
const cha*/
|
496
|
-
const char* string;
|
497
|
-
};
|
498
|
-
|
499
|
-
|
500
|
-
Object::operator const std::string() const {
|
501
|
-
Object_v val_;
|
502
|
-
|
503
|
-
val_.d = this->value;
|
504
|
-
|
505
|
-
switch ((size_t)this->type) {
|
506
|
-
case STRING:
|
507
|
-
return val_.string;
|
508
|
-
case NEEDS_DELETING:
|
509
|
-
return "[needs_deleting]";
|
510
|
-
case NEEDS_FREEING:return val_.string;
|
511
|
-
// return std::string(val_.string) + ";
|
512
|
-
case NEEDS_DELETING_ARRAY: return "[needs_deleting_array]";
|
513
|
-
case INT:
|
514
|
-
return std::to_string((long long int)val_.long_long );
|
515
|
-
case DOUBLE:
|
516
|
-
return std::to_string(val_.d);
|
517
|
-
case VECTOR:
|
518
|
-
return val_.array->to_s();
|
519
|
-
case MAP:
|
520
|
-
std::string map_str = "{";
|
521
|
-
// std::map<A,
|
522
|
-
|
523
|
-
//auto& map = val_->map;
|
524
|
-
for (const auto i : *val_.map) {
|
525
|
-
map_str += (std::string)(i.first);
|
526
|
-
map_str += ": ";
|
527
|
-
|
528
|
-
map_str += (std::string)(i.second);
|
529
|
-
|
530
|
-
map_str += ", ";
|
531
|
-
}
|
532
|
-
// map_str[map_str.size() =
|
533
|
-
if (map_str.size () ) {
|
534
|
-
map_str[map_str.size() - 2] = '}';
|
535
|
-
map_str.resize(map_str.size() - 1);
|
536
|
-
}
|
537
|
-
|
538
|
-
// std::cout << map_str;
|
539
|
-
|
540
|
-
return map_str;
|
541
|
-
}
|
542
|
-
|
543
|
-
return "Error string";
|
544
|
-
};
|
545
|
-
|
546
|
-
const Object& Object::print() const {
|
547
|
-
std::cout << (std::string)(*this) << "<br/>";
|
548
|
-
return *this;
|
549
|
-
}
|
550
|
-
Object construct(const long long int a) { union Object_v un; un.long_long = a; return Object {0, un.d}; }
|
551
|
-
Object construct(const std::map<Object, Object> && a) {Object_v un; un.map = &a; return Object{4, un.d}; }
|
552
|
-
|
553
|
-
Object construct(Array && a ) {Object_v q; q.array = &a; return Object{3, q.d}; }
|
554
|
-
Object operator ""_c(unsigned long long a) {
|
555
|
-
return construct(a);
|
556
|
-
}
|
557
|
-
|
558
|
-
Object construct(const double a) {
|
559
|
-
return Object{1, a};
|
560
|
-
|
561
|
-
}
|
562
|
-
|
563
|
-
|
564
|
-
Object construct(const char* a) {
|
565
|
-
union {
|
566
|
-
double d;
|
567
|
-
const void* v; } b;
|
568
|
-
b.v = a;
|
569
|
-
|
570
|
-
return Object{2, b.d};
|
571
|
-
}
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
` + additional_cpp_code()); //moremore+more_cpp_code();
|
576
|
-
}
|
577
|
-
function nums(a) {
|
578
|
-
if (typeof a != "number") return mod(a);
|
579
|
-
|
580
|
-
//while (1) console.log(a)
|
581
|
-
if (a.toString().includes(".")) {
|
582
|
-
return surround(a);
|
583
|
-
} else {
|
584
|
-
return surround(a + "ll");
|
585
|
-
}
|
586
|
-
}
|
587
|
-
|
588
|
-
function cpp_pre_code() {
|
589
|
-
return cpp_code();
|
590
|
-
}
|
591
|
-
function set_kv(kv) {
|
592
|
-
for (var i_ of [0, 1]) kv[i_] = nums(kv[i_]);
|
593
|
-
|
594
|
-
//}
|
595
|
-
|
596
|
-
//}
|
597
|
-
}
|
598
|
-
|
599
|
-
function surround(a) {
|
600
|
-
return "construct(" + a + ")";
|
601
|
-
}
|
602
|
-
function mod(array, a = 0) {
|
603
|
-
if (typeof array == "string") {
|
604
|
-
return surround(JSON.stringify(array));
|
605
|
-
}
|
606
|
-
a = a + 1;
|
607
|
-
if (a == 1) {
|
608
|
-
var str = " Array{";
|
609
|
-
} else var str = "";
|
610
|
-
var element = false;
|
611
|
-
|
612
|
-
try {
|
613
|
-
// let str = "";
|
614
|
-
if (typeof array == "object" && array.length === undefined) {
|
615
|
-
str = "construct(" + "\n" + "\t".repeat(a) + " std::map<Object, Object >{";
|
616
|
-
// var element
|
617
|
-
var a = 0;
|
618
|
-
console.log(array);
|
619
|
-
// fs.writeFileSync("args/" +
|
620
|
-
const s = JSON.stringify;
|
621
|
-
for (var i in array) {
|
622
|
-
var kv = [i, array[i]];
|
623
|
-
element = true;
|
624
|
-
set_kv(kv);
|
625
|
-
const t = " Object ";
|
626
|
-
const pair = "std::pair<" + t + "," + t + ">";
|
627
|
-
str += pair + "(" + kv.join(",") + ")";
|
628
|
-
|
629
|
-
str += ", ";
|
630
|
-
}
|
631
|
-
str = str.replace(/, $/, "}" + ") , /* end of map */"); //";
|
632
|
-
} else if (array.length === undefined) {
|
633
|
-
array = ["", array];
|
634
|
-
set_kv(array);
|
635
|
-
return array[1];
|
636
|
-
} else
|
637
|
-
for (var i of array) {
|
638
|
-
// if (a ==
|
639
|
-
if (typeof i != "number") {
|
640
|
-
if (typeof i == "object" && i.join === undefined) {
|
641
|
-
str += mod(i, a);
|
642
|
-
} else if (typeof i == "string") {
|
643
|
-
const SEPARATOR = ",";
|
644
|
-
str +=
|
645
|
-
"construct(" + JSON.stringify(i) + ") /* string literal */" + SEPARATOR;
|
646
|
-
} else {
|
647
|
-
str +=
|
648
|
-
"\t".repeat(a) +
|
649
|
-
"construct(" +
|
650
|
-
"Array" +
|
651
|
-
"{" +
|
652
|
-
"\n" +
|
653
|
-
"\t".repeat(a) +
|
654
|
-
mod(i, a) +
|
655
|
-
"\t".repeat(a - 1) +
|
656
|
-
"}" +
|
657
|
-
")" +
|
658
|
-
",\n";
|
659
|
-
}
|
660
|
-
} else {
|
661
|
-
const value = ["", i];
|
662
|
-
set_kv(value);
|
663
|
-
str += value[1] + ", ";
|
664
|
-
}
|
665
|
-
}
|
666
|
-
|
667
|
-
if (a == 1) str += "}";
|
668
|
-
//str = str.slice(0, s
|
669
|
-
|
670
|
-
return str.replace(/, $/, "");
|
671
|
-
} catch (e) {
|
672
|
-
console.warn(e);
|
673
|
-
process.exit(1);
|
674
|
-
}
|
675
|
-
}
|
676
|
-
|
677
|
-
//#include <iostream>
|
678
|
-
|
679
|
-
function additional_cpp_code() {
|
680
|
-
return `
|
681
|
-
#include \"fcgio.h\"
|
682
|
-
using namespace std;
|
683
|
-
#define endl "<br />"
|
684
|
-
static inline void* ${prog_name}_main ();
|
685
|
-
static int mmain();
|
686
|
-
|
687
|
-
int
|
688
|
-
main_
|
689
|
-
(
|
690
|
-
int argc, char** argv, char** envp)
|
691
|
-
{
|
692
|
-
(void)envp;
|
693
|
-
Array args{};
|
694
|
-
for (int i = 0; i < argc; ++i)
|
695
|
-
args << construct(argv[i]);
|
696
|
-
//auto content = (string)args.html("Title"); //cout << c
|
697
|
-
auto content=std::string{};
|
698
|
-
cout << Array{construct(1ll)}.html("Hello");
|
699
|
-
//cout << content;
|
700
|
-
|
701
|
-
|
702
|
-
const auto server=0;
|
703
|
-
|
704
|
-
if (server) {
|
705
|
-
// Backup the stdio streambufs
|
706
|
-
streambuf * cin_streambuf = cin.rdbuf();
|
707
|
-
streambuf * cout_streambuf = cout.rdbuf();
|
708
|
-
streambuf * cerr_streambuf = cerr.rdbuf();
|
709
|
-
|
710
|
-
FCGX_Request request;
|
711
|
-
|
712
|
-
FCGX_Init();
|
713
|
-
/*
|
714
|
-
*
|
715
|
-
*
|
716
|
-
*
|
717
|
-
* The above function seems to memory leak 1 block of 768 bytes. It never deletes it at exit.
|
718
|
-
*
|
719
|
-
*
|
720
|
-
*
|
721
|
-
*/
|
722
|
-
FCGX_InitRequest(&request, 0, 0);
|
723
|
-
|
724
|
-
while (FCGX_Accept_r(&request) == 0) {
|
725
|
-
fcgi_streambuf cin_fcgi_streambuf(request.in);
|
726
|
-
fcgi_streambuf cout_fcgi_streambuf(request.out);
|
727
|
-
fcgi_streambuf cerr_fcgi_streambuf(request.err);
|
728
|
-
|
729
|
-
cin.rdbuf(&cin_fcgi_streambuf);
|
730
|
-
cout.rdbuf(&cout_fcgi_streambuf);
|
731
|
-
cerr.rdbuf(&cerr_fcgi_streambuf);
|
732
|
-
|
733
|
-
cout << content;
|
734
|
-
|
735
|
-
// system(\"echo 5 > /root/six\");
|
736
|
-
mmain();
|
737
|
-
cout << "Where?";
|
738
|
-
// system(\"echo 6\");
|
739
|
-
|
740
|
-
// Note: the fcgi_streambuf destructor will auto flush
|
741
|
-
}
|
742
|
-
|
743
|
-
// restore stdio streambufs
|
744
|
-
cin.rdbuf(cin_streambuf);
|
745
|
-
cout.rdbuf(cout_streambuf);
|
746
|
-
cerr.rdbuf(cerr_streambuf);
|
747
|
-
}
|
748
|
-
|
749
|
-
${prog_name}_main();
|
750
|
-
|
751
|
-
return 0;
|
752
|
-
}
|
753
|
-
|
754
|
-
|
755
|
-
static int mmain()
|
756
|
-
{
|
757
|
-
std::string command(\"ls * 2>&1\");
|
758
|
-
|
759
|
-
char buffer[4096];
|
760
|
-
std::string result;
|
761
|
-
|
762
|
-
// std::cout << "Opening reading pipe"
|
763
|
-
FILE* pipe = popen(command.c_str(), \"r\");
|
764
|
-
if (!pipe)
|
765
|
-
{
|
766
|
-
std::cerr << \"Couldn't start command.\" << endl;
|
767
|
-
return 0;
|
768
|
-
}
|
769
|
-
while (fgets(buffer, sizeof(buffer), pipe) != NULL) {
|
770
|
-
//std::cout << \"Reading...\" << std::endl;
|
771
|
-
result += buffer;
|
772
|
-
}
|
773
|
-
auto returnCode = pclose(pipe);
|
774
|
-
|
775
|
-
std::cout << result << endl;
|
776
|
-
std::cout << returnCode << endl;
|
777
|
-
|
778
|
-
// ${prog_name}_main();
|
779
|
-
|
780
|
-
${prog_name}_main ();
|
781
|
-
return 0;
|
782
|
-
}
|
783
|
-
`;
|
784
|
-
}
|