├── .gitattributes ├── .gitignore ├── LICENSE ├── README.md ├── clibalgserver.sln ├── clibalgserver ├── clibalgserver.cpp ├── clibalgserver.vcxproj ├── clibalgserver.vcxproj.filters ├── code │ ├── exe │ │ ├── append.cpp │ │ ├── bat.cpp │ │ ├── cat.cpp │ │ ├── cd.cpp │ │ ├── echo.cpp │ │ ├── env.cpp │ │ ├── grep.cpp │ │ ├── head.cpp │ │ ├── help.cpp │ │ ├── ll.cpp │ │ ├── loop.cpp │ │ ├── ls.cpp │ │ ├── mkdir.cpp │ │ ├── od.cpp │ │ ├── pipe.cpp │ │ ├── ps.cpp │ │ ├── pwd.cpp │ │ ├── range.cpp │ │ ├── rm.cpp │ │ ├── sleep.cpp │ │ ├── tail.cpp │ │ ├── time.cpp │ │ ├── touch.cpp │ │ ├── tree.cpp │ │ ├── uptime.cpp │ │ ├── wc.cpp │ │ ├── whoami.cpp │ │ └── write.cpp │ ├── include │ │ ├── exec.cpp │ │ ├── format.cpp │ │ ├── fs.cpp │ │ ├── intr.cpp │ │ ├── io.cpp │ │ ├── map.cpp │ │ ├── math.cpp │ │ ├── memory.cpp │ │ ├── proc.cpp │ │ ├── shell.cpp │ │ ├── string.cpp │ │ ├── sys.cpp │ │ ├── trace.cpp │ │ ├── vector.cpp │ │ ├── xtoa_atoi.cpp │ │ ├── xtoa_cached_powers.cpp │ │ ├── xtoa_dtoa.cpp │ │ ├── xtoa_itoa.cpp │ │ └── xtoa_lut.cpp │ └── sys │ │ └── entry.cpp ├── event2 │ ├── buffer.h │ ├── buffer_compat.h │ ├── bufferevent.h │ ├── bufferevent_compat.h │ ├── bufferevent_ssl.h │ ├── bufferevent_struct.h │ ├── dns.h │ ├── dns_compat.h │ ├── dns_struct.h │ ├── event-config.h │ ├── event.h │ ├── event_compat.h │ ├── event_struct.h │ ├── http.h │ ├── http_compat.h │ ├── http_struct.h │ ├── keyvalq_struct.h │ ├── listener.h │ ├── rpc.h │ ├── rpc_compat.h │ ├── rpc_struct.h │ ├── tag.h │ ├── tag_compat.h │ ├── thread.h │ └── util.h ├── lib │ ├── libevent.lib │ ├── libevent_core.lib │ └── libevent_extras.lib ├── mime.cpp ├── mime.h ├── rapidjson │ ├── allocators.h │ ├── document.h │ ├── encodedstream.h │ ├── encodings.h │ ├── error │ │ ├── en.h │ │ └── error.h │ ├── filereadstream.h │ ├── filewritestream.h │ ├── fwd.h │ ├── internal │ │ ├── biginteger.h │ │ ├── diyfp.h │ │ ├── dtoa.h │ │ ├── ieee754.h │ │ ├── itoa.h │ │ ├── meta.h │ │ ├── pow10.h │ │ ├── regex.h │ │ ├── stack.h │ │ ├── strfunc.h │ │ ├── strtod.h │ │ └── swap.h │ ├── istreamwrapper.h │ ├── memorybuffer.h │ ├── memorystream.h │ ├── msinttypes │ │ ├── inttypes.h │ │ └── stdint.h │ ├── ostreamwrapper.h │ ├── pointer.h │ ├── prettywriter.h │ ├── rapidjson.h │ ├── reader.h │ ├── schema.h │ ├── stream.h │ ├── stringbuffer.h │ └── writer.h ├── server │ ├── ace │ │ ├── ace.js │ │ ├── ext-beautify.js │ │ ├── ext-elastic_tabstops_lite.js │ │ ├── ext-emmet.js │ │ ├── ext-error_marker.js │ │ ├── ext-keybinding_menu.js │ │ ├── ext-language_tools.js │ │ ├── ext-linking.js │ │ ├── ext-modelist.js │ │ ├── ext-options.js │ │ ├── ext-prompt.js │ │ ├── ext-rtl.js │ │ ├── ext-searchbox.js │ │ ├── ext-settings_menu.js │ │ ├── ext-spellcheck.js │ │ ├── ext-split.js │ │ ├── ext-static_highlight.js │ │ ├── ext-statusbar.js │ │ ├── ext-textarea.js │ │ ├── ext-themelist.js │ │ ├── ext-whitespace.js │ │ ├── keybinding-emacs.js │ │ ├── keybinding-sublime.js │ │ ├── keybinding-vim.js │ │ ├── mode-c_cpp.js │ │ ├── snippets │ │ │ ├── c_cpp.js │ │ │ └── text.js │ │ └── theme-chrome.js │ ├── alg.html │ ├── css │ │ ├── Chart.min.css │ │ └── layx.min.css │ ├── example │ │ ├── backtrace │ │ │ └── n-queen.cpp │ │ ├── dp │ │ │ ├── edit.cpp │ │ │ └── lcs.cpp │ │ ├── graph │ │ │ ├── bfs.cpp │ │ │ ├── dfs.cpp │ │ │ ├── dijkstra.cpp │ │ │ └── mst_prim.cpp │ │ ├── sort │ │ │ ├── bubble.cpp │ │ │ ├── insert.cpp │ │ │ ├── merge.cpp │ │ │ ├── quick.cpp │ │ │ ├── selection.cpp │ │ │ └── shell.cpp │ │ ├── test.cpp │ │ ├── test_1d.cpp │ │ ├── test_2d.cpp │ │ └── test_var.cpp │ ├── favicon.ico │ ├── index.html │ ├── js │ │ ├── Chart.min.js │ │ ├── alg.js │ │ ├── chartjs-plugin-datalabels.js │ │ ├── eventbus.js │ │ ├── go.js │ │ ├── jquery.min.js │ │ ├── layx.min.js │ │ └── vue.min.js │ └── layui │ │ ├── css │ │ ├── layui.css │ │ ├── layui.mobile.css │ │ └── modules │ │ │ ├── code.css │ │ │ ├── laydate │ │ │ └── default │ │ │ │ └── laydate.css │ │ │ └── layer │ │ │ └── default │ │ │ ├── icon-ext.png │ │ │ ├── icon.png │ │ │ ├── layer.css │ │ │ ├── loading-0.gif │ │ │ ├── loading-1.gif │ │ │ └── loading-2.gif │ │ ├── font │ │ ├── iconfont.eot │ │ ├── iconfont.svg │ │ ├── iconfont.ttf │ │ ├── iconfont.woff │ │ └── iconfont.woff2 │ │ ├── images │ │ └── face │ │ │ ├── 0.gif │ │ │ ├── 1.gif │ │ │ ├── 10.gif │ │ │ ├── 11.gif │ │ │ ├── 12.gif │ │ │ ├── 13.gif │ │ │ ├── 14.gif │ │ │ ├── 15.gif │ │ │ ├── 16.gif │ │ │ ├── 17.gif │ │ │ ├── 18.gif │ │ │ ├── 19.gif │ │ │ ├── 2.gif │ │ │ ├── 20.gif │ │ │ ├── 21.gif │ │ │ ├── 22.gif │ │ │ ├── 23.gif │ │ │ ├── 24.gif │ │ │ ├── 25.gif │ │ │ ├── 26.gif │ │ │ ├── 27.gif │ │ │ ├── 28.gif │ │ │ ├── 29.gif │ │ │ ├── 3.gif │ │ │ ├── 30.gif │ │ │ ├── 31.gif │ │ │ ├── 32.gif │ │ │ ├── 33.gif │ │ │ ├── 34.gif │ │ │ ├── 35.gif │ │ │ ├── 36.gif │ │ │ ├── 37.gif │ │ │ ├── 38.gif │ │ │ ├── 39.gif │ │ │ ├── 4.gif │ │ │ ├── 40.gif │ │ │ ├── 41.gif │ │ │ ├── 42.gif │ │ │ ├── 43.gif │ │ │ ├── 44.gif │ │ │ ├── 45.gif │ │ │ ├── 46.gif │ │ │ ├── 47.gif │ │ │ ├── 48.gif │ │ │ ├── 49.gif │ │ │ ├── 5.gif │ │ │ ├── 50.gif │ │ │ ├── 51.gif │ │ │ ├── 52.gif │ │ │ ├── 53.gif │ │ │ ├── 54.gif │ │ │ ├── 55.gif │ │ │ ├── 56.gif │ │ │ ├── 57.gif │ │ │ ├── 58.gif │ │ │ ├── 59.gif │ │ │ ├── 6.gif │ │ │ ├── 60.gif │ │ │ ├── 61.gif │ │ │ ├── 62.gif │ │ │ ├── 63.gif │ │ │ ├── 64.gif │ │ │ ├── 65.gif │ │ │ ├── 66.gif │ │ │ ├── 67.gif │ │ │ ├── 68.gif │ │ │ ├── 69.gif │ │ │ ├── 7.gif │ │ │ ├── 70.gif │ │ │ ├── 71.gif │ │ │ ├── 8.gif │ │ │ └── 9.gif │ │ ├── lay │ │ └── modules │ │ │ ├── carousel.js │ │ │ ├── code.js │ │ │ ├── colorpicker.js │ │ │ ├── element.js │ │ │ ├── flow.js │ │ │ ├── form.js │ │ │ ├── jquery.js │ │ │ ├── laydate.js │ │ │ ├── layedit.js │ │ │ ├── layer.js │ │ │ ├── laypage.js │ │ │ ├── laytpl.js │ │ │ ├── mobile.js │ │ │ ├── rate.js │ │ │ ├── slider.js │ │ │ ├── table.js │ │ │ ├── transfer.js │ │ │ ├── tree.js │ │ │ ├── upload.js │ │ │ └── util.js │ │ ├── layui.all.js │ │ └── layui.js ├── stdafx.cpp └── stdafx.h ├── cparser ├── base │ ├── defines.h │ └── parser2d │ │ ├── cast.cpp │ │ ├── cast.h │ │ ├── cexception.cpp │ │ ├── cexception.h │ │ ├── cgen.cpp │ │ ├── cgen.h │ │ ├── cgui.cpp │ │ ├── cgui.h │ │ ├── clexer.cpp │ │ ├── clexer.h │ │ ├── cmem.cpp │ │ ├── cmem.h │ │ ├── cnet.cpp │ │ ├── cnet.h │ │ ├── cparser.cpp │ │ ├── cparser.h │ │ ├── crev.cpp │ │ ├── crev.h │ │ ├── cunit.cpp │ │ ├── cunit.h │ │ ├── cvfs.cpp │ │ ├── cvfs.h │ │ ├── cvm.cpp │ │ ├── cvm.h │ │ ├── memory.h │ │ ├── types.cpp │ │ └── types.h ├── cparser.vcxproj ├── cparser.vcxproj.filters ├── dllmain.cpp ├── framework.h ├── parser.cpp ├── parser.h ├── stdafx.cpp └── stdafx.h └── screenshots ├── 1.gif ├── 1.png ├── 2.png ├── 3.png ├── 4.png ├── 5.png └── 6.png /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 An Chen 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # clibalgserver 2 | 3 | [![Build status](https://ci.appveyor.com/api/projects/status/lxmhwmad1m7s5gic?svg=true)](https://ci.appveyor.com/project/bajdcc/clibalgserver) 4 | 5 | [代码打包下载](https://ci.appveyor.com/project/bajdcc/clibalgserver/build/artifacts) 6 | 7 | [linux编译版本](https://github.com/bajdcc/clibalgserver_mac) 8 | 9 | 参见:[【算法可视化计划】启程](https://zhuanlan.zhihu.com/p/83573660) 10 | 11 | 实现一个算法可视化网站。 12 | 13 | 代码:C++。 14 | 15 | ## 介绍 16 | 17 | 算法用C语言实现,通过后端处理将C代码编译成可视化步骤。 18 | 19 | ## 前端技术栈 20 | 21 | - jQuery 22 | - LayUI 23 | - layx 24 | - Vue 25 | - Ace editor 26 | - eventbus 27 | - Chartjs 28 | - Gojs 29 | 30 | ## 调试接口 31 | 32 | ```cpp 33 | // 控制台输出 34 | void trace_log(char* text); 35 | // 追踪单个变量 36 | void trace_var(char* name, void* arr, int type); 37 | // 追踪一维数组 38 | void trace_array_1d(char* name, void* arr, int type, int cols); 39 | // 追踪二维数组 40 | void trace_array_2d(char* name, void* arr, int type, int rows, int cols); 41 | // 取消追踪 42 | void trace_end(char* name); 43 | // 设置原子操作 44 | void trace_rapid(int flag); 45 | // 追踪一维数组图表 46 | void trace_array_1d_chart(char* name, void* arr, int type, int cols); 47 | // 追踪图(邻接矩阵) 48 | void trace_graph(char* name, void* id, void* adj, int inf, int type, int n); 49 | // 等待 50 | void trace_delay(int flag); 51 | ``` 52 | 53 | ## 知乎文章列表 54 | 55 | - [​【算法可视化计划】启程](https://zhuanlan.zhihu.com/p/83573660) 56 | - [​【算法可视化计划】虚拟系统](https://zhuanlan.zhihu.com/p/83863115) 57 | - [【算法可视化计划】变量跟踪](https://zhuanlan.zhihu.com/p/84017677) 58 | - [【算法可视化计划】图表呈现](https://zhuanlan.zhihu.com/p/84395451) 59 | 60 | ## 截图 61 | 62 | ![main](https://raw.githubusercontent.com/bajdcc/clibalgserver/master/screenshots/1.gif) 63 | 64 | ![main](https://raw.githubusercontent.com/bajdcc/clibalgserver/master/screenshots/1.png) 65 | 66 | ![main](https://raw.githubusercontent.com/bajdcc/clibalgserver/master/screenshots/2.png) 67 | 68 | ![main](https://raw.githubusercontent.com/bajdcc/clibalgserver/master/screenshots/3.png) 69 | 70 | ![main](https://raw.githubusercontent.com/bajdcc/clibalgserver/master/screenshots/4.png) 71 | 72 | ![main](https://raw.githubusercontent.com/bajdcc/clibalgserver/master/screenshots/5.png) 73 | 74 | ![main](https://raw.githubusercontent.com/bajdcc/clibalgserver/master/screenshots/6.png) -------------------------------------------------------------------------------- /clibalgserver.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.29215.179 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "clibalgserver", "clibalgserver\clibalgserver.vcxproj", "{1FBE3BB0-D321-4979-AE7C-256268F7699F}" 7 | ProjectSection(ProjectDependencies) = postProject 8 | {058D6383-4E04-4803-966F-43E19996A828} = {058D6383-4E04-4803-966F-43E19996A828} 9 | EndProjectSection 10 | EndProject 11 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cparser", "cparser\cparser.vcxproj", "{058D6383-4E04-4803-966F-43E19996A828}" 12 | EndProject 13 | Global 14 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 15 | Debug|x64 = Debug|x64 16 | Debug|x86 = Debug|x86 17 | Release|x64 = Release|x64 18 | Release|x86 = Release|x86 19 | EndGlobalSection 20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 21 | {1FBE3BB0-D321-4979-AE7C-256268F7699F}.Debug|x64.ActiveCfg = Debug|x64 22 | {1FBE3BB0-D321-4979-AE7C-256268F7699F}.Debug|x64.Build.0 = Debug|x64 23 | {1FBE3BB0-D321-4979-AE7C-256268F7699F}.Debug|x86.ActiveCfg = Debug|Win32 24 | {1FBE3BB0-D321-4979-AE7C-256268F7699F}.Debug|x86.Build.0 = Debug|Win32 25 | {1FBE3BB0-D321-4979-AE7C-256268F7699F}.Release|x64.ActiveCfg = Release|x64 26 | {1FBE3BB0-D321-4979-AE7C-256268F7699F}.Release|x64.Build.0 = Release|x64 27 | {1FBE3BB0-D321-4979-AE7C-256268F7699F}.Release|x86.ActiveCfg = Release|Win32 28 | {1FBE3BB0-D321-4979-AE7C-256268F7699F}.Release|x86.Build.0 = Release|Win32 29 | {058D6383-4E04-4803-966F-43E19996A828}.Debug|x64.ActiveCfg = Debug|x64 30 | {058D6383-4E04-4803-966F-43E19996A828}.Debug|x64.Build.0 = Debug|x64 31 | {058D6383-4E04-4803-966F-43E19996A828}.Debug|x86.ActiveCfg = Debug|Win32 32 | {058D6383-4E04-4803-966F-43E19996A828}.Debug|x86.Build.0 = Debug|Win32 33 | {058D6383-4E04-4803-966F-43E19996A828}.Release|x64.ActiveCfg = Release|x64 34 | {058D6383-4E04-4803-966F-43E19996A828}.Release|x64.Build.0 = Release|x64 35 | {058D6383-4E04-4803-966F-43E19996A828}.Release|x86.ActiveCfg = Release|Win32 36 | {058D6383-4E04-4803-966F-43E19996A828}.Release|x86.Build.0 = Release|Win32 37 | EndGlobalSection 38 | GlobalSection(SolutionProperties) = preSolution 39 | HideSolutionNode = FALSE 40 | EndGlobalSection 41 | GlobalSection(ExtensibilityGlobals) = postSolution 42 | SolutionGuid = {F822CCEF-51C0-4E3D-939D-1FDF22DB8721} 43 | EndGlobalSection 44 | EndGlobal 45 | -------------------------------------------------------------------------------- /clibalgserver/code/exe/append.cpp: -------------------------------------------------------------------------------- 1 | #include "/include/io" 2 | #include "/include/fs" 3 | #include "/include/string" 4 | #include "/include/memory" 5 | int write_file(int handle) { 6 | int c, r; 7 | int state = input_lock(); 8 | while ((c = input_valid()) != -1) { 9 | r = write(handle, (char) input_char()); 10 | if (r < 0) { 11 | switch (r) { 12 | case -1: 13 | set_fg(240, 0, 0); 14 | put_string("[ERROR] File not exists."); 15 | restore_fg(); 16 | break; 17 | case -2: 18 | set_fg(240, 0, 0); 19 | put_string("[ERROR] Forbidden."); 20 | restore_fg(); 21 | break; 22 | case -3: 23 | set_fg(240, 0, 0); 24 | put_string("[ERROR] Invalid handle."); 25 | restore_fg(); 26 | break; 27 | } 28 | break; 29 | } 30 | } 31 | input_unlock(); 32 | close(handle); 33 | } 34 | char *trim(char *text) { 35 | while (*text == ' ') 36 | text++; 37 | return text; 38 | }; 39 | int main(int argc, char **argv) { 40 | if (argc > 1) { 41 | char *path = malloc(256); 42 | char *p = path; 43 | *p = '\0'; 44 | int i; 45 | for (i = 1; i < argc; ++i) { 46 | strcat(p, argv[i]); 47 | } 48 | char *name = trim(path); 49 | touch(name); 50 | int handle = open(name); 51 | free((int) path); 52 | switch (handle) { 53 | default: 54 | // put_string("[INFO] Success."); 55 | write_file(handle); 56 | break; 57 | case -1: 58 | set_fg(240, 0, 0); 59 | put_string("[ERROR] File not exists."); 60 | restore_fg(); 61 | break; 62 | case -2: 63 | set_fg(240, 0, 0); 64 | put_string("[ERROR] Path is not file."); 65 | restore_fg(); 66 | break; 67 | case -3: 68 | set_fg(240, 0, 0); 69 | put_string("[ERROR] File is locked."); 70 | restore_fg(); 71 | break; 72 | } 73 | } 74 | return 0; 75 | } -------------------------------------------------------------------------------- /clibalgserver/code/exe/bat.cpp: -------------------------------------------------------------------------------- 1 | #include "/include/io" 2 | #include "/include/memory" 3 | #include "/include/shell" 4 | #include "/include/string" 5 | #include "/include/xtoa_atoi" 6 | #include "/include/shell" 7 | struct string { 8 | char *text; 9 | int capacity; 10 | int length; 11 | }; 12 | string new_string() { 13 | string s; 14 | s.text = malloc(16); 15 | s.capacity = 16; 16 | s.length = 0; 17 | return s; 18 | } 19 | struct node { 20 | string text; 21 | node *prev; 22 | node *next; 23 | }; 24 | void push(node **head, string s) { 25 | node *new_node = (node *) malloc(sizeof(node)); 26 | new_node->text = s; 27 | new_node->prev = 0; 28 | new_node->next = *head; 29 | if (new_node->next) 30 | new_node->next->prev = new_node; 31 | *head = new_node; 32 | } 33 | void append_char(string *s, char c) { 34 | if (s->length >= s->capacity - 1) { 35 | s->capacity <<= 1; 36 | char *new_text = malloc(s->capacity); 37 | strcpy(new_text, s->text); 38 | free(s->text); 39 | s->text = new_text; 40 | } 41 | (s->text)[s->length++] = c; 42 | (s->text)[s->length] = 0; 43 | } 44 | void run(node *list) { 45 | node *prev = list; 46 | while (list) { 47 | prev = list; 48 | list = list->next; 49 | } 50 | while (prev) { 51 | shell((prev->text).text); 52 | newline(); 53 | prev = prev->prev; 54 | } 55 | } 56 | void bat() { 57 | int c, cmd = 0; 58 | node *list = (node *) 0; 59 | string s = new_string(); 60 | input_lock(); 61 | while ((c = input_valid()) != -1) { 62 | c = input_char(); 63 | if (((char)c) == '\033') { 64 | cmd = 1 - cmd; 65 | } 66 | else if (cmd == 0) { 67 | if (((char)c) == '\n') { 68 | push(&list, s); 69 | s = new_string(); 70 | } 71 | else { 72 | append_char(&s, c); 73 | } 74 | } 75 | else { 76 | append_char(&s, c); 77 | } 78 | } 79 | input_unlock(); 80 | if (s.length > 0) 81 | push(&list, s); 82 | run(list); 83 | } 84 | int main(int argc, char** argv) { 85 | bat(); 86 | return 0; 87 | } -------------------------------------------------------------------------------- /clibalgserver/code/exe/cat.cpp: -------------------------------------------------------------------------------- 1 | #include "/include/io" 2 | #include "/include/fs" 3 | int read_file(int handle) { 4 | int c; 5 | while (c = read(handle), c < 0x1000) { 6 | put_char(c); 7 | } 8 | switch (c) { 9 | case 0x2000: 10 | // put_string("[INFO] Read to the end."); 11 | break; 12 | case 0x2001: 13 | set_fg(240, 0, 0); 14 | put_string("[ERROR] Read error."); 15 | restore_fg(); 16 | break; 17 | } 18 | close(handle); 19 | } 20 | int main(int argc, char **argv) { 21 | if (argc > 1) { 22 | int handle = open(argv[1]); 23 | switch (handle) { 24 | default: 25 | // put_string("[INFO] Success."); 26 | read_file(handle); 27 | break; 28 | case -1: 29 | set_fg(240, 0, 0); 30 | put_string("[ERROR] File not exists."); 31 | restore_fg(); 32 | break; 33 | case -2: 34 | set_fg(240, 0, 0); 35 | put_string("[ERROR] Path is not file."); 36 | restore_fg(); 37 | break; 38 | case -3: 39 | set_fg(240, 0, 0); 40 | put_string("[ERROR] File is locked."); 41 | restore_fg(); 42 | break; 43 | } 44 | } 45 | return 0; 46 | } -------------------------------------------------------------------------------- /clibalgserver/code/exe/cd.cpp: -------------------------------------------------------------------------------- 1 | #include "/include/io" 2 | #include "/include/fs" 3 | #include "/include/memory" 4 | int main(int argc, char **argv) { 5 | if (argc > 1) { 6 | switch (cd(argv[1])) { 7 | case 0: 8 | // put_string("[INFO] Success."); 9 | break; 10 | case -1: 11 | set_fg(240, 0, 0); 12 | put_string("[ERROR] Path not exists."); 13 | restore_fg(); 14 | break; 15 | case -2: 16 | set_fg(240, 0, 0); 17 | put_string("[ERROR] Path is not directory."); 18 | restore_fg(); 19 | break; 20 | } 21 | } 22 | return 0; 23 | } -------------------------------------------------------------------------------- /clibalgserver/code/exe/echo.cpp: -------------------------------------------------------------------------------- 1 | #include "/include/io" 2 | int main(int argc, char **argv) { 3 | int i; 4 | for (i = 1; i < argc; ++i) { 5 | put_string(argv[i]); 6 | if (i < argc - 1) 7 | put_string(" "); 8 | } 9 | return 0; 10 | } -------------------------------------------------------------------------------- /clibalgserver/code/exe/env.cpp: -------------------------------------------------------------------------------- 1 | #include "/include/shell" 2 | #include "/include/proc" 3 | #include "/include/xtoa_itoa" 4 | #include "/include/string" 5 | int main(int argc, char** argv) { 6 | int pid = get_pid(); 7 | char* pids = malloc(32); 8 | i32toa(pid, pids); 9 | char* cmd = malloc(256); 10 | strcpy(cmd, "cat /proc/"); 11 | strcat(cmd, pids); 12 | strcat(cmd, "/path"); 13 | shell(cmd); 14 | return 0; 15 | } -------------------------------------------------------------------------------- /clibalgserver/code/exe/grep.cpp: -------------------------------------------------------------------------------- 1 | #include "/include/io" 2 | #include "/include/memory" 3 | #include "/include/string" 4 | struct string { 5 | char *text; 6 | int capacity; 7 | int length; 8 | }; 9 | string new_string() { 10 | string s; 11 | s.text = malloc(16); 12 | s.capacity = 16; 13 | s.length = 0; 14 | return s; 15 | } 16 | void append_char(string *s, char c) { 17 | if (s->length >= s->capacity - 1) { 18 | s->capacity <<= 1; 19 | char *new_text = malloc(s->capacity); 20 | strcpy(new_text, s->text); 21 | free(s->text); 22 | s->text = new_text; 23 | } 24 | (s->text)[s->length++] = c; 25 | (s->text)[s->length] = 0; 26 | } 27 | // KMP 28 | int *build_next(char *rep) { 29 | int len = strlen(rep), i, u = 0, v = -1; 30 | int *arr = malloc(len * sizeof(int)); 31 | for (i = 0; i < len; ++i) { 32 | arr[i] = -1; 33 | } 34 | while (u < len - 1) { 35 | if (v == -1 || (rep[u] == rep[v])) { 36 | u++; 37 | v++; 38 | arr[u] = v; 39 | } else { 40 | v = arr[v]; 41 | } 42 | } 43 | return arr; 44 | } 45 | int match(char *str, int slen, char *rep, int len, int *arr) { 46 | int i = 0, j = 0, slen = strlen(str); 47 | while (i < slen && j < len) { 48 | if (j == -1 || (str[i] == rep[j])) { 49 | i++; j++; 50 | } else { 51 | j = arr[j]; 52 | } 53 | } 54 | if (j == len) { 55 | return i - j; 56 | } 57 | return -1; 58 | } 59 | void grep(char *rep) { 60 | int c, cmd = 0; 61 | string s = new_string(); 62 | string s2 = new_string(); 63 | int *arr = build_next(rep), len = strlen(rep); 64 | input_lock(); 65 | while ((c = input_valid()) != -1) { 66 | c = input_char(); 67 | if (((char) c) == '\033') { 68 | append_char(&s, c); 69 | cmd = 1 - cmd; 70 | } else if (cmd == 0) { 71 | if (((char) c) == '\n') { 72 | if (match(s2.text, s2.length, rep, len, arr) != -1) { 73 | put_string(s.text); 74 | put_string("\n"); 75 | } else { 76 | free(s.text); 77 | } 78 | free(s2.text); 79 | s = new_string(); 80 | s2 = new_string(); 81 | } else { 82 | append_char(&s2, c); 83 | append_char(&s, c); 84 | } 85 | } else { 86 | append_char(&s, c); 87 | } 88 | } 89 | input_unlock(); 90 | } 91 | int main(int argc, char **argv) { 92 | char *cmd = malloc(1024); 93 | int i; 94 | for (i = 1; i < argc; ++i) { 95 | strcat(cmd, argv[i]); 96 | if (i < argc - 1) 97 | strcat(cmd, " "); 98 | } 99 | grep(cmd); 100 | return 0; 101 | } -------------------------------------------------------------------------------- /clibalgserver/code/exe/head.cpp: -------------------------------------------------------------------------------- 1 | #include "/include/io" 2 | #include "/include/fs" 3 | #include "/include/memory" 4 | #include "/include/shell" 5 | #include "/include/string" 6 | #include "/include/xtoa_atoi" 7 | struct string { 8 | char *text; 9 | int capacity; 10 | int length; 11 | }; 12 | string new_string() { 13 | string s; 14 | s.text = malloc(16); 15 | s.capacity = 16; 16 | s.length = 0; 17 | return s; 18 | } 19 | struct node { 20 | string text; 21 | node *prev; 22 | node *next; 23 | }; 24 | void push(node **head, string s) { 25 | node *new_node = (node *) malloc(sizeof(node)); 26 | new_node->text = s; 27 | new_node->prev = 0; 28 | new_node->next = *head; 29 | if (new_node->next) 30 | new_node->next->prev = new_node; 31 | *head = new_node; 32 | } 33 | void append_char(string *s, char c) { 34 | if (s->length >= s->capacity - 1) { 35 | s->capacity <<= 1; 36 | char *new_text = malloc(s->capacity); 37 | strcpy(new_text, s->text); 38 | free(s->text); 39 | s->text = new_text; 40 | } 41 | (s->text)[s->length++] = c; 42 | (s->text)[s->length] = 0; 43 | } 44 | void print(node *list) { 45 | node *prev = list; 46 | while (list) { 47 | prev = list; 48 | list = list->next; 49 | } 50 | while (prev) { 51 | put_string((prev->text).text); 52 | put_string("\n"); 53 | prev = prev->prev; 54 | } 55 | } 56 | void head(int n) { 57 | int c, i = 0, cmd = 0; 58 | node *list = (node *) 0; 59 | string s = new_string(); 60 | input_lock(); 61 | while ((c = input_valid()) != -1) { 62 | c = input_char(); 63 | if (i < n) { 64 | if (((char) c) == '\033') { 65 | append_char(&s, c); 66 | cmd = 1 - cmd; 67 | } else if (cmd == 0) { 68 | if (((char) c) == '\n') { 69 | push(&list, s); 70 | s = new_string(); 71 | ++i; 72 | } else { 73 | append_char(&s, c); 74 | } 75 | } else { 76 | append_char(&s, c); 77 | } 78 | } 79 | } 80 | input_unlock(); 81 | print(list); 82 | } 83 | int main(int argc, char **argv) { 84 | if (argc == 1) { // head 85 | shell("pipe"); 86 | } else if (argc == 2) { // head XX 87 | int n = atoi32(argv[1]); 88 | if (n <= 0) 89 | return 1; 90 | head(n); 91 | } else { 92 | set_fg(240, 0, 0); 93 | put_string("[Error] Invalid argument."); 94 | restore_fg(); 95 | } 96 | return 0; 97 | } -------------------------------------------------------------------------------- /clibalgserver/code/exe/help.cpp: -------------------------------------------------------------------------------- 1 | #include "/include/io" 2 | int main(int argc, char **argv) { 3 | set_fg(240, 200, 220); 4 | put_string("Commands:\n"); 5 | put_string("\nSHELL\n"); 6 | put_string(" history - show command history\n"); 7 | put_string("\nDIR ==> /bin\n"); 8 | put_string(" help - command help\n"); 9 | put_string(" sh - shell\n"); 10 | put_string(" echo - echo\n"); 11 | put_string(" pipe - pipe test\n"); 12 | put_string(" whoami - show user name\n"); 13 | put_string(" cd - change dir\n"); 14 | put_string(" mkdir - create dir\n"); 15 | put_string(" pwd - show current dir\n"); 16 | put_string(" touch - touch file\n"); 17 | put_string(" ls - list file\n"); 18 | put_string(" ll - list file(detailed)\n"); 19 | put_string(" tree - list file(tree)\n"); 20 | put_string(" cat - show file content\n"); 21 | put_string(" rm - delete file\n"); 22 | put_string(" write - write to file\n"); 23 | put_string(" append - append to file\n"); 24 | put_string(" wc - word count\n"); 25 | put_string(" od - show binary content\n"); 26 | put_string(" head - show head content\n"); 27 | put_string(" tail - show tail content\n"); 28 | put_string(" ps - show process information\n"); 29 | put_string("\nDIR ==> /usr\n"); 30 | put_string(" test - test all cases\n"); 31 | put_string(" test_rec - test recursion\n"); 32 | put_string(" test_fork - test fork\n"); 33 | put_string(" test_input - test ui input\n"); 34 | put_string(" test_resize - test resize screen\n"); 35 | put_string(" test_malloc - test malloc and free\n"); 36 | put_string(" test_struct - test struct and linked list\n"); 37 | put_string(" test_xtoa - test itoa/dtoa/atoi\n"); 38 | put_string(" test_vector - test vector\n"); 39 | put_string(" draw - test draw function\n"); 40 | put_string(" badapple - test badapple animation\n"); 41 | restore_fg(); 42 | return 0; 43 | } -------------------------------------------------------------------------------- /clibalgserver/code/exe/ll.cpp: -------------------------------------------------------------------------------- 1 | #include "/include/io" 2 | #include "/include/fs" 3 | #include "/include/memory" 4 | #include "/include/shell" 5 | #include "/include/string" 6 | int main(int argc, char **argv) { 7 | if (argc == 1) { // ll 8 | shell("ls -l"); 9 | } else if (argc == 2) { // ll XX 10 | char *cmd = malloc(1024); 11 | strcpy(cmd, "ls -l "); 12 | strcat(cmd, argv[1]); 13 | shell(cmd); 14 | free((int) cmd); 15 | } else { 16 | set_fg(240, 0, 0); 17 | put_string("[Error] Invalid argument."); 18 | restore_fg(); 19 | } 20 | return 0; 21 | } -------------------------------------------------------------------------------- /clibalgserver/code/exe/loop.cpp: -------------------------------------------------------------------------------- 1 | #include "/include/shell" 2 | #include "/include/memory" 3 | #include "/include/proc" 4 | struct string { 5 | char* text; 6 | int capacity; 7 | int length; 8 | }; 9 | string new_string() { 10 | string s; 11 | s.text = malloc(16); 12 | s.capacity = 16; 13 | s.length = 0; 14 | return s; 15 | } 16 | void append_char(string* s, char c) { 17 | if (s->length >= s->capacity - 1) { 18 | s->capacity <<= 1; 19 | char* new_text = malloc(s->capacity); 20 | strcpy(new_text, s->text); 21 | free(s->text); 22 | s->text = new_text; 23 | } 24 | (s->text)[s->length++] = c; 25 | (s->text)[s->length] = 0; 26 | } 27 | int main(int argc, char **argv) { 28 | if (argc <= 1) { 29 | set_fg(240, 0, 0); 30 | put_string("[Error] Missing argument."); 31 | restore_fg(); 32 | return; 33 | } 34 | int i; 35 | string s = new_string(); 36 | for (i = 1; i < argc; ++i) { 37 | char* c = argv[i]; 38 | while (*c) 39 | append_char(&s, *c++); 40 | if (i < argc - 1) 41 | append_char(&s, ' '); 42 | } 43 | for (;;) { 44 | shell(s.text); 45 | sleep(500); 46 | } 47 | return 0; 48 | } -------------------------------------------------------------------------------- /clibalgserver/code/exe/ls.cpp: -------------------------------------------------------------------------------- 1 | #include "/include/io" 2 | #include "/include/fs" 3 | #include "/include/memory" 4 | #include "/include/shell" 5 | #include "/include/string" 6 | int main(int argc, char **argv) { 7 | char *s = malloc(1024); 8 | pwd(s); 9 | if (argc == 1) { // ls 10 | char *cmd = malloc(1024); 11 | strcpy(cmd, "cat "); 12 | strcat(cmd, s); 13 | strcat(cmd, ":ls"); 14 | shell(cmd); 15 | free((int) cmd); 16 | } else if (argc >= 2 && strcmp(argv[1], "-l") == 0) { // ls -l 17 | char *cmd = malloc(1024); 18 | strcpy(cmd, "cat "); 19 | if (argc > 2) 20 | strcat(cmd, argv[2]); 21 | else 22 | strcat(cmd, s); 23 | strcat(cmd, ":ll"); 24 | shell(cmd); 25 | free((int) cmd); 26 | } else if (argc >= 2 && strcmp(argv[1], "-tree") == 0) { // ls -tree 27 | char *cmd = malloc(1024); 28 | strcpy(cmd, "cat "); 29 | if (argc > 2) 30 | strcat(cmd, argv[2]); 31 | else 32 | strcat(cmd, s); 33 | strcat(cmd, ":tree"); 34 | shell(cmd); 35 | free((int) cmd); 36 | } else if (argc == 2) { 37 | char *cmd = malloc(1024); 38 | strcpy(cmd, "cat "); 39 | strcat(cmd, argv[1]); 40 | strcat(cmd, ":ls"); 41 | shell(cmd); 42 | free((int) cmd); 43 | } else { 44 | set_fg(240, 0, 0); 45 | put_string("[Error] Invalid argument."); 46 | restore_fg(); 47 | } 48 | free((int) s); 49 | return 0; 50 | } -------------------------------------------------------------------------------- /clibalgserver/code/exe/mkdir.cpp: -------------------------------------------------------------------------------- 1 | #include "/include/io" 2 | #include "/include/fs" 3 | #include "/include/memory" 4 | int main(int argc, char **argv) { 5 | if (argc > 1) { 6 | switch (mkdir(argv[1])) { 7 | case 0: 8 | // put_string("[INFO] Success."); 9 | break; 10 | case -1: 11 | set_fg(240, 0, 0); 12 | put_string("[ERROR] Directory already exists."); 13 | restore_fg(); 14 | break; 15 | case -2: 16 | set_fg(240, 0, 0); 17 | put_string("[ERROR] Path is invalid."); 18 | restore_fg(); 19 | break; 20 | case -3: 21 | set_fg(240, 0, 0); 22 | put_string("[ERROR] Forbidden."); 23 | restore_fg(); 24 | break; 25 | } 26 | } 27 | return 0; 28 | } -------------------------------------------------------------------------------- /clibalgserver/code/exe/od.cpp: -------------------------------------------------------------------------------- 1 | #include "/include/io" 2 | char *hex = "0123456789ABCDEF"; 3 | int pipe_x() { 4 | int c; 5 | input_lock(); 6 | while ((c = input_valid()) != -1) { 7 | c = input_char(); 8 | put_char(hex[c >> 4]); 9 | put_char(hex[c & 0xF]); 10 | } 11 | input_unlock(); 12 | return 0; 13 | } 14 | int main(int argc, char **argv) { 15 | pipe_x(); 16 | return 0; 17 | } -------------------------------------------------------------------------------- /clibalgserver/code/exe/pipe.cpp: -------------------------------------------------------------------------------- 1 | #include "/include/io" 2 | int pipe() { 3 | int c; 4 | input_lock(); 5 | while ((c = input_valid()) != -1) { 6 | put_char((char) input_char()); 7 | } 8 | input_unlock(); 9 | return 0; 10 | } 11 | int main(int argc, char **argv) { 12 | pipe(); 13 | return 0; 14 | } -------------------------------------------------------------------------------- /clibalgserver/code/exe/ps.cpp: -------------------------------------------------------------------------------- 1 | #include "/include/shell" 2 | int main(int argc, char **argv) { 3 | if (argc == 1) { // ps 4 | shell("cat /sys/ps"); 5 | } else { 6 | set_fg(240, 0, 0); 7 | put_string("[Error] Invalid argument."); 8 | restore_fg(); 9 | } 10 | return 0; 11 | } -------------------------------------------------------------------------------- /clibalgserver/code/exe/pwd.cpp: -------------------------------------------------------------------------------- 1 | #include "/include/io" 2 | #include "/include/fs" 3 | #include "/include/memory" 4 | int main(int argc, char **argv) { 5 | char *s = malloc(1024); 6 | pwd(s); 7 | put_string(s); 8 | free((int) s); 9 | return 0; 10 | } -------------------------------------------------------------------------------- /clibalgserver/code/exe/range.cpp: -------------------------------------------------------------------------------- 1 | #include "/include/io" 2 | #include "/include/xtoa_itoa" 3 | #include "/include/xtoa_atoi" 4 | int main(int argc, char **argv) { 5 | if (argc == 3) { 6 | long start = atoi64(argv[1]); 7 | long end = atoi64(argv[2]); 8 | long i; 9 | char text[128]; 10 | if (start > end) { 11 | for (i = start; i >= end; --i) { 12 | i64toa(i, (char *) &text); 13 | put_string((char *) &text); 14 | put_string("\n"); 15 | } 16 | } else { 17 | for (i = start; i <= end; ++i) { 18 | i64toa(i, (char *) &text); 19 | put_string((char *) &text); 20 | put_string("\n"); 21 | } 22 | } 23 | } else { 24 | set_fg(240, 0, 0); 25 | put_string("[Error] Invalid argument."); 26 | restore_fg(); 27 | } 28 | return 0; 29 | } -------------------------------------------------------------------------------- /clibalgserver/code/exe/rm.cpp: -------------------------------------------------------------------------------- 1 | #include "/include/io" 2 | #include "/include/fs" 3 | int main(int argc, char **argv) { 4 | if (argc == 1) { // rm 5 | set_fg(240, 0, 0); 6 | put_string("[Error] Need path."); 7 | restore_fg(); 8 | } else if (argc == 2) { // rm XX 9 | switch (rm(argv[1])) { 10 | case -1: 11 | set_fg(240, 0, 0); 12 | put_string("[ERROR] File not exists."); 13 | restore_fg(); 14 | break; 15 | case -2: 16 | set_fg(240, 0, 0); 17 | put_string("[ERROR] File is locked."); 18 | restore_fg(); 19 | break; 20 | case -3: 21 | set_fg(240, 0, 0); 22 | put_string("[ERROR] Delete failed."); 23 | restore_fg(); 24 | break; 25 | } 26 | } else { 27 | set_fg(240, 0, 0); 28 | put_string("[Error] Invalid argument."); 29 | restore_fg(); 30 | } 31 | return 0; 32 | } -------------------------------------------------------------------------------- /clibalgserver/code/exe/sleep.cpp: -------------------------------------------------------------------------------- 1 | #include "/include/proc" 2 | #include "/include/xtoa_atoi" 3 | #include "/include/string" 4 | #include "/include/io" 5 | int waiting(int second) { 6 | while (second > 0) { 7 | put_string("Waiting... "); 8 | put_int(second--); 9 | put_string("s"); 10 | put_string(" \r"); 11 | sleep(1000); 12 | } 13 | put_string("\n"); 14 | } 15 | int main(int argc, char **argv) { 16 | int i = 0, show = 0; 17 | if (argc > 1) { 18 | i = atoi32(argv[1]); 19 | } 20 | if (i == 0) { 21 | return 0; 22 | } 23 | if (argc > 2) { 24 | if (strcmp(argv[2], "show") == 0) { 25 | waiting(i); 26 | return 0; 27 | } 28 | } 29 | sleep(i * 1000); 30 | return 0; 31 | } -------------------------------------------------------------------------------- /clibalgserver/code/exe/tail.cpp: -------------------------------------------------------------------------------- 1 | #include "/include/io" 2 | #include "/include/fs" 3 | #include "/include/memory" 4 | #include "/include/shell" 5 | #include "/include/string" 6 | #include "/include/xtoa_atoi" 7 | struct string { 8 | char *text; 9 | int capacity; 10 | int length; 11 | }; 12 | string new_string() { 13 | string s; 14 | s.text = malloc(16); 15 | s.capacity = 16; 16 | s.length = 0; 17 | return s; 18 | } 19 | struct node { 20 | string text; 21 | node *prev; 22 | node *next; 23 | }; 24 | void destroy(node *tmp) { 25 | free(tmp->text.text); 26 | free(tmp); 27 | } 28 | void push(node **head, node **last, string s, int not_remove) { 29 | node *new_node = (node *) malloc(sizeof(node)); 30 | new_node->text = s; 31 | new_node->prev = 0; 32 | new_node->next = *head; 33 | if (new_node->next) 34 | new_node->next->prev = new_node; 35 | if (not_remove == 1) { 36 | if (!*last) 37 | *last = new_node; 38 | } else { 39 | node *tmp = *last; 40 | *last = (*last)->prev; 41 | (*last)->next = 0; 42 | destroy(tmp); 43 | } 44 | *head = new_node; 45 | } 46 | void append_char(string *s, char c) { 47 | if (s->length >= s->capacity - 1) { 48 | s->capacity <<= 1; 49 | char *new_text = malloc(s->capacity); 50 | strcpy(new_text, s->text); 51 | free(s->text); 52 | s->text = new_text; 53 | } 54 | (s->text)[s->length++] = c; 55 | (s->text)[s->length] = 0; 56 | } 57 | void print(node *last) { 58 | while (last) { 59 | put_string((last->text).text); 60 | put_string("\n"); 61 | last = last->prev; 62 | } 63 | } 64 | void tail(int n) { 65 | int c, i = 0, cmd = 0; 66 | node *list = (node *) 0; 67 | node *last = (node *) 0; 68 | string s = new_string(); 69 | input_lock(); 70 | while ((c = input_valid()) != -1) { 71 | c = input_char(); 72 | if (((char) c) == '\033') { 73 | append_char(&s, c); 74 | cmd = 1 - cmd; 75 | } else if (cmd == 0) { 76 | if (((char) c) == '\n') { 77 | push(&list, &last, s, i < n); 78 | s = new_string(); 79 | ++i; 80 | } else { 81 | append_char(&s, c); 82 | } 83 | } else { 84 | append_char(&s, c); 85 | } 86 | } 87 | input_unlock(); 88 | print(last); 89 | } 90 | int main(int argc, char **argv) { 91 | if (argc == 1) { // tail 92 | shell("pipe"); 93 | } else if (argc == 2) { // tail XX 94 | int n = atoi32(argv[1]); 95 | if (n <= 0) 96 | return 1; 97 | tail(n); 98 | } else { 99 | set_fg(240, 0, 0); 100 | put_string("[Error] Invalid argument."); 101 | restore_fg(); 102 | } 103 | return 0; 104 | } -------------------------------------------------------------------------------- /clibalgserver/code/exe/time.cpp: -------------------------------------------------------------------------------- 1 | #include "/include/shell" 2 | #include "/include/io" 3 | #include "/include/proc" 4 | int main(int argc, char **argv) { 5 | for (;;) { 6 | put_string("\r当前时间:"); 7 | shell("cat /sys/time"); 8 | sleep(100); 9 | } 10 | return 0; 11 | } -------------------------------------------------------------------------------- /clibalgserver/code/exe/touch.cpp: -------------------------------------------------------------------------------- 1 | #include "/include/io" 2 | #include "/include/fs" 3 | #include "/include/memory" 4 | int main(int argc, char **argv) { 5 | if (argc > 1) { 6 | switch (touch(argv[1])) { 7 | case 0: 8 | // put_string("[INFO] Success."); 9 | break; 10 | case -1: 11 | // put_string("[INFO] Created file."); 12 | break; 13 | case -2: 14 | set_fg(240, 0, 0); 15 | put_string("[ERROR] Path is not file/dir."); 16 | restore_fg(); 17 | break; 18 | case -3: 19 | set_fg(240, 0, 0); 20 | put_string("[ERROR] Forbidden."); 21 | restore_fg(); 22 | break; 23 | } 24 | } 25 | return 0; 26 | } -------------------------------------------------------------------------------- /clibalgserver/code/exe/tree.cpp: -------------------------------------------------------------------------------- 1 | #include "/include/io" 2 | #include "/include/fs" 3 | #include "/include/memory" 4 | #include "/include/shell" 5 | #include "/include/string" 6 | int main(int argc, char **argv) { 7 | if (argc == 1) { // ll 8 | shell("ls -tree"); 9 | } else if (argc == 2) { // ll XX 10 | char *cmd = malloc(1024); 11 | strcpy(cmd, "ls -tree "); 12 | strcat(cmd, argv[1]); 13 | shell(cmd); 14 | free((int) cmd); 15 | } else { 16 | set_fg(240, 0, 0); 17 | put_string("[Error] Invalid argument."); 18 | restore_fg(); 19 | } 20 | return 0; 21 | } -------------------------------------------------------------------------------- /clibalgserver/code/exe/uptime.cpp: -------------------------------------------------------------------------------- 1 | #include "/include/shell" 2 | #include "/include/io" 3 | #include "/include/proc" 4 | int main(int argc, char **argv) { 5 | for (;;) { 6 | put_string("\r运行时间:"); 7 | shell("cat /sys/uptime"); 8 | sleep(100); 9 | } 10 | return 0; 11 | } -------------------------------------------------------------------------------- /clibalgserver/code/exe/wc.cpp: -------------------------------------------------------------------------------- 1 | #include "/include/io" 2 | int wc(int *lines, int *chars) { 3 | int c; 4 | input_lock(); 5 | while ((c = input_valid()) != -1) { 6 | c = input_char(); 7 | (*chars)++; 8 | if (((char) c) == '\n') 9 | (*lines)++; 10 | } 11 | input_unlock(); 12 | return 0; 13 | } 14 | int main(int argc, char **argv) { 15 | int lines = 0; 16 | int chars = 0; 17 | wc(&lines, &chars); 18 | put_int(lines); 19 | put_string(" "); 20 | put_int(chars); 21 | return 0; 22 | } -------------------------------------------------------------------------------- /clibalgserver/code/exe/whoami.cpp: -------------------------------------------------------------------------------- 1 | #include "/include/io" 2 | #include "/include/fs" 3 | #include "/include/memory" 4 | int main(int argc, char **argv) { 5 | char *s = malloc(1024); 6 | whoami(s); 7 | put_string(s); 8 | free((int) s); 9 | return 0; 10 | } -------------------------------------------------------------------------------- /clibalgserver/code/exe/write.cpp: -------------------------------------------------------------------------------- 1 | #include "/include/io" 2 | #include "/include/fs" 3 | #include "/include/string" 4 | #include "/include/memory" 5 | int write_file(int handle) { 6 | int c, r; 7 | int state = input_lock(); 8 | while ((c = input_valid()) != -1) { 9 | c = input_char(); 10 | r = write(handle, (char) c); 11 | if (r < 0) { 12 | switch (r) { 13 | case -1: 14 | set_fg(240, 0, 0); 15 | put_string("[ERROR] File not exists."); 16 | restore_fg(); 17 | break; 18 | case -2: 19 | set_fg(240, 0, 0); 20 | put_string("[ERROR] Forbidden."); 21 | restore_fg(); 22 | break; 23 | case -3: 24 | set_fg(240, 0, 0); 25 | put_string("[ERROR] Invalid handle."); 26 | restore_fg(); 27 | break; 28 | } 29 | break; 30 | } 31 | } 32 | input_unlock(); 33 | close(handle); 34 | } 35 | char *trim(char *text) { 36 | while (*text == ' ') 37 | text++; 38 | return text; 39 | }; 40 | int main(int argc, char **argv) { 41 | if (argc > 1) { 42 | char *path = malloc(256); 43 | char *p = path; 44 | *p = '\0'; 45 | int i; 46 | for (i = 1; i < argc; ++i) { 47 | strcat(p, argv[i]); 48 | } 49 | char *name = trim(path); 50 | touch(name); 51 | int handle = open(name); 52 | switch (handle) { 53 | default: 54 | // put_string("[INFO] Success."); 55 | truncate(handle); 56 | write_file(handle); 57 | break; 58 | case -1: 59 | set_fg(240, 0, 0); 60 | put_string("[ERROR] File not exists."); 61 | restore_fg(); 62 | break; 63 | case -2: 64 | set_fg(240, 0, 0); 65 | put_string("[ERROR] Path is not file."); 66 | restore_fg(); 67 | break; 68 | case -3: 69 | set_fg(240, 0, 0); 70 | put_string("[ERROR] File is locked."); 71 | restore_fg(); 72 | break; 73 | } 74 | } 75 | return 0; 76 | } -------------------------------------------------------------------------------- /clibalgserver/code/include/exec.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Project: clibparser 3 | // Created by bajdcc 4 | // 5 | 6 | #include "/include/string" 7 | 8 | // 启动进程 9 | int exec(char* path) { 10 | path; 11 | interrupt 51; 12 | } 13 | int exec_sleep(char* path) { 14 | path; 15 | interrupt 53; 16 | } 17 | int exec_wakeup(int pid) { 18 | pid; 19 | interrupt 54; 20 | } 21 | int exec_connect(int left, int right) { 22 | (left << 16) | right; 23 | interrupt 56; 24 | } 25 | int exec_kill_children() { 26 | interrupt 57; 27 | } 28 | 29 | int path_add(char *path) { 30 | path; 31 | interrupt 71; 32 | } 33 | int path_remove(char* path) { 34 | path; 35 | interrupt 72; 36 | } -------------------------------------------------------------------------------- /clibalgserver/code/include/fs.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Project: clibparser 3 | // Created by bajdcc 4 | // 5 | 6 | // 文件系统 7 | 8 | int pwd(char *s) { 9 | s; 10 | interrupt 60; 11 | } 12 | int whoami(char *s) { 13 | s; 14 | interrupt 61; 15 | } 16 | int cd(char *s) { 17 | s; 18 | interrupt 62; 19 | } 20 | int mkdir(char *s) { 21 | s; 22 | interrupt 63; 23 | } 24 | int touch(char *s) { 25 | s; 26 | interrupt 64; 27 | } 28 | int open(char *s) { 29 | s; 30 | interrupt 65; 31 | } 32 | int read(int handle) { 33 | handle; 34 | interrupt 66; 35 | } 36 | int close(int handle) { 37 | handle; 38 | interrupt 67; 39 | } 40 | int rm(char *s) { 41 | s; 42 | interrupt 68; 43 | } 44 | int write(int handle, char c) { 45 | handle << 16 | (c + 0x1000); 46 | interrupt 69; 47 | } 48 | int truncate(int handle) { 49 | handle; 50 | interrupt 70; 51 | } -------------------------------------------------------------------------------- /clibalgserver/code/include/intr.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Project: clibparser 3 | // Created by bajdcc 4 | // 5 | 6 | // 中断表(本文件可不包含,只为了说明) 7 | 8 | enum INTR_TABLE { 9 | INTR_PUT_CHAR = 0, 10 | INTR_PUT_NUMBER = 1, 11 | INTR_PUT_HEX = 2, 12 | INTR_DEBUG = 3, 13 | INTR_PUT_FLOAT = 4, 14 | INTR_HOSTNAME = 5, 15 | INTR_PUT_DOUBLE = 6, 16 | INTR_PUT_LONG = 7, 17 | INTR_PUT_ULONG = 9, 18 | INTR_INPUT_LOCK = 10, 19 | INTR_INPUT_CHAR = 11, 20 | INTR_INPUT_STOP = 12, 21 | INTR_INPUT_STATE = 13, 22 | INTR_INPUT_VALID = 14, 23 | INTR_RESIZE = 20, 24 | INTR_MALLOC = 30, 25 | INTR_FREE = 31, 26 | INTR_EXIT = 40, 27 | INTR_PID = 50, 28 | INTR_PUT_EXEC_FILE = 51, 29 | INTR_PUT_EXEC_WAIT = 52, 30 | INTR_PUT_EXEC_SLEEP = 53, 31 | INTR_PUT_EXEC_WAKEUP = 54, 32 | INTR_PUT_FORK = 55, 33 | INTR_PUT_IO_CONNECT = 56, 34 | INTR_PUT_KILL_CHILDREN = 57, 35 | INTR_SWITCH_TASK = 58, 36 | INTR_SET_CYCLE = 59, 37 | INTR_FS_GET_PWD = 60, 38 | INTR_FS_GET_USER = 61, 39 | INTR_FS_CD = 62, 40 | INTR_FS_MKDIR = 63, 41 | INTR_FS_TOUCH = 64, 42 | INTR_FS_OPEN = 65, 43 | INTR_FS_READ = 66, 44 | INTR_FS_CLOSE = 67, 45 | INTR_FS_RM = 68, 46 | INTR_FS_WRITE = 69, 47 | INTR_FS_TRUNCATE = 70, 48 | INTR_PATH_ADD = 71, 49 | INTR_PATH_REMOVE = 72, 50 | INTR_SLEEP_RECORD = 100, 51 | INTR_SLEEP_REACH = 101, 52 | INTR_TIMESTAMP = 102, 53 | // MATH 54 | INTR_MATH_SQRT = 201, 55 | INTR_MATH_RAND = 202, 56 | // TRACE 57 | INTR_TRACE_SINGLE = 301, 58 | INTR_TRACE_1D = 302, 59 | INTR_TRACE_2D = 303, 60 | INTR_TRACE_END = 304, 61 | INTR_TRACE_LOG = 305, 62 | INTR_TRACE_RAPID = 306, 63 | INTR_TRACE_DELAY = 307, 64 | INTR_TRACE_GRAPH = 308, 65 | }; 66 | -------------------------------------------------------------------------------- /clibalgserver/code/include/io.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Project: clibparser 3 | // Created by bajdcc 4 | // 5 | 6 | // IO输入与输出 7 | 8 | // 输出部分 9 | int put_char(char c) { 10 | c; 11 | interrupt 0; 12 | } 13 | int put_string(char *text) { 14 | while (*text) put_char(*text++); 15 | } 16 | int put_int(int number) { 17 | number; 18 | interrupt 1; 19 | } 20 | int put_hex(int number) { 21 | number; 22 | interrupt 2; 23 | } 24 | float put_float(float number) { 25 | number; 26 | interrupt 4; 27 | } 28 | double put_double(double number) { 29 | number; 30 | interrupt 6; 31 | } 32 | long put_long(long number) { 33 | number; 34 | interrupt 7; 35 | } 36 | unsigned long put_ulong(unsigned number) { 37 | number; 38 | interrupt 9; 39 | } 40 | int input_character(char c) { 41 | c; 42 | interrupt 8; 43 | } 44 | int input_string(char *text) { 45 | while (input_character(*text++)); 46 | } 47 | 48 | // 输入部分 49 | enum input_special { 50 | INPUT_BEGIN = -9, 51 | INPUT_UP = -10, 52 | INPUT_DOWN = -11, 53 | INPUT_LEFT = -12, 54 | INPUT_RIGHT = -13, 55 | }; 56 | int input_char() { 57 | interrupt 11; 58 | } 59 | int input_lock() { 60 | interrupt 10; 61 | } 62 | int input_unlock() { 63 | interrupt 12; 64 | } 65 | int input_state() { 66 | interrupt 13; 67 | } 68 | int input_valid() { 69 | interrupt 14; 70 | } 71 | int input(char *text, int len) { 72 | int i, c; 73 | int state = input_lock(); 74 | input_string(text); 75 | for (i = 0; i < len - 1 && ((c = input_valid()) != -1); ++i) { 76 | if (c <= INPUT_BEGIN) { 77 | input_unlock(); 78 | text[i] = '\0'; 79 | return c; 80 | } 81 | text[i] = input_char(); 82 | } 83 | input_unlock(); 84 | text[i] = '\0'; 85 | if (i == len - 1) return -1; 86 | return c; 87 | } 88 | 89 | // 界面部分 90 | int resize(int rows, int cols) { 91 | (rows << 16) | cols; 92 | interrupt 20; 93 | } 94 | int set_bg(int r, int g, int b) { 95 | put_char('\033'); 96 | put_char('B'); 97 | put_hex((0xff << 24) | (r << 16) | (g << 8) | b); 98 | put_char('\033'); 99 | } 100 | int set_fg(int r, int g, int b) { 101 | put_char('\033'); 102 | put_char('F'); 103 | put_hex((0xff << 24) | (r << 16) | (g << 8) | b); 104 | put_char('\033'); 105 | } 106 | int gui_cfg(char c) { 107 | put_char('\033'); 108 | put_char('S'); 109 | put_char(c); 110 | put_char('\033'); 111 | } 112 | int newline() { 113 | gui_cfg('0'); 114 | } 115 | int save_bg() { 116 | gui_cfg('1'); 117 | } 118 | int save_fg() { 119 | gui_cfg('2'); 120 | } 121 | int restore_bg() { 122 | gui_cfg('3'); 123 | } 124 | int restore_fg() { 125 | gui_cfg('4'); 126 | } 127 | -------------------------------------------------------------------------------- /clibalgserver/code/include/math.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Project: clibparser 3 | // Created by bajdcc 4 | // 5 | 6 | // 数学函数(为了精度,默认先做double) 7 | double sqrt(double number) { 8 | number; 9 | interrupt 201; 10 | } 11 | 12 | int rand() { 13 | interrupt 202; 14 | } -------------------------------------------------------------------------------- /clibalgserver/code/include/memory.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Project: clibparser 3 | // Created by bajdcc 4 | // 5 | 6 | // 内存管理 7 | char *malloc(int size) { 8 | size; 9 | interrupt 30; 10 | } 11 | int free(int addr) { 12 | addr; 13 | interrupt 31; 14 | } 15 | void memmove(char *dst, char *src, int n) { 16 | if (dst < src) while (n-- > 0) *dst++ = *src++; 17 | else { 18 | src += n - 1; 19 | dst += n - 1; 20 | while (n-- > 0) *dst-- = *src--; 21 | } 22 | } 23 | void memset(char *src, char c, int n) { 24 | for (; 0 < n; ++src, --n) 25 | *src = c; 26 | } 27 | -------------------------------------------------------------------------------- /clibalgserver/code/include/proc.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Project: clibparser 3 | // Created by bajdcc 4 | // 5 | 6 | // 进程控制 7 | int sleep(int ms) { 8 | ms; 9 | interrupt 100; 10 | interrupt 101; 11 | } 12 | int wait() { 13 | interrupt 52; 14 | } 15 | int fork() { 16 | interrupt 55; 17 | } 18 | int get_pid() { 19 | interrupt 50; 20 | } 21 | int switch_task() { 22 | interrupt 58; 23 | } 24 | int exit(int n) { 25 | n; 26 | interrupt 40; 27 | } 28 | -------------------------------------------------------------------------------- /clibalgserver/code/include/shell.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Project: clibparser 3 | // Created by bajdcc 4 | // 5 | 6 | #include "/include/exec" 7 | #include "/include/proc" 8 | #include "/include/fs" 9 | #include "/include/io" 10 | #include "/include/string" 11 | #include "/include/memory" 12 | 13 | int process(char* text) { 14 | char* tmp = malloc(256), c; 15 | int i = 0, j = 0; 16 | while (true) { 17 | c = text[i]; 18 | if (c == '>') { 19 | i++; 20 | if (text[i] == '>') { // append 21 | i++; 22 | strcpy(tmp + j, "| append "); 23 | j += 9; 24 | } 25 | else { // truncate 26 | strcpy(tmp + j, "| write "); 27 | j += 8; 28 | } 29 | } 30 | tmp[j++] = text[i++]; 31 | if (c == (char)0) 32 | break; 33 | } 34 | strcpy(text, tmp); 35 | } 36 | int exec_single(char* text, int* total, int right) { 37 | int pid; 38 | while (*text == ' ') 39 | text++; 40 | if (strncmp(text, "/sys/", 5) == 0) { 41 | return -3; 42 | } 43 | if (strncmp(text, "/", 1) != 0) { 44 | char* path = malloc(200); 45 | pwd(path); 46 | if (strlen(path) != 1) 47 | strcat(path, "/"); 48 | strcat(path, text); 49 | pid = exec_sleep(path); 50 | free(path); 51 | if (pid >= 0) { 52 | exec_connect(pid, get_pid()); 53 | (*total)++; 54 | return pid; 55 | } 56 | } 57 | (*total)++; 58 | pid = exec_sleep(text); 59 | exec_connect(pid, get_pid()); 60 | return pid; 61 | } 62 | int exec_start(char* text, int* total) { 63 | char* c = strchr(text, '|'); 64 | if (c == (char*)0) { 65 | return exec_single(text, total, 1); 66 | } 67 | else { 68 | *c++ = '\0'; 69 | if (*c == '\0') 70 | return exec_single(text, total, 1); 71 | int right = exec_start(c, total); 72 | if (right < 0) 73 | return right; 74 | int left = exec_single(text, total, 0); 75 | exec_connect(left, right); 76 | exec_wakeup(right); 77 | return left; 78 | } 79 | } 80 | void output() { 81 | int i, c; 82 | int state = input_lock(); 83 | while ((c = input_valid()) != -1 && c > INPUT_BEGIN) { 84 | put_char(input_char()); 85 | } 86 | input_unlock(); 87 | } 88 | int shell(char *path) { 89 | int len = strlen(path), total = 0, i; 90 | char* new_path = malloc(len + 1); 91 | strcpy(new_path, path); 92 | process(new_path); 93 | int pid = exec_start(new_path, &total); 94 | free(new_path); 95 | if (pid >= 0) { 96 | exec_wakeup(pid); 97 | output(); 98 | for (i = 0; i < total; ++i) { 99 | wait(); 100 | } 101 | return 0; 102 | } 103 | else { 104 | exec_kill_children(); 105 | return pid; 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /clibalgserver/code/include/string.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Project: clibparser 3 | // Created by bajdcc 4 | // 5 | 6 | // 字符串操作 7 | 8 | int strlen(char *text) { 9 | int i = 0; 10 | while (*text++) 11 | i++; 12 | return i; 13 | } 14 | int strcpy(char *dst, char *src) { 15 | while (*dst++ = *src++); 16 | } 17 | int strncpy(char *dst, char *src, int n) { 18 | if (dst < src) while (n-- > 0 && (*dst++ = *src++)); 19 | else { 20 | src += n - 1; 21 | dst += n - 1; 22 | while (n-- > 0 && (*dst-- = *src--)); 23 | } 24 | } 25 | int strcmp(char *a, char *b) { 26 | int len = 0; 27 | while(*a && *b && (*a == *b)) { 28 | a++, b++; 29 | } 30 | return *a - *b; 31 | } 32 | int strncmp(char *a, char *b, int n) { 33 | while(n-- && *a && *b) { 34 | if (*a != *b) { 35 | return *a - *b; 36 | } else { 37 | a++, b++; 38 | } 39 | } 40 | if (n < 0) 41 | return 0; 42 | return *a - *b; 43 | } 44 | char *strchr(char *text, char c) { 45 | for (; *text; ++text) 46 | if (*text == c) 47 | return text; 48 | return (char *) 0; 49 | } 50 | char *strcat(char *dst, char *src) { 51 | char *s = dst; 52 | while (*s++); s--; 53 | while (*s++ = *src++); 54 | return dst; 55 | } 56 | -------------------------------------------------------------------------------- /clibalgserver/code/include/sys.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Project: clibparser 3 | // Created by bajdcc 4 | // 5 | 6 | // 系统属性 7 | int hostname(char *s) { 8 | s; 9 | interrupt 5; 10 | } 11 | int set_cycle(int cycle) { 12 | cycle; 13 | interrupt 59; 14 | } 15 | int reset_cycle(int cycle) { 16 | set_cycle(0); 17 | } 18 | long timestamp() { 19 | interrupt 102; 20 | } 21 | -------------------------------------------------------------------------------- /clibalgserver/code/include/trace.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Project: clibparser 3 | // Created by bajdcc 4 | // 5 | 6 | // 控制台输出 7 | void trace_log(char* text) { 8 | text; 9 | interrupt 305; 10 | } 11 | 12 | // 设置原子操作 13 | void trace_rapid(int flag) { 14 | flag; 15 | interrupt 306; 16 | } 17 | 18 | // 延迟 19 | void trace_delay(int n) { 20 | n; 21 | interrupt 307; 22 | } 23 | 24 | // 支持的追踪类型 25 | enum trace_type { 26 | T_CHAR, 27 | T_INT, 28 | T_FLOAT, 29 | }; 30 | 31 | struct __trace_var__ { 32 | char* name; 33 | void* arr; 34 | int type; 35 | }; 36 | 37 | // 追踪单个变量 38 | void trace_var(char* name, void* arr, int type) { 39 | __trace_var__ s; 40 | s.name = name; 41 | s.arr = arr; 42 | s.type = type; 43 | &s; 44 | interrupt 301; 45 | } 46 | 47 | struct __trace_1d__ { 48 | __trace_var__ v; 49 | int cols; 50 | int chart; 51 | }; 52 | 53 | // 追踪一维数组 54 | void trace_array_1d(char* name, void* arr, int type, int cols) { 55 | __trace_1d__ s; 56 | s.v.name = name; 57 | s.v.arr = arr; 58 | s.v.type = type; 59 | s.cols = cols; 60 | s.chart = 0; 61 | &s; 62 | interrupt 302; 63 | } 64 | 65 | // 追踪一维数组图表 66 | void trace_array_1d_chart(char* name, void* arr, int type, int cols) { 67 | __trace_1d__ s; 68 | s.v.name = name; 69 | s.v.arr = arr; 70 | s.v.type = type; 71 | s.cols = cols; 72 | s.chart = 1; 73 | &s; 74 | interrupt 302; 75 | } 76 | 77 | struct __trace_2d__ { 78 | __trace_var__ v; 79 | int rows, cols; 80 | }; 81 | 82 | // 追踪二维数组 83 | void trace_array_2d(char* name, void* arr, int type, int rows, int cols) { 84 | __trace_2d__ s; 85 | s.v.name = name; 86 | s.v.arr = arr; 87 | s.v.type = type; 88 | s.rows = rows; 89 | s.cols = cols; 90 | &s; 91 | interrupt 303; 92 | } 93 | 94 | // 取消追踪 95 | void trace_end(char* name) { 96 | name; 97 | interrupt 304; 98 | } 99 | 100 | struct __trace_graph__ { 101 | char* name; 102 | int type; 103 | void* id; 104 | void* adj; 105 | int n; 106 | int inf; 107 | }; 108 | 109 | // 追踪图 110 | void trace_graph(char* name, void* id, void* adj, int inf, int type, int n) { 111 | __trace_graph__ s; 112 | s.name = name; 113 | s.type = type; 114 | s.id = id; 115 | s.adj = adj; 116 | s.n = n; 117 | s.inf = inf; 118 | &s; 119 | interrupt 308; 120 | } -------------------------------------------------------------------------------- /clibalgserver/code/include/vector.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Project: clibparser 3 | // Created by bajdcc 4 | // 5 | 6 | #include "/include/memory" 7 | #include "/include/string" 8 | 9 | int _vector_initial_size_ = 16; 10 | struct _vector_struct_ { 11 | int _sizeof; 12 | char *data; 13 | int capacity; 14 | int size; 15 | }; 16 | 17 | void *vector_new(int _sizeof) { 18 | _vector_struct_ *s = malloc(sizeof(_vector_struct_)); 19 | s->_sizeof = _sizeof; 20 | s->capacity = _vector_initial_size_; 21 | s->size = 0; 22 | s->data = malloc(s->capacity * s->_sizeof); 23 | return s; 24 | } 25 | 26 | void vector_del(void *p) { 27 | _vector_struct_ *s = (_vector_struct_ *) p; 28 | free(s->data); 29 | free(s); 30 | } 31 | 32 | void vector_push(void *p, void *data) { 33 | _vector_struct_ *s = (_vector_struct_ *) p; 34 | if (s->size == s->capacity) { 35 | s->capacity <<= 1; 36 | void *new_data = malloc(s->capacity * s->_sizeof); 37 | memmove(new_data, s->data, s->size * s->_sizeof); 38 | free(s->data); 39 | s->data = new_data; 40 | } 41 | memmove(s->data + s->size++ * s->_sizeof, data, s->_sizeof); 42 | } 43 | 44 | void vector_pop(void *p) { 45 | _vector_struct_ *s = (_vector_struct_ *) p; 46 | if (s->size > 0) { 47 | s->size--; 48 | } 49 | } 50 | 51 | void vector_insert(void *p, int n, void *data) { 52 | _vector_struct_ *s = (_vector_struct_ *) p; 53 | if (n >= 0 && n <= s->size) { 54 | if (s->size == s->capacity) { 55 | s->capacity <<= 1; 56 | void *new_data = malloc(s->capacity * s->_sizeof); 57 | memmove(new_data, s->data, s->capacity * s->_sizeof); 58 | free(s->data); 59 | s->data = new_data; 60 | } 61 | memmove(s->data + (n + 1) * s->_sizeof, 62 | s->data + (n) * s->_sizeof, 63 | (s->size++ - n) * s->_sizeof); 64 | memmove(s->data + n * s->_sizeof, data, s->_sizeof); 65 | } 66 | } 67 | 68 | int vector_size(void *p) { 69 | _vector_struct_ *s = (_vector_struct_ *) p; 70 | return s->size; 71 | } 72 | 73 | void *vector_get(void *p, int index) { 74 | _vector_struct_ *s = (_vector_struct_ *) p; 75 | if (index >= 0 && index < s->size) { 76 | return s->data + index * s->_sizeof; 77 | } 78 | return 0; 79 | } 80 | 81 | void vector_set(void *p, int index, void *data) { 82 | _vector_struct_ *s = (_vector_struct_ *) p; 83 | if (index > 0 && index < s->size) { 84 | memmove(s->data + index * s->_sizeof, data, s->_sizeof); 85 | } 86 | } 87 | 88 | void vector_clear(void *p) { 89 | _vector_struct_ *s = (_vector_struct_ *) p; 90 | s->size = 0; 91 | } -------------------------------------------------------------------------------- /clibalgserver/code/include/xtoa_atoi.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Project: clibparser 3 | // Created by bajdcc 4 | // 5 | 6 | int atoi32(char* str) { 7 | int temp = 0; 8 | char *ptr = str; 9 | if (*str == '-' || *str == '+') { 10 | str++; 11 | } 12 | while (*str != 0) { 13 | if ((*str < '0') || (*str > '9')) { 14 | break; 15 | } 16 | temp = temp * 10 + (*str - '0'); 17 | str++; 18 | } 19 | if (*ptr == '-') { 20 | temp = -temp; 21 | } 22 | return temp; 23 | } 24 | 25 | unsigned int atou32(char* str) { 26 | unsigned int temp = 0U; 27 | char *ptr = str; 28 | if (*str == '-' || *str == '+') { 29 | str++; 30 | } 31 | while (*str != 0) { 32 | if ((*str < '0') || (*str > '9')) { 33 | break; 34 | } 35 | temp = temp * 10U + (unsigned int)(*str - '0'); 36 | str++; 37 | } 38 | if (*ptr == '-') { 39 | temp = ~temp + 1U; 40 | } 41 | return temp; 42 | } 43 | 44 | long atoi64(char* str) { 45 | long temp = 0L; 46 | char *ptr = str; 47 | if (*str == '-' || *str == '+') { 48 | str++; 49 | } 50 | while (*str != 0) { 51 | if ((*str < '0') || (*str > '9')) { 52 | break; 53 | } 54 | temp = temp * 10L + (*str - '0'); 55 | str++; 56 | } 57 | if (*ptr == '-') { 58 | temp = -temp; 59 | } 60 | return temp; 61 | } 62 | 63 | unsigned long atou64(char* str) { 64 | unsigned long temp = 0UL; 65 | char *ptr = str; 66 | if (*str == '-' || *str == '+') { 67 | str++; 68 | } 69 | while (*str != 0) { 70 | if ((*str < '0') || (*str > '9')) { 71 | break; 72 | } 73 | temp = temp * 10UL + (unsigned int)(*str - '0'); 74 | str++; 75 | } 76 | if (*ptr == '-') { 77 | temp = ~temp + 1UL; 78 | } 79 | return temp; 80 | } -------------------------------------------------------------------------------- /clibalgserver/code/include/xtoa_cached_powers.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Project: clibparser 3 | // Created by bajdcc 4 | // 5 | 6 | // Refer: https://github.com/miloyip/dtoa-benchmark 7 | 8 | unsigned long xtoa_kCachedPowers_F[0] = { 9 | 0xfa8fd5a0081c0288, 0xbaaee17fa23ebf76, 10 | 0x8b16fb203055ac76, 0xcf42894a5dce35ea, 11 | 0x9a6bb0aa55653b2d, 0xe61acf033d1a45df, 12 | 0xab70fe17c79ac6ca, 0xff77b1fcbebcdc4f, 13 | 0xbe5691ef416bd60c, 0x8dd01fad907ffc3c, 14 | 0xd3515c2831559a83, 0x9d71ac8fada6c9b5, 15 | 0xea9c227723ee8bcb, 0xaecc49914078536d, 16 | 0x823c12795db6ce57, 0xc21094364dfb5637, 17 | 0x9096ea6f3848984f, 0xd77485cb25823ac7, 18 | 0xa086cfcd97bf97f4, 0xef340a98172aace5, 19 | 0xb23867fb2a35b28e, 0x84c8d4dfd2c63f3b, 20 | 0xc5dd44271ad3cdba, 0x936b9fcebb25c996, 21 | 0xdbac6c247d62a584, 0xa3ab66580d5fdaf6, 22 | 0xf3e2f893dec3f126, 0xb5b5ada8aaff80b8, 23 | 0x87625f056c7c4a8b, 0xc9bcff6034c13053, 24 | 0x964e858c91ba2655, 0xdff9772470297ebd, 25 | 0xa6dfbd9fb8e5b88f, 0xf8a95fcf88747d94, 26 | 0xb94470938fa89bcf, 0x8a08f0f8bf0f156b, 27 | 0xcdb02555653131b6, 0x993fe2c6d07b7fac, 28 | 0xe45c10c42a2b3b06, 0xaa242499697392d3, 29 | 0xfd87b5f28300ca0e, 0xbce5086492111aeb, 30 | 0x8cbccc096f5088cc, 0xd1b71758e219652c, 31 | 0x9c40000000000000, 0xe8d4a51000000000, 32 | 0xad78ebc5ac620000, 0x813f3978f8940984, 33 | 0xc097ce7bc90715b3, 0x8f7e32ce7bea5c70, 34 | 0xd5d238a4abe98068, 0x9f4f2726179a2245, 35 | 0xed63a231d4c4fb27, 0xb0de65388cc8ada8, 36 | 0x83c7088e1aab65db, 0xc45d1df942711d9a, 37 | 0x924d692ca61be758, 0xda01ee641a708dea, 38 | 0xa26da3999aef774a, 0xf209787bb47d6b85, 39 | 0xb454e4a179dd1877, 0x865b86925b9bc5c2, 40 | 0xc83553c5c8965d3d, 0x952ab45cfa97a0b3, 41 | 0xde469fbd99a05fe3, 0xa59bc234db398c25, 42 | 0xf6c69a72a3989f5c, 0xb7dcbf5354e9bece, 43 | 0x88fcf317f22241e2, 0xcc20ce9bd35c78a5, 44 | 0x98165af37b2153df, 0xe2a0b5dc971f303a, 45 | 0xa8d9d1535ce3b396, 0xfb9b7cd9a4a7443c, 46 | 0xbb764c4ca7a44410, 0x8bab8eefb6409c1a, 47 | 0xd01fef10a657842c, 0x9b10a4e5e9913129, 48 | 0xe7109bfba19c0c9d, 0xac2820d9623bf429, 49 | 0x80444b5e7aa7cf85, 0xbf21e44003acdd2d, 50 | 0x8e679c2f5e44ff8f, 0xd433179d9c8cb841, 51 | 0x9e19db92b4e31ba9, 0xeb96bf6ebadf77d9, 52 | 0xaf87023b9bf0ee6b 53 | }; 54 | 55 | int xtoa_kCachedPowers_E[0] = { 56 | -1220, -1193, -1166, -1140, -1113, -1087, -1060, -1034, -1007, -980, 57 | -954, -927, -901, -874, -847, -821, -794, -768, -741, -715, 58 | -688, -661, -635, -608, -582, -555, -529, -502, -475, -449, 59 | -422, -396, -369, -343, -316, -289, -263, -236, -210, -183, 60 | -157, -130, -103, -77, -50, -24, 3, 30, 56, 83, 61 | 109, 136, 162, 189, 216, 242, 269, 295, 322, 348, 62 | 375, 402, 428, 455, 481, 508, 534, 561, 588, 614, 63 | 641, 667, 694, 720, 747, 774, 800, 827, 853, 880, 64 | 907, 933, 960, 986, 1013, 1039, 1066 65 | }; 66 | -------------------------------------------------------------------------------- /clibalgserver/code/include/xtoa_lut.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Project: clibparser 3 | // Created by bajdcc 4 | // 5 | 6 | // Refer: https://github.com/miloyip/itoa-benchmark 7 | 8 | char *g_xtoa_lut = "00010203040506070809101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899"; -------------------------------------------------------------------------------- /clibalgserver/code/sys/entry.cpp: -------------------------------------------------------------------------------- 1 | #include "/include/io" 2 | #include "/include/shell" 3 | int main(int argc, char **argv) { 4 | path_add("/exe"); 5 | int pid = shell("/usr/main"); 6 | if (pid < 0) { 7 | switch (pid) { 8 | case -1: 9 | set_fg(240, 0, 0); 10 | put_string("[ERROR] File not exists.\n"); 11 | restore_fg(); 12 | break; 13 | case -2: 14 | set_fg(240, 0, 0); 15 | put_string("[ERROR] Compile failed.\n"); 16 | shell("cat /log/err"); 17 | restore_fg(); 18 | break; 19 | case -3: 20 | set_fg(240, 0, 0); 21 | put_string("[ERROR] Cannot execute system programs!\n"); 22 | restore_fg(); 23 | break; 24 | } 25 | } 26 | return 0; 27 | } -------------------------------------------------------------------------------- /clibalgserver/event2/dns_struct.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2007 Niels Provos 3 | * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #ifndef _EVENT2_DNS_STRUCT_H_ 28 | #define _EVENT2_DNS_STRUCT_H_ 29 | 30 | /** @file event2/dns_struct.h 31 | 32 | Data structures for dns. Using these structures may hurt forward 33 | compatibility with later versions of Libevent: be careful! 34 | 35 | */ 36 | 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | #include 42 | #ifdef _EVENT_HAVE_SYS_TYPES_H 43 | #include 44 | #endif 45 | #ifdef _EVENT_HAVE_SYS_TIME_H 46 | #include 47 | #endif 48 | 49 | /* For int types. */ 50 | #include 51 | 52 | /* 53 | * Structures used to implement a DNS server. 54 | */ 55 | 56 | struct evdns_server_request { 57 | int flags; 58 | int nquestions; 59 | struct evdns_server_question **questions; 60 | }; 61 | struct evdns_server_question { 62 | int type; 63 | #ifdef __cplusplus 64 | int dns_question_class; 65 | #else 66 | /* You should refer to this field as "dns_question_class". The 67 | * name "class" works in C for backward compatibility, and will be 68 | * removed in a future version. (1.5 or later). */ 69 | int class; 70 | #define dns_question_class class 71 | #endif 72 | char name[1]; 73 | }; 74 | 75 | #ifdef __cplusplus 76 | } 77 | #endif 78 | 79 | #endif /* _EVENT2_DNS_STRUCT_H_ */ 80 | 81 | -------------------------------------------------------------------------------- /clibalgserver/event2/http_compat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2007 Niels Provos 3 | * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #ifndef _EVENT2_HTTP_COMPAT_H_ 28 | #define _EVENT2_HTTP_COMPAT_H_ 29 | 30 | /** @file event2/http_compat.h 31 | 32 | Potentially non-threadsafe versions of the functions in http.h: provided 33 | only for backwards compatibility. 34 | 35 | */ 36 | 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | #include 42 | #ifdef _EVENT_HAVE_SYS_TYPES_H 43 | #include 44 | #endif 45 | #ifdef _EVENT_HAVE_SYS_TIME_H 46 | #include 47 | #endif 48 | 49 | /* For int types. */ 50 | #include 51 | 52 | /** 53 | * Start an HTTP server on the specified address and port 54 | * 55 | * @deprecated It does not allow an event base to be specified 56 | * 57 | * @param address the address to which the HTTP server should be bound 58 | * @param port the port number on which the HTTP server should listen 59 | * @return an struct evhttp object 60 | */ 61 | struct evhttp *evhttp_start(const char *address, unsigned short port); 62 | 63 | /** 64 | * A connection object that can be used to for making HTTP requests. The 65 | * connection object tries to establish the connection when it is given an 66 | * http request object. 67 | * 68 | * @deprecated It does not allow an event base to be specified 69 | */ 70 | struct evhttp_connection *evhttp_connection_new( 71 | const char *address, unsigned short port); 72 | 73 | /** 74 | * Associates an event base with the connection - can only be called 75 | * on a freshly created connection object that has not been used yet. 76 | * 77 | * @deprecated XXXX Why? 78 | */ 79 | void evhttp_connection_set_base(struct evhttp_connection *evcon, 80 | struct event_base *base); 81 | 82 | 83 | /** Returns the request URI */ 84 | #define evhttp_request_uri evhttp_request_get_uri 85 | 86 | #ifdef __cplusplus 87 | } 88 | #endif 89 | 90 | #endif /* _EVENT2_EVENT_COMPAT_H_ */ 91 | -------------------------------------------------------------------------------- /clibalgserver/event2/keyvalq_struct.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2007 Niels Provos 3 | * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #ifndef _EVENT2_EVENT_KEYVALQ_STRUCT_H_ 28 | #define _EVENT2_EVENT_KEYVALQ_STRUCT_H_ 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | /* Fix so that people don't have to run with */ 35 | /* XXXX This code is duplicated with event_struct.h */ 36 | #ifndef TAILQ_ENTRY 37 | #define _EVENT_DEFINED_TQENTRY 38 | #define TAILQ_ENTRY(type) \ 39 | struct { \ 40 | struct type *tqe_next; /* next element */ \ 41 | struct type **tqe_prev; /* address of previous next element */ \ 42 | } 43 | #endif /* !TAILQ_ENTRY */ 44 | 45 | #ifndef TAILQ_HEAD 46 | #define _EVENT_DEFINED_TQHEAD 47 | #define TAILQ_HEAD(name, type) \ 48 | struct name { \ 49 | struct type *tqh_first; \ 50 | struct type **tqh_last; \ 51 | } 52 | #endif 53 | 54 | /* 55 | * Key-Value pairs. Can be used for HTTP headers but also for 56 | * query argument parsing. 57 | */ 58 | struct evkeyval { 59 | TAILQ_ENTRY(evkeyval) next; 60 | 61 | char *key; 62 | char *value; 63 | }; 64 | 65 | TAILQ_HEAD (evkeyvalq, evkeyval); 66 | 67 | /* XXXX This code is duplicated with event_struct.h */ 68 | #ifdef _EVENT_DEFINED_TQENTRY 69 | #undef TAILQ_ENTRY 70 | #endif 71 | 72 | #ifdef _EVENT_DEFINED_TQHEAD 73 | #undef TAILQ_HEAD 74 | #endif 75 | 76 | #ifdef __cplusplus 77 | } 78 | #endif 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /clibalgserver/event2/rpc_compat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006-2007 Niels Provos 3 | * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #ifndef _EVENT2_RPC_COMPAT_H_ 28 | #define _EVENT2_RPC_COMPAT_H_ 29 | 30 | /** @file event2/rpc_compat.h 31 | 32 | Deprecated versions of the functions in rpc.h: provided only for 33 | backwards compatibility. 34 | 35 | */ 36 | 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | /** backwards compatible accessors that work only with gcc */ 42 | #if defined(__GNUC__) && !defined(__STRICT_ANSI__) 43 | 44 | #undef EVTAG_ASSIGN 45 | #undef EVTAG_GET 46 | #undef EVTAG_ADD 47 | 48 | #define EVTAG_ASSIGN(msg, member, args...) \ 49 | (*(msg)->base->member##_assign)(msg, ## args) 50 | #define EVTAG_GET(msg, member, args...) \ 51 | (*(msg)->base->member##_get)(msg, ## args) 52 | #define EVTAG_ADD(msg, member, args...) \ 53 | (*(msg)->base->member##_add)(msg, ## args) 54 | #endif 55 | #define EVTAG_LEN(msg, member) ((msg)->member##_length) 56 | 57 | #ifdef __cplusplus 58 | } 59 | #endif 60 | 61 | #endif /* _EVENT2_EVENT_COMPAT_H_ */ 62 | -------------------------------------------------------------------------------- /clibalgserver/event2/rpc_struct.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006-2007 Niels Provos 3 | * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #ifndef _EVENT2_RPC_STRUCT_H_ 28 | #define _EVENT2_RPC_STRUCT_H_ 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | /** @file event2/rpc_struct.h 35 | 36 | Structures used by rpc.h. Using these structures directly may harm 37 | forward compatibility: be careful! 38 | 39 | */ 40 | 41 | /** 42 | * provides information about the completed RPC request. 43 | */ 44 | struct evrpc_status { 45 | #define EVRPC_STATUS_ERR_NONE 0 46 | #define EVRPC_STATUS_ERR_TIMEOUT 1 47 | #define EVRPC_STATUS_ERR_BADPAYLOAD 2 48 | #define EVRPC_STATUS_ERR_UNSTARTED 3 49 | #define EVRPC_STATUS_ERR_HOOKABORTED 4 50 | int error; 51 | 52 | /* for looking at headers or other information */ 53 | struct evhttp_request *http_req; 54 | }; 55 | 56 | /* the structure below needs to be synchronized with evrpc_req_generic */ 57 | 58 | /* Encapsulates a request */ 59 | struct evrpc { 60 | TAILQ_ENTRY(evrpc) next; 61 | 62 | /* the URI at which the request handler lives */ 63 | const char* uri; 64 | 65 | /* creates a new request structure */ 66 | void *(*request_new)(void *); 67 | void *request_new_arg; 68 | 69 | /* frees the request structure */ 70 | void (*request_free)(void *); 71 | 72 | /* unmarshals the buffer into the proper request structure */ 73 | int (*request_unmarshal)(void *, struct evbuffer *); 74 | 75 | /* creates a new reply structure */ 76 | void *(*reply_new)(void *); 77 | void *reply_new_arg; 78 | 79 | /* frees the reply structure */ 80 | void (*reply_free)(void *); 81 | 82 | /* verifies that the reply is valid */ 83 | int (*reply_complete)(void *); 84 | 85 | /* marshals the reply into a buffer */ 86 | void (*reply_marshal)(struct evbuffer*, void *); 87 | 88 | /* the callback invoked for each received rpc */ 89 | void (*cb)(struct evrpc_req_generic *, void *); 90 | void *cb_arg; 91 | 92 | /* reference for further configuration */ 93 | struct evrpc_base *base; 94 | }; 95 | 96 | #ifdef __cplusplus 97 | } 98 | #endif 99 | 100 | #endif /* _EVENT2_RPC_STRUCT_H_ */ 101 | -------------------------------------------------------------------------------- /clibalgserver/event2/tag_compat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2007 Niels Provos 3 | * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #ifndef _EVENT2_TAG_COMPAT_H_ 28 | #define _EVENT2_TAG_COMPAT_H_ 29 | 30 | /** @file event2/tag_compat.h 31 | 32 | Obsolete/deprecated functions from tag.h; provided only for backwards 33 | compatibility. 34 | */ 35 | 36 | /** 37 | @name Misnamed functions 38 | 39 | @deprecated These macros are deprecated because their names don't follow 40 | Libevent's naming conventions. Use evtag_encode_int and 41 | evtag_encode_int64 instead. 42 | 43 | @{ 44 | */ 45 | #define encode_int(evbuf, number) evtag_encode_int((evbuf), (number)) 46 | #define encode_int64(evbuf, number) evtag_encode_int64((evbuf), (number)) 47 | /**@}*/ 48 | 49 | #endif /* _EVENT2_TAG_H_ */ 50 | -------------------------------------------------------------------------------- /clibalgserver/lib/libevent.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/lib/libevent.lib -------------------------------------------------------------------------------- /clibalgserver/lib/libevent_core.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/lib/libevent_core.lib -------------------------------------------------------------------------------- /clibalgserver/lib/libevent_extras.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/lib/libevent_extras.lib -------------------------------------------------------------------------------- /clibalgserver/mime.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace clib { 4 | 5 | std::string get_mime_from_ext(std::string); 6 | } -------------------------------------------------------------------------------- /clibalgserver/rapidjson/filereadstream.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_FILEREADSTREAM_H_ 16 | #define RAPIDJSON_FILEREADSTREAM_H_ 17 | 18 | #include "stream.h" 19 | #include 20 | 21 | #ifdef __clang__ 22 | RAPIDJSON_DIAG_PUSH 23 | RAPIDJSON_DIAG_OFF(padded) 24 | RAPIDJSON_DIAG_OFF(unreachable-code) 25 | RAPIDJSON_DIAG_OFF(missing-noreturn) 26 | #endif 27 | 28 | RAPIDJSON_NAMESPACE_BEGIN 29 | 30 | //! File byte stream for input using fread(). 31 | /*! 32 | \note implements Stream concept 33 | */ 34 | class FileReadStream { 35 | public: 36 | typedef char Ch; //!< Character type (byte). 37 | 38 | //! Constructor. 39 | /*! 40 | \param fp File pointer opened for read. 41 | \param buffer user-supplied buffer. 42 | \param bufferSize size of buffer in bytes. Must >=4 bytes. 43 | */ 44 | FileReadStream(std::FILE* fp, char* buffer, size_t bufferSize) : fp_(fp), buffer_(buffer), bufferSize_(bufferSize), bufferLast_(0), current_(buffer_), readCount_(0), count_(0), eof_(false) { 45 | RAPIDJSON_ASSERT(fp_ != 0); 46 | RAPIDJSON_ASSERT(bufferSize >= 4); 47 | Read(); 48 | } 49 | 50 | Ch Peek() const { return *current_; } 51 | Ch Take() { Ch c = *current_; Read(); return c; } 52 | size_t Tell() const { return count_ + static_cast(current_ - buffer_); } 53 | 54 | // Not implemented 55 | void Put(Ch) { RAPIDJSON_ASSERT(false); } 56 | void Flush() { RAPIDJSON_ASSERT(false); } 57 | Ch* PutBegin() { RAPIDJSON_ASSERT(false); return 0; } 58 | size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; } 59 | 60 | // For encoding detection only. 61 | const Ch* Peek4() const { 62 | return (current_ + 4 <= bufferLast_) ? current_ : 0; 63 | } 64 | 65 | private: 66 | void Read() { 67 | if (current_ < bufferLast_) 68 | ++current_; 69 | else if (!eof_) { 70 | count_ += readCount_; 71 | readCount_ = fread(buffer_, 1, bufferSize_, fp_); 72 | bufferLast_ = buffer_ + readCount_ - 1; 73 | current_ = buffer_; 74 | 75 | if (readCount_ < bufferSize_) { 76 | buffer_[readCount_] = '\0'; 77 | ++bufferLast_; 78 | eof_ = true; 79 | } 80 | } 81 | } 82 | 83 | std::FILE* fp_; 84 | Ch *buffer_; 85 | size_t bufferSize_; 86 | Ch *bufferLast_; 87 | Ch *current_; 88 | size_t readCount_; 89 | size_t count_; //!< Number of characters read 90 | bool eof_; 91 | }; 92 | 93 | RAPIDJSON_NAMESPACE_END 94 | 95 | #ifdef __clang__ 96 | RAPIDJSON_DIAG_POP 97 | #endif 98 | 99 | #endif // RAPIDJSON_FILESTREAM_H_ 100 | -------------------------------------------------------------------------------- /clibalgserver/rapidjson/filewritestream.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_FILEWRITESTREAM_H_ 16 | #define RAPIDJSON_FILEWRITESTREAM_H_ 17 | 18 | #include "stream.h" 19 | #include 20 | 21 | #ifdef __clang__ 22 | RAPIDJSON_DIAG_PUSH 23 | RAPIDJSON_DIAG_OFF(unreachable-code) 24 | #endif 25 | 26 | RAPIDJSON_NAMESPACE_BEGIN 27 | 28 | //! Wrapper of C file stream for input using fread(). 29 | /*! 30 | \note implements Stream concept 31 | */ 32 | class FileWriteStream { 33 | public: 34 | typedef char Ch; //!< Character type. Only support char. 35 | 36 | FileWriteStream(std::FILE* fp, char* buffer, size_t bufferSize) : fp_(fp), buffer_(buffer), bufferEnd_(buffer + bufferSize), current_(buffer_) { 37 | RAPIDJSON_ASSERT(fp_ != 0); 38 | } 39 | 40 | void Put(char c) { 41 | if (current_ >= bufferEnd_) 42 | Flush(); 43 | 44 | *current_++ = c; 45 | } 46 | 47 | void PutN(char c, size_t n) { 48 | size_t avail = static_cast(bufferEnd_ - current_); 49 | while (n > avail) { 50 | std::memset(current_, c, avail); 51 | current_ += avail; 52 | Flush(); 53 | n -= avail; 54 | avail = static_cast(bufferEnd_ - current_); 55 | } 56 | 57 | if (n > 0) { 58 | std::memset(current_, c, n); 59 | current_ += n; 60 | } 61 | } 62 | 63 | void Flush() { 64 | if (current_ != buffer_) { 65 | size_t result = fwrite(buffer_, 1, static_cast(current_ - buffer_), fp_); 66 | if (result < static_cast(current_ - buffer_)) { 67 | // failure deliberately ignored at this time 68 | // added to avoid warn_unused_result build errors 69 | } 70 | current_ = buffer_; 71 | } 72 | } 73 | 74 | // Not implemented 75 | char Peek() const { RAPIDJSON_ASSERT(false); return 0; } 76 | char Take() { RAPIDJSON_ASSERT(false); return 0; } 77 | size_t Tell() const { RAPIDJSON_ASSERT(false); return 0; } 78 | char* PutBegin() { RAPIDJSON_ASSERT(false); return 0; } 79 | size_t PutEnd(char*) { RAPIDJSON_ASSERT(false); return 0; } 80 | 81 | private: 82 | // Prohibit copy constructor & assignment operator. 83 | FileWriteStream(const FileWriteStream&); 84 | FileWriteStream& operator=(const FileWriteStream&); 85 | 86 | std::FILE* fp_; 87 | char *buffer_; 88 | char *bufferEnd_; 89 | char *current_; 90 | }; 91 | 92 | //! Implement specialized version of PutN() with memset() for better performance. 93 | template<> 94 | inline void PutN(FileWriteStream& stream, char c, size_t n) { 95 | stream.PutN(c, n); 96 | } 97 | 98 | RAPIDJSON_NAMESPACE_END 99 | 100 | #ifdef __clang__ 101 | RAPIDJSON_DIAG_POP 102 | #endif 103 | 104 | #endif // RAPIDJSON_FILESTREAM_H_ 105 | -------------------------------------------------------------------------------- /clibalgserver/rapidjson/internal/ieee754.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_IEEE754_ 16 | #define RAPIDJSON_IEEE754_ 17 | 18 | #include "../rapidjson.h" 19 | 20 | RAPIDJSON_NAMESPACE_BEGIN 21 | namespace internal { 22 | 23 | class Double { 24 | public: 25 | Double() {} 26 | Double(double d) : d_(d) {} 27 | Double(uint64_t u) : u_(u) {} 28 | 29 | double Value() const { return d_; } 30 | uint64_t Uint64Value() const { return u_; } 31 | 32 | double NextPositiveDouble() const { 33 | RAPIDJSON_ASSERT(!Sign()); 34 | return Double(u_ + 1).Value(); 35 | } 36 | 37 | bool Sign() const { return (u_ & kSignMask) != 0; } 38 | uint64_t Significand() const { return u_ & kSignificandMask; } 39 | int Exponent() const { return static_cast(((u_ & kExponentMask) >> kSignificandSize) - kExponentBias); } 40 | 41 | bool IsNan() const { return (u_ & kExponentMask) == kExponentMask && Significand() != 0; } 42 | bool IsInf() const { return (u_ & kExponentMask) == kExponentMask && Significand() == 0; } 43 | bool IsNanOrInf() const { return (u_ & kExponentMask) == kExponentMask; } 44 | bool IsNormal() const { return (u_ & kExponentMask) != 0 || Significand() == 0; } 45 | bool IsZero() const { return (u_ & (kExponentMask | kSignificandMask)) == 0; } 46 | 47 | uint64_t IntegerSignificand() const { return IsNormal() ? Significand() | kHiddenBit : Significand(); } 48 | int IntegerExponent() const { return (IsNormal() ? Exponent() : kDenormalExponent) - kSignificandSize; } 49 | uint64_t ToBias() const { return (u_ & kSignMask) ? ~u_ + 1 : u_ | kSignMask; } 50 | 51 | static unsigned EffectiveSignificandSize(int order) { 52 | if (order >= -1021) 53 | return 53; 54 | else if (order <= -1074) 55 | return 0; 56 | else 57 | return static_cast(order) + 1074; 58 | } 59 | 60 | private: 61 | static const int kSignificandSize = 52; 62 | static const int kExponentBias = 0x3FF; 63 | static const int kDenormalExponent = 1 - kExponentBias; 64 | static const uint64_t kSignMask = RAPIDJSON_UINT64_C2(0x80000000, 0x00000000); 65 | static const uint64_t kExponentMask = RAPIDJSON_UINT64_C2(0x7FF00000, 0x00000000); 66 | static const uint64_t kSignificandMask = RAPIDJSON_UINT64_C2(0x000FFFFF, 0xFFFFFFFF); 67 | static const uint64_t kHiddenBit = RAPIDJSON_UINT64_C2(0x00100000, 0x00000000); 68 | 69 | union { 70 | double d_; 71 | uint64_t u_; 72 | }; 73 | }; 74 | 75 | } // namespace internal 76 | RAPIDJSON_NAMESPACE_END 77 | 78 | #endif // RAPIDJSON_IEEE754_ 79 | -------------------------------------------------------------------------------- /clibalgserver/rapidjson/internal/strfunc.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_INTERNAL_STRFUNC_H_ 16 | #define RAPIDJSON_INTERNAL_STRFUNC_H_ 17 | 18 | #include "../stream.h" 19 | 20 | RAPIDJSON_NAMESPACE_BEGIN 21 | namespace internal { 22 | 23 | //! Custom strlen() which works on different character types. 24 | /*! \tparam Ch Character type (e.g. char, wchar_t, short) 25 | \param s Null-terminated input string. 26 | \return Number of characters in the string. 27 | \note This has the same semantics as strlen(), the return value is not number of Unicode codepoints. 28 | */ 29 | template 30 | inline SizeType StrLen(const Ch* s) { 31 | const Ch* p = s; 32 | while (*p) ++p; 33 | return SizeType(p - s); 34 | } 35 | 36 | //! Returns number of code points in a encoded string. 37 | template 38 | bool CountStringCodePoint(const typename Encoding::Ch* s, SizeType length, SizeType* outCount) { 39 | GenericStringStream is(s); 40 | const typename Encoding::Ch* end = s + length; 41 | SizeType count = 0; 42 | while (is.src_ < end) { 43 | unsigned codepoint; 44 | if (!Encoding::Decode(is, &codepoint)) 45 | return false; 46 | count++; 47 | } 48 | *outCount = count; 49 | return true; 50 | } 51 | 52 | } // namespace internal 53 | RAPIDJSON_NAMESPACE_END 54 | 55 | #endif // RAPIDJSON_INTERNAL_STRFUNC_H_ 56 | -------------------------------------------------------------------------------- /clibalgserver/rapidjson/internal/swap.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_INTERNAL_SWAP_H_ 16 | #define RAPIDJSON_INTERNAL_SWAP_H_ 17 | 18 | #include "../rapidjson.h" 19 | 20 | #if defined(__clang__) 21 | RAPIDJSON_DIAG_PUSH 22 | RAPIDJSON_DIAG_OFF(c++98-compat) 23 | #endif 24 | 25 | RAPIDJSON_NAMESPACE_BEGIN 26 | namespace internal { 27 | 28 | //! Custom swap() to avoid dependency on C++ header 29 | /*! \tparam T Type of the arguments to swap, should be instantiated with primitive C++ types only. 30 | \note This has the same semantics as std::swap(). 31 | */ 32 | template 33 | inline void Swap(T& a, T& b) RAPIDJSON_NOEXCEPT { 34 | T tmp = a; 35 | a = b; 36 | b = tmp; 37 | } 38 | 39 | } // namespace internal 40 | RAPIDJSON_NAMESPACE_END 41 | 42 | #if defined(__clang__) 43 | RAPIDJSON_DIAG_POP 44 | #endif 45 | 46 | #endif // RAPIDJSON_INTERNAL_SWAP_H_ 47 | -------------------------------------------------------------------------------- /clibalgserver/rapidjson/memorybuffer.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_MEMORYBUFFER_H_ 16 | #define RAPIDJSON_MEMORYBUFFER_H_ 17 | 18 | #include "stream.h" 19 | #include "internal/stack.h" 20 | 21 | RAPIDJSON_NAMESPACE_BEGIN 22 | 23 | //! Represents an in-memory output byte stream. 24 | /*! 25 | This class is mainly for being wrapped by EncodedOutputStream or AutoUTFOutputStream. 26 | 27 | It is similar to FileWriteBuffer but the destination is an in-memory buffer instead of a file. 28 | 29 | Differences between MemoryBuffer and StringBuffer: 30 | 1. StringBuffer has Encoding but MemoryBuffer is only a byte buffer. 31 | 2. StringBuffer::GetString() returns a null-terminated string. MemoryBuffer::GetBuffer() returns a buffer without terminator. 32 | 33 | \tparam Allocator type for allocating memory buffer. 34 | \note implements Stream concept 35 | */ 36 | template 37 | struct GenericMemoryBuffer { 38 | typedef char Ch; // byte 39 | 40 | GenericMemoryBuffer(Allocator* allocator = 0, size_t capacity = kDefaultCapacity) : stack_(allocator, capacity) {} 41 | 42 | void Put(Ch c) { *stack_.template Push() = c; } 43 | void Flush() {} 44 | 45 | void Clear() { stack_.Clear(); } 46 | void ShrinkToFit() { stack_.ShrinkToFit(); } 47 | Ch* Push(size_t count) { return stack_.template Push(count); } 48 | void Pop(size_t count) { stack_.template Pop(count); } 49 | 50 | const Ch* GetBuffer() const { 51 | return stack_.template Bottom(); 52 | } 53 | 54 | size_t GetSize() const { return stack_.GetSize(); } 55 | 56 | static const size_t kDefaultCapacity = 256; 57 | mutable internal::Stack stack_; 58 | }; 59 | 60 | typedef GenericMemoryBuffer<> MemoryBuffer; 61 | 62 | //! Implement specialized version of PutN() with memset() for better performance. 63 | template<> 64 | inline void PutN(MemoryBuffer& memoryBuffer, char c, size_t n) { 65 | std::memset(memoryBuffer.stack_.Push(n), c, n * sizeof(c)); 66 | } 67 | 68 | RAPIDJSON_NAMESPACE_END 69 | 70 | #endif // RAPIDJSON_MEMORYBUFFER_H_ 71 | -------------------------------------------------------------------------------- /clibalgserver/rapidjson/memorystream.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_MEMORYSTREAM_H_ 16 | #define RAPIDJSON_MEMORYSTREAM_H_ 17 | 18 | #include "stream.h" 19 | 20 | #ifdef __clang__ 21 | RAPIDJSON_DIAG_PUSH 22 | RAPIDJSON_DIAG_OFF(unreachable-code) 23 | RAPIDJSON_DIAG_OFF(missing-noreturn) 24 | #endif 25 | 26 | RAPIDJSON_NAMESPACE_BEGIN 27 | 28 | //! Represents an in-memory input byte stream. 29 | /*! 30 | This class is mainly for being wrapped by EncodedInputStream or AutoUTFInputStream. 31 | 32 | It is similar to FileReadBuffer but the source is an in-memory buffer instead of a file. 33 | 34 | Differences between MemoryStream and StringStream: 35 | 1. StringStream has encoding but MemoryStream is a byte stream. 36 | 2. MemoryStream needs size of the source buffer and the buffer don't need to be null terminated. StringStream assume null-terminated string as source. 37 | 3. MemoryStream supports Peek4() for encoding detection. StringStream is specified with an encoding so it should not have Peek4(). 38 | \note implements Stream concept 39 | */ 40 | struct MemoryStream { 41 | typedef char Ch; // byte 42 | 43 | MemoryStream(const Ch *src, size_t size) : src_(src), begin_(src), end_(src + size), size_(size) {} 44 | 45 | Ch Peek() const { return RAPIDJSON_UNLIKELY(src_ == end_) ? '\0' : *src_; } 46 | Ch Take() { return RAPIDJSON_UNLIKELY(src_ == end_) ? '\0' : *src_++; } 47 | size_t Tell() const { return static_cast(src_ - begin_); } 48 | 49 | Ch* PutBegin() { RAPIDJSON_ASSERT(false); return 0; } 50 | void Put(Ch) { RAPIDJSON_ASSERT(false); } 51 | void Flush() { RAPIDJSON_ASSERT(false); } 52 | size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; } 53 | 54 | // For encoding detection only. 55 | const Ch* Peek4() const { 56 | return Tell() + 4 <= size_ ? src_ : 0; 57 | } 58 | 59 | const Ch* src_; //!< Current read position. 60 | const Ch* begin_; //!< Original head of the string. 61 | const Ch* end_; //!< End of stream. 62 | size_t size_; //!< Size of the stream. 63 | }; 64 | 65 | RAPIDJSON_NAMESPACE_END 66 | 67 | #ifdef __clang__ 68 | RAPIDJSON_DIAG_POP 69 | #endif 70 | 71 | #endif // RAPIDJSON_MEMORYBUFFER_H_ 72 | -------------------------------------------------------------------------------- /clibalgserver/rapidjson/ostreamwrapper.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_OSTREAMWRAPPER_H_ 16 | #define RAPIDJSON_OSTREAMWRAPPER_H_ 17 | 18 | #include "stream.h" 19 | #include 20 | 21 | #ifdef __clang__ 22 | RAPIDJSON_DIAG_PUSH 23 | RAPIDJSON_DIAG_OFF(padded) 24 | #endif 25 | 26 | RAPIDJSON_NAMESPACE_BEGIN 27 | 28 | //! Wrapper of \c std::basic_ostream into RapidJSON's Stream concept. 29 | /*! 30 | The classes can be wrapped including but not limited to: 31 | 32 | - \c std::ostringstream 33 | - \c std::stringstream 34 | - \c std::wpstringstream 35 | - \c std::wstringstream 36 | - \c std::ifstream 37 | - \c std::fstream 38 | - \c std::wofstream 39 | - \c std::wfstream 40 | 41 | \tparam StreamType Class derived from \c std::basic_ostream. 42 | */ 43 | 44 | template 45 | class BasicOStreamWrapper { 46 | public: 47 | typedef typename StreamType::char_type Ch; 48 | BasicOStreamWrapper(StreamType& stream) : stream_(stream) {} 49 | 50 | void Put(Ch c) { 51 | stream_.put(c); 52 | } 53 | 54 | void Flush() { 55 | stream_.flush(); 56 | } 57 | 58 | // Not implemented 59 | char Peek() const { RAPIDJSON_ASSERT(false); return 0; } 60 | char Take() { RAPIDJSON_ASSERT(false); return 0; } 61 | size_t Tell() const { RAPIDJSON_ASSERT(false); return 0; } 62 | char* PutBegin() { RAPIDJSON_ASSERT(false); return 0; } 63 | size_t PutEnd(char*) { RAPIDJSON_ASSERT(false); return 0; } 64 | 65 | private: 66 | BasicOStreamWrapper(const BasicOStreamWrapper&); 67 | BasicOStreamWrapper& operator=(const BasicOStreamWrapper&); 68 | 69 | StreamType& stream_; 70 | }; 71 | 72 | typedef BasicOStreamWrapper OStreamWrapper; 73 | typedef BasicOStreamWrapper WOStreamWrapper; 74 | 75 | #ifdef __clang__ 76 | RAPIDJSON_DIAG_POP 77 | #endif 78 | 79 | RAPIDJSON_NAMESPACE_END 80 | 81 | #endif // RAPIDJSON_OSTREAMWRAPPER_H_ 82 | -------------------------------------------------------------------------------- /clibalgserver/server/ace/ext-error_marker.js: -------------------------------------------------------------------------------- 1 | ; (function() { 2 | window.require(["ace/ext/error_marker"], function(m) { 3 | if (typeof module == "object" && typeof exports == "object" && module) { 4 | module.exports = m; 5 | } 6 | }); 7 | })(); 8 | -------------------------------------------------------------------------------- /clibalgserver/server/ace/ext-keybinding_menu.js: -------------------------------------------------------------------------------- 1 | define("ace/ext/menu_tools/overlay_page",["require","exports","module","ace/lib/dom"],function(e,t,n){"use strict";var r=e("../../lib/dom"),i="#ace_settingsmenu, #kbshortcutmenu {background-color: #F7F7F7;color: black;box-shadow: -5px 4px 5px rgba(126, 126, 126, 0.55);padding: 1em 0.5em 2em 1em;overflow: auto;position: absolute;margin: 0;bottom: 0;right: 0;top: 0;z-index: 9991;cursor: default;}.ace_dark #ace_settingsmenu, .ace_dark #kbshortcutmenu {box-shadow: -20px 10px 25px rgba(126, 126, 126, 0.25);background-color: rgba(255, 255, 255, 0.6);color: black;}.ace_optionsMenuEntry:hover {background-color: rgba(100, 100, 100, 0.1);transition: all 0.3s}.ace_closeButton {background: rgba(245, 146, 146, 0.5);border: 1px solid #F48A8A;border-radius: 50%;padding: 7px;position: absolute;right: -8px;top: -8px;z-index: 100000;}.ace_closeButton{background: rgba(245, 146, 146, 0.9);}.ace_optionsMenuKey {color: darkslateblue;font-weight: bold;}.ace_optionsMenuCommand {color: darkcyan;font-weight: normal;}.ace_optionsMenuEntry input, .ace_optionsMenuEntry button {vertical-align: middle;}.ace_optionsMenuEntry button[ace_selected_button=true] {background: #e7e7e7;box-shadow: 1px 0px 2px 0px #adadad inset;border-color: #adadad;}.ace_optionsMenuEntry button {background: white;border: 1px solid lightgray;margin: 0px;}.ace_optionsMenuEntry button:hover{background: #f0f0f0;}";r.importCssString(i),n.exports.overlayPage=function(t,n,r){function s(e){e.keyCode===27&&o()}function o(){if(!i)return;document.removeEventListener("keydown",s),i.parentNode.removeChild(i),t.focus(),i=null,r&&r()}var i=document.createElement("div");return i.style.cssText="margin: 0; padding: 0; position: fixed; top:0; bottom:0; left:0; right:0;z-index: 9990; background-color: rgba(0, 0, 0, 0.3);",i.addEventListener("click",function(){o()}),document.addEventListener("keydown",s),n.addEventListener("click",function(e){e.stopPropagation()}),i.appendChild(n),document.body.appendChild(i),t.blur(),{close:o}}}),define("ace/ext/menu_tools/get_editor_keyboard_shortcuts",["require","exports","module","ace/lib/keys"],function(e,t,n){"use strict";var r=e("../../lib/keys");n.exports.getEditorKeybordShortcuts=function(e){var t=r.KEY_MODS,n=[],i={};return e.keyBinding.$handlers.forEach(function(e){var t=e.commandKeyBinding;for(var r in t){var s=r.replace(/(^|-)\w/g,function(e){return e.toUpperCase()}),o=t[r];Array.isArray(o)||(o=[o]),o.forEach(function(e){typeof e!="string"&&(e=e.name),i[e]?i[e].key+="|"+s:(i[e]={key:s,command:e},n.push(i[e]))})}}),n}}),define("ace/ext/keybinding_menu",["require","exports","module","ace/editor","ace/ext/menu_tools/overlay_page","ace/ext/menu_tools/get_editor_keyboard_shortcuts"],function(e,t,n){"use strict";function i(t){if(!document.getElementById("kbshortcutmenu")){var n=e("./menu_tools/overlay_page").overlayPage,r=e("./menu_tools/get_editor_keyboard_shortcuts").getEditorKeybordShortcuts,i=r(t),s=document.createElement("div"),o=i.reduce(function(e,t){return e+'
'+t.command+" : "+''+t.key+"
"},"");s.id="kbshortcutmenu",s.innerHTML="

Keyboard Shortcuts

"+o+"",n(t,s)}}var r=e("../editor").Editor;n.exports.init=function(e){r.prototype.showKeyboardShortcuts=function(){i(this)},e.commands.addCommands([{name:"showKeyboardShortcuts",bindKey:{win:"Ctrl-Alt-h",mac:"Command-Alt-h"},exec:function(e,t){e.showKeyboardShortcuts()}}])}}); (function() { 2 | window.require(["ace/ext/keybinding_menu"], function(m) { 3 | if (typeof module == "object" && typeof exports == "object" && module) { 4 | module.exports = m; 5 | } 6 | }); 7 | })(); 8 | -------------------------------------------------------------------------------- /clibalgserver/server/ace/ext-linking.js: -------------------------------------------------------------------------------- 1 | define("ace/ext/linking",["require","exports","module","ace/editor","ace/config"],function(e,t,n){function i(e){var n=e.editor,r=e.getAccelKey();if(r){var n=e.editor,i=e.getDocumentPosition(),s=n.session,o=s.getTokenAt(i.row,i.column);t.previousLinkingHover&&t.previousLinkingHover!=o&&n._emit("linkHoverOut"),n._emit("linkHover",{position:i,token:o}),t.previousLinkingHover=o}else t.previousLinkingHover&&(n._emit("linkHoverOut"),t.previousLinkingHover=!1)}function s(e){var t=e.getAccelKey(),n=e.getButton();if(n==0&&t){var r=e.editor,i=e.getDocumentPosition(),s=r.session,o=s.getTokenAt(i.row,i.column);r._emit("linkClick",{position:i,token:o})}}var r=e("../editor").Editor;e("../config").defineOptions(r.prototype,"editor",{enableLinking:{set:function(e){e?(this.on("click",s),this.on("mousemove",i)):(this.off("click",s),this.off("mousemove",i))},value:!1}}),t.previousLinkingHover=!1}); (function() { 2 | window.require(["ace/ext/linking"], function(m) { 3 | if (typeof module == "object" && typeof exports == "object" && module) { 4 | module.exports = m; 5 | } 6 | }); 7 | })(); 8 | -------------------------------------------------------------------------------- /clibalgserver/server/ace/ext-rtl.js: -------------------------------------------------------------------------------- 1 | define("ace/ext/rtl",["require","exports","module","ace/editor","ace/config"],function(e,t,n){"use strict";function s(e,t){var n=t.getSelection().lead;t.session.$bidiHandler.isRtlLine(n.row)&&n.column===0&&(t.session.$bidiHandler.isMoveLeftOperation&&n.row>0?t.getSelection().moveCursorTo(n.row-1,t.session.getLine(n.row-1).length):t.getSelection().isEmpty()?n.column+=1:n.setPosition(n.row,n.column+1))}function o(e){e.editor.session.$bidiHandler.isMoveLeftOperation=/gotoleft|selectleft|backspace|removewordleft/.test(e.command.name)}function u(e,t){var n=t.session;n.$bidiHandler.currentRow=null;if(n.$bidiHandler.isRtlLine(e.start.row)&&e.action==="insert"&&e.lines.length>1)for(var r=e.start.row;r0&&!(s%l)&&!(f%l)&&(r[l]=(r[l]||0)+1),n[f]=(n[f]||0)+1}s=f}while(up.score&&(p={score:v,length:u})}if(p.score&&p.score>1.4)var m=p.length;if(i>d+1){if(m==1||di+1)return{ch:" ",length:m}},t.detectIndentation=function(e){var n=e.getLines(0,1e3),r=t.$detectIndentation(n)||{};return r.ch&&e.setUseSoftTabs(r.ch==" "),r.length&&e.setTabSize(r.length),r},t.trimTrailingSpace=function(e,t){var n=e.getDocument(),r=n.getAllLines(),i=t&&t.trimEmpty?-1:0,s=[],o=-1;t&&t.keepCursorPosition&&(e.selection.rangeCount?e.selection.rangeList.ranges.forEach(function(e,t,n){var r=n[t+1];if(r&&r.cursor.row==e.cursor.row)return;s.push(e.cursor)}):s.push(e.selection.getCursor()),o=0);var u=s[o]&&s[o].row;for(var a=0,f=r.length;ai&&(c=s[o].column),o++,u=s[o]?s[o].row:-1),c>i&&n.removeInLine(a,c,l.length)}},t.convertIndentation=function(e,t,n){var i=e.getTabString()[0],s=e.getTabSize();n||(n=s),t||(t=i);var o=t==" "?t:r.stringRepeat(t,n),u=e.doc,a=u.getAllLines(),f={},l={};for(var c=0,h=a.length;cdiv{position:absolute;width:1000000px;height:1000000px;left:0;top:0}.chartjs-size-monitor-shrink>div{position:absolute;width:200%;height:200%;left:0;top:0} -------------------------------------------------------------------------------- /clibalgserver/server/example/backtrace/n-queen.cpp: -------------------------------------------------------------------------------- 1 | #include "/include/io" 2 | #include "/include/trace" 3 | #include "/include/format" 4 | int L; 5 | int pt(int x, int y) { 6 | return x * L + y; 7 | } 8 | void output(char* text) { 9 | trace_log(text); 10 | free(text); 11 | } 12 | int dir[0] = {0, 1, 0, -1, 1, 0, -1, 0}; 13 | int suc = 0; 14 | int a[20],b[40],c[40];//ai是竖列,b、c 是对角线 15 | int dfs(char* map, int n, int k) { 16 | if (n == k - 1) { 17 | ++suc; 18 | output(format("发现第%d个解", suc)); 19 | trace_delay(1); 20 | return 1; 21 | } 22 | int i; 23 | for (i = 0; i < n; i++){ 24 | if (a[i]) continue; 25 | if (b[i-k+n]) continue; 26 | if (c[i+k-1]) continue; 27 | a[i] = b[i-k+n] = c[i+k-1] = 1; 28 | map[pt(k - 1, i)] = 'O'; 29 | dfs(map, n, k+1); 30 | map[pt(k - 1, i)] = ' '; 31 | a[i] = b[i-k+n] = c[i+k-1] = 0; 32 | } 33 | return 0; 34 | } 35 | int main(int argc, char** argv) { 36 | int n = 8, i, j; 37 | L = n; 38 | char* map = malloc(n * n * sizeof(char)); 39 | output(format("%d皇后问题", n)); 40 | trace_array_2d("棋盘", map, T_CHAR, n, n); 41 | trace_log("初始化棋盘"); 42 | for (i = 0; i < n; i++) { 43 | trace_rapid(1); 44 | for (j = 0; j < n; j++) 45 | map[pt(i, j)] = ' '; 46 | trace_rapid(0); 47 | } 48 | trace_rapid(1); 49 | dfs(map, n, 1); 50 | trace_rapid(0); 51 | if (suc > 0) 52 | trace_log("成功"); 53 | else 54 | trace_log("失败"); 55 | trace_end("棋盘"); 56 | } -------------------------------------------------------------------------------- /clibalgserver/server/example/dp/edit.cpp: -------------------------------------------------------------------------------- 1 | #include "/include/io" 2 | #include "/include/math" 3 | #include "/include/format" 4 | #include "/include/trace" 5 | void output(char* text) { 6 | trace_log(text); 7 | free(text); 8 | } 9 | void select(char* s, int n) { 10 | trace_rapid(1); 11 | int i; 12 | for (i = 0; i < n; i++) { 13 | s[i] = s[i]; 14 | } 15 | trace_rapid(0); 16 | } 17 | void select_(int* arr, int na, int nb) { 18 | trace_rapid(1); 19 | int i; 20 | for (i = 0; i < na; i++) { 21 | arr[i * nb] = i; 22 | } 23 | for (i = 1; i < nb; i++) { 24 | arr[i] = i; 25 | } 26 | trace_rapid(0); 27 | } 28 | void idle_(char* a) { 29 | *a = *a; 30 | } 31 | void idle3(char* a, char* b, char* c) { 32 | trace_rapid(1); 33 | *a = *a; 34 | *b = *b; 35 | *c = *c; 36 | trace_rapid(0); 37 | } 38 | void idle(char* a, char* b) { 39 | trace_rapid(1); 40 | *a = *a; 41 | *b = *b; 42 | trace_rapid(0); 43 | } 44 | int min(int a, int b) { 45 | return a < b ? a : b; 46 | } 47 | int main(int argc, char** argv) { 48 | int i, j; 49 | char* a = "racket"; int na = strlen(a) + 1; 50 | char* b = "stack";int nb = strlen(b) + 1; 51 | int* dp = malloc(na * nb * sizeof(int)); 52 | memset(dp, 0, na * nb * sizeof(int)); 53 | trace_log("编辑距离"); 54 | trace_array_1d("串A", a, T_CHAR, na - 1); 55 | trace_array_1d("串B", b, T_CHAR, nb - 1); 56 | trace_array_2d("DP", dp, T_INT, na, nb); 57 | select(a, na - 1); 58 | select(b, nb - 1); 59 | select_(dp, na, nb); 60 | for (i = 1; i < na; i++) { 61 | for (j = 1; j < nb; j++) { 62 | idle(&(a[i - 1]), &(b[j - 1])); 63 | if (a[i - 1] == b[j - 1]) { 64 | idle_(&(dp[(i-1) * nb + j-1])); 65 | dp[i * nb + j] = dp[(i-1) * nb + j-1]; 66 | } 67 | else { 68 | idle3(&(dp[(i-1) * nb + j]), &(dp[(i) * nb + j-1]), &(dp[(i-1) * nb + j-1])); 69 | dp[i * nb + j] = min(min(dp[(i-1) * nb + j], dp[(i) * nb + j-1]), dp[(i-1) * nb + j-1]) + 1; 70 | } 71 | } 72 | } 73 | output(format("答案为:%d", dp[na * nb - 1])); 74 | trace_end("串A"); 75 | trace_end("串B"); 76 | trace_end("DP"); 77 | free(dp); 78 | } -------------------------------------------------------------------------------- /clibalgserver/server/example/dp/lcs.cpp: -------------------------------------------------------------------------------- 1 | #include "/include/io" 2 | #include "/include/math" 3 | #include "/include/format" 4 | #include "/include/trace" 5 | void output(char* text) { 6 | trace_log(text); 7 | free(text); 8 | } 9 | void select(char* s, int n) { 10 | trace_rapid(1); 11 | int i; 12 | for (i = 0; i < n; i++) { 13 | s[i] = s[i]; 14 | } 15 | trace_rapid(0); 16 | } 17 | void select_(int* arr, int na, int nb) { 18 | trace_rapid(1); 19 | int i; 20 | for (i = 0; i < na; i++) { 21 | arr[i * nb] = arr[i * nb]; 22 | } 23 | for (i = 1; i < nb; i++) { 24 | arr[i] = arr[i]; 25 | } 26 | trace_rapid(0); 27 | } 28 | void idle_(char* a) { 29 | *a = *a; 30 | } 31 | void idle(char* a, char* b) { 32 | trace_rapid(1); 33 | *a = *a; 34 | *b = *b; 35 | trace_rapid(0); 36 | } 37 | int max(int a, int b) { 38 | return a > b ? a : b; 39 | } 40 | int main(int argc, char** argv) { 41 | int i, j; 42 | char* a = "BDCABA"; int na = strlen(a) + 1; 43 | char* b = "ABCBDAB";int nb = strlen(b) + 1; 44 | int* dp = malloc(na * nb * sizeof(int)); 45 | memset(dp, 0, na * nb * sizeof(int)); 46 | trace_log("最长公共子序列"); 47 | trace_array_1d("串A", a, T_CHAR, na - 1); 48 | trace_array_1d("串B", b, T_CHAR, nb - 1); 49 | trace_array_2d("DP", dp, T_INT, na, nb); 50 | select(a, na - 1); 51 | select(b, nb - 1); 52 | select_(dp, na, nb); 53 | for (i = 1; i < na; i++) { 54 | for (j = 1; j < nb; j++) { 55 | idle(&(a[i - 1]), &(b[j - 1])); 56 | if (a[i - 1] == b[j - 1]) { 57 | idle_(&(dp[(i-1) * nb + j-1])); 58 | dp[i * nb + j] = dp[(i-1) * nb + j-1]+1; 59 | } 60 | else { 61 | idle(&(dp[(i-1) * nb + j]), &(dp[(i) * nb + j-1])); 62 | dp[i * nb + j] = max(dp[(i-1) * nb + j], dp[(i) * nb + j-1]); 63 | } 64 | } 65 | } 66 | output(format("答案为:%d", dp[na * nb - 1])); 67 | trace_end("串A"); 68 | trace_end("串B"); 69 | trace_end("DP"); 70 | free(dp); 71 | } -------------------------------------------------------------------------------- /clibalgserver/server/example/graph/bfs.cpp: -------------------------------------------------------------------------------- 1 | #include "/include/io" 2 | #include "/include/math" 3 | #include "/include/trace" 4 | #include "/include/format" 5 | struct point { 6 | int x, y; 7 | }; 8 | point new_pt(int x, int y) { 9 | point pt; 10 | pt.x = x; 11 | pt.y = y; 12 | return pt; 13 | } 14 | int L; 15 | int pt(int x, int y) { 16 | return x * L + y; 17 | } 18 | void output(char* text) { 19 | trace_log(text); 20 | free(text); 21 | } 22 | int dir[0] = {0, 1, 0, -1, 1, 0, -1, 0}; 23 | int suc = 0; 24 | void bfs(char* map, int m, int n, int sx, int sy, int ex, int ey) { 25 | point* queue = malloc(m * n * sizeof(point)); 26 | int front = 0, rear = 0, i; 27 | queue[rear++] = new_pt(sx, sy); 28 | while (front < rear) { 29 | output(format("队列:头=%d,尾=%d", front, rear)); 30 | point p = queue[front++]; 31 | sx = p.x; sy = p.y; 32 | if (sx == ex && sy == ey) { 33 | output(format("到达终点:(%d,%d)", sx, sy)); 34 | suc = true; 35 | break; 36 | } 37 | if (map[pt(sx, sy)] != 'S' && map[pt(sx, sy)] != ' ') 38 | continue; 39 | if (map[pt(sx, sy)] == ' ') 40 | map[pt(sx, sy)] = '*'; 41 | output(format("遍历:(%d,%d)", sx, sy)); 42 | for (i = 0; i < 4; i++) { 43 | int x = sx + dir[i * 2]; 44 | int y = sy + dir[i * 2 + 1]; 45 | if (map[pt(x, y)] == ' ' || map[pt(x, y)] == 'E') { 46 | queue[rear++] = new_pt(x, y); 47 | } 48 | } 49 | } 50 | } 51 | int main(int argc, char** argv) { 52 | int m = 8, n = 8, i, j; 53 | int sx = 1, sy = 1, ex = m, ey = n; 54 | int rands = m * n / 4; 55 | char* map = malloc((m + 2) * (n + 2) * sizeof(char)); 56 | L = n + 2; 57 | trace_log("宽度优先搜索"); 58 | trace_array_2d("图表", map, T_CHAR, m + 2, n + 2); 59 | trace_log("造墙中"); 60 | for (i = 1; i <= m; i++) { 61 | trace_rapid(1); 62 | for (j = 1; j <= n; j++) 63 | map[pt(i, j)] = ' '; 64 | trace_rapid(0); 65 | } 66 | trace_rapid(1); 67 | for (i = 0; i < m + 2; i++) 68 | map[pt(i, 0)] = map[pt(i, n + 1)] = 'X'; 69 | for (j = 0; j < n + 2; j++) 70 | map[pt(0, j)] = map[pt(m + 1, j)] = 'X'; 71 | trace_rapid(0); 72 | trace_log("设置起点"); 73 | map[pt(sx, sy)] = 'S'; 74 | trace_log("设置终点"); 75 | map[pt(ex, ey)] = 'E'; 76 | trace_log("造障碍物"); 77 | for (i = 0; i < rands;) { 78 | int x = rand() % m + 1; 79 | int y = rand() % n + 1; 80 | if (map[pt(x, y)] == ' ') { 81 | map[pt(x, y)] = 'O'; 82 | i++; 83 | } 84 | } 85 | bfs(map, m, n, sx, sy, ex, ey); 86 | if (suc) 87 | trace_log("成功"); 88 | else 89 | trace_log("失败"); 90 | trace_end("图表"); 91 | } -------------------------------------------------------------------------------- /clibalgserver/server/example/graph/dfs.cpp: -------------------------------------------------------------------------------- 1 | #include "/include/io" 2 | #include "/include/math" 3 | #include "/include/trace" 4 | #include "/include/format" 5 | int L; 6 | int pt(int x, int y) { 7 | return x * L + y; 8 | } 9 | void output(char* text) { 10 | trace_log(text); 11 | free(text); 12 | } 13 | int dir[0] = {0, 1, 0, -1, 1, 0, -1, 0}; 14 | int suc = 0; 15 | int dfs(char* map, int sx, int sy, int ex, int ey) { 16 | if (sx == ex && sy == ey) { 17 | output(format("到达终点:(%d,%d)", sx, sy)); 18 | suc = true; 19 | return 1; 20 | } 21 | if (map[pt(sx, sy)] != 'S' && map[pt(sx, sy)] != ' ') 22 | return; 23 | if (map[pt(sx, sy)] == ' ') 24 | map[pt(sx, sy)] = '*'; 25 | output(format("遍历:(%d,%d)", sx, sy)); 26 | int i; 27 | for (i = 0; i < 4; i++) { 28 | int x = sx + dir[i * 2]; 29 | int y = sy + dir[i * 2 + 1]; 30 | if (map[pt(x, y)] == ' ' || map[pt(x, y)] == 'E') { 31 | if (dfs(map, x, y, ex, ey)) return 1; 32 | } 33 | } 34 | return 0; 35 | } 36 | int main(int argc, char** argv) { 37 | int m = 8, n = 8, i, j; 38 | int sx = 1, sy = 1, ex = m, ey = n; 39 | int rands = m * n / 4; 40 | char* map = malloc((m + 2) * (n + 2) * sizeof(char)); 41 | L = n + 2; 42 | trace_log("深度优先搜索"); 43 | trace_array_2d("图表", map, T_CHAR, m + 2, n + 2); 44 | trace_log("造墙中"); 45 | for (i = 1; i <= m; i++) { 46 | trace_rapid(1); 47 | for (j = 1; j <= n; j++) 48 | map[pt(i, j)] = ' '; 49 | trace_rapid(0); 50 | } 51 | trace_rapid(1); 52 | for (i = 0; i < m + 2; i++) 53 | map[pt(i, 0)] = map[pt(i, n + 1)] = 'X'; 54 | for (j = 0; j < n + 2; j++) 55 | map[pt(0, j)] = map[pt(m + 1, j)] = 'X'; 56 | trace_rapid(0); 57 | trace_log("设置起点"); 58 | map[pt(sx, sy)] = 'S'; 59 | trace_log("设置终点"); 60 | map[pt(ex, ey)] = 'E'; 61 | trace_log("造障碍物"); 62 | for (i = 0; i < rands;) { 63 | int x = rand() % m + 1; 64 | int y = rand() % n + 1; 65 | if (map[pt(x, y)] == ' ') { 66 | map[pt(x, y)] = 'O'; 67 | i++; 68 | } 69 | } 70 | dfs(map, sx, sy, ex, ey); 71 | if (suc) 72 | trace_log("成功"); 73 | else 74 | trace_log("失败"); 75 | trace_end("图表"); 76 | } -------------------------------------------------------------------------------- /clibalgserver/server/example/graph/dijkstra.cpp: -------------------------------------------------------------------------------- 1 | #include "/include/io" 2 | #include "/include/math" 3 | #include "/include/trace" 4 | #include "/include/format" 5 | int L; 6 | int pt(int x, int y) { 7 | return x * L + y; 8 | } 9 | char* sname(int n) { 10 | char** ptr = malloc(n * sizeof(char*)); 11 | char** ret = ptr; 12 | char* str = malloc(n * 2 * sizeof(char)); 13 | int i; 14 | char* p = str; 15 | for (i = 0; i < n; i++) { 16 | *ptr++ = p; 17 | *p++ = (char)('A' + i); 18 | *p++ = '\0'; 19 | } 20 | return ret; 21 | } 22 | int INF = 999; 23 | int main(int argc, char** argv) { 24 | int n = 8, i, j, start = 0; 25 | L = n; 26 | char* name = sname(n); 27 | int* adj = malloc(n * n * sizeof(int)); 28 | trace_log("Dijkstra最短路径"); 29 | trace_array_2d("邻接矩阵", adj, T_INT, n, n); 30 | trace_graph("图", name, adj, INF, T_INT, n); 31 | trace_log("初始化"); 32 | for (i = 0; i < n; i++) { 33 | trace_rapid(1); 34 | for (j = i + 1; j < n; j++) { 35 | if (rand() % 3 == 0) 36 | adj[pt(i, j)] = adj[pt(j, i)] = rand() % n + 1; 37 | else 38 | adj[pt(i, j)] = adj[pt(j, i)] = INF; 39 | } 40 | trace_rapid(0); 41 | } 42 | int* visited = malloc(n * sizeof(int)); 43 | trace_array_1d("访问", visited, T_INT, n); 44 | trace_rapid(1); 45 | for (i = 0; i < n; i++) { 46 | visited[i] = 0; 47 | } 48 | trace_rapid(0); 49 | int* dist = malloc(n * sizeof(int)); 50 | trace_array_1d("最短距离", dist, T_INT, n); 51 | trace_rapid(1); 52 | for (i = 0; i < n; i++) { 53 | dist[i] = adj[pt(start, i)]; 54 | } 55 | trace_rapid(0); 56 | visited[start] = 1; 57 | char** nm = (char**)name; 58 | for (i = 0; i < n; i++) { 59 | if (i == start) continue; 60 | int min = INF, m; 61 | for (j = 0; j < n; j++) { 62 | if (j == start) continue; 63 | if (visited[j] == 0 && dist[j] < min) { 64 | dist[j] = dist[j]; 65 | min = dist[j]; 66 | m = j; 67 | } 68 | } 69 | if (min == INF) break; 70 | trace_log(format("访问:%s", nm[m])); 71 | visited[m] = 1; 72 | for (j = 0; j < n; j++) { 73 | if (j == m) continue; 74 | adj[pt(m, j)] = adj[pt(m, j)]; 75 | if (adj[pt(m, j)] < INF && dist[j] > dist[m] + adj[pt(m, j)]) 76 | dist[j] = dist[m] + adj[pt(m, j)]; 77 | } 78 | } 79 | for (i = 0; i < n; i++) { 80 | if (i == start) continue; 81 | trace_log(format("%s -> %s => %d", nm[start], nm[i], dist[i])); 82 | } 83 | } -------------------------------------------------------------------------------- /clibalgserver/server/example/graph/mst_prim.cpp: -------------------------------------------------------------------------------- 1 | #include "/include/io" 2 | #include "/include/math" 3 | #include "/include/trace" 4 | #include "/include/format" 5 | int L; 6 | int pt(int x, int y) { 7 | return x * L + y; 8 | } 9 | char* sname(int n) { 10 | char** ptr = malloc(n * sizeof(char*)); 11 | char** ret = ptr; 12 | char* str = malloc(n * 2 * sizeof(char)); 13 | int i; 14 | char* p = str; 15 | for (i = 0; i < n; i++) { 16 | *ptr++ = p; 17 | *p++ = (char)('A' + i); 18 | *p++ = '\0'; 19 | } 20 | return ret; 21 | } 22 | int INF = 999; 23 | int main(int argc, char** argv) { 24 | int n = 8, i, j, k, start = 0; 25 | L = n; 26 | char* name = sname(n); 27 | int* adj = malloc(n * n * sizeof(int)); 28 | trace_log("Prim最小生成树"); 29 | trace_array_2d("邻接矩阵", adj, T_INT, n, n); 30 | trace_graph("图", name, adj, INF, T_INT, n); 31 | trace_log("初始化"); 32 | for (i = 0; i < n; i++) { 33 | trace_rapid(1); 34 | for (j = i + 1; j < n; j++) { 35 | if (rand() % 3 == 0) 36 | adj[pt(i, j)] = adj[pt(j, i)] = rand() % n + 1; 37 | else 38 | adj[pt(i, j)] = adj[pt(j, i)] = INF; 39 | } 40 | trace_rapid(0); 41 | } 42 | int* visited = malloc(n * sizeof(int)); 43 | trace_array_1d("访问", visited, T_INT, n); 44 | trace_rapid(1); 45 | for (i = 0; i < n; i++) { 46 | visited[i] = 0; 47 | } 48 | trace_rapid(0); 49 | int* dist = malloc(n * sizeof(int)); 50 | trace_array_1d("连通距离", dist, T_INT, n); 51 | trace_rapid(1); 52 | for (i = 0; i < n; i++) { 53 | dist[i] = adj[pt(start, i)]; 54 | } 55 | trace_rapid(0); 56 | int* mst = malloc(2 * n * sizeof(int)); 57 | trace_array_2d("最小生成树", mst, T_INT, n - 1, 2); 58 | trace_rapid(1); 59 | for (i = 0; i < n; i++) { 60 | mst[i * 2] = mst[i * 2 + 1] = -1; 61 | } 62 | trace_rapid(0); 63 | char** nm = (char**)name; 64 | visited[start] = 1; 65 | for (i = 0, k = 0; i < n; i++) { 66 | int min = INF, m, t; 67 | for (j = 0; j < n; j++) { 68 | if (visited[j] == 0 && dist[j] < min) { 69 | dist[j] = dist[j]; 70 | min = dist[j]; 71 | m = j; 72 | } 73 | } 74 | if (min == INF) break; 75 | trace_log(format("访问:%s", nm[m])); 76 | for (j = 0; j < n; j++) { 77 | if (j == m) continue; 78 | adj[pt(m, j)] = adj[pt(m, j)]; 79 | if (adj[pt(m, j)] < INF && dist[j] > adj[pt(m, j)]) 80 | dist[j] = adj[pt(m, j)]; 81 | } 82 | min = INF; 83 | for (j = 0; j < n; j++) { 84 | if (visited[j] == 1 && adj[pt(j, m)] < INF && adj[pt(j, m)] < min) { 85 | min = adj[pt(j, m)]; 86 | t = j; 87 | } 88 | } 89 | trace_rapid(1); 90 | mst[k++] = t; mst[k++] = m; 91 | trace_rapid(0); 92 | visited[m] = 1; 93 | } 94 | trace_rapid(1); 95 | for (i = 0; i < n - 1; i++) { 96 | int idx = pt(mst[i * 2], mst[i * 2 + 1]); 97 | adj[idx] = adj[idx]; 98 | } 99 | trace_rapid(0); 100 | } -------------------------------------------------------------------------------- /clibalgserver/server/example/sort/bubble.cpp: -------------------------------------------------------------------------------- 1 | #include "/include/io" 2 | #include "/include/math" 3 | #include "/include/trace" 4 | #include "/include/xtoa_itoa" 5 | #include "/include/format" 6 | void swap(int* a, int* b) { 7 | trace_rapid(1); 8 | int tmp = *a; 9 | *a = *b; 10 | *b = tmp; 11 | trace_rapid(0); 12 | } 13 | void idle(int* a, int* b) { 14 | trace_rapid(1); 15 | *a = *a; 16 | *b = *b; 17 | trace_rapid(0); 18 | } 19 | int main(int argc, char** argv) { 20 | int a[10], i, j; 21 | int n = sizeof(a) / sizeof(int); 22 | trace_log("冒泡排序"); 23 | trace_array_1d("数组", &a, T_INT, n); 24 | trace_array_1d_chart("图表", &a, T_INT, n); 25 | trace_log("初始化数组"); 26 | for (i = 0; i < n; i++) 27 | a[i] = rand() % 89 + 10; 28 | for (i = 0; i < n - 1; i++) { 29 | char* f = format("第%d趟排序", i + 1); 30 | trace_log(f); 31 | free(f); 32 | for (j = 0; j < n - i - 1; j++) 33 | if (a[j] > a[j + 1]) 34 | swap(&(a[j]), &(a[j + 1])); 35 | else 36 | idle(&(a[j]), &(a[j + 1])); 37 | } 38 | trace_end("数组"); 39 | trace_end("图表"); 40 | } -------------------------------------------------------------------------------- /clibalgserver/server/example/sort/insert.cpp: -------------------------------------------------------------------------------- 1 | #include "/include/io" 2 | #include "/include/math" 3 | #include "/include/trace" 4 | #include "/include/xtoa_itoa" 5 | #include "/include/format" 6 | void swap(int* a, int* b) { 7 | trace_rapid(1); 8 | int tmp = *a; 9 | *a = *b; 10 | *b = tmp; 11 | trace_rapid(0); 12 | } 13 | void idle(int* a, int* b) { 14 | trace_rapid(1); 15 | *a = *a; 16 | *b = *b; 17 | trace_rapid(0); 18 | } 19 | int main(int argc, char** argv) { 20 | int a[10], i, j; 21 | int n = sizeof(a) / sizeof(int); 22 | trace_log("插入排序"); 23 | trace_array_1d("数组", &a, T_INT, n); 24 | trace_array_1d_chart("图表", &a, T_INT, n); 25 | trace_log("初始化数组"); 26 | for (i = 0; i < n; i++) 27 | a[i] = rand() % 89 + 10; 28 | for (i = 1; i < n; i++) { 29 | char* f = format("第%d趟排序", i); 30 | trace_log(f); 31 | free(f); 32 | for (j = 0; j < i; j++) 33 | if (a[i] < a[j]) 34 | swap(&(a[i]), &(a[j])); 35 | else 36 | idle(&(a[i]), &(a[j])); 37 | } 38 | trace_end("数组"); 39 | trace_end("图表"); 40 | } -------------------------------------------------------------------------------- /clibalgserver/server/example/sort/merge.cpp: -------------------------------------------------------------------------------- 1 | #include "/include/io" 2 | #include "/include/math" 3 | #include "/include/trace" 4 | #include "/include/xtoa_itoa" 5 | #include "/include/format" 6 | void output(char* text) { 7 | trace_log(text); 8 | free(text); 9 | } 10 | void swap(int* a, int* b) { 11 | trace_rapid(1); 12 | int tmp = *a; 13 | *a = *b; 14 | *b = tmp; 15 | trace_rapid(0); 16 | } 17 | int idle(int* a, int* b) { 18 | trace_rapid(1); 19 | *a = *a; 20 | *b = *b; 21 | trace_rapid(0); 22 | return 1; 23 | } 24 | void select(int* arr, int left, int right) { 25 | trace_rapid(1); 26 | int i; 27 | for (i = left; i <= right; i++) { 28 | arr[i] = arr[i]; 29 | } 30 | trace_rapid(0); 31 | } 32 | void merge(int* arr, int* tmp, int left, int mid, int right) { 33 | int i = left, j = mid + 1, k, p = left; 34 | while(i <= mid && j <= right) { 35 | idle(&(arr[i]), &(arr[j])); 36 | if (arr[i] > arr[j]) { 37 | tmp[p++] = arr[j++]; 38 | } else { 39 | tmp[p++] = arr[i++]; 40 | } 41 | } 42 | while(i <= mid) tmp[p++] = arr[i++]; 43 | while(j <= right) tmp[p++] = arr[j++]; 44 | for (k = left; k < p; k++) 45 | arr[k] = tmp[k]; 46 | } 47 | void merge_sort(int* arr, int* tmp, int left, int right) { 48 | if (left >= right) 49 | return; 50 | int mid = (left + right) / 2; 51 | output(format("归并 [%d,%d] => [%d,%d] + [%d,%d]", left, right, left, mid, mid + 1, right)); 52 | select(arr, left, right); 53 | merge_sort(arr, tmp, left, mid); 54 | merge_sort(arr, tmp, mid + 1, right); 55 | merge(arr, tmp, left, mid, right); 56 | } 57 | int main(int argc, char** argv) { 58 | int a[10], i, j; 59 | int n = sizeof(a) / sizeof(int); 60 | int* tmp = malloc(sizeof(a)); 61 | trace_log("归并排序"); 62 | trace_array_1d_chart("数组", &a, T_INT, n); 63 | trace_array_1d_chart("临时", tmp, T_INT, n); 64 | trace_log("初始化数组"); 65 | for (i = 0; i < n; i++) 66 | a[i] = rand() % 89 + 10; 67 | merge_sort(&a, tmp, 0, n - 1); 68 | trace_end("数组"); 69 | trace_end("临时"); 70 | free(tmp); 71 | } -------------------------------------------------------------------------------- /clibalgserver/server/example/sort/quick.cpp: -------------------------------------------------------------------------------- 1 | #include "/include/io" 2 | #include "/include/math" 3 | #include "/include/trace" 4 | #include "/include/xtoa_itoa" 5 | #include "/include/format" 6 | void output(char* text) { 7 | trace_log(text); 8 | free(text); 9 | } 10 | void swap(int* a, int* b) { 11 | trace_rapid(1); 12 | int tmp = *a; 13 | *a = *b; 14 | *b = tmp; 15 | trace_rapid(0); 16 | } 17 | int idle(int* a, int* b) { 18 | trace_rapid(1); 19 | *a = *a; 20 | *b = *b; 21 | trace_rapid(0); 22 | return 1; 23 | } 24 | void select(int* arr, int left, int right) { 25 | trace_rapid(1); 26 | int i; 27 | for (i = left; i <= right; i++) { 28 | arr[i] = arr[i]; 29 | } 30 | trace_rapid(0); 31 | } 32 | int partition(int* arr, int left, int right) { 33 | int i = left + 1; 34 | int j = right; 35 | int temp = arr[left]; 36 | while (i <= j) { 37 | while (i <= j && idle(&(arr[i]), &(arr[left])) > 0 && arr[i] < temp) i++; 38 | while (i <= j && idle(&(arr[j]), &(arr[left])) > 0 && arr[j] > temp) j--; 39 | if (i < j) 40 | swap(&(arr[i++]), &(arr[j--])); 41 | else { 42 | i++; 43 | idle(&(arr[i]), &(arr[j])); 44 | } 45 | } 46 | swap(&(arr[j]), &(arr[left])); 47 | return j; 48 | } 49 | void quick_sort(int* arr, int left, int right) 50 | { 51 | output(format("快排 [%d,%d]", left, right)); 52 | select(arr, left, right); 53 | if (left > right) 54 | return; 55 | int j = partition(arr, left, right); 56 | output(format("分组 [%d,%d] => [%d,%d] + [%d,%d]", left, right, left, j - 1, j + 1, right)); 57 | quick_sort(arr, left, j - 1); 58 | quick_sort(arr, j + 1, right); 59 | } 60 | int main(int argc, char** argv) { 61 | int a[10], i, j; 62 | int n = sizeof(a) / sizeof(int); 63 | trace_log("快速排序"); 64 | trace_array_1d("数组", &a, T_INT, n); 65 | trace_array_1d_chart("图表", &a, T_INT, n); 66 | trace_log("初始化数组"); 67 | for (i = 0; i < n; i++) 68 | a[i] = rand() % 89 + 10; 69 | quick_sort(&a, 0, n - 1); 70 | trace_end("数组"); 71 | trace_end("图表"); 72 | } -------------------------------------------------------------------------------- /clibalgserver/server/example/sort/selection.cpp: -------------------------------------------------------------------------------- 1 | #include "/include/io" 2 | #include "/include/math" 3 | #include "/include/trace" 4 | #include "/include/xtoa_itoa" 5 | #include "/include/format" 6 | void swap(int* a, int* b) { 7 | trace_rapid(1); 8 | int tmp = *a; 9 | *a = *b; 10 | *b = tmp; 11 | trace_rapid(0); 12 | } 13 | void idle(int* a, int* b, int* c) { 14 | trace_rapid(1); 15 | *a = *a; 16 | *b = *b; 17 | *c = *c; 18 | trace_rapid(0); 19 | } 20 | int main(int argc, char** argv) { 21 | int a[10], i, j; 22 | int n = sizeof(a) / sizeof(int); 23 | trace_log("选择排序"); 24 | trace_array_1d("数组", &a, T_INT, n); 25 | trace_array_1d_chart("图表", &a, T_INT, n); 26 | trace_log("初始化数组"); 27 | for (i = 0; i < n; i++) 28 | a[i] = rand() % 89 + 10; 29 | for (i = 0; i < n - 1; i++) { 30 | char* f = format("第%d趟排序", i + 1); 31 | trace_log(f); 32 | free(f); 33 | int min_idx = i; 34 | for (j = i + 1; j < n; j++){ 35 | idle(&(a[i]), &(a[j]), &(a[min_idx])); 36 | if (a[j] < a[min_idx]) 37 | min_idx = j; 38 | } 39 | swap(&(a[i]), &(a[min_idx])); 40 | } 41 | trace_end("数组"); 42 | trace_end("图表"); 43 | } -------------------------------------------------------------------------------- /clibalgserver/server/example/sort/shell.cpp: -------------------------------------------------------------------------------- 1 | #include "/include/io" 2 | #include "/include/math" 3 | #include "/include/trace" 4 | #include "/include/format" 5 | void swap(int* a, int* b) { 6 | trace_rapid(1); 7 | int tmp = *a; 8 | *a = *b; 9 | *b = tmp; 10 | trace_rapid(0); 11 | } 12 | void idle(int* a, int* b) { 13 | trace_rapid(1); 14 | *a = *a; 15 | *b = *b; 16 | trace_rapid(0); 17 | } 18 | int main(int argc, char** argv) { 19 | int a[10], i, j, k, gap; 20 | int n = sizeof(a) / sizeof(int); 21 | trace_log("希尔排序"); 22 | trace_array_1d("数组", &a, T_INT, n); 23 | trace_array_1d_chart("图表", &a, T_INT, n); 24 | trace_log("初始化数组"); 25 | for (i = 0; i < n; i++) 26 | a[i] = rand() % 89 + 10; 27 | for (gap = n / 2, k = 1; gap > 0; gap /= 2, k++) { 28 | char* f = format("第%d趟排序,增量为%d", k, gap); 29 | trace_log(f); 30 | free(f); 31 | for (i = gap; i < n; i++) { 32 | idle(&(a[i - gap]), &(a[i])); 33 | for (j = i; j >= gap && a[j - gap] > a[j]; j -= gap) 34 | swap(&(a[j - gap]), &(a[j])); 35 | } 36 | } 37 | trace_end("数组"); 38 | trace_end("图表"); 39 | } -------------------------------------------------------------------------------- /clibalgserver/server/example/test.cpp: -------------------------------------------------------------------------------- 1 | #include "/include/io" 2 | int main(int argc, char** argv) { 3 | put_string("Hello world!"); 4 | } -------------------------------------------------------------------------------- /clibalgserver/server/example/test_1d.cpp: -------------------------------------------------------------------------------- 1 | #include "/include/io" 2 | #include "/include/math" 3 | #include "/include/trace" 4 | void swap(int* a, int* b) { 5 | trace_rapid(1); 6 | int tmp = *a; 7 | *a = *b; 8 | *b = tmp; 9 | trace_rapid(0); 10 | } 11 | void idle(int* a, int* b) { 12 | trace_rapid(1); 13 | *a = *a; 14 | *b = *b; 15 | trace_rapid(0); 16 | } 17 | int main(int argc, char** argv) { 18 | int a[10], i, j; 19 | int n = sizeof(a) / sizeof(int); 20 | trace_log("一维数组修改示例"); 21 | trace_array_1d("数组", &a, T_INT, n); 22 | trace_array_1d_chart("图表", &a, T_INT, n); 23 | for (i = 0; i < n; i++) 24 | a[i] = rand() % 89 + 10; 25 | for (i = 0; i < n - 1; i++) 26 | for (j = 0; j < n - i - 1; j++) 27 | if (a[j] > a[j + 1]) 28 | swap(&(a[j]), &(a[j + 1])); 29 | else 30 | idle(&(a[j]), &(a[j + 1])); 31 | trace_end("数组"); 32 | trace_end("图表"); 33 | } -------------------------------------------------------------------------------- /clibalgserver/server/example/test_2d.cpp: -------------------------------------------------------------------------------- 1 | #include "/include/io" 2 | #include "/include/math" 3 | #include "/include/trace" 4 | int main(int argc, char** argv) { 5 | int a[3][4], i; 6 | int n = sizeof(a) / sizeof(int); 7 | trace_log("二维数组修改示例"); 8 | trace_array_2d("数组", &a, T_INT, 3, 4); 9 | for (i = 0; i < n; i++) 10 | ((int*)&a)[i] = i; 11 | trace_end("数组"); 12 | } -------------------------------------------------------------------------------- /clibalgserver/server/example/test_var.cpp: -------------------------------------------------------------------------------- 1 | #include "/include/io" 2 | #include "/include/trace" 3 | int main(int argc, char** argv) { 4 | int a = 0; 5 | trace_log("变量修改示例"); 6 | trace_var("a", &a, T_INT); 7 | a = 1; 8 | trace_end("a"); 9 | } -------------------------------------------------------------------------------- /clibalgserver/server/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/favicon.ico -------------------------------------------------------------------------------- /clibalgserver/server/js/eventbus.js: -------------------------------------------------------------------------------- 1 | (function(exporter) { 2 | function isFunc(fn) { return typeof fn === "function" } 3 | 4 | function str(s) { 5 | if (s == null) { 6 | return null; 7 | } 8 | s = s.replace(/^\s+|\s+$/g, ""); 9 | return s.length > 0 ? s.toLowerCase() : null; 10 | } 11 | 12 | function handler() { 13 | var fns = []; 14 | var datas = []; 15 | this.add = function(fn, data) { 16 | fns.push(fn); 17 | datas.push(data); 18 | } 19 | this.remove = function(fn) { 20 | var i = fns.indexOf(fn); 21 | if (i >= 0) { 22 | fns.splice(i, 1); 23 | datas.splice(i, 1); 24 | } 25 | } 26 | this.invoke = function(sender, data) { 27 | fns.forEach((fn, i) => { 28 | try { 29 | fn(sender, data, datas[i]) 30 | } catch (error) { 31 | console.error(error); 32 | } 33 | }); 34 | } 35 | } 36 | 37 | function eventBus() { 38 | var handers = {} 39 | this.on = function(eventName, fnOrData, fn) { 40 | eventName = str(eventName); 41 | if (eventName == null) { 42 | throw new Error("事件名无效"); 43 | } 44 | if (!isFunc(fn)) { 45 | var temp = fn; 46 | fn = fnOrData; 47 | fnOrData = temp; 48 | } 49 | if (!isFunc(fn)) { 50 | throw new Error("必须提供事件函数"); 51 | } 52 | var handle = handers[eventName]; 53 | if (handle == null) { 54 | handle = new handler(); 55 | handers[eventName] = handle; 56 | } 57 | handle.add(fn, fnOrData); 58 | } 59 | this.off = function(eventName, fn) { 60 | eventName = str(eventName); 61 | if (eventName == null) { 62 | return; 63 | } 64 | var handle = handers[eventName]; 65 | if (handle != null) { 66 | if (fn == null) { 67 | delete handers[eventName]; 68 | } else { 69 | handle.remove(fn); 70 | } 71 | } 72 | } 73 | this.offAll = function(eventName, fn) { 74 | handers = {}; 75 | } 76 | this.fire = this.emit = this.trigger = 77 | function(eventName, sender, data) { 78 | eventName = str(eventName); 79 | if (eventName == null) { 80 | return; 81 | } 82 | var handle = handers[eventName]; 83 | if (handle != null) { 84 | handle.invoke(sender, data); 85 | } 86 | } 87 | var bus = this; 88 | this.bindTo = function(obj) { 89 | if (obj == null) { 90 | throw new Error("obj is null"); 91 | } 92 | for (const key in bus) { 93 | if (bus.hasOwnProperty(key) && key !== "bindTo") { 94 | obj[key] = bus[key]; 95 | } 96 | } 97 | } 98 | } 99 | var instance = new eventBus(); 100 | instance.bindTo(eventBus); 101 | exporter(eventBus); 102 | })(c => window.eventBus = c) -------------------------------------------------------------------------------- /clibalgserver/server/layui/css/modules/code.css: -------------------------------------------------------------------------------- 1 | /** layui-v2.5.5 MIT License By https://www.layui.com */ 2 | html #layuicss-skincodecss{display:none;position:absolute;width:1989px}.layui-code-h3,.layui-code-view{position:relative;font-size:12px}.layui-code-view{display:block;margin:10px 0;padding:0;border:1px solid #e2e2e2;border-left-width:6px;background-color:#F2F2F2;color:#333;font-family:Courier New}.layui-code-h3{padding:0 10px;height:32px;line-height:32px;border-bottom:1px solid #e2e2e2}.layui-code-h3 a{position:absolute;right:10px;top:0;color:#999}.layui-code-view .layui-code-ol{position:relative;overflow:auto}.layui-code-view .layui-code-ol li{position:relative;margin-left:45px;line-height:20px;padding:0 5px;border-left:1px solid #e2e2e2;list-style-type:decimal-leading-zero;*list-style-type:decimal;background-color:#fff}.layui-code-view pre{margin:0}.layui-code-notepad{border:1px solid #0C0C0C;border-left-color:#3F3F3F;background-color:#0C0C0C;color:#C2BE9E}.layui-code-notepad .layui-code-h3{border-bottom:none}.layui-code-notepad .layui-code-ol li{background-color:#3F3F3F;border-left:none} -------------------------------------------------------------------------------- /clibalgserver/server/layui/css/modules/layer/default/icon-ext.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/css/modules/layer/default/icon-ext.png -------------------------------------------------------------------------------- /clibalgserver/server/layui/css/modules/layer/default/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/css/modules/layer/default/icon.png -------------------------------------------------------------------------------- /clibalgserver/server/layui/css/modules/layer/default/loading-0.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/css/modules/layer/default/loading-0.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/css/modules/layer/default/loading-1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/css/modules/layer/default/loading-1.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/css/modules/layer/default/loading-2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/css/modules/layer/default/loading-2.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/font/iconfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/font/iconfont.eot -------------------------------------------------------------------------------- /clibalgserver/server/layui/font/iconfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/font/iconfont.ttf -------------------------------------------------------------------------------- /clibalgserver/server/layui/font/iconfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/font/iconfont.woff -------------------------------------------------------------------------------- /clibalgserver/server/layui/font/iconfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/font/iconfont.woff2 -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/0.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/0.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/1.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/10.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/10.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/11.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/11.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/12.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/12.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/13.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/13.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/14.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/14.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/15.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/15.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/16.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/16.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/17.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/17.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/18.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/18.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/19.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/19.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/2.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/20.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/20.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/21.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/21.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/22.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/22.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/23.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/23.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/24.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/24.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/25.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/25.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/26.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/26.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/27.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/27.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/28.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/28.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/29.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/29.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/3.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/30.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/30.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/31.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/31.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/32.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/32.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/33.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/33.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/34.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/34.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/35.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/35.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/36.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/36.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/37.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/37.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/38.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/38.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/39.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/39.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/4.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/4.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/40.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/40.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/41.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/41.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/42.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/42.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/43.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/43.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/44.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/44.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/45.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/45.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/46.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/46.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/47.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/47.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/48.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/48.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/49.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/49.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/5.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/5.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/50.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/50.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/51.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/51.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/52.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/52.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/53.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/53.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/54.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/54.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/55.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/55.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/56.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/56.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/57.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/57.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/58.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/58.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/59.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/59.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/6.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/6.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/60.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/60.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/61.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/61.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/62.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/62.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/63.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/63.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/64.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/64.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/65.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/65.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/66.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/66.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/67.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/67.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/68.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/68.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/69.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/69.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/7.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/7.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/70.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/70.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/71.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/71.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/8.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/8.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/images/face/9.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/clibalgserver/server/layui/images/face/9.gif -------------------------------------------------------------------------------- /clibalgserver/server/layui/lay/modules/code.js: -------------------------------------------------------------------------------- 1 | /** layui-v2.5.5 MIT License By https://www.layui.com */ 2 | ;layui.define("jquery",function(e){"use strict";var a=layui.$,l="http://www.layui.com/doc/modules/code.html";e("code",function(e){var t=[];e=e||{},e.elem=a(e.elem||".layui-code"),e.about=!("about"in e)||e.about,e.elem.each(function(){t.push(this)}),layui.each(t.reverse(),function(t,i){var c=a(i),o=c.html();(c.attr("lay-encode")||e.encode)&&(o=o.replace(/&(?!#?[a-zA-Z0-9]+;)/g,"&").replace(//g,">").replace(/'/g,"'").replace(/"/g,""")),c.html('
  1. '+o.replace(/[\r\t\n]+/g,"
  2. ")+"
"),c.find(">.layui-code-h3")[0]||c.prepend('

'+(c.attr("lay-title")||e.title||"code")+(e.about?'layui.code':"")+"

");var d=c.find(">.layui-code-ol");c.addClass("layui-box layui-code-view"),(c.attr("lay-skin")||e.skin)&&c.addClass("layui-code-"+(c.attr("lay-skin")||e.skin)),(d.find("li").length/100|0)>0&&d.css("margin-left",(d.find("li").length/100|0)+"px"),(c.attr("lay-height")||e.height)&&d.css("max-height",c.attr("lay-height")||e.height)})})}).addcss("modules/code.css","skincodecss"); -------------------------------------------------------------------------------- /clibalgserver/server/layui/lay/modules/flow.js: -------------------------------------------------------------------------------- 1 | /** layui-v2.5.5 MIT License By https://www.layui.com */ 2 | ;layui.define("jquery",function(e){"use strict";var l=layui.$,o=function(e){},t='';o.prototype.load=function(e){var o,i,n,r,a=this,c=0;e=e||{};var f=l(e.elem);if(f[0]){var m=l(e.scrollElem||document),u=e.mb||50,s=!("isAuto"in e)||e.isAuto,v=e.end||"没有更多了",y=e.scrollElem&&e.scrollElem!==document,d="加载更多",h=l('");f.find(".layui-flow-more")[0]||f.append(h);var p=function(e,t){e=l(e),h.before(e),t=0==t||null,t?h.html(v):h.find("a").html(d),i=t,o=null,n&&n()},g=function(){o=!0,h.find("a").html(t),"function"==typeof e.done&&e.done(++c,p)};if(g(),h.find("a").on("click",function(){l(this);i||o||g()}),e.isLazyimg)var n=a.lazyimg({elem:e.elem+" img",scrollElem:e.scrollElem});return s?(m.on("scroll",function(){var e=l(this),t=e.scrollTop();r&&clearTimeout(r),i||(r=setTimeout(function(){var i=y?e.height():l(window).height(),n=y?e.prop("scrollHeight"):document.documentElement.scrollHeight;n-t-i<=u&&(o||g())},100))}),a):a}},o.prototype.lazyimg=function(e){var o,t=this,i=0;e=e||{};var n=l(e.scrollElem||document),r=e.elem||"img",a=e.scrollElem&&e.scrollElem!==document,c=function(e,l){var o=n.scrollTop(),r=o+l,c=a?function(){return e.offset().top-n.offset().top+o}():e.offset().top;if(c>=o&&c<=r&&!e.attr("src")){var m=e.attr("lay-src");layui.img(m,function(){var l=t.lazyimg.elem.eq(i);e.attr("src",m).removeAttr("lay-src"),l[0]&&f(l),i++})}},f=function(e,o){var f=a?(o||n).height():l(window).height(),m=n.scrollTop(),u=m+f;if(t.lazyimg.elem=l(r),e)c(e,f);else for(var s=0;su)break}};if(f(),!o){var m;n.on("scroll",function(){var e=l(this);m&&clearTimeout(m),m=setTimeout(function(){f(null,e)},50)}),o=!0}return f},e("flow",new o)}); -------------------------------------------------------------------------------- /clibalgserver/server/layui/lay/modules/laytpl.js: -------------------------------------------------------------------------------- 1 | /** layui-v2.5.5 MIT License By https://www.layui.com */ 2 | ;layui.define(function(e){"use strict";var r={open:"{{",close:"}}"},c={exp:function(e){return new RegExp(e,"g")},query:function(e,c,t){var o=["#([\\s\\S])+?","([^{#}])*?"][e||0];return n((c||"")+r.open+o+r.close+(t||""))},escape:function(e){return String(e||"").replace(/&(?!#?[a-zA-Z0-9]+;)/g,"&").replace(//g,">").replace(/'/g,"'").replace(/"/g,""")},error:function(e,r){var c="Laytpl Error:";return"object"==typeof console&&console.error(c+e+"\n"+(r||"")),c+e}},n=c.exp,t=function(e){this.tpl=e};t.pt=t.prototype,window.errors=0,t.pt.parse=function(e,t){var o=this,p=e,a=n("^"+r.open+"#",""),l=n(r.close+"$","");e=e.replace(/\s+|\r|\t|\n/g," ").replace(n(r.open+"#"),r.open+"# ").replace(n(r.close+"}"),"} "+r.close).replace(/\\/g,"\\\\").replace(n(r.open+"!(.+?)!"+r.close),function(e){return e=e.replace(n("^"+r.open+"!"),"").replace(n("!"+r.close),"").replace(n(r.open+"|"+r.close),function(e){return e.replace(/(.)/g,"\\$1")})}).replace(/(?="|')/g,"\\").replace(c.query(),function(e){return e=e.replace(a,"").replace(l,""),'";'+e.replace(/\\/g,"")+';view+="'}).replace(c.query(1),function(e){var c='"+(';return e.replace(/\s/g,"")===r.open+r.close?"":(e=e.replace(n(r.open+"|"+r.close),""),/^=/.test(e)&&(e=e.replace(/^=/,""),c='"+_escape_('),c+e.replace(/\\/g,"")+')+"')}),e='"use strict";var view = "'+e+'";return view;';try{return o.cache=e=new Function("d, _escape_",e),e(t,c.escape)}catch(u){return delete o.cache,c.error(u,p)}},t.pt.render=function(e,r){var n,t=this;return e?(n=t.cache?t.cache(e,c.escape):t.parse(t.tpl,e),r?void r(n):n):c.error("no data")};var o=function(e){return"string"!=typeof e?c.error("Template not found"):new t(e)};o.config=function(e){e=e||{};for(var c in e)r[c]=e[c]},o.v="1.2.0",e("laytpl",o)}); -------------------------------------------------------------------------------- /clibalgserver/server/layui/lay/modules/rate.js: -------------------------------------------------------------------------------- 1 | /** layui-v2.5.5 MIT License By https://www.layui.com */ 2 | ;layui.define("jquery",function(e){"use strict";var a=layui.jquery,i={config:{},index:layui.rate?layui.rate.index+1e4:0,set:function(e){var i=this;return i.config=a.extend({},i.config,e),i},on:function(e,a){return layui.onevent.call(this,n,e,a)}},l=function(){var e=this,a=e.config;return{setvalue:function(a){e.setvalue.call(e,a)},config:a}},n="rate",t="layui-rate",o="layui-icon-rate",s="layui-icon-rate-solid",u="layui-icon-rate-half",r="layui-icon-rate-solid layui-icon-rate-half",c="layui-icon-rate-solid layui-icon-rate",f="layui-icon-rate layui-icon-rate-half",v=function(e){var l=this;l.index=++i.index,l.config=a.extend({},l.config,i.config,e),l.render()};v.prototype.config={length:5,text:!1,readonly:!1,half:!1,value:0,theme:""},v.prototype.render=function(){var e=this,i=e.config,l=i.theme?'style="color: '+i.theme+';"':"";i.elem=a(i.elem),parseInt(i.value)!==i.value&&(i.half||(i.value=Math.ceil(i.value)-i.value<.5?Math.ceil(i.value):Math.floor(i.value)));for(var n='
    ",u=1;u<=i.length;u++){var r='
  • ";i.half&&parseInt(i.value)!==i.value&&u==Math.ceil(i.value)?n=n+'
  • ":n+=r}n+="
"+(i.text?''+i.value+"星":"")+"";var c=i.elem,f=c.next("."+t);f[0]&&f.remove(),e.elemTemp=a(n),i.span=e.elemTemp.next("span"),i.setText&&i.setText(i.value),c.html(e.elemTemp),c.addClass("layui-inline"),i.readonly||e.action()},v.prototype.setvalue=function(e){var a=this,i=a.config;i.value=e,a.render()},v.prototype.action=function(){var e=this,i=e.config,l=e.elemTemp,n=l.find("i").width();l.children("li").each(function(e){var t=e+1,v=a(this);v.on("click",function(e){if(i.value=t,i.half){var o=e.pageX-a(this).offset().left;o<=n/2&&(i.value=i.value-.5)}i.text&&l.next("span").text(i.value+"星"),i.choose&&i.choose(i.value),i.setText&&i.setText(i.value)}),v.on("mousemove",function(e){if(l.find("i").each(function(){a(this).addClass(o).removeClass(r)}),l.find("i:lt("+t+")").each(function(){a(this).addClass(s).removeClass(f)}),i.half){var c=e.pageX-a(this).offset().left;c<=n/2&&v.children("i").addClass(u).removeClass(s)}}),v.on("mouseleave",function(){l.find("i").each(function(){a(this).addClass(o).removeClass(r)}),l.find("i:lt("+Math.floor(i.value)+")").each(function(){a(this).addClass(s).removeClass(f)}),i.half&&parseInt(i.value)!==i.value&&l.children("li:eq("+Math.floor(i.value)+")").children("i").addClass(u).removeClass(c)})})},v.prototype.events=function(){var e=this;e.config},i.render=function(e){var a=new v(e);return l.call(a)},e(n,i)}); -------------------------------------------------------------------------------- /clibalgserver/server/layui/lay/modules/util.js: -------------------------------------------------------------------------------- 1 | /** layui-v2.5.5 MIT License By https://www.layui.com */ 2 | ;layui.define("jquery",function(t){"use strict";var e=layui.$,i={fixbar:function(t){var i,n,a="layui-fixbar",o="layui-fixbar-top",r=e(document),l=e("body");t=e.extend({showHeight:200},t),t.bar1=t.bar1===!0?"":t.bar1,t.bar2=t.bar2===!0?"":t.bar2,t.bgcolor=t.bgcolor?"background-color:"+t.bgcolor:"";var c=[t.bar1,t.bar2,""],g=e(['
    ',t.bar1?'
  • '+c[0]+"
  • ":"",t.bar2?'
  • '+c[1]+"
  • ":"",'
  • '+c[2]+"
  • ","
"].join("")),s=g.find("."+o),u=function(){var e=r.scrollTop();e>=t.showHeight?i||(s.show(),i=1):i&&(s.hide(),i=0)};e("."+a)[0]||("object"==typeof t.css&&g.css(t.css),l.append(g),u(),g.find("li").on("click",function(){var i=e(this),n=i.attr("lay-type");"top"===n&&e("html,body").animate({scrollTop:0},200),t.click&&t.click.call(this,n)}),r.on("scroll",function(){clearTimeout(n),n=setTimeout(function(){u()},100)}))},countdown:function(t,e,i){var n=this,a="function"==typeof e,o=new Date(t).getTime(),r=new Date(!e||a?(new Date).getTime():e).getTime(),l=o-r,c=[Math.floor(l/864e5),Math.floor(l/36e5)%24,Math.floor(l/6e4)%60,Math.floor(l/1e3)%60];a&&(i=e);var g=setTimeout(function(){n.countdown(t,r+1e3,i)},1e3);return i&&i(l>0?c:[0,0,0,0],e,g),l<=0&&clearTimeout(g),g},timeAgo:function(t,e){var i=this,n=[[],[]],a=(new Date).getTime()-new Date(t).getTime();return a>6912e5?(a=new Date(t),n[0][0]=i.digit(a.getFullYear(),4),n[0][1]=i.digit(a.getMonth()+1),n[0][2]=i.digit(a.getDate()),e||(n[1][0]=i.digit(a.getHours()),n[1][1]=i.digit(a.getMinutes()),n[1][2]=i.digit(a.getSeconds())),n[0].join("-")+" "+n[1].join(":")):a>=864e5?(a/1e3/60/60/24|0)+"天前":a>=36e5?(a/1e3/60/60|0)+"小时前":a>=12e4?(a/1e3/60|0)+"分钟前":a<0?"未来":"刚刚"},digit:function(t,e){var i="";t=String(t),e=e||2;for(var n=t.length;n/g,">").replace(/'/g,"'").replace(/"/g,""")},event:function(t,n,a){n=i.event[t]=e.extend(!0,i.event[t],n)||{},e("body").on(a||"click","*["+t+"]",function(){var i=e(this),a=i.attr(t);n[a]&&n[a].call(this,i)})}};!function(t,e,i){"$:nomunge";function n(){a=e[l](function(){o.each(function(){var e=t(this),i=e.width(),n=e.height(),a=t.data(this,g);(i!==a.w||n!==a.h)&&e.trigger(c,[a.w=i,a.h=n])}),n()},r[s])}var a,o=t([]),r=t.resize=t.extend(t.resize,{}),l="setTimeout",c="resize",g=c+"-special-event",s="delay",u="throttleWindow";r[s]=250,r[u]=!0,t.event.special[c]={setup:function(){if(!r[u]&&this[l])return!1;var e=t(this);o=o.add(e),t.data(this,g,{w:e.width(),h:e.height()}),1===o.length&&n()},teardown:function(){if(!r[u]&&this[l])return!1;var e=t(this);o=o.not(e),e.removeData(g),o.length||clearTimeout(a)},add:function(e){function n(e,n,o){var r=t(this),l=t.data(this,g)||{};l.w=n!==i?n:r.width(),l.h=o!==i?o:r.height(),a.apply(this,arguments)}if(!r[u]&&this[l])return!1;var a;return t.isFunction(e)?(a=e,n):(a=e.handler,void(e.handler=n))}}}(e,window),t("util",i)}); -------------------------------------------------------------------------------- /clibalgserver/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // pch.cpp: 与预编译标头对应的源文件 2 | 3 | #include "stdafx.h" 4 | 5 | // 当使用预编译的头时,需要使用此源文件,编译才能成功。 6 | -------------------------------------------------------------------------------- /clibalgserver/stdafx.h: -------------------------------------------------------------------------------- 1 | // pch.h: 这是预编译标头文件。 2 | // 下方列出的文件仅编译一次,提高了将来生成的生成性能。 3 | // 这还将影响 IntelliSense 性能,包括代码完成和许多代码浏览功能。 4 | // 但是,如果此处列出的文件中的任何一个在生成之间有更新,它们全部都将被重新编译。 5 | // 请勿在此处添加要频繁更新的文件,这将使得性能优势无效。 6 | 7 | #ifndef PCH_H 8 | #define PCH_H 9 | 10 | #define NOMINMAX 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #include "event2/event.h" 25 | 26 | #pragma comment(lib, "ws2_32.lib") 27 | #pragma comment(lib, "lib\\libevent") 28 | #pragma comment(lib, "lib\\libevent_core") 29 | #pragma comment(lib, "lib\\libevent_extras") 30 | 31 | #ifdef _DEBUG 32 | #pragma comment(lib, "..\\Debug\\cparser") 33 | #else 34 | #pragma comment(lib, "..\\Release\\cparser") 35 | #endif 36 | 37 | #endif //PCH_H 38 | -------------------------------------------------------------------------------- /cparser/base/defines.h: -------------------------------------------------------------------------------- 1 | #ifndef DEFINES_H 2 | #define DEFINES_H 3 | 4 | using cint8 = signed __int8; 5 | using uint8 = unsigned __int8; 6 | using cint16 = signed __int16; 7 | using uint16 = unsigned __int16; 8 | using cint32 = signed __int32; 9 | using uint32 = unsigned __int32; 10 | using cint64 = signed __int64; 11 | using uint64 = unsigned __int64; 12 | 13 | #ifdef WIN32 14 | using cint = cint32; 15 | using uint = uint32; 16 | #else 17 | using cint = cint64; 18 | using uint = uint64; 19 | #endif 20 | 21 | using byte = uint8; 22 | using size_t = uint; 23 | 24 | #ifndef WM_SYSTIMER 25 | #define WM_SYSTIMER 0x0118 //(caret blink) 26 | #endif 27 | 28 | #endif -------------------------------------------------------------------------------- /cparser/base/parser2d/cexception.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Project: clibparser 3 | // Author: bajdcc 4 | // 5 | 6 | #include "stdafx.h" 7 | #include 8 | #include "cexception.h" 9 | 10 | namespace clib { 11 | 12 | std::tuple ex_string_list[] = { 13 | std::make_tuple(ex_none, ""), 14 | std::make_tuple(ex_unit, "UNIT ERROR"), 15 | std::make_tuple(ex_ast, "AST ERROR"), 16 | std::make_tuple(ex_parser, "PARSER ERROR"), 17 | std::make_tuple(ex_vm, "VM ERROR"), 18 | std::make_tuple(ex_gen, "GEN ERROR"), 19 | std::make_tuple(ex_gui, "GUI ERROR"), 20 | std::make_tuple(ex_mem, "MEMORY ERROR"), 21 | std::make_tuple(ex_vfs, "VFS ERROR"), 22 | }; 23 | 24 | const string_t& ex_str(ex_t t) { 25 | assert(t >= ex_none && t <= ex_vfs); 26 | return std::get<1>(ex_string_list[t]); 27 | } 28 | 29 | cexception::cexception(ex_t e, const string_t & msg) noexcept : msg(msg), e(e) {} 30 | 31 | string_t cexception::message() const { 32 | return ex_str(e) + ": " + msg; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /cparser/base/parser2d/cexception.h: -------------------------------------------------------------------------------- 1 | // 2 | // Project: clibparser 3 | // Author: bajdcc 4 | // 5 | #ifndef CLIBVM_EXCEPTION_H 6 | #define CLIBVM_EXCEPTION_H 7 | 8 | #include 9 | #include "types.h" 10 | 11 | namespace clib { 12 | 13 | enum ex_t { 14 | ex_none, 15 | ex_unit, 16 | ex_ast, 17 | ex_parser, 18 | ex_vm, 19 | ex_gen, 20 | ex_gui, 21 | ex_mem, 22 | ex_vfs, 23 | }; 24 | 25 | const string_t& ex_str(ex_t); 26 | 27 | class cexception : public std::exception { 28 | public: 29 | explicit cexception(ex_t e, const string_t& msg) noexcept; 30 | 31 | cexception(const cexception& e) = default; 32 | cexception& operator = (const cexception& e) = default; 33 | 34 | string_t message() const; 35 | 36 | string_t msg; 37 | ex_t e{ ex_none }; 38 | }; 39 | } 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /cparser/base/parser2d/cmem.h: -------------------------------------------------------------------------------- 1 | // 2 | // Project: clibparser 3 | // Created by bajdcc 4 | // 5 | 6 | #ifndef CLIBPARSER_CMEM_H 7 | #define CLIBPARSER_CMEM_H 8 | 9 | #include 10 | #include 11 | #include "types.h" 12 | 13 | #define MAX_PAGE_PER_PROCESS 65536 14 | 15 | namespace clib { 16 | 17 | class imem { 18 | public: 19 | virtual void map_page(uint32_t addr, uint32_t id) = 0; 20 | }; 21 | 22 | class cmem { 23 | public: 24 | explicit cmem(imem* m); 25 | 26 | cmem(const cmem&) = delete; 27 | cmem& operator=(const cmem&) = delete; 28 | 29 | uint32_t alloc(uint32_t size); 30 | uint32_t free(uint32_t addr); 31 | int page_size() const; 32 | int available() const; 33 | 34 | void copy_from(const cmem& mem); 35 | void dump_str(std::ostream& os) const; 36 | 37 | private: 38 | uint32_t new_page(uint32_t size); 39 | uint32_t new_page_single(); 40 | uint32_t new_page_all(uint32_t size); 41 | 42 | void error(const string_t&) const; 43 | void dump() const; 44 | void check() const; 45 | 46 | private: 47 | std::vector> memory; 48 | std::vector memory_page; 49 | std::map memory_free; 50 | std::map memory_used; 51 | size_t available_size{ 0 }; 52 | imem* m{ nullptr }; 53 | }; 54 | } 55 | 56 | #endif //CLIBPARSER_CMEM_H 57 | -------------------------------------------------------------------------------- /cparser/base/parser2d/cnet.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Project: clibparser 3 | // Created by bajdcc 4 | // 5 | 6 | #include "stdafx.h" 7 | #include "cnet.h" 8 | 9 | #define LOG_NET 0 10 | 11 | namespace clib { 12 | 13 | CString cnet::Utf8ToStringT(LPCSTR str) 14 | { 15 | _ASSERT(str); 16 | USES_CONVERSION; 17 | auto length = MultiByteToWideChar(CP_UTF8, 0, str, -1, nullptr, 0); 18 | CString s; 19 | auto buf = s.GetBuffer(length + 1); 20 | ZeroMemory(buf, (length + 1) * sizeof(WCHAR)); 21 | MultiByteToWideChar(CP_UTF8, 0, str, -1, buf, length); 22 | s.ReleaseBuffer(); 23 | return s; 24 | } 25 | 26 | CString cnet::GBKToStringT(LPCSTR str) 27 | { 28 | _ASSERT(str); 29 | USES_CONVERSION; 30 | auto length = MultiByteToWideChar(CP_ACP, 0, str, -1, nullptr, 0); 31 | CString s; 32 | auto buf = s.GetBuffer(length + 1); 33 | ZeroMemory(buf, (length + 1) * sizeof(WCHAR)); 34 | MultiByteToWideChar(CP_ACP, 0, str, -1, buf, length); 35 | s.ReleaseBuffer(); 36 | return s; 37 | } 38 | 39 | CStringA cnet::StringTToUtf8(CString str) 40 | { 41 | USES_CONVERSION; 42 | auto length = WideCharToMultiByte(CP_UTF8, 0, str, -1, nullptr, 0, nullptr, nullptr); 43 | CStringA s; 44 | auto buf = s.GetBuffer(length + 1); 45 | ZeroMemory(buf, (length + 1) * sizeof(CHAR)); 46 | WideCharToMultiByte(CP_UTF8, 0, str, -1, buf, length, nullptr, nullptr); 47 | return s; 48 | } 49 | } -------------------------------------------------------------------------------- /cparser/base/parser2d/cnet.h: -------------------------------------------------------------------------------- 1 | // 2 | // Project: clibparser 3 | // Created by bajdcc 4 | // 5 | 6 | #ifndef CLIBPARSER_CNET_H 7 | #define CLIBPARSER_CNET_H 8 | 9 | #include "types.h" 10 | #include "cvfs.h" 11 | 12 | namespace clib { 13 | 14 | class cnet { 15 | public: 16 | cnet() = default; 17 | 18 | cnet(const cnet&) = delete; 19 | cnet& operator=(const cnet&) = delete; 20 | 21 | static CString Utf8ToStringT(LPCSTR str); 22 | static CString GBKToStringT(LPCSTR str); 23 | static CStringA StringTToUtf8(CString str); 24 | }; 25 | } 26 | 27 | #endif //CLIBPARSER_CNET_H 28 | -------------------------------------------------------------------------------- /cparser/base/parser2d/cparser.h: -------------------------------------------------------------------------------- 1 | // 2 | // Project: CMiniLang 3 | // Author: bajdcc 4 | // 5 | #ifndef CMINILANG_PARSER_H 6 | #define CMINILANG_PARSER_H 7 | 8 | #include 9 | #include "types.h" 10 | #include "clexer.h" 11 | #include "cast.h" 12 | #include "cunit.h" 13 | 14 | namespace clib { 15 | 16 | enum backtrace_direction { 17 | b_success, 18 | b_next, 19 | b_error, 20 | b_fail, 21 | b_fallback, 22 | }; 23 | 24 | struct backtrace_t { 25 | int lexer_index; 26 | std::vector state_stack; 27 | std::vector ast_stack; 28 | int current_state; 29 | uint coll_index; 30 | uint reduce_index; 31 | std::vector trans_ids; 32 | std::unordered_set ast_ids; 33 | backtrace_direction direction; 34 | }; 35 | 36 | class csemantic { 37 | public: 38 | virtual backtrace_direction check(pda_edge_t, ast_node*) = 0; 39 | virtual void error_handler(int, const std::vector&, int&) = 0; 40 | }; 41 | 42 | class cparser { 43 | public: 44 | cparser() = default; 45 | ~cparser() = default; 46 | 47 | cparser(const cparser&) = delete; 48 | cparser& operator=(const cparser&) = delete; 49 | 50 | ast_node* parse(const string_t& str, csemantic* s = nullptr); 51 | ast_node* root() const; 52 | void clear_ast(); 53 | 54 | private: 55 | void next(); 56 | 57 | void gen(); 58 | void program(); 59 | ast_node* terminal(); 60 | 61 | bool valid_trans(const pda_trans& trans) const; 62 | void do_trans(int state, backtrace_t& bk, const pda_trans& trans); 63 | bool LA(unit* u) const; 64 | 65 | private: 66 | void expect(bool, const string_t&); 67 | void match_keyword(keyword_t); 68 | void match_operator(operator_t); 69 | void match_type(lexer_t); 70 | void match_number(); 71 | void match_integer(); 72 | 73 | void error(const string_t&); 74 | 75 | private: 76 | lexer_t base_type{ l_none }; 77 | std::vector state_stack; 78 | std::vector ast_stack; 79 | std::vector ast_cache; 80 | uint ast_cache_index{ 0 }; 81 | std::vector ast_coll_cache; 82 | std::vector ast_reduce_cache; 83 | 84 | private: 85 | cunit unit; 86 | std::unique_ptr lexer; 87 | csemantic* semantic{ nullptr }; 88 | std::unique_ptr ast; 89 | }; 90 | } 91 | #endif //CMINILANG_PARSER_H -------------------------------------------------------------------------------- /cparser/base/parser2d/crev.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Project: clibparser 3 | // Author: bajdcc 4 | // 5 | 6 | #include "stdafx.h" 7 | #include "crev.h" 8 | #include "cgen.h" 9 | #include "cexception.h" 10 | 11 | namespace clib { 12 | 13 | void crev::error(const string_t& str) { 14 | throw cexception(ex_ast, str); 15 | } 16 | 17 | std::vector crev::conv(const std::vector& file) 18 | { 19 | PE* pe = (PE*)file.data(); 20 | auto text_size = pe->text_len / sizeof(int); 21 | auto text_start = (uint32_t*)(&pe->data + pe->data_len); 22 | std::stringstream ss; 23 | static char sz[16]; 24 | for (auto i = 0U; i < text_size;) { 25 | snprintf(sz, sizeof(sz), "%-4s", INS_STRING((ins_t)text_start[i]).c_str()); 26 | ss << sz; 27 | auto n = INS_OPNUM((ins_t)text_start[i]); 28 | if (n >= 1) { 29 | snprintf(sz, sizeof(sz), " 0x%08X", text_start[i + 1]); 30 | ss << sz; 31 | } 32 | if (n >= 2) { 33 | snprintf(sz, sizeof(sz), " 0x%08X", text_start[i + 2]); 34 | ss << sz; 35 | } 36 | ss << std::endl; 37 | i += n + 1; 38 | } 39 | auto s = ss.str(); 40 | std::vector v(s.begin(), s.end()); 41 | return v; 42 | } 43 | } -------------------------------------------------------------------------------- /cparser/base/parser2d/crev.h: -------------------------------------------------------------------------------- 1 | // 2 | // Project: clibparser 3 | // Author: bajdcc 4 | // 5 | 6 | #ifndef CLIBPARSER_CREV_H 7 | #define CLIBPARSER_CREV_H 8 | 9 | #include "types.h" 10 | 11 | namespace clib { 12 | 13 | class crev { 14 | public: 15 | static void error(const string_t&); 16 | static std::vector conv(const std::vector& file); 17 | }; 18 | } 19 | 20 | #endif //CMINILANG_VM_H 21 | -------------------------------------------------------------------------------- /cparser/dllmain.cpp: -------------------------------------------------------------------------------- 1 | // dllmain.cpp : 定义 DLL 应用程序的入口点。 2 | #include "stdafx.h" 3 | 4 | BOOL APIENTRY DllMain( HMODULE hModule, 5 | DWORD ul_reason_for_call, 6 | LPVOID lpReserved 7 | ) 8 | { 9 | switch (ul_reason_for_call) 10 | { 11 | case DLL_PROCESS_ATTACH: 12 | case DLL_THREAD_ATTACH: 13 | case DLL_THREAD_DETACH: 14 | case DLL_PROCESS_DETACH: 15 | break; 16 | } 17 | return TRUE; 18 | } 19 | 20 | -------------------------------------------------------------------------------- /cparser/framework.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define NOMINMAX 4 | 5 | #define WIN32_LEAN_AND_MEAN // 从 Windows 头文件中排除极少使用的内容 6 | // Windows 头文件 7 | #include 8 | 9 | // C 运行时头文件 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #include 33 | 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | #include 40 | 41 | #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // 某些 CString 构造函数将是显式的 42 | 43 | #include 44 | #include 45 | 46 | #include "defines.h" -------------------------------------------------------------------------------- /cparser/parser.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "parser.h" 3 | #include "parser2d/cgui.h" 4 | 5 | #define SHOW_TEXT 0 6 | 7 | namespace clib { 8 | 9 | CPARSER_API parser_ret parser(std::string input, std::string& output) 10 | { 11 | using namespace std::chrono; 12 | using namespace std::literals::chrono_literals; 13 | cgui gui; 14 | gui.set_main(input); 15 | auto now = std::chrono::system_clock::now(); 16 | auto last_clock = std::chrono::system_clock::now(); 17 | auto dt = std::chrono::duration_cast(now - last_clock); 18 | while (gui.is_running() && dt < 2s) { 19 | gui.draw(false, 30.0); 20 | now = std::chrono::system_clock::now(); 21 | dt = std::chrono::duration_cast(now - last_clock); 22 | } 23 | auto run = gui.is_running(); 24 | output = gui.output(); 25 | gui.reset(); 26 | if (run) 27 | output += "\n[ERROR] Running time out."; 28 | return P_OK; 29 | } 30 | 31 | CPARSER_API parser_ret visualize(std::string input, std::string& output) 32 | { 33 | using namespace std::chrono; 34 | using namespace std::literals::chrono_literals; 35 | cgui gui; 36 | gui.set_main(input); 37 | auto now = std::chrono::system_clock::now(); 38 | auto last_clock = std::chrono::system_clock::now(); 39 | auto dt = std::chrono::duration_cast(now - last_clock); 40 | while (gui.is_running() && dt < 2s) { 41 | gui.draw(false, 30.0); 42 | now = std::chrono::system_clock::now(); 43 | dt = std::chrono::duration_cast(now - last_clock); 44 | } 45 | auto run = gui.is_running(); 46 | #if SHOW_TEXT 47 | output = gui.tracer(); 48 | if (output.empty()) { 49 | output = gui.output(); 50 | } 51 | if (run) 52 | output += "\n[ERROR] Running time out."; 53 | #else 54 | output = gui.tracer_json(); 55 | if (output.empty()) { 56 | output = "{\"code\":400,\"error\":\"empty tracer\"}"; 57 | } 58 | else if (run) { 59 | output = "{\"code\":400,\"error\":\"running timeout\"}"; 60 | } 61 | #endif 62 | gui.reset(); 63 | return P_OK; 64 | } 65 | } -------------------------------------------------------------------------------- /cparser/parser.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #ifdef CPARSER_EXPORTS 6 | #define CPARSER_API __declspec(dllexport) 7 | #else 8 | #define CPARSER_API __declspec(dllimport) 9 | #endif 10 | 11 | namespace clib { 12 | 13 | enum parser_ret { 14 | P_OK, 15 | P_ERROR, 16 | }; 17 | 18 | CPARSER_API parser_ret parser(std::string input, std::string& output); 19 | CPARSER_API parser_ret visualize(std::string input, std::string& output); 20 | } -------------------------------------------------------------------------------- /cparser/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // pch.cpp: 与预编译标头对应的源文件 2 | 3 | #include "stdafx.h" 4 | 5 | // 当使用预编译的头时,需要使用此源文件,编译才能成功。 6 | -------------------------------------------------------------------------------- /cparser/stdafx.h: -------------------------------------------------------------------------------- 1 | // pch.h: 这是预编译标头文件。 2 | // 下方列出的文件仅编译一次,提高了将来生成的生成性能。 3 | // 这还将影响 IntelliSense 性能,包括代码完成和许多代码浏览功能。 4 | // 但是,如果此处列出的文件中的任何一个在生成之间有更新,它们全部都将被重新编译。 5 | // 请勿在此处添加要频繁更新的文件,这将使得性能优势无效。 6 | 7 | #ifndef PCH_H 8 | #define PCH_H 9 | 10 | // 添加要在此处预编译的标头 11 | #include "framework.h" 12 | 13 | #endif //PCH_H 14 | -------------------------------------------------------------------------------- /screenshots/1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/screenshots/1.gif -------------------------------------------------------------------------------- /screenshots/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/screenshots/1.png -------------------------------------------------------------------------------- /screenshots/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/screenshots/2.png -------------------------------------------------------------------------------- /screenshots/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/screenshots/3.png -------------------------------------------------------------------------------- /screenshots/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/screenshots/4.png -------------------------------------------------------------------------------- /screenshots/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/screenshots/5.png -------------------------------------------------------------------------------- /screenshots/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajdcc/clibalgserver/0a464b1657c70244d18345ab8b2a4f222b32c18a/screenshots/6.png --------------------------------------------------------------------------------