Commit e725ca2d14e433b5e96ef73d831efb3a3789d4df
1 parent
b61efc88
new organisation of libraries for Anubis 1.6.5
Showing
80 changed files
with
1131 additions
and
2885 deletions
Show diff stats
| 1 | + | |
| 2 | + *Project* The Anubis Project | |
| 3 | + | |
| 4 | + *Title* Automatic generation of all library source files. | |
| 5 | + | |
| 6 | + *Copyright* Copyright (c) Alain Prouté 2005. | |
| 7 | + | |
| 8 | + | |
| 9 | + *Author* Alain Prouté | |
| 10 | + | |
| 11 | + | |
| 12 | + *Created: 2006 01 02 | |
| 13 | + *Author: David René | |
| 14 | + | |
| 15 | + Compil all examples | |
| 16 | + | |
| 17 | +read examples/args.anubis | |
| 18 | +read examples/conditional_examples.anubis | |
| 19 | +read examples/determinism.anubis.c | |
| 20 | +read examples/file_manager_example.anubis | |
| 21 | +read examples/for_loop.anubis.c | |
| 22 | +read examples/hello.anubis | |
| 23 | +read examples/kbd.anubis | |
| 24 | +read examples/ls.anubis | |
| 25 | +read examples/mkdir_test.anubis | |
| 26 | +read examples/OOCounter.cpp | |
| 27 | +read examples/peano.anubis | |
| 28 | +read examples/restart.anubis | |
| 29 | +read examples/saturate_example.anubis | |
| 30 | +read examples/syracuse.anubis | |
| 31 | +read examples/try_protect.anubis | |
| 32 | + read examples/watt.anubis | |
| 33 | +read examples/graphism/diaporama.anubis | |
| 34 | +read examples/graphism/paint.anubis | |
| 35 | + read examples/graphism/paint2.anubis | |
| 36 | +read examples/graphism/runge_kutta.anubis | |
| 37 | + read examples/graphism/show_image.anubis | |
| 38 | +read examples/graphism/try_window.anubis | |
| 39 | +read examples/network/client_browser_info.anubis | |
| 40 | +read examples/network/client_server.anubis | |
| 41 | +read examples/network/port_scan.anubis | |
| 42 | + read examples/network/sokoban.anubis | |
| 43 | +read examples/network/try_dns.anubis | |
| 44 | +read examples/network/upload.anubis | |
| 45 | + | |
| 46 | +read cryptography/sha1.anubis | |
| 47 | + | |
| 48 | +read data_base/import_csv.anubis | |
| 49 | +read data_base/sdbms.anubis | |
| 50 | +read data_base/sqlite.anubis | |
| 51 | + | |
| 52 | +read doc_tools/latex.anubis | |
| 53 | +read doc_tools/maml.anubis | |
| 54 | + | |
| 55 | +read graphism/image_tools.anubis | |
| 56 | +read graphism/jpeg.anubis | |
| 57 | +read graphism/jpeg_size.anubis | |
| 58 | + | |
| 59 | +read mail/send_mail.anubis | |
| 60 | + | |
| 61 | +read network/dns.anubis | |
| 62 | + | |
| 63 | +read system_colors/rgb.anubis | |
| 64 | +read system_colors/system_colors.anubis | |
| 65 | + | |
| 66 | + read system_fonts/draw_font.anubis | |
| 67 | + read system_fonts/font_table.anubis | |
| 68 | + | |
| 69 | +read tools/base64.anubis | |
| 70 | +read tools/basis.anubis | |
| 71 | +read tools/connections.anubis | |
| 72 | +read tools/findstring.anubis | |
| 73 | +read tools/hashtable.anubis | |
| 74 | +read tools/maybefloat.anubis | |
| 75 | +read tools/saturate.anubis | |
| 76 | +read tools/streams.anubis | |
| 77 | +read tools/tables.anubis | |
| 78 | +read tools/tools.anubis | |
| 79 | + | |
| 80 | +read web/web_arg_encode.anubis | |
| 81 | +read web/common.anubis | |
| 82 | +read web/cookies.anubis | |
| 83 | +read web/file_manager.anubis | |
| 84 | +read web/generic_form.anubis | |
| 85 | +read web/generic_table.anubis | |
| 86 | +read web/http_get.anubis | |
| 87 | +read web/http_get_common.anubis | |
| 88 | +read web/https_get.anubis | |
| 89 | +read web/making_a_web_site.anubis | |
| 90 | + read web/making_forms.anubis | |
| 91 | +read web/mime.anubis | |
| 92 | +read web/multihost_http_server.anubis | |
| 93 | +read web/read_html.anubis | ... | ... |
| 1 | +<?xml version="1.0" encoding="ascii"?> | |
| 2 | +<projectmodel> | |
| 3 | + <cmd_line></cmd_line> | |
| 4 | + <files objtype="list"> | |
| 5 | + <item>./compil_all.anubis</item> | |
| 6 | + <item>./examples/args.anubis</item> | |
| 7 | + <item>./examples/conditional_examples.anubis</item> | |
| 8 | + <item>./examples/determinism.anubis.c</item> | |
| 9 | + <item>./examples/file_manager_example.anubis</item> | |
| 10 | + <item>./examples/for_loop.anubis.c</item> | |
| 11 | + <item>./examples/hello.anubis</item> | |
| 12 | + <item>./examples/kbd.anubis</item> | |
| 13 | + <item>./examples/ls.anubis</item> | |
| 14 | + <item>./examples/mkdir_test.anubis</item> | |
| 15 | + <item>./examples/OOCounter.cpp</item> | |
| 16 | + <item>./examples/peano.anubis</item> | |
| 17 | + <item>./examples/playing_with_functions.anubis</item> | |
| 18 | + <item>./examples/restart.anubis</item> | |
| 19 | + <item>./examples/runge_kutta.anubis</item> | |
| 20 | + <item>./examples/saturate_example.anubis</item> | |
| 21 | + <item>./examples/syracuse.anubis</item> | |
| 22 | + <item>./examples/test_web_site.anubis</item> | |
| 23 | + <item>./examples/try_dns.anubis</item> | |
| 24 | + <item>./examples/try_protect.anubis</item> | |
| 25 | + <item>./examples/try_window.anubis</item> | |
| 26 | + <item>./examples/watt.anubis</item> | |
| 27 | + <item>./cryptography/sha1.anubis</item> | |
| 28 | + <item>./data_base/import_csv.anubis</item> | |
| 29 | + <item>./data_base/sdbms.anubis</item> | |
| 30 | + <item>./data_base/sqlite.anubis</item> | |
| 31 | + <item>./doc_tools/latex.anubis</item> | |
| 32 | + <item>./doc_tools/maml.anubis</item> | |
| 33 | + <item>./graphism/image_tools.anubis</item> | |
| 34 | + <item>./graphism/jpeg.anubis</item> | |
| 35 | + <item>./graphism/jpeg_size.anubis</item> | |
| 36 | + <item>./mail/send_mail.anubis</item> | |
| 37 | + <item>./network/dns.anubis</item> | |
| 38 | + <item>./system_colors/rgb.anubis</item> | |
| 39 | + <item>./system_colors/system_colors.anubis</item> | |
| 40 | + <item>./system_fonts/draw_font.anubis</item> | |
| 41 | + <item>./system_fonts/font_table.anubis</item> | |
| 42 | + <item>./tools/base64.anubis</item> | |
| 43 | + <item>./tools/basis.anubis</item> | |
| 44 | + <item>./tools/connections.anubis</item> | |
| 45 | + <item>./tools/findstring.anubis</item> | |
| 46 | + <item>./tools/hashtable.anubis</item> | |
| 47 | + <item>./tools/maybefloat.anubis</item> | |
| 48 | + <item>./tools/saturate.anubis</item> | |
| 49 | + <item>./tools/streams.anubis</item> | |
| 50 | + <item>./tools/tables.anubis</item> | |
| 51 | + <item>./tools/tools.anubis</item> | |
| 52 | + <item>./web/web_arg_encode.anubis</item> | |
| 53 | + <item>./web/common.anubis</item> | |
| 54 | + <item>./web/cookies.anubis</item> | |
| 55 | + <item>./web/file_manager.anubis</item> | |
| 56 | + <item>./web/generic_form.anubis</item> | |
| 57 | + <item>./web/generic_table.anubis</item> | |
| 58 | + <item>./web/http_get.anubis</item> | |
| 59 | + <item>./web/http_get_common.anubis</item> | |
| 60 | + <item>./web/https_get.anubis</item> | |
| 61 | + <item>./web/making_a_web_site.anubis</item> | |
| 62 | + <item>./web/making_forms.anubis</item> | |
| 63 | + <item>./web/mime.anubis</item> | |
| 64 | + <item>./web/multihost_http_server.anubis</item> | |
| 65 | + <item>./web/read_html.anubis</item> | |
| 66 | + <item>./examples/graphism/diaporama.anubis</item> | |
| 67 | + <item>./examples/graphism/paint2.anubis</item> | |
| 68 | + <item>./examples/graphism/paint.anubis</item> | |
| 69 | + <item>./examples/graphism/show_image.anubis</item> | |
| 70 | + <item>./examples/network/client_browser_info.anubis</item> | |
| 71 | + <item>./examples/network/client_server.anubis</item> | |
| 72 | + <item>./examples/network/port_scan.anubis</item> | |
| 73 | + <item>./examples/network/sokoban.anubis</item> | |
| 74 | + <item>./examples/network/upload.anubis</item> | |
| 75 | + </files> | |
| 76 | + <startup_file></startup_file> | |
| 77 | + <working_dir></working_dir> | |
| 78 | +</projectmodel> | ... | ... |
| 1 | + | |
| 2 | + | |
| 3 | + *Project* The Anubis Project | |
| 4 | + | |
| 5 | + *Title* Reading CSV tables. | |
| 6 | + | |
| 7 | + *Copyright* Copyright (c) Alain Prouté 2003. | |
| 8 | + | |
| 9 | + *Created* | |
| 10 | + *Author* Alain Prouté | |
| 11 | + | |
| 12 | + *Overview* | |
| 13 | + This file defines a tool for reading tables. A 'table' is a file containing 'lines' | |
| 14 | + separated by a special character (or a combination of special characters), most often | |
| 15 | + '\n' (ASCII 10) or '\r' (ASCII 13). Each line is separated into 'cells'. A special | |
| 16 | + character is used for separating the cells within a line, most often '\t' (ASCII 9), | |
| 17 | + ';' or '&'. Of course, this implies that these special characters are not used for the | |
| 18 | + content of the cells themselves. | |
| 19 | + | |
| 20 | + Below is an example of a table whose line separator is '\n' (hence invisible in the | |
| 21 | + example), and cell separator is '&': | |
| 22 | + | |
| 23 | + cell_1_1&cell_1_2&cell_1_3 | |
| 24 | + cell_2_1&cell_2_2 | |
| 25 | + | |
| 26 | + This table has two lines. Notice that the lines need not have the same number of | |
| 27 | + cells. Also, no line separator is following the string "cell_2_2" (the last byte in the | |
| 28 | + file is '2'), otherwise the table would have 3 lines (with the last line empty). | |
| 29 | + | |
| 30 | + The content of a cell is considered as a character string. The contents of selected | |
| 31 | + cells must eventually be transformed into integers or floating point numbers (or | |
| 32 | + anything else), but this transformation is not handled here. The function defined here | |
| 33 | + returns (maybe) a datum of type: | |
| 34 | + | |
| 35 | + List(List(String)) | |
| 36 | + | |
| 37 | + which is to be interpreted as a list of lines, each line being a list of cells, each | |
| 38 | + cell being a character strings. | |
| 39 | + | |
| 40 | + The function requires that you declare the possible separators. Each line separator is | |
| 41 | + declared as a list of 'Int8'. For example, if the lines of the table to be read are | |
| 42 | + separated by carriage return '\r' and line feed '\n' (in this order), the line | |
| 43 | + separator is represented by '[13,10]', or by '['\r','\n']'. | |
| 44 | + | |
| 45 | + On the contrary, we assume that only one character is used as cell separator. Hence, a | |
| 46 | + cell separator is represented by a single Int8. Below are realistic examples: | |
| 47 | + | |
| 48 | + ';' '&' '\t' 9 | |
| 49 | + | |
| 50 | + The function below can handle several line separators and several cell separators | |
| 51 | + simultaneously, so that the same call to the function can handle tables whose | |
| 52 | + separators are different, or even handle tables with mixed separators (not usual). The | |
| 53 | + function can also ignore some charaters (typically the space (ASCII 32)). | |
| 54 | + | |
| 55 | +public define Maybe(List(List(String))) | |
| 56 | + read_table | |
| 57 | + ( | |
| 58 | + String filename, | |
| 59 | + NonEmptyList(NonEmptyList(Int8)) line_separators, | |
| 60 | + NonEmptyList(Int8) cell_separators | |
| 61 | + ). | |
| 62 | + | |
| 63 | + For example, the next call can read several sorts of tables: | |
| 64 | + | |
| 65 | + read_table(filename, | |
| 66 | + [[10],[13],[13,10]], | |
| 67 | + [';','\t']) | |
| 68 | + | |
| 69 | + It reads tables whose lines are separated either by '\n', '\r' or '\r' followed by | |
| 70 | + '\n', and whose cells are separated either by ';' or by a tabulator. | |
| 71 | + | |
| 72 | + The result is 'failure' when the file cannot be opened. Otherwise, a table is always | |
| 73 | + read (which may be empty, or wrong if you do not choose the right separators). | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + --- That's all for the public part. --------------------------------------------------- | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + Transforming a non empty list into a list. | |
| 85 | + | |
| 86 | +define List($T) | |
| 87 | + to_list | |
| 88 | + ( | |
| 89 | + NonEmptyList($T) l | |
| 90 | + ) = | |
| 91 | + if l is [first . others] then [first . others]. | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + Checking if a list of Int8 'candidate' is a prefix in a line separator. | |
| 100 | + | |
| 101 | + | |
| 102 | +define Bool | |
| 103 | + begins_line_separator | |
| 104 | + ( | |
| 105 | + List(Int8) candidate, | |
| 106 | + List(Int8) line_sep | |
| 107 | + ) = | |
| 108 | + if candidate is | |
| 109 | + { | |
| 110 | + [ ] then true, | |
| 111 | + [ch . ct] then | |
| 112 | + if line_sep is | |
| 113 | + { | |
| 114 | + [ ] then false, | |
| 115 | + [sh . st] then | |
| 116 | + if ch = sh | |
| 117 | + then begins_line_separator(ct,st) | |
| 118 | + else false | |
| 119 | + } | |
| 120 | + }. | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + Here is the test. | |
| 125 | + | |
| 126 | +define Bool | |
| 127 | + begins_line_separator | |
| 128 | + ( | |
| 129 | + List(Int8) candidate, | |
| 130 | + List(List(Int8)) line_seps | |
| 131 | + ) = | |
| 132 | + if line_seps is | |
| 133 | + { | |
| 134 | + [ ] then false, | |
| 135 | + [s . others] then | |
| 136 | + if begins_line_separator(candidate,s) | |
| 137 | + then true | |
| 138 | + else begins_line_separator(candidate,others) | |
| 139 | + }. | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + We have two cross recursive functions 'read_table' and 'read_more_lines'. | |
| 145 | + | |
| 146 | +define List(List(String)) | |
| 147 | + read_table | |
| 148 | + ( | |
| 149 | + RAddr(Int8) file, | |
| 150 | + List(List(Int8)) line_seps, | |
| 151 | + List(Int8) line_sep_firsts, | |
| 152 | + List(Int8) cell_seps, | |
| 153 | + List(List(String)) so_far, | |
| 154 | + List(String) current_line, | |
| 155 | + List(Int8) current_cell | |
| 156 | + ). | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + Reading more lines from a table. We have already read several lines (at least one) and | |
| 161 | + we have read a character 'c' (or several) which is (are) the first in a line separator. | |
| 162 | + We read a new character 'd'. If a line separator begins by 'c' 'd' we continue until | |
| 163 | + the characters read do not form a line separator. Of course we must handle end of | |
| 164 | + file. If end of file is read, the last line of the table is empty. Otherwise, we | |
| 165 | + return to 'read_table', with the correct 'current_line' and 'current_cell'. | |
| 166 | + | |
| 167 | +define List(List(String)) | |
| 168 | + read_more_lines | |
| 169 | + ( | |
| 170 | + RAddr(Int8) file, | |
| 171 | + List(List(Int8)) line_seps, | |
| 172 | + List(Int8) line_sep_firsts, | |
| 173 | + List(Int8) cell_seps, | |
| 174 | + List(List(String)) so_far, // lines read so far | |
| 175 | + List(Int8) firsts_in_sep // first characters of line separator (just read) | |
| 176 | + ) = | |
| 177 | + if *file is | |
| 178 | + { | |
| 179 | + failure then reverse([[] . so_far]), // last line empty | |
| 180 | + success(d) then with firsts = (List(Int8))[d . firsts_in_sep], | |
| 181 | + if begins_line_separator(firsts,line_seps) | |
| 182 | + then read_more_lines(file,line_seps,line_sep_firsts,cell_seps,so_far,firsts) | |
| 183 | + else read_table(file,line_seps,line_sep_firsts,cell_seps,so_far,[],[d]) | |
| 184 | + }. | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + Reading a table from an already opened file. | |
| 189 | + | |
| 190 | +define List(List(String)) | |
| 191 | + read_table | |
| 192 | + ( | |
| 193 | + RAddr(Int8) file, | |
| 194 | + List(List(Int8)) line_seps, | |
| 195 | + List(Int8) line_sep_firsts, // first characters in line separators | |
| 196 | + List(Int8) cell_seps, | |
| 197 | + List(List(String)) so_far, // lines read so far | |
| 198 | + List(String) current_line, // cells read so far in the current line | |
| 199 | + List(Int8) current_cell // characters read so far in the current cell | |
| 200 | + ) = | |
| 201 | + if *file is | |
| 202 | + { | |
| 203 | + failure then | |
| 204 | + reverse([reverse([implode(reverse(current_cell)) . current_line]) . so_far]), | |
| 205 | + | |
| 206 | + success(c) then | |
| 207 | + if member(line_sep_firsts,c) | |
| 208 | + then read_more_lines(file,line_seps,line_sep_firsts,cell_seps, | |
| 209 | + [reverse([implode(reverse(current_cell)) . current_line]) . so_far],[c]) | |
| 210 | + else if member(cell_seps,c) | |
| 211 | + then read_table(file,line_seps,line_sep_firsts,cell_seps,so_far, | |
| 212 | + [implode(reverse(current_cell)) . current_line],[]) | |
| 213 | + else read_table(file,line_seps,line_sep_firsts,cell_seps,so_far,current_line, | |
| 214 | + [c . current_cell]) | |
| 215 | + }. | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + Now, here is our tool. | |
| 222 | + | |
| 223 | +public define Maybe(List(List(String))) | |
| 224 | + read_table | |
| 225 | + ( | |
| 226 | + String filename, | |
| 227 | + NonEmptyList(NonEmptyList(Int8)) line_separators, | |
| 228 | + NonEmptyList(Int8) cell_separators | |
| 229 | + ) = | |
| 230 | + if (Maybe(RAddr(Int8)))file(filename,read) is | |
| 231 | + { | |
| 232 | + failure then failure, | |
| 233 | + success(file) then with line_seps = to_list(line_separators), | |
| 234 | + success(read_table(file, | |
| 235 | + map(reverse,map(to_list,line_seps)), | |
| 236 | + map((NonEmptyList(Int8) l) |-> if l is [h.t] then h, line_seps), | |
| 237 | + to_list(cell_separators), | |
| 238 | + [],[],[])) | |
| 239 | + }. | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + Try it ! | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | +define One | |
| 251 | + table_print | |
| 252 | + ( | |
| 253 | + List(String) l | |
| 254 | + ) = | |
| 255 | + if l is | |
| 256 | + { | |
| 257 | + [ ] then print("\n"), | |
| 258 | + [h . t] then print(h); | |
| 259 | + (if t is [] then unique else print(" | ")); | |
| 260 | + table_print(t) | |
| 261 | + }. | |
| 262 | + | |
| 263 | +define One | |
| 264 | + table_print | |
| 265 | + ( | |
| 266 | + List(List(String)) t | |
| 267 | + ) = | |
| 268 | + if t is | |
| 269 | + { | |
| 270 | + [ ] then unique, | |
| 271 | + [h . t] then table_print(h); table_print(t) | |
| 272 | + }. | |
| 273 | + | |
| 274 | +define One | |
| 275 | + table_print | |
| 276 | + ( | |
| 277 | + Maybe(List(List(String))) t | |
| 278 | + ) = | |
| 279 | + if t is | |
| 280 | + { | |
| 281 | + failure then print("File not found.\n"), | |
| 282 | + success(l) then table_print(l) | |
| 283 | + }. | |
| 284 | + | |
| 285 | +global define One | |
| 286 | + read_csv_table | |
| 287 | + ( | |
| 288 | + List(String) args | |
| 289 | + ) = | |
| 290 | + if args is | |
| 291 | + { | |
| 292 | + [ ] then print("Usage: read_csv_table <filename>\n"), | |
| 293 | + [h . t] then | |
| 294 | + table_print(read_table(h, | |
| 295 | + [[10],[13],[13,10]], | |
| 296 | + [';','\t','&'])) | |
| 297 | + }. | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 0 | 301 | \ No newline at end of file | ... | ... |
anubis_dev/library/tools/sdbms.anubis renamed to anubis_dev/library/data_base/sdbms.anubis
| 1 | 1 | |
| 2 | 2 | |
| 3 | - The Anubis/Paradize Project. | |
| 3 | + *Project* The Anubis Project | |
| 4 | 4 | |
| 5 | - A Simple Data Base Management System. | |
| 5 | + *Title* A Simple Data Base Management System. | |
| 6 | 6 | |
| 7 | - Copyright (c) Alain Prouté 2004-2005. | |
| 7 | + *Copyright* Copyright (c) Alain Prouté 2004-2005. | |
| 8 | 8 | |
| 9 | 9 | |
| 10 | - Author: Alain Prouté | |
| 10 | + *Author* Alain Prouté | |
| 11 | 11 | |
| 12 | - Last revision: January 2005. | |
| 12 | + *Revised* January 2005. | |
| 13 | 13 | |
| 14 | 14 | |
| 15 | 15 | ... | ... |
anubis_dev/library/data_base/sqlite.anubis
| 1 | 1 | |
| 2 | - *Project: Anubis | |
| 2 | + *Project* Anubis | |
| 3 | 3 | |
| 4 | - *Title: SQLite wrapper library | |
| 4 | + *Title* SQLite wrapper library | |
| 5 | 5 | |
| 6 | - *Copyright: Copyright (c) Constructive Mathematics 2005. | |
| 6 | + *Copyright* Copyright (c) Alain Prouté 2005. | |
| 7 | 7 | |
| 8 | 8 | |
| 9 | 9 | |
| 10 | - | |
| 11 | - | |
| 12 | - *Author: David René | |
| 10 | + *Author* David René | |
| 13 | 11 | |
| 14 | - *Created: 2005 12 27 | |
| 15 | - *Revised: december 2005 | |
| 16 | - *Compatibility: 1.6.5 | |
| 12 | + *Created* 2005 12 27 | |
| 13 | + *Revised* december 2005 | |
| 14 | + *Compatibility* 1.6.5 | |
| 17 | 15 | |
| 18 | - *Intro: This library is intended to make easy to use the SQLite Database. We tried to made | |
| 16 | + *Overview* | |
| 17 | + This library is intended to make easy to use the SQLite Database. We tried to made | |
| 19 | 18 | just all necessaries functions for using SQLite with no Dr Shadoko's principle. |
| 20 | 19 | All boring stuff are made by this library. But if, we forgotten some function, you are welcome |
| 21 | 20 | to add them in this file. |
| 22 | 21 | |
| 23 | - *Public: | |
| 22 | + *Public* | |
| 24 | 23 | |
| 25 | - *Description: | |
| 24 | + *Description* | |
| 26 | 25 | |
| 27 | 26 | This function print on current output, the content of datatabase table. The content of table |
| 28 | 27 | result of sql_query. All rows and columns are stored in list of list of string. the result of |
| ... | ... | @@ -42,9 +41,9 @@ public define One db_print_table ( List(List(String)) l ) = |
| 42 | 41 | db_print_table(t) |
| 43 | 42 | }. |
| 44 | 43 | |
| 45 | - *Public: | |
| 44 | + *Public* | |
| 46 | 45 | |
| 47 | - *Description: | |
| 46 | + *Description* | |
| 48 | 47 | |
| 49 | 48 | This function print on current output, the database error number with your own message |
| 50 | 49 | in msg | ... | ... |
anubis_dev/library/tools/latex.anubis renamed to anubis_dev/library/doc_tools/latex.anubis
anubis_dev/library/doc_tools/make_doc.anubis
| 1 | - | |
| 2 | - *Project* Anubis | |
| 1 | + | |
| 2 | + *Project* The Anubis Project | |
| 3 | 3 | |
| 4 | 4 | *Title* Automatic generation of documentation from source files. |
| 5 | 5 | |
| 6 | - *Copyright* Copyright (c) Alain Prouté 2005. | |
| 6 | + *Copyright* Copyright (c) Alain Prouté 2005. | |
| 7 | 7 | |
| 8 | 8 | |
| 9 | 9 | |
| 10 | 10 | |
| 11 | 11 | |
| 12 | - *Author* Alain Prouté | |
| 13 | - *Author* David René | |
| 12 | + *Author* Alain Prouté | |
| 13 | + *Author* David René | |
| 14 | 14 | |
| 15 | 15 | *Revised* december 2005 |
| 16 | 16 | |
| ... | ... | @@ -24,7 +24,7 @@ |
| 24 | 24 | |
| 25 | 25 | Items are introduced by --tags--. Each tag is made of a star `*`, a name, and again a |
| 26 | 26 | star `*`. It may also be made only of stars. It is recognized if it has only white |
| 27 | - spaces (and tabulators) on its left. The scope of the tag begins juste after the tag | |
| 27 | + spaces (and tabulators) on its left. The scope of the tag begins just after the tag | |
| 28 | 28 | itself, and extends to the next tag, the beginning of the next Anubis paragraph or the |
| 29 | 29 | end of the file. |
| 30 | 30 | |
| ... | ... | @@ -127,7 +127,7 @@ public define List(DocItem) |
| 127 | 127 | ). |
| 128 | 128 | |
| 129 | 129 | |
| 130 | -read tools/maml.anubis | |
| 130 | +read doc_tools/maml.anubis | |
| 131 | 131 | |
| 132 | 132 | |
| 133 | 133 | *Name* DocLanguageSet | ... | ... |
anubis_dev/library/tools/maml.anubis renamed to anubis_dev/library/doc_tools/maml.anubis
| 1 | 1 | |
| 2 | + | |
| 3 | + *Project* The Anubis Project | |
| 4 | + | |
| 5 | + *Title* The Minimal Anubis Markup Language. | |
| 6 | + (MAML) | |
| 2 | 7 | |
| 3 | - The Minimal Anubis Markup Language. | |
| 4 | - (MAML) | |
| 8 | + *Copyright* Copyright (c) Alain Prouté 2005. | |
| 9 | + | |
| 10 | + | |
| 11 | + *Author* Alain Prouté | |
| 12 | + | |
| 5 | 13 | |
| 6 | 14 | |
| 7 | 15 | |
| ... | ... | @@ -129,7 +137,7 @@ public define Result(Int32,String) |
| 129 | 137 | |
| 130 | 138 | |
| 131 | 139 | read tools/basis.anubis |
| 132 | -read tools/latex.anubis | |
| 140 | +read doc_tools/latex.anubis | |
| 133 | 141 | |
| 134 | 142 | define String |
| 135 | 143 | html_format | ... | ... |
anubis_dev/library/examples/OOCounter.cpp
anubis_dev/library/examples/args.anubis
| 1 | 1 | |
| 2 | - The Anubis Project. | |
| 2 | + *Project* The Anubis Project | |
| 3 | 3 | |
| 4 | - Getting command line arguments. | |
| 4 | + *Title* Getting command line arguments. | |
| 5 | 5 | |
| 6 | - | |
| 7 | - Author: Alain Proute' | |
| 6 | + *Copyright* Copyright (c) Alain Prouté 2005. | |
| 7 | + | |
| 8 | + | |
| 9 | + *Author* Alain Prouté | |
| 8 | 10 | |
| 9 | 11 | This is a simple example to show how Anubis modules can get their command line |
| 10 | 12 | arguments. | ... | ... |
anubis_dev/library/examples/client_browser_info.anubis deleted
| 1 | - | |
| 2 | - | |
| 3 | - The Anubis/Paradize Project. | |
| 4 | - | |
| 5 | - Testing the HTTP server. | |
| 6 | - | |
| 7 | - Copyright (c) Alain Prouté 2004-2005. | |
| 8 | - | |
| 9 | - | |
| 10 | - Authors: Alain Proute' | |
| 11 | - | |
| 12 | - | |
| 13 | - This is just a demo showing how the HTTP server may be used and how it may recover all | |
| 14 | - the info coming from the clients browser, including the IP address, and all HTTP | |
| 15 | - headers. | |
| 16 | - | |
| 17 | - | |
| 18 | -read tools/basis.anubis | |
| 19 | - | |
| 20 | -read web/common.anubis | |
| 21 | -read web/html.anubis | |
| 22 | -read web/calculatrice.anubis | |
| 23 | - | |
| 24 | -define List(Table_row) | |
| 25 | - http_headers_rows | |
| 26 | - ( | |
| 27 | - List(HTTP_header) headers | |
| 28 | - ) = | |
| 29 | - if headers is | |
| 30 | - { | |
| 31 | - [ ] then [ ], | |
| 32 | - [h . t] then if h is http_header(name,value) then | |
| 33 | - [row([cell([nowrap,right],text(name)), | |
| 34 | - cell([absolute_width(10)],text(":")), | |
| 35 | - cell([left],text(value))]) | |
| 36 | - . http_headers_rows(t)] | |
| 37 | - }. | |
| 38 | - | |
| 39 | - | |
| 40 | -define Web_item | |
| 41 | - http_headers_table | |
| 42 | - ( | |
| 43 | - List(HTTP_header) headers | |
| 44 | - ) = | |
| 45 | - table([border(0,0,0),absolute_width(600)],http_headers_rows(headers)+[row(calculatrice)]). | |
| 46 | - | |
| 47 | - | |
| 48 | -read web/http_server.anubis | |
| 49 | - | |
| 50 | - | |
| 51 | -public define (String,String,Web_page) | |
| 52 | - tickets_and_web_page | |
| 53 | - ( | |
| 54 | - Int32 ip_address, | |
| 55 | - String uri, | |
| 56 | - List(HTTP_header) headers, | |
| 57 | - List(Web_arg) lwa, | |
| 58 | - Server server | |
| 59 | - ) = | |
| 60 | - ("","",web_page("Client Browser Informations",[],script_calculatrice, | |
| 61 | - body([background_color(rgb(255,255,0) /* yellow */ )], | |
| 62 | - center(table([nude], | |
| 63 | - [ | |
| 64 | - row(text("Your IP address is: "+ip_addr_to_string(ip_address))), | |
| 65 | - row(text("You requested the URI: "+uri)), | |
| 66 | - row(big(text("The HTTP headers your browser sent:"))), | |
| 67 | - row(http_headers_table(headers)) | |
| 68 | - ] | |
| 69 | - ))))). | |
| 70 | - | |
| 71 | - | |
| 72 | - | |
| 73 | -define HTTP_ServerDescription | |
| 74 | - description | |
| 75 | - = | |
| 76 | - http_server_description(ip_address((127,0,0,1)), | |
| 77 | - 80, | |
| 78 | - [redirect("/","127.0.0.1","/info.awp")], | |
| 79 | - ".", | |
| 80 | - [".awp",".html",".exe",""], | |
| 81 | - ["user-agent","host"], | |
| 82 | - tickets_and_web_page, | |
| 83 | - identity). | |
| 84 | - | |
| 85 | - | |
| 86 | - | |
| 87 | - The command for starting the server. | |
| 88 | - | |
| 89 | -global define One | |
| 90 | - browser_info_site | |
| 91 | - ( | |
| 92 | - List(String) args | |
| 93 | - ) = | |
| 94 | - if start_http_server(description) is | |
| 95 | - { | |
| 96 | - unique then unique | |
| 97 | - }. | |
| 98 | - | |
| 99 | - | |
| 100 | - | |
| 101 | - | |
| 102 | - Ok, now compile this file: anubis client_browser_info.anubis | |
| 103 | - start the server: browser_info_site | |
| 104 | - open your browser: netscape (maybe) | |
| 105 | - and try the address: http://127.0.0.1 | |
| 106 | - | |
| 107 | - You will see the infos on your request and browser. | |
| 108 | - | |
| 109 | - | |
| 110 | - | |
| 111 | 0 | \ No newline at end of file |
anubis_dev/library/examples/client_server.anubis deleted
| 1 | - | |
| 2 | - | |
| 3 | - The Anubis Project. | |
| 4 | - | |
| 5 | - A simple client/server program. | |
| 6 | - | |
| 7 | - Copyright (c) Alain Prouté 2005. | |
| 8 | - | |
| 9 | - | |
| 10 | - Author: Alain Prouté | |
| 11 | - | |
| 12 | - | |
| 13 | - This file contains a example of a server and the corresponding client. It is a | |
| 14 | - 'minimalist' program, as simple as possible. In this file you learn how to use the | |
| 15 | - following functions: | |
| 16 | - | |
| 17 | - function defined in | |
| 18 | - ---------------------------------------------------------------------- | |
| 19 | - start_server predefined.anubis | |
| 20 | - remote_IP_address_and_port predefined.anubis | |
| 21 | - ip_addr_to_string tools/basis.anubis | |
| 22 | - prompt tools/basis.anubis | |
| 23 | - reliable_write tools/basis.anubis | |
| 24 | - tcp tools/connections.anubis | |
| 25 | - to_byte_array predefined.anubis | |
| 26 | - ip_address tools/basis.anubis | |
| 27 | - connect predefined.anubis | |
| 28 | - | |
| 29 | - | |
| 30 | - In order to try it out, compile this file and open two consoles. In the first console, | |
| 31 | - issue the command: | |
| 32 | - | |
| 33 | - simple_server 3000 | |
| 34 | - | |
| 35 | - In the second console, issue the command: | |
| 36 | - | |
| 37 | - simple_client 127.0.0.1 3000 | |
| 38 | - | |
| 39 | - Now, enter some text in the client (second) console. It should appear in the server | |
| 40 | - (first) console. | |
| 41 | - | |
| 42 | - | |
| 43 | - | |
| 44 | - *** Description. | |
| 45 | - | |
| 46 | - The server starts and waits for one or several client programs to connect. When a | |
| 47 | - client program is connected, the user of this client program may input sentences using | |
| 48 | - the keyboard. Each line is transmitted to the server, and the server prints it on its | |
| 49 | - console. That's all. | |
| 50 | - | |
| 51 | - There is nothing to do in order to handle several clients simultaneously. This is done | |
| 52 | - automatically by the functions defined in 'predefined.anubis'. | |
| 53 | - | |
| 54 | - | |
| 55 | -read tools/basis.anubis | |
| 56 | -read tools/connections.anubis | |
| 57 | - | |
| 58 | - | |
| 59 | - | |
| 60 | - *** The server. | |
| 61 | - | |
| 62 | - The server needs a 'handler'. Recall (see 'predefined.anubis') that when a client is | |
| 63 | - connected, the server starts a virtual machine for handling this client (one machine | |
| 64 | - per client). This virtual machine runs the following program, which is an 'infinite' | |
| 65 | - loop. Actually, the loop is exited when the client closes the connection. | |
| 66 | - | |
| 67 | - The server handler reads bytes from the connection until a line feed ('\n') is | |
| 68 | - found. Then, it prints the bytes prefixed by the address and port of the client. It | |
| 69 | - continues to read until the connection is closed by the client. | |
| 70 | - | |
| 71 | -define One | |
| 72 | - server_handler | |
| 73 | - ( | |
| 74 | - RWAddr(Int8) connection, // the connection with the client | |
| 75 | - List(Int8) read_so_far, // the bytes read so far (in reverse order) | |
| 76 | - String from // the prefix string (for example: | |
| 77 | - // "From 127.0.0.1:12345: ") | |
| 78 | - ) = | |
| 79 | - if *connection is // read one byte from the connection | |
| 80 | - // (this expression waits for the next byte or the connection | |
| 81 | - // is closed by the client) | |
| 82 | - { | |
| 83 | - failure then // the connection has been closed by the client | |
| 84 | - print(from+"Connection closed by client.\n"), | |
| 85 | - | |
| 86 | - success(c) then // the byte 'c' has been read | |
| 87 | - if c = '\n' | |
| 88 | - // if this byte is '\n', it is time to print the message received from the client | |
| 89 | - then (print(from+ | |
| 90 | - implode(reverse(read_so_far))+"\n"); // print the message | |
| 91 | - server_handler(connection,[],from)) // continue to wait for bytes | |
| 92 | - | |
| 93 | - // otherwise, just remember the byte read and continue to wait for bytes | |
| 94 | - else server_handler(connection,[c . read_so_far],from) | |
| 95 | - }. | |
| 96 | - | |
| 97 | - | |
| 98 | - Notice that the recursive calls to 'server_handler' above are terminal so that the | |
| 99 | - above function is an actual loop (the stack of the virtual machine does not grow at | |
| 100 | - each call). | |
| 101 | - | |
| 102 | - | |
| 103 | - The function 'start_server' requires the handler in the form of a function of type: | |
| 104 | - | |
| 105 | - Server -> ((RWAddr(Int8)) -> One) | |
| 106 | - | |
| 107 | - (see 'predefined.anubis'). The 'Server' argument is not used by the handler. The next | |
| 108 | - function 'make_server_handler' is just an interface so that 'start_server' can get the | |
| 109 | - handler with the required type. | |
| 110 | - | |
| 111 | -define Server -> ((RWAddr(Int8)) -> One) | |
| 112 | - make_server_handler | |
| 113 | - ( | |
| 114 | - One u // this dummy argument is required because the Anubis compiler | |
| 115 | - // version 1 cannot handle definition of functions at top level | |
| 116 | - // with no argument after the name. This is due to the fact that | |
| 117 | - // version 1 identifies functions of zero operand with the result | |
| 118 | - // of applying this function to zero operand. This was an | |
| 119 | - // unfortunate design idea. | |
| 120 | - ) = | |
| 121 | - (Server s) |-> | |
| 122 | - (RWAddr(Int8) connection) |-> | |
| 123 | - // | |
| 124 | - // we use 'remote_IP_address_and_port' (see 'predefined.anubis') | |
| 125 | - // for getting the address and port of the client. | |
| 126 | - // | |
| 127 | - if remote_IP_address_and_port(connection) is (a,p) then | |
| 128 | - print("New connection from "+ip_addr_to_string(a)+":"+p+"\n"); | |
| 129 | - server_handler(connection, | |
| 130 | - [], | |
| 131 | - // | |
| 132 | - // and we construct the prefix string once and for all | |
| 133 | - // | |
| 134 | - "From "+ip_addr_to_string(a)+":"+p+": "). | |
| 135 | - | |
| 136 | - | |
| 137 | - The 'simple_server' program must be started with a port number. The function below | |
| 138 | - recalls the syntax. | |
| 139 | - | |
| 140 | -define One | |
| 141 | - server_syntax | |
| 142 | - = | |
| 143 | - print("Usage: simple_server <port number>\n"). | |
| 144 | - | |
| 145 | - | |
| 146 | - Now, here is the function generating the module 'simple_server.adm'. We need to read | |
| 147 | - the port number (which is a string), to transform it to an integer, and to start the | |
| 148 | - server. All these operations may produce errors, which are handled by error messages. | |
| 149 | - | |
| 150 | -global define One | |
| 151 | - simple_server | |
| 152 | - ( | |
| 153 | - List(String) args | |
| 154 | - ) = | |
| 155 | - if args is | |
| 156 | - { | |
| 157 | - [ ] then server_syntax, | |
| 158 | - [h . _] then | |
| 159 | - if string_to_integer(h) is | |
| 160 | - { | |
| 161 | - failure then server_syntax, | |
| 162 | - success(port) then | |
| 163 | - if start_server(0, // listen on all network interfaces | |
| 164 | - port, | |
| 165 | - make_server_handler(unique), | |
| 166 | - (One u) |-> u) is | |
| 167 | - { | |
| 168 | - cannot_create_the_socket then print("Cannot create the socket for listening.\n"), | |
| 169 | - cannot_bind_to_port then print("Cannot bind to port "+h+".\n"), | |
| 170 | - cannot_listen_on_port then print("Cannot listen on port "+h+".\n"), | |
| 171 | - ok(server) then print("Simple Server started on port "+h+".\n") | |
| 172 | - } | |
| 173 | - } | |
| 174 | - }. | |
| 175 | - | |
| 176 | - | |
| 177 | - | |
| 178 | - | |
| 179 | - | |
| 180 | - *** The client. | |
| 181 | - | |
| 182 | - The client handler sends a 'prompt' to the client console, and waits for a line of | |
| 183 | - text. The function 'prompt' used below is taken from 'tools/basis.anubis'. We use | |
| 184 | - 'reliable_write' (also defined in 'tools/basis.anubis') for sending the message. The | |
| 185 | - function 'reliable_write' requires a connection of type 'Connection' (defined in | |
| 186 | - 'tools/connections.anubis'). This is why the constructor 'tcp' is required here. Also, | |
| 187 | - the text must be transformed into a byte array before being sent. The conversion | |
| 188 | - function 'to_byte_array' is defined in 'predefined.anubis'. | |
| 189 | - | |
| 190 | -define One | |
| 191 | - client_handler | |
| 192 | - ( | |
| 193 | - RWAddr(Int8) connection | |
| 194 | - ) = | |
| 195 | - with text = prompt("simple_client> "), | |
| 196 | - if reliable_write(tcp(connection),to_byte_array(text+"\n")) is | |
| 197 | - { | |
| 198 | - failure then print("Cannot send message.\n"), | |
| 199 | - success(n) then unique | |
| 200 | - }; | |
| 201 | - client_handler(connection). | |
| 202 | - | |
| 203 | - Notice again that the above is an 'infinite' loop. Actually, this loop cannot be exited | |
| 204 | - within the program. It is exited only when 'anbexec' (of the client) is stopped by a | |
| 205 | - [Ctrl C]. Also notice that we must not forget to send "\n" appended to the | |
| 206 | - text. Otherwise, the server will wait indefinitely for the end of the line, and will | |
| 207 | - print nothing. This "\n" is part of our 'simple transmission protocol'. | |
| 208 | - | |
| 209 | - | |
| 210 | - The client program requires an IP address and port number in order to be able to find | |
| 211 | - the server. The next function recalls the syntax of 'simple_client'. | |
| 212 | - | |
| 213 | -define One | |
| 214 | - client_syntax | |
| 215 | - ( | |
| 216 | - String additional_message | |
| 217 | - ) = | |
| 218 | - print("Usage: simple_client <IP address> <port number>\n"); | |
| 219 | - print(additional_message). | |
| 220 | - | |
| 221 | - | |
| 222 | - Now, here is the function generating the module 'simple_client.adm'. The arguments (IP | |
| 223 | - address and port number) are first read and converted. | |
| 224 | - | |
| 225 | -global define One | |
| 226 | - simple_client | |
| 227 | - ( | |
| 228 | - List(String) args | |
| 229 | - ) = | |
| 230 | - if args is | |
| 231 | - { | |
| 232 | - [ ] then // no argument on command line | |
| 233 | - client_syntax("Address and port number missing.\n"), | |
| 234 | - | |
| 235 | - [a . t] then if t is | |
| 236 | - { | |
| 237 | - [ ] then // only one argument on command line | |
| 238 | - client_syntax("Port number missing.\n"), | |
| 239 | - | |
| 240 | - [p . _] then // try to convert the IP address | |
| 241 | - // 'ip_address' is defined in 'tools/basis.anubis' | |
| 242 | - if ip_address(a) is | |
| 243 | - { | |
| 244 | - failure then | |
| 245 | - client_syntax("Incorrect IP address.\n"), | |
| 246 | - | |
| 247 | - success(addr) then // try to convert the port number | |
| 248 | - if string_to_integer(p) is | |
| 249 | - { | |
| 250 | - failure then | |
| 251 | - client_syntax("Incorrect port number.\n"), | |
| 252 | - | |
| 253 | - success(port) then // try to connect to server | |
| 254 | - if connect(addr,port) is | |
| 255 | - { | |
| 256 | - error(msg) then | |
| 257 | - print("Cannot connect to "+a+":"+p+"\n"), | |
| 258 | - | |
| 259 | - ok(connection) then | |
| 260 | - // | |
| 261 | - // connection to server is OK | |
| 262 | - // just run the client handler | |
| 263 | - // | |
| 264 | - print("Connected to "+a+":"+p+"\n"); | |
| 265 | - client_handler(connection) | |
| 266 | - } | |
| 267 | - } | |
| 268 | - } | |
| 269 | - } | |
| 270 | - }. | |
| 271 | - | |
| 272 | - | |
| 273 | - | |
| 274 | - | |
| 275 | 0 | \ No newline at end of file |
anubis_dev/library/examples/conditional_examples.anubis
| 1 | 1 | |
| 2 | 2 | |
| 3 | - The Anubis/Paradize project. | |
| 3 | + *Project* The Anubis Project | |
| 4 | 4 | |
| 5 | - Simple examples of use of conditionals. | |
| 5 | + *Title* Simple examples of use of conditionals. | |
| 6 | 6 | |
| 7 | - Copyright (c) Alain Prouté 2005. | |
| 7 | + *Copyright* Copyright (c) Alain Prouté 2005. | |
| 8 | + | |
| 8 | 9 | |
| 9 | 10 | |
| 10 | - Author: Alain Prouté | |
| 11 | + *Author* Alain Prouté | |
| 11 | 12 | |
| 12 | 13 | |
| 13 | 14 | Below, we give simple and representative examples of use of conditionals. | ... | ... |
anubis_dev/library/cryptography/sha1.anubis renamed to anubis_dev/library/examples/cryptography/sha1.anubis
anubis_dev/library/examples/determinism.anubis.c
anubis_dev/library/examples/file_manager_example.anubis
anubis_dev/library/examples/for_loop.anubis.c
anubis_dev/library/graphism/diaporama.anubis renamed to anubis_dev/library/examples/graphism/diaporama.anubis
| 1 | 1 | |
| 2 | + *Project* The Anubis Project | |
| 2 | 3 | |
| 3 | - The Anubis Project. | |
| 4 | - Viewing JPEG files in a diaporama. | |
| 5 | - | |
| 6 | - Copyright (c) Alain Proute' 2003. | |
| 7 | - | |
| 8 | - | |
| 4 | + *Title* Viewing JPEG files in a diaporama. | |
| 9 | 5 | |
| 6 | + *Copyright* Copyright (c) Alain Prouté 2003. | |
| 7 | + | |
| 8 | + | |
| 9 | + *Author* Alain Prouté | |
| 10 | + | |
| 11 | + | |
| 12 | + *Overview* | |
| 10 | 13 | This file implements a simple diaporama program, which displays all the JPEG file in a |
| 11 | 14 | given directory (and optionally in the subdirectories in a recursive way). This |
| 12 | 15 | program is based on 'predefined.anubis', and does not use 'graphism/widgets.anubis'. | ... | ... |
23.6 KB
28.9 KB
22.4 KB
32.9 KB
17.4 KB
36.9 KB
anubis_dev/library/examples/paint.anubis renamed to anubis_dev/library/examples/graphism/paint.anubis
| 1 | 1 | |
| 2 | + *Project* The Anubis Project | |
| 2 | 3 | |
| 3 | - The Anubis/Paradize project. | |
| 4 | - | |
| 5 | - A simple 'paint' program. | |
| 6 | - | |
| 7 | - Copyright (c) Alain Prouté 2005. | |
| 8 | - | |
| 9 | - | |
| 10 | - Author: Alain Prouté | |
| 11 | - | |
| 4 | + *Title* A simple 'paint' program. | |
| 12 | 5 | |
| 6 | + *Copyright* Copyright (c) Alain Prouté 2005. | |
| 7 | + | |
| 8 | + | |
| 9 | + *Author* Alain Prouté | |
| 10 | + | |
| 11 | + | |
| 12 | + *Overview* | |
| 13 | 13 | This file contains a minimalist example of use of the following primitives, which are |
| 14 | 14 | all defined in 'library/predefined.anubis'. |
| 15 | 15 | ... | ... |
anubis_dev/library/examples/paint2.anubis renamed to anubis_dev/library/examples/graphism/paint2.anubis
| 1 | 1 | |
| 2 | + *Project* The Anubis Project | |
| 2 | 3 | |
| 3 | - The Anubis/Paradize project. | |
| 4 | + *Title* A simple 'paint' program. | |
| 4 | 5 | |
| 5 | - A simple 'paint' program. | |
| 6 | - | |
| 7 | - Copyright (c) Alain Prouté 2005. | |
| 8 | - | |
| 9 | - | |
| 10 | - Author: Alain Prouté | |
| 6 | + *Copyright* Copyright (c) Alain Prouté 2005. | |
| 7 | + | |
| 8 | + | |
| 9 | + *Author* Alain Prouté | |
| 11 | 10 | |
| 12 | 11 | |
| 12 | + *Overview* | |
| 13 | 13 | This is actually an ``enhanced'' version of 'paint.anubis'. |
| 14 | 14 | |
| 15 | 15 | |
| ... | ... | @@ -122,7 +122,7 @@ define (HostWindow hw, HostWindowEvent(One) e) -> List(Rectangle) |
| 122 | 122 | remains invisible. |
| 123 | 123 | |
| 124 | 124 | global define One |
| 125 | - my_paint | |
| 125 | + my_paint2 | |
| 126 | 126 | ( |
| 127 | 127 | List(String) args |
| 128 | 128 | ) = | ... | ... |
anubis_dev/library/graphism/show_image.anubis renamed to anubis_dev/library/examples/graphism/show_image.anubis
anubis_dev/library/examples/hello.anubis
| 1 | 1 | |
| 2 | 2 | |
| 3 | - The Anubis Project. | |
| 3 | + *Project* The Anubis Project | |
| 4 | 4 | |
| 5 | - The 'Hello' sample program. | |
| 6 | - | |
| 7 | - | |
| 8 | - Copyright (c) Alain Proute' 2001. | |
| 9 | - All rights reserved. | |
| 5 | + *Title* The 'Hello' sample program. | |
| 10 | 6 | |
| 7 | + *Copyright* Copyright (c) Alain Prouté 2001. | |
| 8 | + | |
| 11 | 9 | |
| 10 | + | |
| 12 | 11 | |
| 12 | + *Overview* | |
| 13 | 13 | This is the Anubis version of the celebrated 'hello.c' program of the C language. |
| 14 | 14 | Notice that comments may be freely written while we are outside any so-called |
| 15 | 15 | 'paragraph'. | ... | ... |
anubis_dev/library/examples/kbd.anubis
| 1 | 1 | |
| 2 | 2 | |
| 3 | - The Anubis Project | |
| 3 | + *Project* The Anubis Project | |
| 4 | 4 | |
| 5 | - Testing mouse and keyboard events in a host window. | |
| 5 | + *Title* Testing mouse and keyboard events in a host window. | |
| 6 | 6 | |
| 7 | - Copyright (c) Alain Proute' 2005. | |
| 8 | - | |
| 9 | - | |
| 10 | - | |
| 11 | - Author: Alain Proute' | |
| 7 | + *Copyright* Copyright (c) Alain Prouté 2005. | |
| 8 | + | |
| 9 | + | |
| 10 | + *Author* Alain Prouté | |
| 12 | 11 | |
| 13 | 12 | |
| 14 | 13 | define Int32 length( List($T) l) = | ... | ... |
anubis_dev/library/examples/ls.anubis
| 1 | 1 | |
| 2 | - *Project: Anubis | |
| 2 | + *Project* Anubis | |
| 3 | 3 | |
| 4 | - *Title: unix ls like. | |
| 4 | + *Title* very simple unix like ls. | |
| 5 | 5 | |
| 6 | - *Copyright: Copyright (c) David RENE 2005. | |
| 6 | + *Copyright* Copyright (c) Alain Prouté 2005. | |
| 7 | 7 | |
| 8 | 8 | |
| 9 | 9 | |
| 10 | 10 | |
| 11 | 11 | |
| 12 | - *Author: David René | |
| 12 | + *Author* David René | |
| 13 | + *Created* december 2005 | |
| 13 | 14 | |
| 14 | - *Revised: december 2005 | |
| 15 | - | |
| 16 | - *Intro: This a really the first Anubis program of David. | |
| 15 | + *Overview* This a really the first Anubis program of David. | |
| 17 | 16 | |
| 18 | 17 | |
| 19 | 18 | define One printList ( List (String) liste)= |
| ... | ... | @@ -24,4 +23,4 @@ define One printList ( List (String) liste)= |
| 24 | 23 | }. |
| 25 | 24 | |
| 26 | 25 | global define One ls( List(String) args ) = |
| 27 | - printfList(directory_list( ".", "*")). | |
| 28 | 26 | \ No newline at end of file |
| 27 | + printList(directory_list( ".", "*")). | |
| 29 | 28 | \ No newline at end of file | ... | ... |
anubis_dev/library/examples/mkdir_test.anubis
anubis_dev/library/examples/peano.anubis
| 1 | 1 | |
| 2 | - The Anubis/Paradize Project | |
| 2 | + *Project* The Anubis Project | |
| 3 | 3 | |
| 4 | - Playing with Peano numbers. | |
| 4 | + *Title* Playing with Peano numbers. | |
| 5 | 5 | |
| 6 | - Copyright (c) Alain Prouté 2005. | |
| 6 | + *Copyright* Copyright (c) Alain Prouté 2005. | |
| 7 | 7 | |
| 8 | 8 | |
| 9 | - Author: Alain Prouté | |
| 9 | + *Author* Alain Prouté | |
| 10 | 10 | |
| 11 | 11 | |
| 12 | 12 | This file contains several classical exercices on Peano numbers and recursive | ... | ... |
anubis_dev/library/examples/playing_with_functions.anubis
anubis_dev/library/examples/port_scan.anubis deleted
| 1 | -read tools/basis.anubis | |
| 2 | -read tools/connections.anubis | |
| 3 | - | |
| 4 | -define One | |
| 5 | - erreur | |
| 6 | - ( | |
| 7 | - String prob | |
| 8 | - ) = | |
| 9 | - print("usage : ports_scan <adresse_ip> <port_debut> <port_fin>\n"); | |
| 10 | - print(prob). | |
| 11 | - | |
| 12 | -define One fin = unique. print("Fin du scan\n"). | |
| 13 | - | |
| 14 | -define One | |
| 15 | - comp | |
| 16 | - ( | |
| 17 | - Int32 n, | |
| 18 | - Int32 n2, | |
| 19 | - Int32 addr | |
| 20 | - ) = | |
| 21 | - if n =< n2 then | |
| 22 | - (delegate | |
| 23 | - //print("machine "+virtual_machine_id+" scanning port "+n+"\n"); | |
| 24 | - if (Result(NetworkConnectError,RWAddr(Int8)))connect(addr,n) is | |
| 25 | - { | |
| 26 | - error(error) then unique, | |
| 27 | - | |
| 28 | - /* | |
| 29 | - print(if error is | |
| 30 | - { | |
| 31 | - cannot_create_the_socket then "Cannot open the socket", | |
| 32 | - address_port_not_available then "Adress:port not available", | |
| 33 | - connection_refused then "Connection refused", | |
| 34 | - network_unreachable then "Network unreachable", | |
| 35 | - address_port_already_in_use then "address:port already in use", | |
| 36 | - out_of_time then "Time is out" | |
| 37 | - }+" [port "+n+"]\n"), | |
| 38 | - */ | |
| 39 | - | |
| 40 | - ok(connection) then print("port "+n+" ouvert\n") | |
| 41 | - }, | |
| 42 | - comp(n+1,n2,addr)) | |
| 43 | - else fin. | |
| 44 | - | |
| 45 | -global define One | |
| 46 | - port_scan | |
| 47 | - ( | |
| 48 | - List(String) args | |
| 49 | - ) = | |
| 50 | - if args is | |
| 51 | - { | |
| 52 | - [ ] then erreur(""), | |
| 53 | - [ a . t ] then if ip_address(a) is { failure then print("Adresse IP incorrecte"), success(ad) then | |
| 54 | - if t is | |
| 55 | - { | |
| 56 | - [ ] then erreur("Ports de debut et de fin maquant\n"), | |
| 57 | - [ p_d . t_ ] then | |
| 58 | - if t_ is | |
| 59 | - { | |
| 60 | - [ ] then erreur("Port de fin manquant\n"), | |
| 61 | - [ p_f . _ ] then | |
| 62 | - if string_to_integer(p_d) is | |
| 63 | - { | |
| 64 | - failure then erreur("Port de debut incorrecte\n"), | |
| 65 | - success(n) then | |
| 66 | - if string_to_integer(p_f) is | |
| 67 | - { | |
| 68 | - failure then erreur("Port de fin incorrecte\n"), | |
| 69 | - success(n2) then comp(n,n2,ad) | |
| 70 | - } | |
| 71 | - } | |
| 72 | - } | |
| 73 | - }} | |
| 74 | - }. | |
| 75 | - | |
| 76 | - | |
| 77 | - | |
| 78 | - | |
| 79 | - | |
| 80 | - | |
| 81 | - | |
| 82 | - | |
| 83 | - | |
| 84 | - |
anubis_dev/library/examples/restart.anubis
anubis_dev/library/examples/runge_kutta.anubis deleted
| 1 | - | |
| 2 | - | |
| 3 | - The Anubis/Paradize project. | |
| 4 | - | |
| 5 | - Drawing solutions of first order differential equations | |
| 6 | - using the fourth order Runge-Kutta method. | |
| 7 | - | |
| 8 | - Copyright (c) Alain Prouté 2005. | |
| 9 | - | |
| 10 | - | |
| 11 | - Author: Alain Prouté | |
| 12 | - | |
| 13 | - | |
| 14 | - The program defined in this file opens a host window. When a point of the window is | |
| 15 | - clicked upon, the solution of a given first order differential equation which passes | |
| 16 | - through this point is drawn. | |
| 17 | - | |
| 18 | - First order differential equations (when solved with respect to y') have the following | |
| 19 | - form: | |
| 20 | - | |
| 21 | - y' = f(x,y) | |
| 22 | - | |
| 23 | - where y is the unknown function, x the free (time) variable, and f a function defined | |
| 24 | - on a subset of R^2. A solution of this equation is a function g (defined on some | |
| 25 | - interval of the reals), such that for all x in this interval, we have: | |
| 26 | - | |
| 27 | - g'(x) = f(x,g(x)) | |
| 28 | - | |
| 29 | - The Cauchy-Lipschitz theorem asserts that if f is locally lipschitzian relative to its | |
| 30 | - second variable, then, by every point of the domain of f, passes one and exactly one | |
| 31 | - maximal (i.e. non extendable) solution of the equation. | |
| 32 | - | |
| 33 | - Below is the function f used in this example (you may customize). | |
| 34 | - | |
| 35 | -read tools/maybefloat.anubis | |
| 36 | - | |
| 37 | -define Maybe(Float) _1 = success(1). | |
| 38 | -define Maybe(Float) _2 = success(2). | |
| 39 | -define Maybe(Float) _3 = success(3). | |
| 40 | - | |
| 41 | -define Maybe(Float) | |
| 42 | - f | |
| 43 | - ( | |
| 44 | - Maybe(Float) x, | |
| 45 | - Maybe(Float) y | |
| 46 | - ) = | |
| 47 | - x - y*y. | |
| 48 | - abs(x)^y. | |
| 49 | - x+y*y*y. | |
| 50 | - x*x + y. | |
| 51 | - x*x - y*y. | |
| 52 | - x - y*x*y. | |
| 53 | - _3 * ((y*y)^(_1/_3)). | |
| 54 | - sin(x*y). | |
| 55 | - success(1)/y. | |
| 56 | - sin(y). | |
| 57 | - | |
| 58 | - | |
| 59 | - | |
| 60 | - | |
| 61 | - The Runge-Kutta method allows the computation of points on the graph of a solution | |
| 62 | - starting at some point of this graph. Starting at a point (x_0,y_0) in the domain of | |
| 63 | - f, we compute the points (x_n,y_n) belonging to the graph of the solution passing | |
| 64 | - through (x_0,y_0) as follows: | |
| 65 | - | |
| 66 | - x_(n+1) = x_n + h | |
| 67 | - k_1 = hf(x_n,y_n) | |
| 68 | - k_2 = hf(x_n + h/2, y_n + k_1/2) | |
| 69 | - k_3 = hf(x_n + h/2, y_n + k_2/2) | |
| 70 | - k_4 = hf(x_n + h, y_n + k_3) | |
| 71 | - y_(n+1) = y_n + k_1/6 + k_2/3 + k_3/3 + k_4/6 | |
| 72 | - | |
| 73 | - The error made by this method against the actual solution is of the order of h^5 at | |
| 74 | - each step. | |
| 75 | - | |
| 76 | - The next function computes y_(n+1) from x_n, y_n and h, using f. | |
| 77 | - | |
| 78 | -define Maybe(Float) | |
| 79 | - runge_kutta_4 | |
| 80 | - ( | |
| 81 | - Maybe(Float) x_n, | |
| 82 | - Maybe(Float) y_n, | |
| 83 | - Maybe(Float) h, | |
| 84 | - (Maybe(Float) x, Maybe(Float) y) -> Maybe(Float) f | |
| 85 | - ) = | |
| 86 | - with h2 = h/success(2), | |
| 87 | - k_1 = h * f(x_n,y_n), | |
| 88 | - k_2 = h * f(x_n + h2, y_n + k_1/success(2)), | |
| 89 | - k_3 = h * f(x_n + h2, y_n + k_2/success(2)), | |
| 90 | - k_4 = h * f(x_n + h, y_n + k_3), | |
| 91 | - y_n + ((k_1+k_4)/success(6)) + ((k_2+k_3)/success(3)). | |
| 92 | - | |
| 93 | - | |
| 94 | - A point of coordinates (x,y) must be painted into the buffer (of type HostImage). We | |
| 95 | - have two scaling numbers 'h_scale' and 'v_scale'. | |
| 96 | - | |
| 97 | -define RGB white = rgb(255,255,255). | |
| 98 | - | |
| 99 | -define Bool | |
| 100 | - paint | |
| 101 | - ( | |
| 102 | - HostImage buffer, | |
| 103 | - Maybe(Float) x, | |
| 104 | - Maybe(Float) y, | |
| 105 | - Maybe(Float) h_scale, | |
| 106 | - Maybe(Float) v_scale, | |
| 107 | - Int32 xmax, | |
| 108 | - Int32 ymax | |
| 109 | - ) = | |
| 110 | - with x1 = x/h_scale, y1 = y/v_scale, | |
| 111 | - if x1 is success(x2) | |
| 112 | - then if y1 is success(y2) | |
| 113 | - then with x3 = integral_part(x2), | |
| 114 | - y3 = integral_part(y2), | |
| 115 | - if (0 =< x3 & x3 < xmax & 0 =< y3 & y3 < ymax) | |
| 116 | - then (paint_rectangle(buffer,rect(x3,y3,x3+1,y3+1),white); true) | |
| 117 | - else false | |
| 118 | - else false | |
| 119 | - else false. | |
| 120 | - | |
| 121 | - | |
| 122 | - Now, if we want to draw a solution we must iterate the above function. | |
| 123 | - | |
| 124 | -define One | |
| 125 | - draw_solution | |
| 126 | - ( | |
| 127 | - Maybe(Float) x, | |
| 128 | - Maybe(Float) y, | |
| 129 | - Maybe(Float) h, | |
| 130 | - (Maybe(Float) x, Maybe(Float) y) -> Maybe(Float) f, | |
| 131 | - Maybe(Float) h_scale, | |
| 132 | - Maybe(Float) v_scale, | |
| 133 | - Maybe(Float) x_trans, | |
| 134 | - Maybe(Float) y_trans, | |
| 135 | - HostImage buffer, | |
| 136 | - Int32 xmax, | |
| 137 | - Int32 ymax | |
| 138 | - ) = | |
| 139 | - if y is | |
| 140 | - { | |
| 141 | - failure then unique, // overflow | |
| 142 | - success(_) then | |
| 143 | - if paint(buffer, | |
| 144 | - x, | |
| 145 | - success(integer_to_float(ymax))*v_scale - y, | |
| 146 | - h_scale, | |
| 147 | - v_scale, | |
| 148 | - xmax, | |
| 149 | - ymax) | |
| 150 | - then draw_solution(x+h, | |
| 151 | - runge_kutta_4(x,y,h, | |
| 152 | - (Maybe(Float) _x, Maybe(Float) _y) |-> | |
| 153 | - f(x+x_trans,y+y_trans)), | |
| 154 | - h, | |
| 155 | - f, | |
| 156 | - h_scale,v_scale, | |
| 157 | - x_trans,y_trans, | |
| 158 | - buffer, | |
| 159 | - xmax,ymax) | |
| 160 | - else unique | |
| 161 | - }. | |
| 162 | - | |
| 163 | - | |
| 164 | - | |
| 165 | - The next function makes the paint_method. It just copies the content of the buffer to | |
| 166 | - the window, but only within the given rectangle. | |
| 167 | - | |
| 168 | -define (HostWindow hw, List(Rectangle) rs) -> One | |
| 169 | - make_paint_method | |
| 170 | - ( | |
| 171 | - HostImage buffer, | |
| 172 | - Int32 x_trans, | |
| 173 | - Int32 y_trans, | |
| 174 | - Int32 xmax, | |
| 175 | - Int32 ymax, | |
| 176 | - Int32 hs, | |
| 177 | - Int32 vs | |
| 178 | - ) = | |
| 179 | - with red = rgb(255,0,0), | |
| 180 | - (HostWindow hw, List(Rectangle) rs) |-> | |
| 181 | - forget(map((Rectangle r) |-> paint_image(hw,r,0,0,buffer),rs)); // copy buffer to window within r | |
| 182 | - paint_rectangle(hw,rect( | |
| 183 | - 0, | |
| 184 | - ymax+y_trans-1, | |
| 185 | - xmax, | |
| 186 | - ymax+y_trans | |
| 187 | - ),red); | |
| 188 | - paint_rectangle(hw,rect( | |
| 189 | - -x_trans+hs, | |
| 190 | - ymax+y_trans-4, | |
| 191 | - -x_trans+hs+1, | |
| 192 | - ymax+y_trans+4 | |
| 193 | - ),red); | |
| 194 | - paint_rectangle(hw,rect( | |
| 195 | - -x_trans, | |
| 196 | - 0, | |
| 197 | - -x_trans+1, | |
| 198 | - ymax | |
| 199 | - ),red); | |
| 200 | - paint_rectangle(hw,rect( | |
| 201 | - -x_trans-4, | |
| 202 | - ymax+y_trans-vs-1, | |
| 203 | - -x_trans+4, | |
| 204 | - ymax+y_trans-vs | |
| 205 | - ),red). | |
| 206 | - | |
| 207 | - | |
| 208 | - The event handler. | |
| 209 | - | |
| 210 | - | |
| 211 | -define One | |
| 212 | - handle_keys | |
| 213 | - ( | |
| 214 | - KeyboardState ks, | |
| 215 | - KeyboardKey kk, | |
| 216 | - Var(Maybe(Float)) h_scale, | |
| 217 | - Var(Maybe(Float)) v_scale | |
| 218 | - ) = | |
| 219 | - if kk is | |
| 220 | - { | |
| 221 | - unknown then unique, | |
| 222 | - char(c) then if c = '+' then (h_scale <- (*h_scale) * success(0.5); | |
| 223 | - v_scale <- (*v_scale) * success(0.5)) else | |
| 224 | - if c = '-' then (h_scale <- (*h_scale) * success(2); | |
| 225 | - v_scale <- (*v_scale) * success(2)) else | |
| 226 | - unique, | |
| 227 | - unicode(a,b) then unique, | |
| 228 | - special(s) then unique | |
| 229 | - }. | |
| 230 | - | |
| 231 | - | |
| 232 | -define (HostWindow hw, HostWindowEvent(One) e) -> List(Rectangle) | |
| 233 | - make_event_handler | |
| 234 | - ( | |
| 235 | - Rectangle default, | |
| 236 | - HostImage buffer, | |
| 237 | - Var(Maybe(Float)) h_scale, | |
| 238 | - Var(Maybe(Float)) v_scale, | |
| 239 | - Int32 h, | |
| 240 | - Int32 x_trans, | |
| 241 | - Int32 y_trans, | |
| 242 | - Int32 xmax, | |
| 243 | - Int32 ymax | |
| 244 | - ) = | |
| 245 | - (HostWindow hw, HostWindowEvent(One) e) |-> | |
| 246 | - if e is | |
| 247 | - { | |
| 248 | - quit then [], | |
| 249 | - expose then [default] | |
| 250 | - pointer_entering then [], | |
| 251 | - pointer_leaving then [], | |
| 252 | - key_down(ks,kk) then handle_keys(ks, | |
| 253 | - kk, | |
| 254 | - h_scale, | |
| 255 | - v_scale); [default], | |
| 256 | - mouse_move(ks,x,y) then [], | |
| 257 | - mouse_click(ks,mc,x,y) then if mc is left_down | |
| 258 | - then ( | |
| 259 | - draw_solution( // to the right (if h > 0) | |
| 260 | - success(integer_to_float(x))**h_scale, | |
| 261 | - success(integer_to_float(ymax-y))**v_scale, | |
| 262 | - success(integer_to_float(h))**h_scale, | |
| 263 | - f, | |
| 264 | - *h_scale, | |
| 265 | - *v_scale, | |
| 266 | - success(integer_to_float(x_trans))**h_scale, | |
| 267 | - success(integer_to_float(y_trans))**v_scale, | |
| 268 | - buffer, | |
| 269 | - xmax,ymax); | |
| 270 | - draw_solution( // to the left (if h > 0) | |
| 271 | - success(integer_to_float(x))**h_scale, | |
| 272 | - success(integer_to_float(ymax-y))**v_scale, | |
| 273 | - success(integer_to_float(-h))**h_scale, | |
| 274 | - f, | |
| 275 | - *h_scale, | |
| 276 | - *v_scale, | |
| 277 | - success(integer_to_float(x_trans))**h_scale, | |
| 278 | - success(integer_to_float(y_trans))**v_scale, | |
| 279 | - buffer, | |
| 280 | - xmax,ymax); | |
| 281 | - [default] | |
| 282 | - ) | |
| 283 | - else [], | |
| 284 | - mouse_wheel(ks,d,x,y) then [], | |
| 285 | - tick then [], | |
| 286 | - repaint(l) then [], | |
| 287 | - specific(_) then [] | |
| 288 | - }. | |
| 289 | - | |
| 290 | - | |
| 291 | - Finally, here is our program. It first creates the buffer, then opens the host | |
| 292 | - window. If the host window has been opened, it must be shown by 'show', otherwise it | |
| 293 | - remains invisible. | |
| 294 | - | |
| 295 | -global define One | |
| 296 | - runge_kutta | |
| 297 | - ( | |
| 298 | - List(String) args | |
| 299 | - ) = | |
| 300 | - with iw = (Int32)800, | |
| 301 | - ih = (Int32)600, | |
| 302 | - default = rect(0,0,iw,ih), | |
| 303 | - hs = (Int32)60, | |
| 304 | - vs = (Int32)60, | |
| 305 | - step = (Int32)1, | |
| 306 | - x_trans = (Int32)-(iw>>1), | |
| 307 | - y_trans = (Int32)-(ih>>1), | |
| 308 | - with buffer = to_host_image(create_rgba_image(iw,ih,rgba(100,100,100,255)),1), | |
| 309 | - if open_host_window(rect(100,50,100+iw,50+ih), | |
| 310 | - "Runge Kutta Method", | |
| 311 | - managed, | |
| 312 | - make_paint_method(buffer,x_trans,y_trans,iw,ih,hs,vs), | |
| 313 | - make_event_handler(default,buffer, | |
| 314 | - var(success(1.0)/success(integer_to_float(hs))), | |
| 315 | - var(success(1.0)/success(integer_to_float(vs))), | |
| 316 | - step, | |
| 317 | - x_trans,y_trans, | |
| 318 | - iw,ih), | |
| 319 | - (List(HostWindowEvent(One)) l) |-> l) is | |
| 320 | - { | |
| 321 | - failure then print("Cannot open window.\n"), | |
| 322 | - success(hw) then show(hw) | |
| 323 | - }. | |
| 324 | - | |
| 325 | - | |
| 326 | - | |
| 327 | 0 | \ No newline at end of file |
anubis_dev/library/examples/saturate_example.anubis
| 1 | 1 | |
| 2 | 2 | |
| 3 | - The Anubis/Paradize project. | |
| 3 | + *Project* The Anubis Project | |
| 4 | 4 | |
| 5 | - A saturation example. | |
| 5 | + *Title* A saturation example. | |
| 6 | 6 | |
| 7 | - Copyright (c) Alain Prouté 2004. | |
| 8 | - | |
| 9 | - | |
| 10 | - Authors: Alain Prouté | |
| 7 | + *Copyright* Copyright (c) Alain Prouté 2004. | |
| 8 | + | |
| 9 | + | |
| 10 | + *Author* Alain Prouté | |
| 11 | + | |
| 11 | 12 | |
| 12 | -read tools/saturate.anubis | |
| 13 | 13 | |
| 14 | - | |
| 14 | + *Overview* | |
| 15 | 15 | A typical example of use of 'saturate' is the following. Imagine that you have a graph |
| 16 | 16 | presented in the form of a list of pairs 'vertex(n,l)' where 'n' is the name of the |
| 17 | 17 | vertex, and 'l' the list of names of all vertices towards which 'n' sends an |
| 18 | 18 | arrow. Given a vertex 'a', you may want to determine the subgraph of all vertices |
| 19 | 19 | reachable from 'a'. |
| 20 | 20 | |
| 21 | +read tools/saturate.anubis | |
| 21 | 22 | |
| 22 | 23 | type Vertex: |
| 23 | 24 | vertex(String name, | ... | ... |
anubis_dev/library/examples/syracuse.anubis
anubis_dev/library/examples/test_web_site.anubis
| 1 | 1 | |
| 2 | 2 | |
| 3 | - The Anubis/Paradize Project. | |
| 4 | - Testing 'web/making_a_web_site.anubis'. | |
| 3 | + *Project* The Anubis Project | |
| 5 | 4 | |
| 6 | - Copyright (c) Alain Prouté 2004. | |
| 7 | - | |
| 8 | - | |
| 9 | - Authors: Alain Proute' | |
| 5 | + *Title* Testing 'web/making_a_web_site.anubis'. | |
| 10 | 6 | |
| 7 | + *Copyright* Copyright (c) Alain Prouté 2004. | |
| 8 | + | |
| 9 | + | |
| 10 | + *Author* Alain Prouté | |
| 11 | + | |
| 12 | + | |
| 11 | 13 | |
| 12 | 14 | read web/making_a_web_site.anubis |
| 13 | 15 | ... | ... |
anubis_dev/library/examples/try_dns.anubis deleted
| 1 | - | |
| 2 | - The Anubis project. | |
| 3 | - | |
| 4 | - Trying the 'dns' primitive. | |
| 5 | - | |
| 6 | - Copyright (c) Alain Proute' 2001. All rights reserved. | |
| 7 | - | |
| 8 | - | |
| 9 | - Devide two integers, avoiding the 'Maybe' (that is, if division is not possible, assume | |
| 10 | - that the result is 0). | |
| 11 | - | |
| 12 | -define Int32 | |
| 13 | - div | |
| 14 | - ( Int32 a, Int32 b) = | |
| 15 | - if a/b is | |
| 16 | - { | |
| 17 | - failure then 0, | |
| 18 | - success(n) then n | |
| 19 | - }. | |
| 20 | - | |
| 21 | - | |
| 22 | - Print an IP address. | |
| 23 | - | |
| 24 | -define One | |
| 25 | - print_IP_addr | |
| 26 | - ( | |
| 27 | - Int32 n | |
| 28 | - ) = | |
| 29 | - print(integer_to_string(n (mod 256))); | |
| 30 | - print("."); | |
| 31 | - print(integer_to_string(div(n,256) (mod 256))); | |
| 32 | - print("."); | |
| 33 | - print(integer_to_string(div(n,(256*256)) (mod 256))); | |
| 34 | - print("."); | |
| 35 | - print(integer_to_string(div(n,(256*256*256)) (mod 256))). | |
| 36 | - | |
| 37 | - | |
| 38 | - | |
| 39 | - Construct module 'dns.adm'. | |
| 40 | - | |
| 41 | -global define One | |
| 42 | - dns | |
| 43 | - ( | |
| 44 | - List(String) args | |
| 45 | - ) = | |
| 46 | - if args is | |
| 47 | - { | |
| 48 | - [ ] then print("No host name given.\n"), | |
| 49 | - [name . _] then | |
| 50 | - if dns(name) is | |
| 51 | - { | |
| 52 | - host_not_found then print("host not found\n"), | |
| 53 | - no_address_found then print("no address found\n"), | |
| 54 | - try_again then print("try again\n"), | |
| 55 | - non_recoverable_error then print("non recoverable error\n"), | |
| 56 | - ok(n) then print_IP_addr(n) | |
| 57 | - } | |
| 58 | - }. | |
| 59 | - | |
| 60 | - | |
| 61 | - To try this, just compile this file: | |
| 62 | - | |
| 63 | - anubis try_dns.anubis | |
| 64 | - | |
| 65 | - and run the module 'dns.adm': | |
| 66 | - | |
| 67 | - anbexec dns.adm www.gnu.org | |
| 68 | - | |
| 69 | - this should produce something like: | |
| 70 | - | |
| 71 | - 198.186.203.18 | |
| 72 | - | |
| 73 | - | |
| 74 | - | |
| 75 | 0 | \ No newline at end of file |
anubis_dev/library/examples/try_protect.anubis
| 1 | 1 | |
| 2 | 2 | |
| 3 | - The Anubis/Paradize project. | |
| 4 | - | |
| 5 | - Testing the 'protect' mecanism. | |
| 6 | - | |
| 7 | - Copyright (c) Alain Prouté 2004-2005. | |
| 8 | - | |
| 9 | - | |
| 10 | - Author: Alain Prouté | |
| 11 | - | |
| 3 | + *Project* The Anubis Project | |
| 12 | 4 | |
| 5 | + *Title* Testing the 'protect' mecanism. | |
| 13 | 6 | |
| 7 | + *Copyright* Copyright (c) Alain Prouté 2004-2005. | |
| 8 | + | |
| 9 | + | |
| 10 | + *Author* Alain Prouté | |
| 11 | + | |
| 12 | + | |
| 13 | + *Overview* | |
| 14 | 14 | This small program is just a test for the protect mecanism. It works as follows. We |
| 15 | 15 | start 2 virtual machines, which are both doing the same thing: they print a text on the |
| 16 | 16 | console (the same text): | ... | ... |
anubis_dev/library/examples/try_window.anubis deleted
| 1 | - | |
| 2 | - | |
| 3 | - This is just a test for the graphic screen primitives. | |
| 4 | - | |
| 5 | - | |
| 6 | -read tools/basis.anubis (required for 'identity' and 'sleep') | |
| 7 | - | |
| 8 | - | |
| 9 | - | |
| 10 | -define One | |
| 11 | - paint_method | |
| 12 | - ( | |
| 13 | - HostWindow window, | |
| 14 | - List(Rectangle) rs | |
| 15 | - ) = | |
| 16 | - forget(map((Rectangle r) |-> | |
| 17 | - paint_rectangle(window,r,rgb(128,128,128)); | |
| 18 | - paint_rectangle(window,rect(10,10,50,50),rgb(255,0,0)); | |
| 19 | - paint_rectangle(window,rect(60,10,100,50),rgb(0,255,0)); | |
| 20 | - paint_rectangle(window,rect(110,10,150,50),rgb(0,0,255)),rs)). | |
| 21 | - | |
| 22 | - | |
| 23 | - | |
| 24 | -define List(Rectangle) | |
| 25 | - event_handler | |
| 26 | - ( | |
| 27 | - HostWindow window, | |
| 28 | - HostWindowEvent(One) event | |
| 29 | - ) = | |
| 30 | - [ ]. | |
| 31 | - | |
| 32 | - | |
| 33 | - define One | |
| 34 | - flip | |
| 35 | - ( | |
| 36 | - HostWindow window, | |
| 37 | - Bool v | |
| 38 | - ) = | |
| 39 | - print((if v then "Showing" else "Hidding") + " the window.\n"); | |
| 40 | - (if v then show(window) else hide(window)); | |
| 41 | - sleep(1000); | |
| 42 | - flip(window,not(v)). | |
| 43 | - | |
| 44 | - | |
| 45 | -global define One | |
| 46 | - try_window | |
| 47 | - ( | |
| 48 | - List(String) args | |
| 49 | - ) = | |
| 50 | - if open_host_window(rect(100,100,400,400), | |
| 51 | - "Try Window", | |
| 52 | - managed, | |
| 53 | - paint_method, | |
| 54 | - event_handler, | |
| 55 | - identity) is | |
| 56 | - { | |
| 57 | - failure then print("Cannot open the host window.\n") | |
| 58 | - success(window) then | |
| 59 | - show(window) | |
| 60 | - }. | |
| 61 | - | |
| 62 | - | |
| 63 | 0 | \ No newline at end of file |
anubis_dev/library/examples/upload.anubis deleted
| 1 | - | |
| 2 | - The Anubis Project. | |
| 3 | - | |
| 4 | - The upload example. | |
| 5 | - Copyright (c) Alain Proute' 2003. | |
| 6 | - | |
| 7 | - | |
| 8 | - This is just an example on how to use the 'upload' Web_item (see | |
| 9 | - 'web/html.anubis'). This file also provides a very simple example of use of | |
| 10 | - 'web/http_server.anubis'. | |
| 11 | - | |
| 12 | - | |
| 13 | - | |
| 14 | -read tools/basis.anubis | |
| 15 | -read web/html.anubis | |
| 16 | - | |
| 17 | - | |
| 18 | - The directory where the uploaded files will be stored. | |
| 19 | - | |
| 20 | -define String destination_directory = ".". | |
| 21 | - | |
| 22 | - | |
| 23 | - Moving the temporary uploaded file to the above directory. | |
| 24 | - | |
| 25 | -define One | |
| 26 | - move_uploaded_file | |
| 27 | - ( | |
| 28 | - String where, | |
| 29 | - String source | |
| 30 | - ) = | |
| 31 | - forget(execute("mv",[source,where])). | |
| 32 | - | |
| 33 | - | |
| 34 | - Doing that for all files present in the request. | |
| 35 | - | |
| 36 | -define One | |
| 37 | - do_upload | |
| 38 | - ( | |
| 39 | - List(Web_arg) lwa | |
| 40 | - ) = | |
| 41 | - if lwa is | |
| 42 | - { | |
| 43 | - [ ] then unique, | |
| 44 | - [h . t] then if h is | |
| 45 | - { | |
| 46 | - web_arg(_,_) then unique, | |
| 47 | - upload(name,filename,temp_file_path) then | |
| 48 | - move_uploaded_file(destination_directory+"/"+filename,temp_file_path) | |
| 49 | - }; | |
| 50 | - do_upload(t) | |
| 51 | - }. | |
| 52 | - | |
| 53 | - | |
| 54 | - | |
| 55 | - Setting up a HTTP server. | |
| 56 | - | |
| 57 | -read web/http_server.anubis | |
| 58 | - | |
| 59 | -public define (Int8,Int8,Int8,Int8) http_server_IP_address = (0,0,0,0). | |
| 60 | -public define Int32 http_server_IP_port = 80. | |
| 61 | -public define String server_common_name = "". | |
| 62 | -public define List(Redirection) redirections = [redirect("/","127.0.0.1","/upload.awp")]. | |
| 63 | -public define String public_directory = ".". | |
| 64 | -public define String private_download_directory = ".". | |
| 65 | -public define String journal_directory = ".". | |
| 66 | -public define List(String) journal_headers = ["user-agent"]. | |
| 67 | -public define List(String) journal_extensions = []. | |
| 68 | -public define String authorization_secret = "anything". | |
| 69 | -public define String upload_temporary_directory = ".". | |
| 70 | -public define One service_machine = unique. | |
| 71 | - | |
| 72 | - | |
| 73 | - | |
| 74 | - | |
| 75 | - | |
| 76 | -public define (String,String,Web_page) | |
| 77 | - tickets_and_web_page | |
| 78 | - ( | |
| 79 | - Int32 ip_address, | |
| 80 | - String uri, | |
| 81 | - List(HTTP_header) headers, | |
| 82 | - List(Web_arg) lwa, | |
| 83 | - Server server | |
| 84 | - ) = | |
| 85 | - /* eventually upload a file */ | |
| 86 | - do_upload(lwa); | |
| 87 | - /* make the web page */ | |
| 88 | - ("","",web_page("Upload Example", | |
| 89 | - body([], | |
| 90 | - form(["upload.awp"], | |
| 91 | - center(table([nude],[ | |
| 92 | - row(cell([h_center],big(text("Upload Example")))), | |
| 93 | - row(cell([h_center,top,absolute_height(40)],upload("uplex",40))), | |
| 94 | - row(cell([right],submit("Send File"))) | |
| 95 | - ])))))). | |
| 96 | - | |
| 97 | -define HTTP_ServerDescription | |
| 98 | - description | |
| 99 | - = | |
| 100 | - http_server_description(ip_address((0,0,0,0)), | |
| 101 | - 80, | |
| 102 | - [redirect("/","192.168.0.1","/upload.awp")], | |
| 103 | - ".", | |
| 104 | - [".awp"], | |
| 105 | - ["user-agent","host"], | |
| 106 | - tickets_and_web_page, | |
| 107 | - identity). | |
| 108 | - | |
| 109 | - | |
| 110 | - The command for starting the server. | |
| 111 | - | |
| 112 | -global define One | |
| 113 | - upload_example_site | |
| 114 | - ( | |
| 115 | - List(String) args | |
| 116 | - ) = | |
| 117 | - start_http_server(description). | |
| 118 | - | |
| 119 | - | |
| 120 | - | |
| 121 | - | |
| 122 | - Ok, now compile this file: anubis upload.anubis | |
| 123 | - start the server: upload_example_site | |
| 124 | - open your browser: netscape (maybe) | |
| 125 | - and try the address: http://127.0.0.1 | |
| 126 | - | |
| 127 | - You will be able to upload a file. | |
| 128 | - | |
| 129 | - | |
| 130 | 0 | \ No newline at end of file |
anubis_dev/library/examples/watt.anubis
| 1 | 1 | |
| 2 | + *Project* The Anubis Project | |
| 2 | 3 | |
| 3 | - The Anubis/Paradize project. | |
| 4 | - | |
| 5 | - Using type definitions to avoid errors in measure units. | |
| 4 | + *Title* Using type definitions to avoid errors in measure units. | |
| 6 | 5 | |
| 7 | - Copyright (c) Alain Prouté 2005. | |
| 8 | - | |
| 9 | - | |
| 10 | - Author: Alain Prouté | |
| 6 | + *Copyright* Copyright (c) Alain Prouté 2005. | |
| 7 | + | |
| 8 | + | |
| 9 | + *Author* Alain Prouté | |
| 10 | + | |
| 11 | 11 | |
| 12 | 12 | |
| 13 | - | |
| 13 | + *Overview* | |
| 14 | 14 | This example shows how the type system of Anubis can help to avoid errors on measure |
| 15 | 15 | units in programming. |
| 16 | 16 | ... | ... |
anubis_dev/library/graphism/image_tools.anubis
| 1 | 1 | |
| 2 | + *Project* The Anubis Project | |
| 2 | 3 | |
| 3 | - The Anubis Project | |
| 4 | - | |
| 5 | - Tools for transforming images. | |
| 6 | - | |
| 7 | - Copyright (c) Alain Proute' <alp@math.jussieu.fr> 2002. | |
| 8 | - All rights reserved. | |
| 9 | - | |
| 10 | - | |
| 4 | + *Title* Tools for transforming images. | |
| 11 | 5 | |
| 6 | + *Copyright* Copyright (c) Alain Prouté 2002. | |
| 7 | + | |
| 8 | + | |
| 9 | + *Author* Alain Prouté | |
| 10 | + | |
| 11 | + | |
| 12 | + *Overview* | |
| 12 | 13 | This file contains tools for image manipulation. There are tools for: |
| 13 | 14 | |
| 14 | 15 | - creating images from scratch, | ... | ... |
anubis_dev/library/graphism/jpeg.anubis
anubis_dev/library/graphism/jpeg_size.anubis
| 1 | 1 | |
| 2 | + *Project* The Anubis Project | |
| 2 | 3 | |
| 4 | + *Title* Getting the size of a 'jpeg' image. | |
| 3 | 5 | |
| 4 | - The Anubis Project | |
| 5 | - Getting the size of a 'jpeg' image. | |
| 6 | - | |
| 7 | - Copyright (c) Alain Proute' <alp@math.jusieu.fr> 2002. | |
| 8 | - All rights reserved. | |
| 9 | - | |
| 10 | - | |
| 6 | + *Copyright* Copyright (c) Alain Prouté 2002. | |
| 7 | + | |
| 8 | + | |
| 9 | + *Author* Alain Prouté | |
| 11 | 10 | |
| 12 | 11 | |
| 12 | + | |
| 13 | + *Overview* | |
| 13 | 14 | The function 'jpeg_size', taking the name of a 'jpeg' (.jpeg or .jpg) image file as its |
| 14 | 15 | argument, returns (maybe) a pair of Int32: |
| 15 | 16 | ... | ... |
| 1 | +copy .\examples\args.anubis C:\Anubis_dev\anubis_distrib\library\examples\args.anubis | |
| 2 | +copy .\examples\conditional_examples.anubis C:\Anubis_dev\anubis_distrib\library\examples\conditional_examples.anubis | |
| 3 | +copy .\examples\determinism.anubis.c C:\Anubis_dev\anubis_distrib\library\examples\determinism.anubis.c | |
| 4 | +copy .\examples\file_manager_example.anubis C:\Anubis_dev\anubis_distrib\library\examples\file_manager_example.anubis | |
| 5 | +copy .\examples\for_loop.anubis.c C:\Anubis_dev\anubis_distrib\library\examples\for_loop.anubis.c | |
| 6 | +copy .\examples\hello.anubis C:\Anubis_dev\anubis_distrib\library\examples\hello.anubis | |
| 7 | +copy .\examples\kbd.anubis C:\Anubis_dev\anubis_distrib\library\examples\kbd.anubis | |
| 8 | +copy .\examples\ls.anubis C:\Anubis_dev\anubis_distrib\library\examples\ls.anubis | |
| 9 | +copy .\examples\mkdir_test.anubis C:\Anubis_dev\anubis_distrib\library\examples\mkdir_test.anubis | |
| 10 | +copy .\examples\OOCounter.cpp C:\Anubis_dev\anubis_distrib\library\examples\OOCounter.cpp | |
| 11 | +copy .\examples\peano.anubis C:\Anubis_dev\anubis_distrib\library\examples\peano.anubis | |
| 12 | +copy .\examples\restart.anubis C:\Anubis_dev\anubis_distrib\library\examples\restart.anubis | |
| 13 | +copy .\examples\saturate_example.anubis C:\Anubis_dev\anubis_distrib\library\examples\saturate_example.anubis | |
| 14 | +copy .\examples\syracuse.anubis C:\Anubis_dev\anubis_distrib\library\examples\syracuse.anubis | |
| 15 | +copy .\examples\try_protect.anubis C:\Anubis_dev\anubis_distrib\library\examples\try_protect.anubis | |
| 16 | +copy .\examples\watt.anubis C:\Anubis_dev\anubis_distrib\library\examples\watt.anubis | |
| 17 | +copy .\examples\graphism\diaporama.anubis C:\Anubis_dev\anubis_distrib\library\examples\graphism\diaporama.anubis | |
| 18 | +copy .\examples\graphism\paint.anubis C:\Anubis_dev\anubis_distrib\library\examples\graphism\paint.anubis | |
| 19 | +copy .\examples\graphism\paint2.anubis C:\Anubis_dev\anubis_distrib\library\examples\graphism\paint2.anubis | |
| 20 | +copy .\examples\graphism\runge_kutta.anubis C:\Anubis_dev\anubis_distrib\library\examples\graphism\runge_kutta.anubis | |
| 21 | +copy .\examples\graphism\show_image.anubis C:\Anubis_dev\anubis_distrib\library\examples\graphism\show_image.anubis | |
| 22 | +copy .\examples\graphism\try_window.anubis C:\Anubis_dev\anubis_distrib\library\examples\graphism\try_window.anubis | |
| 23 | +copy .\examples\network\client_browser_info.anubis C:\Anubis_dev\anubis_distrib\library\examples\network\client_browser_info.anubis | |
| 24 | +copy .\examples\network\client_server.anubis C:\Anubis_dev\anubis_distrib\library\examples\network\client_server.anubis | |
| 25 | +copy .\examples\network\port_scan.anubis C:\Anubis_dev\anubis_distrib\library\examples\network\port_scan.anubis | |
| 26 | +copy .\examples\network\sokoban.anubis C:\Anubis_dev\anubis_distrib\library\examples\network\sokoban.anubis | |
| 27 | +copy .\examples\network\try_dns.anubis C:\Anubis_dev\anubis_distrib\library\examples\network\try_dns.anubis | |
| 28 | +copy .\examples\network\upload.anubis C:\Anubis_dev\anubis_distrib\library\examples\network\upload.anubis | |
| 29 | +copy .\examples\cryptography\sha1.anubis C:\Anubis_dev\anubis_distrib\library\examples\cryptography\sha1.anubis | |
| 30 | + | |
| 31 | +copy .\data_base\import_csv.anubis C:\Anubis_dev\anubis_distrib\library\data_base\import_csv.anubis | |
| 32 | +copy .\data_base\sdbms.anubis C:\Anubis_dev\anubis_distrib\library\data_base\sdbms.anubis | |
| 33 | +copy .\data_base\sqlite.anubis C:\Anubis_dev\anubis_distrib\library\data_base\sqlite.anubis | |
| 34 | + | |
| 35 | +copy .\doc_tools\latex.anubis C:\Anubis_dev\anubis_distrib\library\doc_tools\latex.anubis | |
| 36 | +copy .\doc_tools\maml.anubis C:\Anubis_dev\anubis_distrib\library\doc_tools\maml.anubis | |
| 37 | + | |
| 38 | +copy .\graphism\image_tools.anubis C:\Anubis_dev\anubis_distrib\library\graphism\image_tools.anubis | |
| 39 | +copy .\graphism\jpeg.anubis C:\Anubis_dev\anubis_distrib\library\graphism\jpeg.anubis | |
| 40 | +copy .\graphism\jpeg_size.anubis C:\Anubis_dev\anubis_distrib\library\graphism\jpeg_size.anubis | |
| 41 | + | |
| 42 | +copy .\mail\send_mail.anubis C:\Anubis_dev\anubis_distrib\library\mail\send_mail.anubis | |
| 43 | + | |
| 44 | +copy .\network\dns.anubis C:\Anubis_dev\anubis_distrib\library\network\dns.anubis | |
| 45 | + | |
| 46 | +copy .\system_colors\rgb.anubis C:\Anubis_dev\anubis_distrib\library\system_colors\rgb.anubis | |
| 47 | +copy .\system_colors\system_colors.anubis C:\Anubis_dev\anubis_distrib\library\system_colors\system_colors.anubis | |
| 48 | + | |
| 49 | +copy .\system_fonts\draw_font.anubis C:\Anubis_dev\anubis_distrib\library\system_fonts\draw_font.anubis | |
| 50 | +copy .\system_fonts\font_table.anubis C:\Anubis_dev\anubis_distrib\library\system_fonts\font_table.anubis | |
| 51 | + | |
| 52 | +copy .\tools\base64.anubis C:\Anubis_dev\anubis_distrib\library\tools\base64.anubis | |
| 53 | +copy .\tools\basis.anubis C:\Anubis_dev\anubis_distrib\library\tools\basis.anubis | |
| 54 | +copy .\tools\connections.anubis C:\Anubis_dev\anubis_distrib\library\tools\connections.anubis | |
| 55 | +copy .\tools\findstring.anubis C:\Anubis_dev\anubis_distrib\library\tools\findstring.anubis | |
| 56 | +copy .\tools\hashtable.anubis C:\Anubis_dev\anubis_distrib\library\tools\hashtable.anubis | |
| 57 | +copy .\tools\maybefloat.anubis C:\Anubis_dev\anubis_distrib\library\tools\maybefloat.anubis | |
| 58 | +copy .\tools\saturate.anubis C:\Anubis_dev\anubis_distrib\library\tools\saturate.anubis | |
| 59 | +copy .\tools\streams.anubis C:\Anubis_dev\anubis_distrib\library\tools\streams.anubis | |
| 60 | +copy .\tools\tables.anubis C:\Anubis_dev\anubis_distrib\library\tools\tables.anubis | |
| 61 | +copy .\tools\tools.anubis C:\Anubis_dev\anubis_distrib\library\tools\tools.anubis | |
| 62 | + | |
| 63 | +copy .\web\web_arg_encode.anubis C:\Anubis_dev\anubis_distrib\library\web\web_arg_encode.anubis | |
| 64 | +copy .\web\common.anubis C:\Anubis_dev\anubis_distrib\library\web\common.anubis | |
| 65 | +copy .\web\cookies.anubis C:\Anubis_dev\anubis_distrib\library\web\cookies.anubis | |
| 66 | +copy .\web\file_manager.anubis C:\Anubis_dev\anubis_distrib\library\web\file_manager.anubis | |
| 67 | +copy .\web\generic_form.anubis C:\Anubis_dev\anubis_distrib\library\web\generic_form.anubis | |
| 68 | +copy .\web\generic_table.anubis C:\Anubis_dev\anubis_distrib\library\web\generic_table.anubis | |
| 69 | +copy .\web\http_get.anubis C:\Anubis_dev\anubis_distrib\library\web\http_get.anubis | |
| 70 | +copy .\web\http_get_common.anubis C:\Anubis_dev\anubis_distrib\library\web\http_get_common.anubis | |
| 71 | +copy .\web\https_get.anubis C:\Anubis_dev\anubis_distrib\library\web\https_get.anubis | |
| 72 | +copy .\web\making_a_web_site.anubis C:\Anubis_dev\anubis_distrib\library\web\making_a_web_site.anubis | |
| 73 | +copy .\web\making_forms.anubis C:\Anubis_dev\anubis_distrib\library\web\making_forms.anubis | |
| 74 | +copy .\web\mime.anubis C:\Anubis_dev\anubis_distrib\library\web\mime.anubis | |
| 75 | +copy .\web\multihost_http_server.anubis C:\Anubis_dev\anubis_distrib\library\web\multihost_http_server.anubis | |
| 76 | +copy .\web\read_html.anubis C:\Anubis_dev\anubis_distrib\library\web\read_html.anubis | |
| 77 | + | |
| 78 | +copy .\compil_all.anubis C:\Anubis_dev\anubis_distrib\library\web\compil_all.anubis | |
| 0 | 79 | \ No newline at end of file | ... | ... |
anubis_dev/library/mail/send_mail.anubis
| 1 | 1 | |
| 2 | + *Project* The Anubis Project | |
| 2 | 3 | |
| 3 | - The Anubis Project | |
| 4 | + *Title* Sending a mail (with attached files). | |
| 4 | 5 | |
| 5 | - Sending a mail (with attached files). | |
| 6 | - | |
| 7 | - Copyright (c) Alain Proute' <alp@math.jussieu.fr> 2001. | |
| 8 | - All rights reserved. | |
| 6 | + *Copyright* Copyright (c) Alain Prouté 2001. | |
| 7 | + | |
| 8 | + | |
| 9 | + *Author* Alain Prouté | |
| 9 | 10 | |
| 10 | 11 | |
| 12 | + *Overview* | |
| 11 | 13 | |
| 12 | 14 | This file defines the function 'send_mail' which you can use to send mail. |
| 13 | 15 | ... | ... |
anubis_dev/library/mail/smtp_server.anubis
| ... | ... | @@ -273,8 +273,7 @@ read tools/findstring.anubis |
| 273 | 273 | string with exactly two digits. This is used for formating days, hours, minutes and |
| 274 | 274 | seconds. |
| 275 | 275 | |
| 276 | -define String | |
| 277 | - zero_pad_2 | |
| 276 | +define String zero_pad_2 | |
| 278 | 277 | ( |
| 279 | 278 | Int32 n |
| 280 | 279 | ) = |
| ... | ... | @@ -293,7 +292,7 @@ define String |
| 293 | 292 | hour. Hence, the name of a journal file must be constructed from the current year, |
| 294 | 293 | month, day and hour. For example, it may be: |
| 295 | 294 | |
| 296 | - 2003_02_12_19 | |
| 295 | + 2003_03_12_19 | |
| 297 | 296 | |
| 298 | 297 | (this is for the journal of 7 PM to 8 PM, 2003/mar/12). |
| 299 | 298 | |
| ... | ... | @@ -653,7 +652,8 @@ define Maybe(String) |
| 653 | 652 | SMTP_ServerDescription desc, |
| 654 | 653 | String mailbox |
| 655 | 654 | ) = |
| 656 | - if directory_full_list(server_directory(desc)+"/users","","",mailbox) is | |
| 655 | +// if directory_full_list(server_directory(desc)+"/users","","",mailbox) is | |
| 656 | + if directory_list(server_directory(desc)+"/users",mailbox) is | |
| 657 | 657 | { |
| 658 | 658 | [ ] then failure, |
| 659 | 659 | [h . t] then | ... | ... |
anubis_dev/library/network/dns.anubis
| 1 | 1 | |
| 2 | - The Anubis Project. | |
| 3 | - Querying Domain Name Servers. | |
| 2 | + *Project* The Anubis Project | |
| 4 | 3 | |
| 5 | - Copyright (c) Alain Proute' 2003. | |
| 6 | - All rights reserved. | |
| 4 | + *Title* Querying Domain Name Servers. | |
| 7 | 5 | |
| 6 | + *Copyright* Copyright (c) Alain Prouté 2003. | |
| 7 | + | |
| 8 | + | |
| 9 | + *Author* Alain Prouté | |
| 8 | 10 | |
| 9 | 11 | |
| 12 | + *Overview* | |
| 10 | 13 | This file defines tools for sending DNS (Domain Name Service) queries. Please refer to |
| 11 | 14 | RFCs 1034 and 1035 (availables at http://www.ietf.org) for informations that you don't |
| 12 | 15 | find here. |
| ... | ... | @@ -14,6 +17,7 @@ |
| 14 | 17 | |
| 15 | 18 | In our type definitions, we have ignored obsolete or experimental features. |
| 16 | 19 | |
| 20 | + | |
| 17 | 21 | In response to a query, a name server sends 'Resource Records' (also known as 'RRs'). |
| 18 | 22 | They are of the following types (more explanations in RFC 1034): |
| 19 | 23 | ... | ... |
anubis_dev/library/system_colors/rgb.anubis
| 1 | 1 | |
| 2 | + *Project* The Anubis Project | |
| 2 | 3 | |
| 4 | + *Title* | |
| 3 | 5 | |
| 6 | + *Copyright* Copyright (c) Alain Prouté 2005. | |
| 7 | + | |
| 8 | + | |
| 9 | + *Author* Alain Prouté | |
| 10 | + | |
| 4 | 11 | |
| 5 | 12 | |
| 6 | - | |
| 13 | + | |
| 14 | + | |
| 15 | + *Overview* | |
| 7 | 16 | The following color definitions were generated from the the file 'rbg.txt' from the X11 |
| 8 | 17 | distribution. |
| 9 | 18 | ... | ... |
anubis_dev/library/system_colors/system_colors.anubis
| 1 | 1 | |
| 2 | - *** System Colors *** | |
| 2 | + *Project* The Anubis Project | |
| 3 | 3 | |
| 4 | + *Title* *** System Colors *** | |
| 4 | 5 | |
| 6 | + *Copyright* Copyright (c) Alain Prouté 2005. | |
| 7 | + | |
| 8 | + | |
| 9 | + *Author* Alain Prouté | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + *Overview* | |
| 5 | 14 | Colors RGB definition and colors name use the symbol. |
| 6 | 15 | The source is the file /usb/lib/X11/rgb.txt |
| 7 | 16 | ... | ... |
anubis_dev/library/system_fonts/draw_font.anubis
| 1 | 1 | |
| 2 | - The Anubis/Paradize Project. | |
| 2 | + *Project* The Anubis Project | |
| 3 | 3 | |
| 4 | - Making Character Fonts. | |
| 4 | + *Title* Making Character Fonts. | |
| 5 | 5 | |
| 6 | - Copyright (c) Alain Prouté 2004. | |
| 6 | + *Copyright* Copyright (c) Alain Prouté 2004. | |
| 7 | 7 | |
| 8 | - | |
| 9 | - Author: Alain Prouté | |
| 10 | - | |
| 8 | + | |
| 9 | + *Author* Alain Prouté | |
| 11 | 10 | |
| 12 | 11 | |
| 13 | 12 | |
| 13 | + *Overview* | |
| 14 | 14 | *** (2) Character fonts. |
| 15 | 15 | |
| 16 | 16 | We want to define our own types of fonts. Primarily, a font should be a set of | ... | ... |
anubis_dev/library/system_fonts/font_table.anubis
| 1 | 1 | |
| 2 | + *Project* The Anubis Project | |
| 2 | 3 | |
| 3 | - The Anubis Project. | |
| 4 | - | |
| 5 | - Printing the ISO 8859-15 table. | |
| 6 | - | |
| 7 | - Copyright (c) Alain Prouté 2004. | |
| 8 | - | |
| 4 | + *Title* Printing the ISO 8859-15 table. | |
| 9 | 5 | |
| 6 | + *Copyright* Copyright (c) Alain Prouté 2004. | |
| 7 | + | |
| 8 | + | |
| 9 | + *Author* Alain Prouté | |
| 10 | + | |
| 10 | 11 | |
| 12 | + | |
| 13 | + *Overview* | |
| 11 | 14 | This small programs prints in ASCII the table of all characters in the ISO 8859-15 |
| 12 | 15 | (latin 1 with euro symbol) font. Actually, it does not print characters of codes 0 to |
| 13 | 16 | 31, neither characters of codes 127 to 159 which are empty. | ... | ... |
anubis_dev/library/tools/base64.anubis
| 1 | 1 | |
| 2 | + *Project* The Anubis Project | |
| 2 | 3 | |
| 4 | + *Title* Base64 encoding/decoding. | |
| 3 | 5 | |
| 4 | - The Anubis Project | |
| 5 | - Base64 encoding/decoding. | |
| 6 | - | |
| 7 | - Copyright (c) Alain Proute' <alp@math.jusieu.fr> 2002. | |
| 8 | - All rights reserved. | |
| 9 | - | |
| 6 | + *Copyright* Copyright (c) Alain Prouté 2002. | |
| 10 | 7 | |
| 11 | 8 | |
| 12 | - | |
| 13 | - | |
| 9 | + *Author* Alain Prouté | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + *Overview* | |
| 14 | 14 | 'Base64' is some simple way of losslessly encoding binary data (sequences of 8 bits |
| 15 | 15 | bytes) into pure ASCII data (sequences of 7 bits bytes), so that the data may be |
| 16 | 16 | transported over public networks without any risk of corruption. Base64 is defined in | ... | ... |
anubis_dev/library/tools/basis.anubis
| 1 | + | |
| 2 | + *Project* The Anubis Project | |
| 3 | + | |
| 4 | + *Title* Some basic definitions. | |
| 1 | 5 | |
| 2 | - | |
| 3 | - The Anubis Project. | |
| 6 | + *Copyright* Copyright (c) Alain Prouté 2001. | |
| 4 | 7 | |
| 5 | - Some basic definitions. | |
| 6 | - | |
| 7 | - Copyright (c) Alain Proute' 2001. | |
| 8 | - All rights reserved. | |
| 8 | + | |
| 9 | + *Author* Alain Prouté | |
| 10 | + | |
| 9 | 11 | |
| 10 | 12 | *** (1) Boolean functions |
| 11 | 13 | *** (2) Int32 functions | ... | ... |
anubis_dev/library/tools/connections.anubis
| 1 | + | |
| 2 | + *Project* The Anubis Project | |
| 1 | 3 | |
| 4 | + *Title* Unifying the handling of connections. | |
| 2 | 5 | |
| 3 | - The Anubis Project. | |
| 4 | - Unifying the handling of connections. | |
| 5 | - | |
| 6 | - Copyright (c) Alain Proute' 2003. | |
| 7 | - All rights reserved. | |
| 8 | - | |
| 6 | + *Copyright* Copyright (c) Alain Prouté 2003. | |
| 7 | + | |
| 8 | + | |
| 9 | + *Author* Alain Prouté | |
| 10 | + | |
| 11 | + | |
| 9 | 12 | |
| 13 | + | |
| 14 | + *Overview* | |
| 10 | 15 | Anubis knows several sorts of connections: |
| 11 | - | |
| 12 | - - connections to files (on disk) | |
| 13 | - - TCP/IP connections | |
| 14 | - - SSL connections. | |
| 15 | - | |
| 16 | + | |
| 17 | + * connections to files (on disk) | |
| 18 | + * TCP/IP connections | |
| 19 | + * SSL connections. | |
| 20 | + | |
| 21 | + | |
| 16 | 22 | Unfortunatly, the system (at least for version 1) has not been conceived |
| 17 | 23 | consistently. Actually, file and TCP/IP connections are of type ?Addr(Int8), while SSL |
| 18 | 24 | connections are of type SSL_Connection. |
| 19 | - | |
| 25 | + | |
| 26 | + | |
| 20 | 27 | In order to unify the handling of all sorts of connections, we first define the |
| 21 | 28 | following type: |
| 22 | - | |
| 29 | + | |
| 30 | + | |
| 23 | 31 | public type Connection: |
| 24 | 32 | file(RAddr(Int8)), |
| 25 | 33 | file(WAddr(Int8)), |
| 26 | 34 | file(RWAddr(Int8)), |
| 27 | 35 | tcp(RWAddr(Int8)), |
| 28 | 36 | ssl(SSL_Connection). |
| 29 | - | |
| 37 | + | |
| 30 | 38 | |
| 31 | 39 | The operations on connections are: |
| 32 | - | |
| 40 | + | |
| 41 | + | |
| 33 | 42 | - opening connections (closing is automatic), |
| 34 | 43 | - writing to a connection |
| 35 | 44 | - reading from a connection. |
| 36 | - | |
| 45 | + | |
| 46 | + | |
| 37 | 47 | For opening connections, see 'file', 'connect' and 'open_SSL_connection' in |
| 38 | 48 | 'predefined.anubis'. |
| 39 | 49 | |
| 40 | 50 | Now, here are the unified tools for reading and writing: |
| 41 | - | |
| 51 | + | |
| 52 | + | |
| 42 | 53 | public define Maybe(ByteArray) // result of reading |
| 43 | 54 | read |
| 44 | 55 | ( |
| ... | ... | @@ -46,22 +57,20 @@ public define Maybe(ByteArray) // result of reading |
| 46 | 57 | Int32 n, // maximal number of bytes to read |
| 47 | 58 | Int32 timeout // in seconds |
| 48 | 59 | ). |
| 49 | - | |
| 60 | + | |
| 61 | + | |
| 50 | 62 | public define Maybe(Int32) // number of bytes actually written |
| 51 | 63 | write |
| 52 | 64 | ( |
| 53 | 65 | Connection c, |
| 54 | 66 | ByteArray ba |
| 55 | 67 | ). |
| 56 | - | |
| 57 | - | |
| 58 | - | |
| 59 | - | |
| 68 | + | |
| 69 | + | |
| 60 | 70 | --- That's all for the public part. --------------------------------------------------- |
| 61 | - | |
| 62 | - | |
| 63 | - | |
| 64 | - | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 65 | 74 | public define Maybe(ByteArray) // result of reading |
| 66 | 75 | read |
| 67 | 76 | ( |
| ... | ... | @@ -69,6 +78,7 @@ public define Maybe(ByteArray) // result of reading |
| 69 | 78 | Int32 n, |
| 70 | 79 | Int32 timeout |
| 71 | 80 | ) = |
| 81 | + | |
| 72 | 82 | if c is |
| 73 | 83 | { |
| 74 | 84 | file(ra) then read(ra,n,timeout), |
| ... | ... | @@ -77,15 +87,15 @@ public define Maybe(ByteArray) // result of reading |
| 77 | 87 | tcp(a) then read(weaken(a),n,timeout), |
| 78 | 88 | ssl(a) then read(a,n,timeout) |
| 79 | 89 | }. |
| 80 | - | |
| 81 | - | |
| 82 | - | |
| 90 | + | |
| 91 | + | |
| 83 | 92 | public define Maybe(Int32) // number of bytes actually written |
| 84 | 93 | write |
| 85 | 94 | ( |
| 86 | 95 | Connection c, |
| 87 | 96 | ByteArray ba |
| 88 | 97 | ) = |
| 98 | + | |
| 89 | 99 | if c is |
| 90 | 100 | { |
| 91 | 101 | file(ra) then alert, |
| ... | ... | @@ -94,8 +104,8 @@ public define Maybe(Int32) // number of bytes actually written |
| 94 | 104 | tcp(a) then write(weaken(a),ba), |
| 95 | 105 | ssl(a) then write(a,ba) |
| 96 | 106 | }. |
| 107 | + | |
| 97 | 108 | |
| 98 | - | |
| 99 | 109 | public define (Int32,Int32) |
| 100 | 110 | remote_IP_address_and_port |
| 101 | 111 | ( |
| ... | ... | @@ -109,5 +119,7 @@ public define (Int32,Int32) |
| 109 | 119 | tcp(a) then remote_IP_address_and_port(a), |
| 110 | 120 | ssl(a) then remote_SSL_address_and_port(a) |
| 111 | 121 | }. |
| 122 | + | |
| 112 | 123 | |
| 124 | + | |
| 113 | 125 | |
| 114 | 126 | \ No newline at end of file | ... | ... |
anubis_dev/library/tools/findstring.anubis
| 1 | 1 | |
| 2 | - The Anubis Project | |
| 3 | - | |
| 4 | - Finding a substring in a string. | |
| 5 | - (and a sub byte array in a byte array) | |
| 6 | - | |
| 7 | - Copyright (c) Alain Proute' 2001. | |
| 8 | - All rights reserved. | |
| 2 | + *Project* The Anubis Project | |
| 9 | 3 | |
| 4 | + *Title* Finding a substring in a string. | |
| 5 | + (and a sub byte array in a byte array) | |
| 10 | 6 | |
| 11 | - | |
| 7 | + *Copyright* Copyright (c) Alain Prouté 2001. | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 12 | 11 | This file defines the function 'find': |
| 13 | 12 | |
| 14 | 13 | public define Maybe(Int32) | ... | ... |
anubis_dev/library/tools/hashtable.anubis
| 1 | + | |
| 2 | + *Project* The Anubis Project | |
| 1 | 3 | |
| 2 | - The Anubis/Paradize project. | |
| 3 | - | |
| 4 | - Creating and using hash tables. | |
| 5 | - | |
| 6 | - Copyright (c) Alain Prouté 2004. | |
| 7 | - | |
| 4 | + *Title* Creating and using hash tables. | |
| 8 | 5 | |
| 9 | - Authors: Alain Prouté | |
| 6 | + *Copyright* Copyright (c) Alain Prouté 2004. | |
| 7 | + | |
| 8 | + | |
| 9 | + *Author* Alain Prouté | |
| 10 | 10 | |
| 11 | + | |
| 11 | 12 | |
| 12 | 13 | --------------------------------- table of Contents ----------------------------------- |
| 13 | 14 | *** (1) Creating a hash table. | ... | ... |
anubis_dev/library/tools/maybefloat.anubis
| 1 | 1 | |
| 2 | + *Project* The Anubis Project | |
| 2 | 3 | |
| 4 | + *Title* Using 'Maybe(Float)' numbers. | |
| 3 | 5 | |
| 4 | - The Anubis Project. | |
| 5 | - | |
| 6 | - Using 'Maybe(Float)' numbers. | |
| 7 | - | |
| 8 | - | |
| 9 | - Copyright (c) Alain Proute' 2001. | |
| 10 | - All rights reserved. | |
| 6 | + *Copyright* Copyright (c) Alain Prouté 2001. | |
| 7 | + | |
| 8 | + | |
| 9 | + *Author* Alain Prouté | |
| 11 | 10 | |
| 12 | 11 | |
| 12 | + *Overview* | |
| 13 | 13 | Data of the primitive type 'Float' represent only actual numbers, not infinity or other |
| 14 | 14 | things as in the usual definitions of floating point numbers (IEEE 754). Nevertheless, |
| 15 | 15 | since floating point operations may fail (division, tangent, etc... and even sum, which | ... | ... |
anubis_dev/library/tools/saturate.anubis
| 1 | 1 | |
| 2 | + *Project* The Anubis Project | |
| 2 | 3 | |
| 3 | - The Anubis/Paradize project. | |
| 4 | - | |
| 5 | - A saturation process. | |
| 6 | - | |
| 7 | - Copyright (c) Alain Prouté 2004. | |
| 8 | - | |
| 9 | - | |
| 10 | - Authors: Alain Prouté | |
| 4 | + *Title* A saturation process. | |
| 11 | 5 | |
| 6 | + *Copyright* Copyright (c) Alain Prouté 2004. | |
| 12 | 7 | |
| 8 | + | |
| 9 | + *Author* Alain Prouté | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + *Overview* | |
| 13 | 14 | This file contains a tool for performing some general saturation process on finite sets |
| 14 | 15 | (actually lists). This process is often useful when problems concerning graphs must be |
| 15 | 16 | handled. It is used several times in 'filtering/make_parser.anubis' for constructing | ... | ... |
anubis_dev/library/tools/streams.anubis
| 1 | 1 | |
| 2 | - The Anubis Project. | |
| 3 | - | |
| 4 | - A simple notion of stream. | |
| 5 | - Copyright (c) Alain Proute' 2005. | |
| 2 | + *Project* The Anubis Project | |
| 6 | 3 | |
| 4 | + *Title* A simple notion of stream. | |
| 7 | 5 | |
| 6 | + *Copyright* Copyright (c) Alain Prouté 2005. | |
| 7 | + | |
| 8 | + | |
| 9 | + *Author* Alain Prouté | |
| 10 | + | |
| 8 | 11 | |
| 12 | + *Overview* | |
| 9 | 13 | An 'input stream' is an object (in the sens of OOP) from which bytes may be read. We |
| 10 | 14 | have defined the opaque type: |
| 11 | 15 | ... | ... |
anubis_dev/library/tools/tables.anubis
anubis_dev/library/tools/tools.anubis
| 1 | 1 | |
| 2 | - | |
| 3 | - The Anubis Project. | |
| 2 | + *Project* The Anubis Project | |
| 3 | + | |
| 4 | + *Title* Some general purpose tools. | |
| 4 | 5 | |
| 5 | - Some general purpose tools. | |
| 6 | - | |
| 7 | - Copyright (c) Alain Proute' 2001. | |
| 8 | - All rights reserved. | |
| 6 | + *Copyright* Copyright (c) Alain Prouté 2001. | |
| 7 | + | |
| 8 | + | |
| 9 | + *Author* Alain Prouté | |
| 10 | + | |
| 9 | 11 | |
| 10 | 12 | |
| 11 | 13 | read web/html.anubis | ... | ... |
anubis_dev/library/web/common.anubis
| 1 | + | |
| 2 | + *Project* The Anubis Project | |
| 3 | + *Title* Some common stuff for the web. | |
| 1 | 4 | |
| 2 | - The Anubis Project. | |
| 3 | - Some common stuff for the web. | |
| 4 | - | |
| 5 | - Copyright (c) Alain Proute' 2003. | |
| 6 | - All rights reserved. | |
| 5 | + *Copyright* Copyright (c) Alain Prouté 2003. | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + *Author* Alain Prouté | |
| 7 | 10 | |
| 8 | - | |
| 11 | + *Public* | |
| 12 | + *Name* HTTP_header | |
| 13 | + *Description* | |
| 9 | 14 | The type 'HTTP_header' describes HTTP headers, which are just pairs '(name,value)'. |
| 10 | 15 | |
| 11 | 16 | public type HTTP_header: |
| 12 | 17 | http_header(String name, |
| 13 | 18 | String value). |
| 14 | 19 | |
| 15 | - | |
| 20 | + *Name* Web_arg | |
| 21 | + *Description* | |
| 22 | + | |
| 16 | 23 | The type 'Web_arg' describes 'web arguments'. A web argument is either a pair |
| 17 | 24 | '(name,value)' (for example it may be 'web_arg("password","foobar")', if the client |
| 18 | 25 | clicks on the submit button of a form containing a password input field named |
| ... | ... | @@ -30,6 +37,8 @@ public type Web_arg: |
| 30 | 37 | String temp_file_path). // temporary file path (relative to server directory) |
| 31 | 38 | |
| 32 | 39 | |
| 40 | + *Name* Web_arg_value | |
| 41 | + *Description* | |
| 33 | 42 | Of course, within the body of a 'web page' operation, you may want to recover the value |
| 34 | 43 | of a particular web argument. To that end, use the operation 'web_arg_value', which |
| 35 | 44 | takes 2 argument: |
| ... | ... | @@ -43,6 +52,8 @@ public type Web_arg_value: |
| 43 | 52 | not_found, |
| 44 | 53 | found(String value). |
| 45 | 54 | |
| 55 | + *Name* Web_arg_value | |
| 56 | + *Description* | |
| 46 | 57 | If the requested argument name is not found in the list, 'not_found' is |
| 47 | 58 | returned. Otherwise, the value returned by 'web_arg_value' has the form 'found(v)', |
| 48 | 59 | where 'v' is the value of the argument. |
| ... | ... | @@ -72,7 +83,8 @@ public define Web_arg_value |
| 72 | 83 | } |
| 73 | 84 | }. |
| 74 | 85 | |
| 75 | - | |
| 86 | + *Ignore* | |
| 87 | + | |
| 76 | 88 | public define Maybe((String,String)) |
| 77 | 89 | file_upload_value |
| 78 | 90 | ( | ... | ... |
anubis_dev/library/web/cookies.anubis
| 1 | 1 | |
| 2 | - The Anubis Project. | |
| 2 | + *Project* The Anubis Project | |
| 3 | 3 | |
| 4 | - Managing Cookies. | |
| 4 | + *Title* Managing Cookies. | |
| 5 | 5 | |
| 6 | - Copyright (c) Alain Proute' 2001. | |
| 7 | - All rights reserved. | |
| 6 | + *Copyright* Copyright (c) Alain Prouté 2001. | |
| 7 | + | |
| 8 | + | |
| 9 | + *Author* Alain Prouté | |
| 10 | + | |
| 11 | + | |
| 8 | 12 | |
| 9 | 13 | |
| 10 | 14 | read tools/basis.anubis |
| ... | ... | @@ -13,6 +17,7 @@ read web/html.anubis |
| 13 | 17 | read web/http_get_common.anubis |
| 14 | 18 | |
| 15 | 19 | |
| 20 | + *Overview* | |
| 16 | 21 | Cookies are defined in RFC 2109. Here is the corresponding Anubis type: |
| 17 | 22 | |
| 18 | 23 | Each cookie has an server name (the name of the server who constructed the cookie), a | ... | ... |
anubis_dev/library/web/file_manager.anubis
| 1 | 1 | |
| 2 | - The Anubis Project. | |
| 2 | + *Project* The Anubis Project | |
| 3 | 3 | |
| 4 | - A Web Oriented File Manager. | |
| 5 | - | |
| 6 | - | |
| 7 | - | |
| 8 | - Author: Alain Proute' | |
| 4 | + *Title* A Web Oriented File Manager. | |
| 9 | 5 | |
| 6 | + *Copyright* Copyright (c) Alain Prouté 2005. | |
| 10 | 7 | |
| 11 | -read making_a_web_site.anubis | |
| 12 | -read common.anubis | |
| 13 | - | |
| 8 | + | |
| 9 | + *Author* Alain Prouté | |
| 14 | 10 | |
| 11 | + | |
| 12 | + | |
| 13 | + *Overview* | |
| 15 | 14 | This file defines a datum of type HTML_Off_Form (see 'web/making_a_web_site.anubis' for |
| 16 | 15 | the definition of this type) which is a tool for managing file through the web. The |
| 17 | 16 | file manager shows the path of the directory currently managed, a list of all files in |
| ... | ... | @@ -31,7 +30,10 @@ read common.anubis |
| 31 | 30 | directory to be managed, and to change the path of this directory. This is why |
| 32 | 31 | 'file_manager' takes such tools as its arguments. The same principles apply to the |
| 33 | 32 | layout. |
| 34 | - | |
| 33 | + | |
| 34 | +read making_a_web_site.anubis | |
| 35 | +read common.anubis | |
| 36 | + | |
| 35 | 37 | public type FileManagerLayout: |
| 36 | 38 | short, // only file names |
| 37 | 39 | long. // file names with details (size, date, ...) | ... | ... |
anubis_dev/library/web/generic_form.anubis
anubis_dev/library/web/generic_table.anubis
| 1 | 1 | |
| 2 | - The ERP project. | |
| 2 | + *Project* The Anubis Project | |
| 3 | 3 | |
| 4 | - Generic table page. | |
| 4 | + *Title* Generic table page. | |
| 5 | 5 | |
| 6 | - Copyright (c) Constructive Mathematics S.A.R.L. 2004 | |
| 7 | - | |
| 8 | - | |
| 9 | - Author: Olivier Duvernois | |
| 6 | + *Copyright* Copyright (c) Alain Prouté 2004. | |
| 7 | + | |
| 8 | + | |
| 9 | + *Author* Alain Prouté | |
| 10 | + *Author* Olivier Duvernois | |
| 10 | 11 | |
| 11 | 12 | |
| 12 | 13 | ... | ... |
anubis_dev/library/web/http_get.anubis
| 1 | 1 | |
| 2 | - The Anubis Project. | |
| 3 | - | |
| 4 | - Getting a document from the Web. | |
| 5 | - | |
| 6 | - Copyright (c) Alain Proute' 2001. | |
| 7 | - All rights reserved. | |
| 2 | + *Project* The Anubis Project | |
| 8 | 3 | |
| 4 | + *Title* Getting a document from the Web. | |
| 9 | 5 | |
| 6 | + *Copyright* Copyright (c) Alain Prouté 2001. | |
| 10 | 7 | |
| 11 | -read tools/basis.anubis | |
| 12 | -read web/common.anubis | |
| 13 | -read web/http_get_common.anubis | |
| 14 | 8 | |
| 9 | + *Author* Alain Prouté | |
| 15 | 10 | |
| 11 | + | |
| 12 | + | |
| 13 | + *Overview* | |
| 16 | 14 | This file defines the function 'http_get' which retrieves a document from the world |
| 17 | 15 | wide web (a similar function 'https_get' for secured documents is defined in |
| 18 | 16 | 'https_get.anubis'). The function simulates the behavior of a browser, at least just |
| ... | ... | @@ -33,6 +31,11 @@ read web/http_get_common.anubis |
| 33 | 31 | which may happen: |
| 34 | 32 | |
| 35 | 33 | |
| 34 | +read tools/basis.anubis | |
| 35 | +read web/common.anubis | |
| 36 | +read web/http_get_common.anubis | |
| 37 | + | |
| 38 | + | |
| 36 | 39 | public type HTTP_GET_Result: |
| 37 | 40 | cannot_resolve_server_name(DNS_Result), |
| 38 | 41 | cannot_connect_to_server(NetworkConnectError), | ... | ... |
anubis_dev/library/web/http_get_common.anubis
| 1 | 1 | |
| 2 | - The Anubis Project. | |
| 2 | + *Project* The Anubis Project | |
| 3 | 3 | |
| 4 | - Getting a document from the Web. | |
| 5 | - | |
| 6 | - Copyright (c) Alain Proute' 2001. | |
| 7 | - All rights reserved. | |
| 4 | + *Title* Getting a document from the Web. | |
| 8 | 5 | |
| 6 | + *Copyright* Copyright (c) Alain Prouté 2001. | |
| 7 | + | |
| 8 | + | |
| 9 | + *Author* Alain Prouté | |
| 9 | 10 | |
| 10 | - | |
| 11 | - | |
| 12 | 11 | |
| 13 | 12 | |
| 14 | 13 | This file contains the types and functions which are common to 'http_get' and | ... | ... |
anubis_dev/library/web/https_get.anubis
| 1 | 1 | |
| 2 | - The Anubis Project. | |
| 3 | - | |
| 4 | - Getting a document from the secured Web. | |
| 5 | - | |
| 6 | - Copyright (c) Alain Proute' 2001. | |
| 7 | - All rights reserved. | |
| 8 | - | |
| 9 | -read tools/basis.anubis | |
| 10 | -read html.anubis | |
| 11 | -read http_get_common.anubis | |
| 12 | -read http_server.anubis | |
| 13 | -read common.anubis | |
| 2 | + *Project* The Anubis Project | |
| 14 | 3 | |
| 4 | + *Title* Getting a document from the secured Web. | |
| 15 | 5 | |
| 6 | + *Copyright* Copyright (c) Alain Prouté 2001. | |
| 7 | + | |
| 8 | + | |
| 9 | + *Author* Alain Prouté | |
| 16 | 10 | |
| 11 | + | |
| 12 | + *Overview* | |
| 17 | 13 | This file defines the function 'https_get' which retrieve a document from the world |
| 18 | 14 | wide web in secured mode (HTTPS). The function is analogous to 'http_get', to be found |
| 19 | 15 | in 'web/http_get.anubis'. |
| ... | ... | @@ -34,6 +30,13 @@ read common.anubis |
| 34 | 30 | The result returned by 'https_get' has the following type, which defines the problems |
| 35 | 31 | which may happen: |
| 36 | 32 | |
| 33 | + | |
| 34 | +read tools/basis.anubis | |
| 35 | +read html.anubis | |
| 36 | +read http_get_common.anubis | |
| 37 | +read http_server.anubis | |
| 38 | +read common.anubis | |
| 39 | + | |
| 37 | 40 | |
| 38 | 41 | public type HTTPS_GET_Result: |
| 39 | 42 | cannot_resolve_server_name(DNS_Result), | ... | ... |
anubis_dev/library/web/making_a_web_site.anubis
| 1 | - | |
| 2 | - | |
| 3 | - The Anubis Project. | |
| 1 | + | |
| 2 | + *Project* The Anubis Project. | |
| 4 | 3 | |
| 5 | - Making interactive Web sites. | |
| 4 | + *Title* Making interactive Web sites. | |
| 6 | 5 | |
| 7 | - Copyright (c) Alain Prouté 2004-2005. | |
| 6 | + *Copyright* Copyright (c) Alain Prouté 2004-2005. | |
| 8 | 7 | |
| 9 | 8 | |
| 10 | - Authors: Alain Prouté | |
| 9 | + *Author* Alain Prouté | |
| 11 | 10 | |
| 12 | - Last revision: January 2005. | |
| 11 | + *Revised* January 2005. | |
| 13 | 12 | |
| 14 | 13 | |
| 15 | - In this file we propose simple tools for making well structured interactive and secured | |
| 14 | + *Overview* | |
| 15 | + In this file we propose simple tools for making well structured interactive and secured | |
| 16 | 16 | web sites. |
| 17 | 17 | |
| 18 | 18 | |
| 19 | 19 | ----------------------------------- Table of Contents --------------------------------- |
| 20 | 20 | |
| 21 | - *** (1) Structure of a web site. | |
| 22 | - *** (1.1) Overview. | |
| 23 | - *** (1.2) What web pages are made of. | |
| 24 | - *** (1.3) Actions. | |
| 25 | - *** (1.4) States. | |
| 21 | + * (1) Structure of a web site. | |
| 22 | + ** (1.1) Overview. | |
| 23 | + ** (1.2) What web pages are made of. | |
| 24 | + ** (1.3) Actions. | |
| 25 | + ** (1.4) States. | |
| 26 | 26 | |
| 27 | - *** (2) Carrying on. | |
| 28 | - *** (2.1) Describing your web sites. | |
| 29 | - *** (2.2) Directories on the server's disk. | |
| 30 | - *** (2.3) Starting your web sites. | |
| 27 | + * (2) Carrying on. | |
| 28 | + ** (2.1) Describing your web sites. | |
| 29 | + ** (2.2) Directories on the server's disk. | |
| 30 | + ** (2.3) Starting your web sites. | |
| 31 | 31 | |
| 32 | - *** (3) The HTML interface. | |
| 33 | - *** (3.1) Types used by the HTML interface. | |
| 34 | - *** (3.2) ``in form'' versus ``off form''. | |
| 35 | - *** (3.3) Defining your own style. | |
| 36 | - *** (3.4) Actioners and forms. | |
| 37 | - *** (3.5) Local popup. | |
| 32 | + * (3) The HTML interface. | |
| 33 | + ** (3.1) Types used by the HTML interface. | |
| 34 | + ** (3.2) ``in form'' versus ``off form''. | |
| 35 | + ** (3.3) Defining your own style. | |
| 36 | + ** (3.4) Actioners and forms. | |
| 37 | + ** (3.5) Local popup. | |
| 38 | 38 | |
| 39 | 39 | --------------------------------------------------------------------------------------- |
| 40 | 40 | |
| ... | ... | @@ -46,7 +46,7 @@ read mime.anubis |
| 46 | 46 | |
| 47 | 47 | |
| 48 | 48 | |
| 49 | - *** (1) Structure of a web site. | |
| 49 | + * (1) Structure of a web site. | |
| 50 | 50 | |
| 51 | 51 | First of all we need to explain what a web site should be made of. Ideally, the client |
| 52 | 52 | should see the web site working as any other interactive computer software. So, it |
| ... | ... | @@ -56,7 +56,7 @@ read mime.anubis |
| 56 | 56 | At each new request (click) from the client, this state must be updated. |
| 57 | 57 | |
| 58 | 58 | |
| 59 | - *** (1.1) Overview. | |
| 59 | + ** (1.1) Overview. | |
| 60 | 60 | |
| 61 | 61 | The data which are stored into the state should be considered as 'session data'. They |
| 62 | 62 | do not encompass 'permanent data', which are typically stored into a data base. We |
| ... | ... | @@ -112,7 +112,7 @@ read mime.anubis |
| 112 | 112 | |
| 113 | 113 | |
| 114 | 114 | |
| 115 | - *** (1.2) What web pages are made of. | |
| 115 | + ** (1.2) What web pages are made of. | |
| 116 | 116 | |
| 117 | 117 | What the client can see in his browser's window may be called a 'page'. Within a page, |
| 118 | 118 | we have several sorts of components: |
| ... | ... | @@ -178,7 +178,7 @@ read mime.anubis |
| 178 | 178 | |
| 179 | 179 | |
| 180 | 180 | |
| 181 | - *** (1.3) Actions. | |
| 181 | + ** (1.3) Actions. | |
| 182 | 182 | |
| 183 | 183 | The client opens a new connection with our web site whenever he clicks on an |
| 184 | 184 | actioner. The result is that a request is sent, essentially made of a list of 'web |
| ... | ... | @@ -282,7 +282,7 @@ public type HTML_Page:... |
| 282 | 282 | |
| 283 | 283 | |
| 284 | 284 | |
| 285 | - *** (1.4) States. | |
| 285 | + ** (1.4) States. | |
| 286 | 286 | |
| 287 | 287 | Now, we explain how to define the type (say 'State') to be used as an instance of the |
| 288 | 288 | type parameter '$State'. |
| ... | ... | @@ -345,9 +345,9 @@ public type HTML_Page:... |
| 345 | 345 | |
| 346 | 346 | |
| 347 | 347 | |
| 348 | - *** (2) Carrying on. | |
| 348 | + * (2) Carrying on. | |
| 349 | 349 | |
| 350 | - *** (2.1) Describing your web sites. | |
| 350 | + ** (2.1) Describing your web sites. | |
| 351 | 351 | |
| 352 | 352 | Before you may start your web site, you must describe it, i.e. produce a datum of the |
| 353 | 353 | opaque type 'Web_Site'. |
| ... | ... | @@ -444,7 +444,7 @@ public define Web_Site |
| 444 | 444 | |
| 445 | 445 | |
| 446 | 446 | |
| 447 | - *** (2.2) Directories on the server's disk. | |
| 447 | + ** (2.2) Directories on the server's disk. | |
| 448 | 448 | |
| 449 | 449 | The description of you site contains the name of the directory within which the |
| 450 | 450 | required files are located. This may be for example: |
| ... | ... | @@ -477,7 +477,7 @@ public define Web_Site |
| 477 | 477 | |
| 478 | 478 | |
| 479 | 479 | |
| 480 | - *** (2.3) Web servers parameters. | |
| 480 | + ** (2.3) Web servers parameters. | |
| 481 | 481 | |
| 482 | 482 | The web servers have several parameters useful for administration. They are described |
| 483 | 483 | as follows: |
| ... | ... | @@ -488,7 +488,7 @@ public define Web_Site |
| 488 | 488 | |
| 489 | 489 | |
| 490 | 490 | |
| 491 | - *** (2.4) Starting your web sites. | |
| 491 | + ** (2.4) Starting your web sites. | |
| 492 | 492 | |
| 493 | 493 | When you have described all your web sites (you may want to have several web sites, and |
| 494 | 494 | they are distinguished by their 'common name'), you may start them all together using |
| ... | ... | @@ -549,14 +549,14 @@ public define Start_Web_Sites_Result |
| 549 | 549 | |
| 550 | 550 | |
| 551 | 551 | |
| 552 | - *** (3) The HTML interface. | |
| 552 | + * (3) The HTML interface. | |
| 553 | 553 | |
| 554 | 554 | We propose an interface to dynamic HTML. Dynamic HTML includes HTML, and a combination |
| 555 | 555 | of CSS (Cascading Style Sheet) and JavaScript techniques for making HTML elements more |
| 556 | 556 | reactive and attractive on the client side. |
| 557 | 557 | |
| 558 | 558 | |
| 559 | - *** (3.1) Types used by the HTML interface. | |
| 559 | + ** (3.1) Types used by the HTML interface. | |
| 560 | 560 | |
| 561 | 561 | For easy reference, we gather below the definitions of all the types used by the HTML |
| 562 | 562 | interface, and we comment them immediately. | ... | ... |
anubis_dev/library/web/making_forms.anubis
| 1 | 1 | |
| 2 | - The Anubis Project. | |
| 2 | + *Project* The Anubis Project | |
| 3 | 3 | |
| 4 | - Making Web Forms. | |
| 4 | + *Title* Making Web Forms. | |
| 5 | 5 | |
| 6 | + *Copyright* Copyright (c) Alain Prouté 2005. | |
| 7 | + | |
| 8 | + | |
| 9 | + *Author* Alain Prouté | |
| 6 | 10 | |
| 7 | - Author: Alain Prouté | |
| 8 | - | |
| 11 | + | |
| 9 | 12 | |
| 10 | 13 | read web/making_a_web_site.anubis |
| 11 | 14 | |
| 12 | 15 | |
| 13 | - | |
| 16 | + *Overview* | |
| 14 | 17 | This file contains tools for helping making forms for a web site, using |
| 15 | 18 | 'making_a_web_site.anubis'. |
| 16 | 19 | ... | ... |
anubis_dev/library/web/mime.anubis
anubis_dev/library/web/multihost_http_server.anubis
| 1 | 1 | |
| 2 | - The Anubis Project. | |
| 3 | - A Multi Host HTTP/HTTPS Server | |
| 4 | - | |
| 5 | - Copyright (c) Alain Proute' 2003. | |
| 6 | - All rights reserved. | |
| 2 | + *Project* The Anubis Project | |
| 7 | 3 | |
| 4 | + *Title* A Multi Host HTTP/HTTPS Server | |
| 8 | 5 | |
| 6 | + *Copyright* Copyright (c) Alain Prouté 2003. | |
| 7 | + | |
| 9 | 8 | |
| 10 | - Last revision: August 2005. | |
| 9 | + *Author* Alain Prouté | |
| 11 | 10 | |
| 11 | + | |
| 12 | + *Revised* August 2005. | |
| 12 | 13 | |
| 13 | 14 | |
| 14 | 15 | |
| 16 | + *Overviews* | |
| 15 | 17 | In this file a HTTP/HTTPS server is defined, which is able to handle multiple hosts |
| 16 | 18 | (virtual hosts). It answers HTTP/HTTPS requests, sends files (images or any other kind |
| 17 | 19 | of file), constructs HTML pages on the fly using informations received from the client | ... | ... |
anubis_dev/library/web/read_html.anubis
| 1 | - | |
| 1 | + | |
| 2 | + *Project* The Anubis Project | |
| 3 | + | |
| 4 | + *Title* Extracting informations from an HTML page. | |
| 5 | + | |
| 6 | + *Copyright* Copyright (c) Alain Prouté 2002. | |
| 7 | + | |
| 8 | + | |
| 9 | + *Author* Alain Prouté | |
| 2 | 10 | |
| 3 | - The Anubis Project | |
| 4 | - Extracting informations from an HTML page. | |
| 11 | + | |
| 5 | 12 | |
| 6 | - Copyright (c) Alain Proute' <alp@math.jusieu.fr> 2002. | |
| 7 | - All rights reserved. | |
| 8 | 13 | |
| 9 | 14 | |
| 10 | 15 | |
| ... | ... | @@ -13,7 +18,7 @@ read https_get.anubis |
| 13 | 18 | read http_get_common.anubis |
| 14 | 19 | read tools/basis.anubis |
| 15 | 20 | |
| 16 | - | |
| 21 | + *Overview* | |
| 17 | 22 | This file contains a tool which allows to extract informations from an HTML page. The |
| 18 | 23 | page may be either a string, the content of a file, or at an URL on the Internet. |
| 19 | 24 | ... | ... |
anubis_dev/library/web/sokoban.anubis deleted
| 1 | - | |
| 2 | - | |
| 3 | - | |
| 4 | - The Anubis Project | |
| 5 | - | |
| 6 | - A Sokoban game for the Web. | |
| 7 | - | |
| 8 | - | |
| 9 | - | |
| 10 | - | |
| 11 | - Author: Alain Proute' | |
| 12 | - | |
| 13 | - | |
| 14 | - Sokoban grids by: Yoshio Murase <yoshio@asahi.email.ne.jp> | |
| 15 | - | |
| 16 | - | |
| 17 | - In this file we define a Sokoban game for the web. | |
| 18 | - | |
| 19 | - | |
| 20 | - | |
| 21 | - | |
| 22 | - *** Testing this program. ************************************************************* | |
| 23 | - | |
| 24 | - First of all, you may want to test this program. | |
| 25 | - | |
| 26 | - Just compile this file: anubis web/sokoban.anubis | |
| 27 | - Start the server: sokoban | |
| 28 | - | |
| 29 | - Try the following address with your browser: http://127.0.0.1 | |
| 30 | - | |
| 31 | - | |
| 32 | - | |
| 33 | -read web/common.anubis | |
| 34 | - | |
| 35 | - | |
| 36 | - | |
| 37 | - | |
| 38 | - *** The Sokoban game. ***************************************************************** | |
| 39 | - | |
| 40 | - A Sokoban problem is a rectangular grid of cells. Primarily, cells are of two sorts: | |
| 41 | - walls and free cells. We cannot play on walls. We play only on free cells. A certain | |
| 42 | - number of free cells are marqued as 'goals'. The same number of free cells (goals or | |
| 43 | - not) contain an object, and one more free cell (goal or not) contains the | |
| 44 | - 'house-keeper' (also called the 'keeper'). The game consists in letting the keeper push | |
| 45 | - all the objects onto the goals. The keeper can only push an object from behind it. He | |
| 46 | - cannot push more than one object at a time. He can walk on all free cells which do not | |
| 47 | - contain an object. | |
| 48 | - | |
| 49 | - We need 9 images for the decoration. The sokoban is more funny if the decoration is | |
| 50 | - not always the same one. Hence, we want to manage 'decoration sets of images': | |
| 51 | - | |
| 52 | -public type SokobanDecorationSet: | |
| 53 | - sok_set(String wall_image, // these strings are file names (or paths) | |
| 54 | - String free_cell_image, | |
| 55 | - String goal_image, | |
| 56 | - String keeper_image, | |
| 57 | - String object_image, | |
| 58 | - String keeper_on_goal_image, | |
| 59 | - String object_on_goal_image, | |
| 60 | - String cloud, // 'clouds' are used to trace the movements of the keeper | |
| 61 | - String cloud_on_goal). | |
| 62 | - | |
| 63 | - The state of the game at any time is determined by the content of cells (clouds are not | |
| 64 | - the matter here): | |
| 65 | - | |
| 66 | -public type SokobanCell: | |
| 67 | - wall, | |
| 68 | - free, | |
| 69 | - goal, | |
| 70 | - keeper, | |
| 71 | - object, | |
| 72 | - keeper_on_goal, | |
| 73 | - object_on_goal. | |
| 74 | - | |
| 75 | - Now a sokoban game (or grid) is just a rectangular array of cells in some given | |
| 76 | - state. We represent this array by a list of lines, where each line is a list of cells: | |
| 77 | - | |
| 78 | -public type SokobanGrid: | |
| 79 | - grid(List(List(SokobanCell))). | |
| 80 | - | |
| 81 | - Now, here is a default decoration set. You are encouraged to create new decorations | |
| 82 | - set. The sole constraint is that all images must be squares of the same size, and that | |
| 83 | - goals must remain visible through objects or through the keeper. | |
| 84 | - | |
| 85 | -public define SokobanDecorationSet | |
| 86 | - default_decoration_set = | |
| 87 | - with path = "/", | |
| 88 | - sok_set(path+"bambou.gif", // these files in '~/my_anubis/server/public/sokoban' | |
| 89 | - path+"bleuc.gif", | |
| 90 | - path+"noir25.gif", | |
| 91 | - path+"tete.gif", | |
| 92 | - path+"boule.gif", | |
| 93 | - path+"gtete.gif", | |
| 94 | - path+"gboule.gif", | |
| 95 | - path+"bleuccloud.gif", | |
| 96 | - path+"noir25cloud.gif"). | |
| 97 | - | |
| 98 | - | |
| 99 | - We provide in this file a series of grids: The Murase grids. The n-th grid of this | |
| 100 | - series is obtained through the function (which returns 'failure' if 'n' is out of | |
| 101 | - bounds): | |
| 102 | - | |
| 103 | -public define Maybe(SokobanGrid) | |
| 104 | - murase_grid | |
| 105 | - ( | |
| 106 | - Int32 n | |
| 107 | - ). | |
| 108 | - | |
| 109 | - | |
| 110 | - Now, we declare the web item which represents the Sokoban game (to be included into | |
| 111 | - your web page). | |
| 112 | - | |
| 113 | -read web/making_a_web_site.anubis | |
| 114 | - | |
| 115 | -public define HTML_Off_Form | |
| 116 | - sokoban | |
| 117 | - ( | |
| 118 | - SokobanDecorationSet images, | |
| 119 | - SokobanGrid grid, | |
| 120 | - String next_url // to be called when game is over | |
| 121 | - ). | |
| 122 | - | |
| 123 | - | |
| 124 | - | |
| 125 | - | |
| 126 | - | |
| 127 | - --- That's all for the public part ! -------------------------------------------------- | |
| 128 | - | |
| 129 | -read tools/basis.anubis | |
| 130 | - | |
| 131 | - | |
| 132 | - Our Sokoban game uses a few words from the natural language. Hence, we need the | |
| 133 | - following type: | |
| 134 | - | |
| 135 | -public type SokobanLanguage: | |
| 136 | - french, | |
| 137 | - english. | |
| 138 | - | |
| 139 | -define String | |
| 140 | - restart_game | |
| 141 | - ( | |
| 142 | - SokobanLanguage lang | |
| 143 | - ) = | |
| 144 | - if lang is | |
| 145 | - { | |
| 146 | - french then "Recommencer", | |
| 147 | - english then "Restart" | |
| 148 | - }. | |
| 149 | - | |
| 150 | - | |
| 151 | - | |
| 152 | - Each cell is a clickable image. Such an image has a name of the form 'sokoban_im_x_y', | |
| 153 | - where 'x' and 'y' are the coordinates of the image in the grid. When this image is | |
| 154 | - clicked, the JavaScript function 'sokoban_click' is called with arguments 'x' and 'y'. | |
| 155 | - | |
| 156 | -define HTML_Off_Form | |
| 157 | - clickable_image | |
| 158 | - ( | |
| 159 | - String file_name, // image for this cell | |
| 160 | - Int32 x, // coordinates of this cell | |
| 161 | - Int32 y | |
| 162 | - ) = | |
| 163 | - literal(["<img src=\"",file_name,"\"", | |
| 164 | - " name=\"sokoban_im_",x,"_",y,"\"", | |
| 165 | - " onMousedown='sokoban_click(",x,",",y,")'\n>"]). | |
| 166 | - | |
| 167 | - | |
| 168 | - | |
| 169 | - A 'menu' is appended to the grid. It contains the following buttons: | |
| 170 | - | |
| 171 | - - restart game, | |
| 172 | - - undo, | |
| 173 | - - redo. | |
| 174 | - | |
| 175 | - | |
| 176 | - | |
| 177 | -define HTML_Row(HTML_Off_Form) | |
| 178 | - menu_row | |
| 179 | - = | |
| 180 | - row(cell([columns(2)], | |
| 181 | - literal(["<img src=\"button_prev.gif\" alt=\"Recommencer\" onMousedown='sokoban_restart();'\n>"]))). | |
| 182 | - | |
| 183 | - | |
| 184 | - | |
| 185 | - | |
| 186 | - The function 'make_grid' constructs the grid as an HTML <table>: | |
| 187 | - | |
| 188 | -define HTML_Cell(HTML_Off_Form) | |
| 189 | - make_grid_cell | |
| 190 | - ( | |
| 191 | - SokobanDecorationSet images, | |
| 192 | - SokobanCell c, | |
| 193 | - Int32 y, | |
| 194 | - Int32 x | |
| 195 | - ) = | |
| 196 | - if images is sok_set(w,f,g,k,o,kg,og,cl,clg) then | |
| 197 | - if c is | |
| 198 | - { | |
| 199 | - wall then cell([],clickable_image(w,x,y)), | |
| 200 | - free then cell([],clickable_image(f,x,y)), | |
| 201 | - goal then cell([],clickable_image(g,x,y)), | |
| 202 | - keeper then cell([],clickable_image(k,x,y)), | |
| 203 | - object then cell([],clickable_image(o,x,y)), | |
| 204 | - keeper_on_goal then cell([],clickable_image(kg,x,y)), | |
| 205 | - object_on_goal then cell([],clickable_image(og,x,y)), | |
| 206 | - }. | |
| 207 | - | |
| 208 | -define List(HTML_Cell(HTML_Off_Form)) | |
| 209 | - make_grid_cells | |
| 210 | - ( | |
| 211 | - SokobanDecorationSet images, | |
| 212 | - List(SokobanCell) cells, | |
| 213 | - Int32 y, | |
| 214 | - Int32 x | |
| 215 | - ) = | |
| 216 | - if cells is | |
| 217 | - { | |
| 218 | - [ ] then [ ], | |
| 219 | - [h . t] then | |
| 220 | - [make_grid_cell(images,h,y,x) . make_grid_cells(images,t,y,x+1)] | |
| 221 | - }. | |
| 222 | - | |
| 223 | -define List(HTML_Row(HTML_Off_Form)) | |
| 224 | - make_grid_lines | |
| 225 | - ( | |
| 226 | - SokobanDecorationSet images, | |
| 227 | - List(List(SokobanCell)) lines, | |
| 228 | - Int32 y | |
| 229 | - ) = | |
| 230 | - if lines is | |
| 231 | - { | |
| 232 | - [ ] then [ ], | |
| 233 | - [h . t] then | |
| 234 | - [ row(make_grid_cells(images,h,y,0)) . make_grid_lines(images,t,y+1)] | |
| 235 | - }. | |
| 236 | - | |
| 237 | -define HTML_Off_Form | |
| 238 | - make_grid | |
| 239 | - ( | |
| 240 | - SokobanDecorationSet images, | |
| 241 | - SokobanGrid grid | |
| 242 | - ) = | |
| 243 | - if grid is grid(lines) then | |
| 244 | - table([nude],append(make_grid_lines(images,lines,0),[menu_row])). | |
| 245 | - | |
| 246 | - | |
| 247 | - | |
| 248 | - | |
| 249 | - The width of a grid is the maximum of the lengths of its lines. | |
| 250 | - | |
| 251 | -define Int32 | |
| 252 | - grid_width | |
| 253 | - ( | |
| 254 | - List(List(SokobanCell)) l, | |
| 255 | - Int32 max | |
| 256 | - ) = | |
| 257 | - if l is | |
| 258 | - { | |
| 259 | - [ ] then max, | |
| 260 | - [h . t] then with w = length(h), | |
| 261 | - if w < max | |
| 262 | - then grid_width(t,max) | |
| 263 | - else grid_width(t,w) | |
| 264 | - }. | |
| 265 | - | |
| 266 | -define Int32 | |
| 267 | - grid_width | |
| 268 | - ( | |
| 269 | - SokobanGrid grid | |
| 270 | - ) = | |
| 271 | - if grid is grid(lines) then grid_width(lines,0). | |
| 272 | - | |
| 273 | - | |
| 274 | - The height of a grid is its number of lines. | |
| 275 | - | |
| 276 | -define Int32 | |
| 277 | - grid_height | |
| 278 | - ( | |
| 279 | - SokobanGrid grid | |
| 280 | - ) = | |
| 281 | - if grid is grid(l) then length(l). | |
| 282 | - | |
| 283 | - | |
| 284 | - | |
| 285 | - Getting the x coordinate of the keeper in a grid. | |
| 286 | - | |
| 287 | -define Maybe(Int32) | |
| 288 | - keeper_x | |
| 289 | - ( | |
| 290 | - List(SokobanCell) l, | |
| 291 | - Int32 n | |
| 292 | - ) = | |
| 293 | - if l is | |
| 294 | - { | |
| 295 | - [ ] then failure, | |
| 296 | - [h . t] then if h is keeper then success(n) else | |
| 297 | - if h is keeper_on_goal then success(n) else | |
| 298 | - keeper_x(t,n+1) | |
| 299 | - }. | |
| 300 | - | |
| 301 | -define Int32 | |
| 302 | - keeper_x | |
| 303 | - ( | |
| 304 | - List(List(SokobanCell)) l | |
| 305 | - ) = | |
| 306 | - if l is | |
| 307 | - { | |
| 308 | - [ ] then alert, | |
| 309 | - [h . t] then | |
| 310 | - if keeper_x(h,0) is | |
| 311 | - { | |
| 312 | - failure then keeper_x(t), | |
| 313 | - success(n) then n | |
| 314 | - } | |
| 315 | - }. | |
| 316 | - | |
| 317 | -define Int32 | |
| 318 | - keeper_x | |
| 319 | - ( | |
| 320 | - SokobanGrid grid | |
| 321 | - ) = | |
| 322 | - if grid is grid(l) then keeper_x(l). | |
| 323 | - | |
| 324 | - | |
| 325 | - | |
| 326 | - Getting the y coordinate of the keeper. | |
| 327 | - | |
| 328 | -define Int32 | |
| 329 | - keeper_y | |
| 330 | - ( | |
| 331 | - List(List(SokobanCell)) l, | |
| 332 | - Int32 n | |
| 333 | - ) = | |
| 334 | - if l is | |
| 335 | - { | |
| 336 | - [ ] then alert, | |
| 337 | - [h . t] then | |
| 338 | - if keeper_x(h,0) is // use 'keeper_x' to test the presence of the keeper in this line | |
| 339 | - { | |
| 340 | - failure then keeper_y(t,n+1), | |
| 341 | - success(_) then n | |
| 342 | - } | |
| 343 | - }. | |
| 344 | - | |
| 345 | -define Int32 | |
| 346 | - keeper_y | |
| 347 | - ( | |
| 348 | - SokobanGrid grid | |
| 349 | - ) = | |
| 350 | - if grid is grid(l) then keeper_y(l,0). | |
| 351 | - | |
| 352 | - | |
| 353 | - | |
| 354 | - When the client clicks on the 'Restart Game' button, the grid is redrawn. This is done | |
| 355 | - in two steps. In the first step, the grid is redrawn without the objects and without | |
| 356 | - the keeper. In the second step the objects and the keeper are put on the grid. This | |
| 357 | - second step is performed by a sequence of calls to the JavaScript function | |
| 358 | - 'sokoban_put', which are generated by 'restart_puts'. | |
| 359 | - | |
| 360 | -define Printable_tree | |
| 361 | - restart_puts | |
| 362 | - ( | |
| 363 | - List(SokobanCell) l, | |
| 364 | - Int32 i, | |
| 365 | - Int32 j | |
| 366 | - ) = | |
| 367 | - if l is | |
| 368 | - { | |
| 369 | - [ ] then [ ], | |
| 370 | - [h . t] then if h is | |
| 371 | - { | |
| 372 | - wall then restart_puts(t,i+1,j), | |
| 373 | - free then restart_puts(t,i+1,j), | |
| 374 | - goal then restart_puts(t,i+1,j), | |
| 375 | - keeper then [ " sokoban_put(",i,",",j,",3);\n" . restart_puts(t,i+1,j)], | |
| 376 | - object then [ " sokoban_put(",i,",",j,",4);\n" . restart_puts(t,i+1,j)], | |
| 377 | - keeper_on_goal then [ " sokoban_put(",i,",",j,",6);\n" . restart_puts(t,i+1,j)], | |
| 378 | - object_on_goal then [ " sokoban_put(",i,",",j,",5);\n" . restart_puts(t,i+1,j)] | |
| 379 | - } | |
| 380 | - }. | |
| 381 | - | |
| 382 | -define Printable_tree | |
| 383 | - restart_puts | |
| 384 | - ( | |
| 385 | - List(List(SokobanCell)) l, | |
| 386 | - Int32 j | |
| 387 | - ) = | |
| 388 | - if l is | |
| 389 | - { | |
| 390 | - [ ] then [ ], | |
| 391 | - [h . t] then | |
| 392 | - [ restart_puts(h,0,j) . restart_puts(t,j+1)] | |
| 393 | - }. | |
| 394 | - | |
| 395 | -define Printable_tree | |
| 396 | - restart_puts | |
| 397 | - ( | |
| 398 | - SokobanGrid grid | |
| 399 | - ) = | |
| 400 | - if grid is grid(l) then restart_puts(l,0). | |
| 401 | - | |
| 402 | - | |
| 403 | - | |
| 404 | - Now, here is the script for the Sokoban game (a piece of parametrized JavaScript). | |
| 405 | - | |
| 406 | -define HTML_Off_Form | |
| 407 | - sokoban_script | |
| 408 | - ( | |
| 409 | - SokobanDecorationSet images, | |
| 410 | - SokobanGrid grid, | |
| 411 | - String next_url | |
| 412 | - ) = | |
| 413 | - if images is sok_set(fname_w,fname_f,fname_g,fname_k,fname_o,fname_kg,fname_og,fname_c,fname_cg) then | |
| 414 | - with gw = grid_width(grid), gh = grid_height(grid), | |
| 415 | - literal( | |
| 416 | - [ | |
| 417 | - "<script\n>", | |
| 418 | - | |
| 419 | - " var sokoban_kx = ",keeper_x(grid),";\n", // always remember where the keeper is | |
| 420 | - " var sokoban_ky = ",keeper_y(grid),";\n", | |
| 421 | - " var game_over = 0; \n", // gets value 1 when game is over. Is set to | |
| 422 | - // 0 again when restarting the game | |
| 423 | - | |
| 424 | - " function sokoban_restart() {\n", // the function which restarts the game | |
| 425 | - " var g = 0; \n", | |
| 426 | - " for(var i = 0; i < ",gw,"; i++)\n", | |
| 427 | - " for(var j = 0; j < ",gh,"; j++)\n", | |
| 428 | - " { g = sokoban_get(i,j); \n", | |
| 429 | - " if (g == 3) sokoban_put(i,j,1); else \n", | |
| 430 | - " if (g == 4) sokoban_put(i,j,1); else \n", | |
| 431 | - " if (g == 5) sokoban_put(i,j,2); else \n", | |
| 432 | - " if (g == 6) sokoban_put(i,j,2); }\n", | |
| 433 | - restart_puts(grid), | |
| 434 | - " sokoban_kx = ",keeper_x(grid),";\n", | |
| 435 | - " sokoban_ky = ",keeper_y(grid),";\n", | |
| 436 | - " game_over = 0; \n", | |
| 437 | - " }\n", | |
| 438 | - | |
| 439 | - " function sokoban_image(i) {\n", // images are numbered | |
| 440 | - " switch(i) {\n", // this function computes the | |
| 441 | - " case 0: return('",fname_w,"');\n", // file name from the number | |
| 442 | - " case 1: return('",fname_f,"');\n", | |
| 443 | - " case 2: return('",fname_g,"');\n", | |
| 444 | - " case 3: return('",fname_k,"');\n", | |
| 445 | - " case 4: return('",fname_o,"');\n", | |
| 446 | - " case 5: return('",fname_og,"');\n", | |
| 447 | - " case 6: return('",fname_kg,"');\n", | |
| 448 | - " case 7: return('",fname_c,"');\n", | |
| 449 | - " case 8: return('",fname_cg,"');\n", | |
| 450 | - " }}\n", | |
| 451 | - | |
| 452 | - " function sokoban_get(x,y) {\n", // this function gets the number of the image | |
| 453 | - // at (x,y) in the grid | |
| 454 | - " var fname = eval('document.sokoban_im_'+x+'_'+y+'.src'); \n", | |
| 455 | - " if (fname.indexOf('/",fname_w,"') >= 0) return 0;\n", | |
| 456 | - " else if (fname.indexOf('/",fname_f,"') >= 0) return 1;\n", | |
| 457 | - " else if (fname.indexOf('/",fname_g,"') >= 0) return 2;\n", | |
| 458 | - " else if (fname.indexOf('/",fname_k,"') >= 0) return 3;\n", | |
| 459 | - " else if (fname.indexOf('/",fname_o,"') >= 0) return 4;\n", | |
| 460 | - " else if (fname.indexOf('/",fname_og,"') >= 0) return 5;\n", | |
| 461 | - " else if (fname.indexOf('/",fname_kg,"') >= 0) return 6;\n", | |
| 462 | - " else if (fname.indexOf('/",fname_c,"') >= 0) return 7;\n", | |
| 463 | - " else if (fname.indexOf('/",fname_cg,"') >= 0) return 8;\n", | |
| 464 | - " }\n", | |
| 465 | - | |
| 466 | - " function sokoban_put(x,y,i) {\n", // put image number i in cell at (x,y) | |
| 467 | - " var com = 'document.sokoban_im_'+x+'_'+y+'.src=\"'+sokoban_image(i)+'\"'; \n", | |
| 468 | - " eval(com); \n", | |
| 469 | - " }\n", | |
| 470 | - | |
| 471 | - " function is_game_over() {\n", // test if game is over (no object still not on a goal) | |
| 472 | - " for(var i = 0; i < ",gw,"; i++)\n", | |
| 473 | - " for(var j = 0; j < ",gh,"; j++)\n", | |
| 474 | - " if (sokoban_get(i,j) == 4) return 0; \n", | |
| 475 | - " game_over = 1; return 1;\n", | |
| 476 | - " }\n", | |
| 477 | - | |
| 478 | - " function sokoban_put_object(x,y) {\n", // put an object in cell at (x,y) | |
| 479 | - " switch (sokoban_get(x,y)) {\n", | |
| 480 | - " case 1: sokoban_put(x,y,4); break; \n", | |
| 481 | - " case 3: sokoban_put(x,y,4); break; \n", | |
| 482 | - " case 4: sokoban_put(x,y,4); break; \n", | |
| 483 | - " case 2: sokoban_put(x,y,5); break; \n", | |
| 484 | - " case 5: sokoban_put(x,y,5); break; \n", | |
| 485 | - " case 6: sokoban_put(x,y,5); break; \n", | |
| 486 | - " }}\n", | |
| 487 | - | |
| 488 | - " function sokoban_put_keeper(x,y) {\n", // put the keeper in cell at (x,y) | |
| 489 | - " switch (sokoban_get(x,y)) {\n", | |
| 490 | - " case 1: sokoban_put(x,y,3); break; \n", | |
| 491 | - " case 3: sokoban_put(x,y,3); break; \n", | |
| 492 | - " case 4: sokoban_put(x,y,3); break; \n", | |
| 493 | - " case 2: sokoban_put(x,y,6); break; \n", | |
| 494 | - " case 5: sokoban_put(x,y,6); break; \n", | |
| 495 | - " case 6: sokoban_put(x,y,6); break; \n", | |
| 496 | - " }}\n", | |
| 497 | - | |
| 498 | - " function sokoban_remove(x,y) {\n", // remove object or keeper from cell at (x,y) | |
| 499 | - " switch (sokoban_get(x,y)) {\n", | |
| 500 | - " case 1: sokoban_put(x,y,7); break; \n", | |
| 501 | - " case 3: sokoban_put(x,y,7); break; \n", | |
| 502 | - " case 4: sokoban_put(x,y,7); break; \n", | |
| 503 | - " case 2: sokoban_put(x,y,8); break; \n", | |
| 504 | - " case 5: sokoban_put(x,y,8); break; \n", | |
| 505 | - " case 6: sokoban_put(x,y,8); break; \n", | |
| 506 | - " }}\n", | |
| 507 | - | |
| 508 | - " function sokoban_push(x,dx,y,dy) {\n", // perform a 'push' from (x,y) to (x+dx,y+dy) | |
| 509 | - " switch (sokoban_get(x+dx,y+dy)) {\n", | |
| 510 | - " case 1: \n", | |
| 511 | - " case 2: sokoban_put_object(x+dx,y+dy); \n", | |
| 512 | - " sokoban_put_keeper(x,y); \n", | |
| 513 | - " sokoban_remove(x-dx,y-dy); \n", | |
| 514 | - " sokoban_kx = x;\n", | |
| 515 | - " sokoban_ky = y;\n", | |
| 516 | - " }}\n", | |
| 517 | - | |
| 518 | - " function sokoban_move(x,dx,y,dy) {\n", // perform a move from (x,y) to (x+dx,y+dy) | |
| 519 | - " switch (sokoban_get(x,y)) {\n", | |
| 520 | - " case 1: \n", | |
| 521 | - " case 2: sokoban_put_keeper(x,y); \n", | |
| 522 | - " sokoban_remove(x-dx,y-dy); \n", | |
| 523 | - " sokoban_kx = x;\n", | |
| 524 | - " sokoban_ky = y;\n", | |
| 525 | - " }}\n", | |
| 526 | - | |
| 527 | - " function sokoban_try_push(x,y) {\n", // try to push the object at (x,y) | |
| 528 | - " if (sokoban_kx == x) {\n", | |
| 529 | - " if (sokoban_ky == y+1) sokoban_push(x,0,y,-1); \n", | |
| 530 | - " else if (sokoban_ky == y-1) sokoban_push(x,0,y,1); }\n", | |
| 531 | - " if (sokoban_ky == y) {\n", | |
| 532 | - " if (sokoban_kx == x+1) sokoban_push(x,-1,y,0); \n", | |
| 533 | - " else if (sokoban_kx == x-1) sokoban_push(x,1,y,0); }\n", | |
| 534 | - " }\n", | |
| 535 | - | |
| 536 | - " function sokoban_try_move(x,y) {\n", // try to move to position (x,y) | |
| 537 | - " if (sokoban_kx == x && sokoban_ky == y+1) sokoban_move(x,0,y,-1); \n", | |
| 538 | - " else if (sokoban_kx == x && sokoban_ky == y-1) sokoban_move(x,0,y,1); \n", | |
| 539 | - " else if (sokoban_ky == y && sokoban_kx == x+1) sokoban_move(x,-1,y,0); \n", | |
| 540 | - " else if (sokoban_ky == y && sokoban_kx == x-1) sokoban_move(x,1,y,0); \n", | |
| 541 | - " else sokoban_big_move(x,y);\n", | |
| 542 | - " }\n", | |
| 543 | - | |
| 544 | - // The next function is called when a cell is clicked. If the keeper moves the cells he | |
| 545 | - // passes through are marked with a cloud. Clouds are removed after a fraction of second. | |
| 546 | - | |
| 547 | - " function sokoban_click(x,y) {\n", | |
| 548 | - " if (game_over) return; \n", | |
| 549 | - " switch (sokoban_get(x,y)) {\n", | |
| 550 | - " case 1: \n", | |
| 551 | - " case 2: sokoban_try_move(x,y); break; \n", | |
| 552 | - " case 4: \n", | |
| 553 | - " case 5: sokoban_try_push(x,y); break; \n", | |
| 554 | - " }\n", | |
| 555 | - " if (is_game_over()) { remove_clouds(); \n", | |
| 556 | - " window.open('",next_url,"','_self'); } else\n", | |
| 557 | - " { setTimeout('remove_clouds()',700); }\n", | |
| 558 | - " }\n", | |
| 559 | - | |
| 560 | - // The next function tries to perform a 'big move', i.e. a sequence of several | |
| 561 | - // elementary moves. An array is constructed representing the grid, with | |
| 562 | - // forbidden cells (walls and objects) marked -2, and allowed cells marked -1. | |
| 563 | - // The destination cell is marked 0. Next cells at distance 1 from the cell marked | |
| 564 | - // 0 are marked 1, cells at distance one from the cells marked 1 are marked 2, and so on. | |
| 565 | - // This process stops if the cell of the keeper is found, or if it is not posible to | |
| 566 | - // mark new cells. If the cell of the keeper is found at distance k, it is enough | |
| 567 | - // to move the keeper to a cell at distance k-1, then to a cell at distance k-2, and | |
| 568 | - // so on until the distance is 0: the destination. Note that this algorithm provides | |
| 569 | - // a path of minimal length. | |
| 570 | - | |
| 571 | - " function sokoban_big_move(x,y) {\n", | |
| 572 | - " var keeper_found = 0; \n", | |
| 573 | - " var distance = 0; \n", | |
| 574 | - " var a = new Array(",gh,");\n", | |
| 575 | - " for(var j = 0; j < ",gh,"; j++) a[j] = new Array(",gw,"); \n", | |
| 576 | - " for(var j = 0; j < ",gh,"; j++)\n", | |
| 577 | - " for(var i = 0; i < ",gw,"; i++)\n", | |
| 578 | - " switch (sokoban_get(i,j)) {\n", | |
| 579 | - " case 0: a[j][i] = -2; break; \n", // -2: forbidden cell | |
| 580 | - " case 1: a[j][i] = -1; break; \n", // -1: allowed cell | |
| 581 | - " case 2: a[j][i] = -1; break; \n", // -1: allowed cell | |
| 582 | - " case 3: a[j][i] = -1; break; \n", | |
| 583 | - " case 4: a[j][i] = -2; break; \n", // -2: forbidden cell | |
| 584 | - " case 5: a[j][i] = -2; break; \n", // -2: forbidden cell | |
| 585 | - " case 6: a[j][i] = -1; break; \n", | |
| 586 | - " }\n", | |
| 587 | - " a[y][x] = 0; \n", // 0: destination cell | |
| 588 | - " while(!keeper_found) { \n", | |
| 589 | - " keeper_found = sokoban_search_keeper(a,distance); \n", | |
| 590 | - " distance++; \n", | |
| 591 | - " } \n", | |
| 592 | - " if (a[sokoban_ky][sokoban_kx] == -1) return; \n", | |
| 593 | - " for(var k = a[sokoban_ky][sokoban_kx]; k > 0; k--) {\n", | |
| 594 | - " if (sokoban_kx-1 >= 0 && a[sokoban_ky][sokoban_kx-1] == k-1) \n", | |
| 595 | - " sokoban_try_move(sokoban_kx-1,sokoban_ky); \n", | |
| 596 | - " else if (sokoban_kx+1 < ",gw," && a[sokoban_ky][sokoban_kx+1] == k-1) \n", | |
| 597 | - " sokoban_try_move(sokoban_kx+1,sokoban_ky); \n", | |
| 598 | - " else if (sokoban_ky-1 >= 0 && a[sokoban_ky-1][sokoban_kx] == k-1) \n", | |
| 599 | - " sokoban_try_move(sokoban_kx,sokoban_ky-1); \n", | |
| 600 | - " else if (sokoban_ky+1 < ",gh," && a[sokoban_ky+1][sokoban_kx] == k-1) \n", | |
| 601 | - " sokoban_try_move(sokoban_kx,sokoban_ky+1); }\n", | |
| 602 | - " }\n", | |
| 603 | - | |
| 604 | - " function sokoban_search_keeper(a,d) {\n", | |
| 605 | - " var something_done = 0; \n", | |
| 606 | - " for(var j = 0; j < ",gh,"; j++)\n", | |
| 607 | - " for(var i = 0; i < ",gw,"; i++)\n", | |
| 608 | - " if (a[j][i] == d) {\n", | |
| 609 | - " if (i == sokoban_kx && j == sokoban_ky) return 1; \n", | |
| 610 | - " if (i-1 >= 0 && a[j][i-1] == -1) { something_done = 1; a[j][i-1] = d+1; } \n", | |
| 611 | - " if (i+1 < ",gw," && a[j][i+1] == -1) { something_done = 1; a[j][i+1] = d+1; } \n", | |
| 612 | - " if (j-1 >= 0 && a[j-1][i] == -1) { something_done = 1; a[j-1][i] = d+1; } \n", | |
| 613 | - " if (j+1 < ",gh," && a[j+1][i] == -1) { something_done = 1; a[j+1][i] = d+1; } \n", | |
| 614 | - " } if (something_done) return 0; else return 1; }\n", | |
| 615 | - | |
| 616 | - " function remove_clouds() {\n", | |
| 617 | - " for(var j = 0; j < ",gh,"; j++)\n", | |
| 618 | - " for(var i = 0; i < ",gw,"; i++)\n", | |
| 619 | - " { var index = sokoban_get(i,j);\n", | |
| 620 | - " if (index == 7) sokoban_put(i,j,1); \n", | |
| 621 | - " if (index == 8) sokoban_put(i,j,2); }\n", | |
| 622 | - " }\n", | |
| 623 | - | |
| 624 | - "</script\n>" | |
| 625 | - ]). | |
| 626 | - | |
| 627 | - | |
| 628 | - | |
| 629 | - Now, we have tools to normalise grids. The function 'constant_line' constructs a line | |
| 630 | - of wall cells of a given width. | |
| 631 | - | |
| 632 | -define List(SokobanCell) | |
| 633 | - constant_line | |
| 634 | - ( | |
| 635 | - Int32 gw | |
| 636 | - ) = | |
| 637 | - if gw < 0 then alert else | |
| 638 | - if gw = 0 then [ ] else | |
| 639 | - [wall . constant_line(gw-1)]. | |
| 640 | - | |
| 641 | - | |
| 642 | - Ths function 'complete_line_2' completes a line with walls on the right, to the desired | |
| 643 | - grid width. | |
| 644 | - | |
| 645 | -define List(SokobanCell) | |
| 646 | - complete_line_2 | |
| 647 | - ( | |
| 648 | - List(SokobanCell) l, | |
| 649 | - Int32 gw | |
| 650 | - ) = | |
| 651 | - if l is | |
| 652 | - { | |
| 653 | - [ ] then constant_line(gw), | |
| 654 | - [h . t] then [h . complete_line_2(t,gw-1)] | |
| 655 | - }. | |
| 656 | - | |
| 657 | - | |
| 658 | - The function 'complete_line' completes a line by replacing leading free cells by walls | |
| 659 | - and adding walls on the right up to the desired grid width. | |
| 660 | - | |
| 661 | -define List(SokobanCell) | |
| 662 | - complete_line | |
| 663 | - ( | |
| 664 | - List(SokobanCell) l, | |
| 665 | - Int32 gw | |
| 666 | - ) = | |
| 667 | - if l is | |
| 668 | - { | |
| 669 | - [ ] then constant_line(gw), | |
| 670 | - [h . t] then if h is free | |
| 671 | - then [wall . complete_line(t,gw-1)] | |
| 672 | - else [h . complete_line_2(t,gw-1)] | |
| 673 | - }. | |
| 674 | - | |
| 675 | - | |
| 676 | - 'complete_lines' does the job for a list of lines. | |
| 677 | - | |
| 678 | -define List(List(SokobanCell)) | |
| 679 | - complete_lines | |
| 680 | - ( | |
| 681 | - List(List(SokobanCell)) l, | |
| 682 | - Int32 gw | |
| 683 | - ) = | |
| 684 | - if l is | |
| 685 | - { | |
| 686 | - [ ] then [ ], | |
| 687 | - [h . t] then | |
| 688 | - [complete_line(h,gw) . complete_lines(t,gw)] | |
| 689 | - }. | |
| 690 | - | |
| 691 | - | |
| 692 | - 'check_grid' normalizes the whole grid. | |
| 693 | - | |
| 694 | -define Maybe(SokobanGrid) | |
| 695 | - check_grid | |
| 696 | - ( | |
| 697 | - List(List(SokobanCell)) l | |
| 698 | - ) = | |
| 699 | - with gw = grid_width(l,0), | |
| 700 | - l = complete_lines(l,gw), | |
| 701 | - success(grid(l)). | |
| 702 | - | |
| 703 | - | |
| 704 | - | |
| 705 | - Now, we have some tools for reading grids from String representations. The function | |
| 706 | - 'decipher_cell' transforms a character into a cell. | |
| 707 | - | |
| 708 | -define SokobanCell | |
| 709 | - decipher_cell | |
| 710 | - ( | |
| 711 | - Int8 c | |
| 712 | - ) = | |
| 713 | - if c = ' ' then free else | |
| 714 | - if c = 'x' then goal else | |
| 715 | - if c = 'p' then keeper else | |
| 716 | - if c = 'o' then object else | |
| 717 | - if c = 'P' then keeper_on_goal else | |
| 718 | - if c = 'O' then object_on_goal else | |
| 719 | - wall. | |
| 720 | - | |
| 721 | - | |
| 722 | - We want to read grids from strings but also from files. Hence, the following type: | |
| 723 | - | |
| 724 | -type Input: | |
| 725 | - file(RAddr(Int8)), | |
| 726 | - string(String). | |
| 727 | - | |
| 728 | -variable Int32 string_index = 0. // used as an index when reading grids from strings. | |
| 729 | - | |
| 730 | - | |
| 731 | - | |
| 732 | - Getting the next character from either a file or a string. | |
| 733 | - | |
| 734 | -define Maybe(Int8) | |
| 735 | - next_char | |
| 736 | - ( | |
| 737 | - Input i | |
| 738 | - ) = | |
| 739 | - if i is | |
| 740 | - { | |
| 741 | - file(f) then *f, | |
| 742 | - string(s) then with result = nth(*string_index,s), | |
| 743 | - (string_index <- *string_index+1; result) | |
| 744 | - }. | |
| 745 | - | |
| 746 | - | |
| 747 | - Reading a complete line from a string represented grid. | |
| 748 | - | |
| 749 | -define List(SokobanCell) | |
| 750 | - load_grid_line | |
| 751 | - ( | |
| 752 | - Input i, | |
| 753 | - List(SokobanCell) so_far | |
| 754 | - ) = | |
| 755 | - if next_char(i) is | |
| 756 | - { | |
| 757 | - failure then reverse(so_far), | |
| 758 | - success(c) then | |
| 759 | - if c = '\n' | |
| 760 | - then reverse(so_far) | |
| 761 | - else load_grid_line(i,[decipher_cell(c) . so_far]) | |
| 762 | - }. | |
| 763 | - | |
| 764 | - | |
| 765 | - Reading the whole grid. | |
| 766 | - | |
| 767 | -define Maybe(SokobanGrid) | |
| 768 | - load_grid | |
| 769 | - ( | |
| 770 | - Input i, | |
| 771 | - List(List(SokobanCell)) so_far | |
| 772 | - ) = | |
| 773 | - if next_char(i) is | |
| 774 | - { | |
| 775 | - failure then check_grid(reverse(so_far)), | |
| 776 | - success(c) then | |
| 777 | - load_grid(i,[load_grid_line(i,[decipher_cell(c)]) . so_far]) | |
| 778 | - }. | |
| 779 | - | |
| 780 | - | |
| 781 | - | |
| 782 | - Reading a grid from a given file. | |
| 783 | - | |
| 784 | -public define Maybe(SokobanGrid) | |
| 785 | - load_grid_from_file | |
| 786 | - ( | |
| 787 | - String filename | |
| 788 | - ) = | |
| 789 | - if (Maybe(RAddr(Int8)))connect to file "public/"+filename is | |
| 790 | - { | |
| 791 | - failure then print(stdout,"cannot find file "+filename+"\n"); failure, | |
| 792 | - success(f) then load_grid(file(f),[]) | |
| 793 | - }. | |
| 794 | - | |
| 795 | - | |
| 796 | - Reading a grid from a given string. | |
| 797 | - | |
| 798 | -define Maybe(SokobanGrid) | |
| 799 | - load_grid_from_string_2 | |
| 800 | - ( | |
| 801 | - Input i | |
| 802 | - ) = | |
| 803 | - if next_char(i) is | |
| 804 | - { | |
| 805 | - failure then failure, | |
| 806 | - success(c) then | |
| 807 | - if c = ' ' then load_grid_from_string_2(i) else | |
| 808 | - if c = 13 then load_grid_from_string_2(i) else | |
| 809 | - load_grid(i,[]) | |
| 810 | - }. | |
| 811 | - | |
| 812 | -public define Maybe(SokobanGrid) | |
| 813 | - load_grid_from_string | |
| 814 | - ( | |
| 815 | - String original | |
| 816 | - ) = | |
| 817 | - string_index <- 0; | |
| 818 | - load_grid_from_string_2(string(original)). | |
| 819 | - | |
| 820 | - | |
| 821 | - | |
| 822 | - Now, here is the 'sokoban' as a web item. | |
| 823 | - | |
| 824 | -public define HTML_Off_Form | |
| 825 | - sokoban | |
| 826 | - ( | |
| 827 | - SokobanDecorationSet images, | |
| 828 | - SokobanGrid grid, | |
| 829 | - String next_url | |
| 830 | - ) = | |
| 831 | - sequence([ sokoban_script(images,grid,next_url), make_grid(images,grid) ]). | |
| 832 | - | |
| 833 | - | |
| 834 | - | |
| 835 | - | |
| 836 | - The following 52 grids were generated by computer by Yoshio Murase. The originals may | |
| 837 | - be found at: | |
| 838 | - | |
| 839 | - http://www.ne.jp/asahi/ai/yoshio/sokoban/auto52/auto52.htm | |
| 840 | - | |
| 841 | - Please, don't forget to cite this URL if you use these grids on a site. | |
| 842 | - | |
| 843 | - | |
| 844 | -define List(String) all_murase_grids = [ | |
| 845 | -" | |
| 846 | - wwwwww | |
| 847 | -ww x w | |
| 848 | -w O w w | |
| 849 | -w xo w | |
| 850 | -w woww | |
| 851 | -ww p w | |
| 852 | - wwwww | |
| 853 | -"," | |
| 854 | -wwwwwww | |
| 855 | -w xp w | |
| 856 | -w wxw w | |
| 857 | -w o w | |
| 858 | -wxoo ww | |
| 859 | -w www | |
| 860 | -wwww | |
| 861 | -"," | |
| 862 | - wwww | |
| 863 | -wwww pw | |
| 864 | -w Oo w | |
| 865 | -w w | |
| 866 | -ww xwww | |
| 867 | - wo w | |
| 868 | - w xw | |
| 869 | - wwww | |
| 870 | -"," | |
| 871 | -www www | |
| 872 | -wxwwwxw | |
| 873 | -w w xw | |
| 874 | -w oo pw | |
| 875 | -w o w | |
| 876 | -w w w | |
| 877 | -w wwww | |
| 878 | -wwww | |
| 879 | -"," | |
| 880 | - wwww | |
| 881 | - w pww | |
| 882 | -wwww w | |
| 883 | -wx woo w | |
| 884 | -w ww | |
| 885 | -wx oww | |
| 886 | -wwx w | |
| 887 | - wwwww | |
| 888 | -"," | |
| 889 | -wwwww | |
| 890 | -w xxwwww | |
| 891 | -w o w | |
| 892 | -w wow w | |
| 893 | -w p xo w | |
| 894 | -wwwwwwww | |
| 895 | -"," | |
| 896 | - wwwww | |
| 897 | -www xw | |
| 898 | -w o w w | |
| 899 | -w Oo w | |
| 900 | -w xwp w | |
| 901 | -w ww | |
| 902 | -w ww | |
| 903 | -wwwww | |
| 904 | -"," | |
| 905 | -wwwwwww | |
| 906 | -wx pxw | |
| 907 | -w ow ww | |
| 908 | -w w ox w | |
| 909 | -w ow w | |
| 910 | -wwww w | |
| 911 | - wwwww | |
| 912 | -"," | |
| 913 | -wwwww | |
| 914 | -wx xwww | |
| 915 | -wxwoo w | |
| 916 | -w p w | |
| 917 | -w ow w | |
| 918 | -ww ww | |
| 919 | - wwwww | |
| 920 | -"," | |
| 921 | -wwwww | |
| 922 | -wx www | |
| 923 | -w w w | |
| 924 | -w x w w | |
| 925 | -w oOo w | |
| 926 | -wwp www | |
| 927 | - w w | |
| 928 | - wwww | |
| 929 | -"," | |
| 930 | -wwwwwwww | |
| 931 | -wx x w | |
| 932 | -w w w w | |
| 933 | -wpo oxw | |
| 934 | -wwwww ow | |
| 935 | - w w | |
| 936 | - wwww | |
| 937 | -"," | |
| 938 | -wwww | |
| 939 | -w w | |
| 940 | -w wwwww | |
| 941 | -w xO w | |
| 942 | -wwo w | |
| 943 | - w wowww | |
| 944 | - wx pw | |
| 945 | - wwwww | |
| 946 | -"," | |
| 947 | - wwwww | |
| 948 | - w p www | |
| 949 | -ww x w | |
| 950 | -wx oxo w | |
| 951 | -wwow www | |
| 952 | - w w | |
| 953 | - wwwww | |
| 954 | -"," | |
| 955 | - wwwww | |
| 956 | -ww w | |
| 957 | -w ow w | |
| 958 | -w x pww | |
| 959 | -w O w | |
| 960 | -ww wo w | |
| 961 | - wx ww | |
| 962 | - wwwww | |
| 963 | -"," | |
| 964 | - wwww | |
| 965 | -ww wwww | |
| 966 | -wxxo xw | |
| 967 | -w wo o w | |
| 968 | -wp w w | |
| 969 | -wwwww w | |
| 970 | - wwww | |
| 971 | -"," | |
| 972 | - wwwwww | |
| 973 | - w xpww | |
| 974 | - w oxw | |
| 975 | - wwwOw w | |
| 976 | -ww w | |
| 977 | -w o ww | |
| 978 | -w www | |
| 979 | -wwwww | |
| 980 | -"," | |
| 981 | - wwww | |
| 982 | - wp w | |
| 983 | - w w | |
| 984 | -wwx wwww | |
| 985 | -w oox xw | |
| 986 | -w o www | |
| 987 | -www w | |
| 988 | - wwww | |
| 989 | -"," | |
| 990 | -wwwww | |
| 991 | -wx w | |
| 992 | -w w www | |
| 993 | -w Oo w | |
| 994 | -w ox w | |
| 995 | -w pwww | |
| 996 | -wwwww | |
| 997 | -"," | |
| 998 | - wwwww | |
| 999 | - w w | |
| 1000 | - w wxw | |
| 1001 | -www xw | |
| 1002 | -wp oo w | |
| 1003 | -w xo w | |
| 1004 | -wwwwwww | |
| 1005 | -"," | |
| 1006 | -wwwwww | |
| 1007 | -w pw | |
| 1008 | -w ow www | |
| 1009 | -w O o w | |
| 1010 | -w ww w | |
| 1011 | -wwx x w | |
| 1012 | - ww ww | |
| 1013 | - wwwww | |
| 1014 | -"," | |
| 1015 | -wwwwww | |
| 1016 | -w pww | |
| 1017 | -w w w | |
| 1018 | -wx o w | |
| 1019 | -w oowxw | |
| 1020 | -www xw | |
| 1021 | - wwwww | |
| 1022 | -"," | |
| 1023 | - wwww | |
| 1024 | -wwwx w | |
| 1025 | -w x www | |
| 1026 | -w oo w | |
| 1027 | -ww x opw | |
| 1028 | - wwwwwww | |
| 1029 | -"," | |
| 1030 | - wwwwww | |
| 1031 | -wwpx w | |
| 1032 | -w ooO w | |
| 1033 | -w w ww | |
| 1034 | -w w xw | |
| 1035 | -wwww w w | |
| 1036 | - w w | |
| 1037 | - wwwww | |
| 1038 | -"," | |
| 1039 | - wwww | |
| 1040 | - w w | |
| 1041 | - wwwoxw | |
| 1042 | - w x w | |
| 1043 | -www wxw | |
| 1044 | -w o o w | |
| 1045 | -w wp w | |
| 1046 | -wwwwwwww | |
| 1047 | -"," | |
| 1048 | -wwwww | |
| 1049 | -w xwww | |
| 1050 | -w oxx w | |
| 1051 | -w wwoww | |
| 1052 | -ww w w | |
| 1053 | - wo pw | |
| 1054 | - w wwww | |
| 1055 | - wwww | |
| 1056 | -"," | |
| 1057 | - wwww | |
| 1058 | - w w | |
| 1059 | - w www | |
| 1060 | -www xx w | |
| 1061 | -w ow w | |
| 1062 | -w xoo w | |
| 1063 | -wwww p w | |
| 1064 | - wwwww | |
| 1065 | -"," | |
| 1066 | -wwwww | |
| 1067 | -w www | |
| 1068 | -w w Opww | |
| 1069 | -w O w | |
| 1070 | -wwwo w | |
| 1071 | - w xw | |
| 1072 | - wwwwww | |
| 1073 | -"," | |
| 1074 | - wwwwww | |
| 1075 | -www x w | |
| 1076 | -w opwx w | |
| 1077 | -w ow ww | |
| 1078 | -w O w | |
| 1079 | -ww w w | |
| 1080 | - ww w | |
| 1081 | - wwwww | |
| 1082 | -"," | |
| 1083 | - wwww | |
| 1084 | -ww www | |
| 1085 | -w ww | |
| 1086 | -w woopw | |
| 1087 | -w x Oxw | |
| 1088 | -wwwwwwww | |
| 1089 | -"," | |
| 1090 | - wwwwwww | |
| 1091 | -wwp w | |
| 1092 | -wx w w | |
| 1093 | -w oooxww | |
| 1094 | -w xw w | |
| 1095 | -w wwww | |
| 1096 | -wwww | |
| 1097 | -"," | |
| 1098 | -wwwwwwww | |
| 1099 | -w w | |
| 1100 | -w w wwOw | |
| 1101 | -w wp o w | |
| 1102 | -wxo x w | |
| 1103 | -wwwww w | |
| 1104 | - w w | |
| 1105 | - wwww | |
| 1106 | -"," | |
| 1107 | - wwwwww | |
| 1108 | - wp ww | |
| 1109 | - wwo w | |
| 1110 | -www x w | |
| 1111 | -w o woww | |
| 1112 | -w x xw | |
| 1113 | -wwww w | |
| 1114 | - wwww | |
| 1115 | -"," | |
| 1116 | -wwwww | |
| 1117 | -w www | |
| 1118 | -w o w | |
| 1119 | -wwoo xw | |
| 1120 | - wp x w | |
| 1121 | - ww w w | |
| 1122 | - w xw | |
| 1123 | - wwwww | |
| 1124 | -"," | |
| 1125 | -wwwww | |
| 1126 | -w wwww | |
| 1127 | -w oo w | |
| 1128 | -w xwx w | |
| 1129 | -w ww ww | |
| 1130 | -w wwow | |
| 1131 | -w p xw | |
| 1132 | -wwwwwww | |
| 1133 | -"," | |
| 1134 | -wwwwww | |
| 1135 | -w x w | |
| 1136 | -w xw www | |
| 1137 | -w poo w | |
| 1138 | -w ox w | |
| 1139 | -wwwwwwww | |
| 1140 | -"," | |
| 1141 | -wwwwwwww | |
| 1142 | -w pxw w | |
| 1143 | -w xo x w | |
| 1144 | -w wo w | |
| 1145 | -w o ww | |
| 1146 | -www ww | |
| 1147 | - w w | |
| 1148 | - wwww | |
| 1149 | -"," | |
| 1150 | - wwwwwww | |
| 1151 | -ww x w | |
| 1152 | -w o opw | |
| 1153 | -wxoxwwww | |
| 1154 | -w ww | |
| 1155 | -w w | |
| 1156 | -w w | |
| 1157 | -wwww | |
| 1158 | -"," | |
| 1159 | -wwwwww | |
| 1160 | -w x w | |
| 1161 | -w wpw | |
| 1162 | -w o ww | |
| 1163 | -wwow w | |
| 1164 | -w w w | |
| 1165 | -wx O w | |
| 1166 | -wwwwwww | |
| 1167 | -"," | |
| 1168 | - wwwww | |
| 1169 | -wwww x w | |
| 1170 | -w Op x w | |
| 1171 | -w o w w | |
| 1172 | -w w o w | |
| 1173 | -w wwww | |
| 1174 | -wwwww | |
| 1175 | -"," | |
| 1176 | - wwww | |
| 1177 | -www www | |
| 1178 | -w xx oxw | |
| 1179 | -w oo pw | |
| 1180 | -wwww w | |
| 1181 | - wwwww | |
| 1182 | -"," | |
| 1183 | - wwww | |
| 1184 | - wp w | |
| 1185 | -wwwww xw | |
| 1186 | -w o o ow | |
| 1187 | -w x w | |
| 1188 | -www x w | |
| 1189 | - wwwwww | |
| 1190 | -"," | |
| 1191 | -wwwwwwww | |
| 1192 | -w w w | |
| 1193 | -w wxo ow | |
| 1194 | -w o w | |
| 1195 | -wwwwwx w | |
| 1196 | - w pw | |
| 1197 | - w xw | |
| 1198 | - wwwwww | |
| 1199 | -"," | |
| 1200 | - wwww | |
| 1201 | - wwp ww | |
| 1202 | - ww xxw | |
| 1203 | -ww owoww | |
| 1204 | -w ox w | |
| 1205 | -w w w | |
| 1206 | -w www | |
| 1207 | -wwwwww | |
| 1208 | -"," | |
| 1209 | -wwwwww | |
| 1210 | -w pw | |
| 1211 | -w oowwww | |
| 1212 | -w o x w | |
| 1213 | -ww wxw w | |
| 1214 | -wx w w | |
| 1215 | -w w | |
| 1216 | -wwwwwwww | |
| 1217 | -"," | |
| 1218 | - wwww | |
| 1219 | - w w | |
| 1220 | -wwww oww | |
| 1221 | -w pox w | |
| 1222 | -w ww w | |
| 1223 | -w ww w | |
| 1224 | -w O xw | |
| 1225 | -wwwwwwww | |
| 1226 | -"," | |
| 1227 | - wwwww | |
| 1228 | - w p w | |
| 1229 | - www w | |
| 1230 | - w o oww | |
| 1231 | -ww o w | |
| 1232 | -wx w w | |
| 1233 | -wxx w | |
| 1234 | -wwwwwww | |
| 1235 | -"," | |
| 1236 | - wwwww | |
| 1237 | -wwwwx pw | |
| 1238 | -w xo w | |
| 1239 | -w w www | |
| 1240 | -w o o xw | |
| 1241 | -wwww w | |
| 1242 | - wwwww | |
| 1243 | -"," | |
| 1244 | -wwwwwwww | |
| 1245 | -w xw pw | |
| 1246 | -w w o w | |
| 1247 | -w oxwo w | |
| 1248 | -ww x w | |
| 1249 | - w wwww | |
| 1250 | - wwww | |
| 1251 | -"," | |
| 1252 | -wwwwwww | |
| 1253 | -w w | |
| 1254 | -wxww xw | |
| 1255 | -wO opw | |
| 1256 | -w wo w | |
| 1257 | -w w w | |
| 1258 | -wwwwwww | |
| 1259 | -"," | |
| 1260 | -wwww | |
| 1261 | -wx w | |
| 1262 | -w ow | |
| 1263 | -w wwwww | |
| 1264 | -w xo p w | |
| 1265 | -w xo w w | |
| 1266 | -www w | |
| 1267 | - wwwwww | |
| 1268 | -"," | |
| 1269 | -wwwwwwww | |
| 1270 | -w w | |
| 1271 | -w wo w | |
| 1272 | -w o pwxw | |
| 1273 | -wwowx w | |
| 1274 | - w xw | |
| 1275 | - wwwwwww | |
| 1276 | -"," | |
| 1277 | -wwwwww | |
| 1278 | -w x w | |
| 1279 | -w www | |
| 1280 | -w woox w | |
| 1281 | -wx ww w | |
| 1282 | -wpo ww w | |
| 1283 | -www w | |
| 1284 | - wwwwww | |
| 1285 | -" | |
| 1286 | -]. | |
| 1287 | - | |
| 1288 | - | |
| 1289 | -public define Maybe(SokobanGrid) | |
| 1290 | - murase_grid | |
| 1291 | - ( | |
| 1292 | - Int32 n | |
| 1293 | - ) = | |
| 1294 | - if nth(n,all_murase_grids) is | |
| 1295 | - { | |
| 1296 | - failure then failure, | |
| 1297 | - success(s) then load_grid_from_string(s) | |
| 1298 | - }. | |
| 1299 | - | |
| 1300 | - | |
| 1301 | - | |
| 1302 | - Finally, we construct a simple web site, just to exemplify this Sokoban game. | |
| 1303 | - | |
| 1304 | -define String | |
| 1305 | - encipher_level | |
| 1306 | - ( | |
| 1307 | - Int32 n | |
| 1308 | - ) = | |
| 1309 | - to_ascii(sha1(n+573454)). // magic number to avoid deciperation by the client | |
| 1310 | - // You should perhaps change it. | |
| 1311 | - | |
| 1312 | - | |
| 1313 | -define Maybe(Int32) | |
| 1314 | - decipher_level | |
| 1315 | - ( | |
| 1316 | - String c, | |
| 1317 | - Int32 n | |
| 1318 | - ) = | |
| 1319 | - if n > 52 then failure else | |
| 1320 | - if encipher_level(n) = c then success(n) else decipher_level(c,n+1). | |
| 1321 | - | |
| 1322 | -define HTML_Page | |
| 1323 | - sokoban | |
| 1324 | - ( | |
| 1325 | - List(Web_arg) lwa | |
| 1326 | - ) = | |
| 1327 | - with numlevel = length(all_murase_grids), | |
| 1328 | - with level = if web_arg_value(lwa,"level") is | |
| 1329 | - { | |
| 1330 | - not_found then 0, | |
| 1331 | - found(v) then if decipher_level(v,0) is | |
| 1332 | - { | |
| 1333 | - failure then 0, | |
| 1334 | - success(n) then n | |
| 1335 | - } | |
| 1336 | - }, | |
| 1337 | - html_page("Sokoban",[], | |
| 1338 | - body([], | |
| 1339 | - center(table([],[ | |
| 1340 | - row(cell([h_center],text([font("helvetica"),size(12)], | |
| 1341 | - "Grilles de <a href=\"http://www.ne.jp/asahi/ai/yoshio/sokoban/auto52/auto52.htm\">"+ | |
| 1342 | - "Yoshio Murase</a>"))), | |
| 1343 | - row(cell([h_center],text([font("helvetica"),size(12)], | |
| 1344 | - "(engendrées par ordinateur)"))), | |
| 1345 | - row(cell([h_center],text([font("helvetica"),size(18)], | |
| 1346 | - if level < numlevel | |
| 1347 | - then "Niveau "+integer_to_string(level+1)+" / "+integer_to_string(numlevel) | |
| 1348 | - else " "))), | |
| 1349 | - row(cell([h_center], | |
| 1350 | - if murase_grid(level) is | |
| 1351 | - { | |
| 1352 | - failure then | |
| 1353 | - ( | |
| 1354 | - if level = numlevel | |
| 1355 | - then text([],"Bravo !") | |
| 1356 | - else text([],"Ce niveau n'existe pas.") | |
| 1357 | - ), | |
| 1358 | - success(g) then | |
| 1359 | - sokoban(default_decoration_set,g,"sokoban.awp?level="+encipher_level(level+1)) | |
| 1360 | - })) | |
| 1361 | - ])))). | |
| 1362 | - | |
| 1363 | - | |
| 1364 | - | |
| 1365 | - | |
| 1366 | - | |
| 1367 | - *** Interface with 'web/multihost_http_server.anubis'. | |
| 1368 | - | |
| 1369 | - | |
| 1370 | - | |
| 1371 | - | |
| 1372 | - | |
| 1373 | -read web/multihost_http_server.anubis | |
| 1374 | - | |
| 1375 | - public define (Int8,Int8,Int8,Int8) http_server_IP_address = (0,0,0,0). | |
| 1376 | - public define Int32 http_server_IP_port = 80. | |
| 1377 | - | |
| 1378 | - public define String authorization_secret = "this string should remain secret". | |
| 1379 | - | |
| 1380 | - | |
| 1381 | - public define List(Redirection) redirections = | |
| 1382 | - [ | |
| 1383 | - redirect("/","127.0.0.1","/sokoban.awp") | |
| 1384 | - ]. | |
| 1385 | - | |
| 1386 | - public define String public_directory = my_anubis_directory+"/server/public". | |
| 1387 | - public define String upload_temporary_directory = my_anubis_directory+"/server/upload_temporary". | |
| 1388 | - public define String journal_directory = my_anubis_directory+"/server/journal". | |
| 1389 | - public define String private_download_directory = my_anubis_directory+"/server/private_download". | |
| 1390 | - | |
| 1391 | - public define List(String) journal_headers = ["host","user-agent"]. | |
| 1392 | - public define List(String) journal_extensions = [".awp",".jpg",".gif"]. | |
| 1393 | - | |
| 1394 | - public define (String,String,Web_page) | |
| 1395 | - tickets_and_web_page | |
| 1396 | - ( | |
| 1397 | - Int32 ip_address, // IP address of your client | |
| 1398 | - String uri, // (redirected) URI requested by your client | |
| 1399 | - List(HTTP_header) headers, // HTTP headers sent by your client | |
| 1400 | - List(Web_arg) web_args // Web arguments sent by your client | |
| 1401 | - ) = | |
| 1402 | - ("","",sokoban(web_args)). | |
| 1403 | - | |
| 1404 | - public define One | |
| 1405 | - service_machine = unique. | |
| 1406 | - | |
| 1407 | - | |
| 1408 | - global define One | |
| 1409 | - sokoban | |
| 1410 | - ( | |
| 1411 | - List(String) args | |
| 1412 | - ) = | |
| 1413 | - http_server. | |
| 1414 | - | |
| 1415 | -global define One | |
| 1416 | - sokoban | |
| 1417 | - ( | |
| 1418 | - List(String) args | |
| 1419 | - ) = | |
| 1420 | - start_web_sites(0, | |
| 1421 | - 80, | |
| 1422 | - 443, | |
| 1423 | - "georges", | |
| 1424 | - [ | |
| 1425 | - make_web_site_description | |
| 1426 | - ( | |
| 1427 | - "127.0.0.1", | |
| 1428 | - | |
| 1429 | - ".", | |
| 1430 | - | |
| 1431 | - (ActionTicket t) |-> unique, | |
| 1432 | - | |
| 1433 | - (ActionTicket t, | |
| 1434 | - HTTP_Info h) |-> [], | |
| 1435 | - | |
| 1436 | - (ActionTicket t, | |
| 1437 | - List(Web_arg) s1, | |
| 1438 | - HTTP_Info h, | |
| 1439 | - List(Web_arg) s2, | |
| 1440 | - Bool b) |-> s1, | |
| 1441 | - | |
| 1442 | - (ActionTicket t, | |
| 1443 | - HTTP_Info h, | |
| 1444 | - List(Web_arg) l, | |
| 1445 | - Bool b) |-> [], | |
| 1446 | - | |
| 1447 | - [http_action("", | |
| 1448 | - (List(Web_arg) l) |-> true, | |
| 1449 | - (List(Web_arg) l1, List(Web_arg) l2) |-> l1)], | |
| 1450 | - | |
| 1451 | - (List(Web_arg) l) |-> sokoban(l), | |
| 1452 | - | |
| 1453 | - 3600, | |
| 1454 | - | |
| 1455 | - [redirect("/","127.0.0.1","/sokoban.awp")], | |
| 1456 | - | |
| 1457 | - [], | |
| 1458 | - [], | |
| 1459 | - "sdfksdjfhskdjfhskdfh", | |
| 1460 | - known_mime_types | |
| 1461 | - ) | |
| 1462 | - ]). | |
| 1463 | - | |
| 1464 | - | |
| 1465 | - | |
| 1466 | 0 | \ No newline at end of file |
anubis_dev/library/web/web_arg_encode.anubis
| 1 | 1 | |
| 2 | + *Project* The Anubis Project | |
| 2 | 3 | |
| 3 | - The Anubis Project. | |
| 4 | - Encoding data for web argument values. | |
| 5 | - | |
| 6 | - Copyright (c) Alain Proute' <alp@math.jusieu.fr> 2002. | |
| 7 | - All rights reserved. | |
| 8 | - | |
| 4 | + *Title* Encoding data for web argument values. | |
| 9 | 5 | |
| 6 | + *Copyright* Copyright (c) Alain Prouté 2002. | |
| 7 | + | |
| 8 | + | |
| 9 | + *Author* Alain Prouté | |
| 10 | + | |
| 10 | 11 | |
| 11 | 12 | |
| 13 | + *Overview* | |
| 12 | 14 | This file contains encoding and decoding functions which allow to put any serializable |
| 13 | 15 | datum as the value of a web argument. The datum is serialized, and the result of |
| 14 | 16 | serialization (a byte array) is encoded in such a way that it can safely be used as the | ... | ... |