Commit b0f0955fe7f6e4e87d022ff7af1175ca9b3e3b0d

Authored by Alain Prouté
1 parent 7697f425

*** empty log message ***

anubis_distrib/library/compil_all.anubis
... ... @@ -32,6 +32,7 @@ read examples/try_now.anubis
32 32 read examples/try_protect.anubis
33 33 read examples/watt.anubis //does not compile, but this is normal. See the file itself.
34 34 read examples/cryptography/sha1.anubis
  35 +read examples/cryptography/md5.anubis
35 36 read examples/graphism/diaporama.anubis
36 37 read examples/graphism/paint.anubis
37 38 read examples/graphism/paint2.anubis
... ...
anubis_distrib/library/data_base/sqlite.anubis
... ... @@ -105,11 +105,12 @@ public define Int32 -> Int32
105 105 public define List(String)
106 106 db_make_string_list
107 107 (
108   - List(String) so_far,
  108 + List(String) so_far,
109 109 One -> SQLite3Row cursor
110 110 ) =
111 111 if cursor(unique) is
112 112 {
  113 + error(_) then so_far,
113 114 no_more_row then so_far,
114 115 row(explorer) then
115 116 with data = text(explorer)(0),
... ... @@ -136,11 +137,12 @@ define Int32
136 137 One -> SQLite3Row cursor,
137 138 Int32 so_far
138 139 ) =
139   - if cursor(unique) is
140   - {
141   - no_more_row then so_far,
142   - row(_) then count_rows_private(cursor, so_far + 1)
143   - }.
  140 + if cursor(unique) is
  141 + {
  142 + error(_) then 0,
  143 + no_more_row then so_far,
  144 + row(_) then count_rows_private(cursor, so_far + 1)
  145 + }.
144 146  
145 147 /** Count the number of rows in the cursor. So this function call
146 148 * itself recursively until the cursor become empty. At each call
... ... @@ -153,11 +155,12 @@ public define Int32
153 155 (
154 156 One -> SQLite3Row cursor
155 157 ) =
156   - if cursor(unique) is
157   - {
158   - no_more_row then 0,
159   - row(_) then count_rows_private(cursor, 1)
160   - }.
  158 + if cursor(unique) is
  159 + {
  160 + error(_) then 0,
  161 + no_more_row then 0,
  162 + row(_) then count_rows_private(cursor, 1)
  163 + }.
161 164  
162 165  
163 166 *Description*
... ... @@ -268,6 +271,7 @@ public define Bool db_table_exists_test( SQLite3DataBase db, String table) =
268 271 ok(table_content) then
269 272 if table_content(unique) is
270 273 {
  274 + error(_) then false,
271 275 no_more_row then print("Table "+table+" does not exist\n"); false,
272 276 row(row1) then print("Table "+table+" exists\n"); true
273 277 }
... ... @@ -287,6 +291,7 @@ public define Bool
287 291 ok(table_content) then
288 292 if table_content(unique) is
289 293 {
  294 + error(_) then false,
290 295 no_more_row then false,
291 296 row(row1) then true
292 297 }
... ...
anubis_distrib/library/examples/cryptography/md5.anubis
... ... @@ -61,4 +61,15 @@ global define One
61 61 [_._] then do_it(args)
62 62 }.
63 63  
64   -
65 64 \ No newline at end of file
  65 +global define One
  66 + md5_string
  67 + (
  68 + List(String) args
  69 + )=
  70 + if args is
  71 + {
  72 + [] then print("no string found\n"),
  73 + [h._] then
  74 + print("MD5 hash of " + ": " +h +"\n is ["+ to_ascii(md5(h)) + "]\n")
  75 +
  76 + }.
... ...
anubis_distrib/library/predefined.anubis
... ... @@ -42,7 +42,8 @@
42 42 *** (2.3) The type scheme 'Result($E,$T)', 'error' and 'ok'.
43 43 *** (2.4) The type schemes 'List($T)', 'NonEmptyList($T)', '[ ]' and '[ . ]'.
44 44 *** (2.5) The types 'Bit' and 'Int8'.
45   - *** (2.5) The types 'RGB' and 'RGBA'.
  45 + *** (2.6) Bigits.
  46 + *** (2.7) The types 'RGB' and 'RGBA'.
46 47  
47 48 *** (3) Useful parameters and informations.
48 49 *** (3.1) Determination of the host system.
... ... @@ -344,7 +345,27 @@ public type Int8:
344 345  
345 346  
346 347  
347   - *** (2.5) The types 'RGB' and 'RGBA'.
  348 + *** (2.6) Bigits.
  349 +
  350 + We want to give an access to the words with which the microprocessor is computing. The
  351 + type 'Bigit' is primitive and represents 'machine words', i.e. arrays of 32 or 64 bits
  352 + (maybe more in the future), the kind of thing which is used in the register of the
  353 + microprocessor for arithmetical computations.
  354 +
  355 + public type Bigit:... (Actually a primitive type)
  356 +
  357 + The reason why this type is called 'Bigit' is that 'Bigit' is the contraction of 'big
  358 + digit'. Indeed, microprocessors compute (as far as arithmetic is concerned) with
  359 + machine words exactly as we compute ourself (by hand) with decimal digits.
  360 +
  361 + The operations which may be performed with Bigits are described below in this
  362 + file. Bigits are used to implement arbitrary large integers.
  363 +
  364 +
  365 +
  366 +
  367 +
  368 + *** (2.7) The types 'RGB' and 'RGBA'.
348 369  
349 370 public type RGB:
350 371 rgb(Int8 red,
... ... @@ -949,13 +970,47 @@ public define String constant_string(Int32 n,
949 970  
950 971  
951 972  
  973 + *** (4.5) Bigits.
  974 +
  975 + Remember that bigits are just 'big digits' (analogous to decimal digits). Computing
  976 + with bigits is just like computing with decimal digits, except that the numeration
  977 + basis is something like 2^32 or 2^64 instead of 10. Like the decimal digits 0, 1,...,
  978 + 9, they are not signed. The actual size of Bigits is implementation dependant. Also,
  979 + recall that decimal notations have an interpretation as bigits provided they are not
  980 + preceded by a minus sign.
952 981  
953 982  
  983 + public define (Bigit,Bit) Bigit x + Bigit y = £avm{ bigit_add }.
954 984  
  985 + This is the addition for bigits. The result is made of a bigit an a bit which is the
  986 + carry.
  987 +
955 988  
  989 + public define (Bigit,Bigit) Bigit x * Bigit y = £avm{ bigit_multiply }.
956 990  
  991 + This is the multiplication for bigits. The result is made of two bigits. For example,
  992 + with decimal digits we have 7*5 = 35, which could be written:
957 993  
958   - *** (4.4) Floating point numbers (type 'Float').
  994 + 7 * 5 = (3,5)
  995 +
  996 + (i.e. with the result given as a pair of digits). This primitive does the same, but
  997 + with bigits.
  998 +
  999 +
  1000 + public define Maybe((Bigit,Bigit)) (Bigit,Bigit) x / Bigit y = £avm{ bigit_divide }.
  1001 +
  1002 + This is the division for bigits. The result is failure if one at least of the following
  1003 + conditions is satified:
  1004 +
  1005 + - y is 0 (division by zero is forbidden)
  1006 + - assuming that x is (a,b), a is greater than or equal to y.
  1007 +
  1008 + Otherwise, the result 'success((q,r))' contains the quotient and the remainder.
  1009 +
  1010 +
  1011 +
  1012 +
  1013 + *** (4.5) Floating point numbers (type 'Float').
959 1014  
960 1015 Many 'float' operations return a datum of type 'Maybe(Float)'. This is because the
961 1016 operation may fail to give an actual number. This may be due to many reasons. Most
... ... @@ -2282,13 +2337,14 @@ public define UTime now = £avm{ now64 }.
2282 2337  
2283 2338 public type Date_and_Time:
2284 2339 date_and_time(Int32 year,
2285   - Int32 month, // from 0 = January to 11 = December
2286   - Int32 day, // from 1 to 31
2287   - Int32 hour, // from 0 to 23
2288   - Int32 minute, // from 0 to 59
2289   - Int32 second, // from 0 to 59
2290   - Int32 week_day, // from 0 = sunday to 6 = saturday
2291   - Int32 year_day). // from 0 = January 1st, to at most 365
  2340 + Int32 month, // from 0 = January to 11 = December
  2341 + Int32 day, // from 1 to 31
  2342 + Int32 hour, // from 0 to 23
  2343 + Int32 minute, // from 0 to 59
  2344 + Int32 second, // from 0 to 59
  2345 + Int32 week_day, // from 0 = sunday to 6 = saturday
  2346 + Int32 year_day, // from 0 = January 1st, to at most 365
  2347 + Bool daylight_saving_time). // if 'true' daylight saving time is applied
2292 2348  
2293 2349  
2294 2350 Time may be convert to and fro:
... ... @@ -4670,8 +4726,9 @@ public type SQLite3Datum:
4670 4726 representing an SQLite3 error code (see http://www.sqlite.org for informations).
4671 4727  
4672 4728 public type SQLite3Row:
  4729 + error(SQLite3Error),
4673 4730 no_more_row,
4674   - row(Int32 -> SQLite3Datum).
  4731 + row(Int32 -> SQLite3Datum).
4675 4732  
4676 4733 public type SQLite3Result:
4677 4734 result(Int32 returned_rows,
... ... @@ -4734,6 +4791,7 @@ define String
4734 4791 £StructPtr(SQLite3) s
4735 4792 ) =
4736 4793 £avm{ sqlite3_errmsg }.
  4794 +
4737 4795  
4738 4796 public define Result(SQLite3Error,SQLite3DataBase)
4739 4797 sqlite3_open
... ... @@ -4742,12 +4800,10 @@ public define Result(SQLite3Error,SQLite3DataBase)
4742 4800 ) =
4743 4801 with handle = £sqlite3_open(filename),
4744 4802 code = £sqlite3_errcode(handle),
4745   - msg = £sqlite3_errmsg(handle),
4746 4803 if code = 0
4747 4804 then ok(£database(handle))
4748   - else error(sqlite3(£sqlite3_errcode(handle),£sqlite3_errmsg(handle))).
  4805 + else error(sqlite3(code,£sqlite3_errmsg(handle))).
4749 4806  
4750   -
4751 4807  
4752 4808 public type £SQLite3DatumType:
4753 4809 £integer,
... ... @@ -4841,7 +4897,12 @@ define Int32
4841 4897 ) =
4842 4898 £avm{ sqlite3_column_count }.
4843 4899  
4844   -define Bool
  4900 +public type £SQLite3NextRowResult:
  4901 + no_more_row,
  4902 + row,
  4903 + error.
  4904 +
  4905 +define £SQLite3NextRowResult
4845 4906 £go_to_next_row
4846 4907 (
4847 4908 £StructPtr(SQLite3Stmt) stmt
... ... @@ -4851,6 +4912,7 @@ define Bool
4851 4912 define One -> SQLite3Row
4852 4913 £make_cursor
4853 4914 (
  4915 + £StructPtr(SQLite3) db,
4854 4916 £StructPtr(SQLite3Stmt) stmt,
4855 4917 Var(Bool) first
4856 4918 ) =
... ... @@ -4858,9 +4920,13 @@ define One -> SQLite3Row
4858 4920 (One _) |->
4859 4921 if *first
4860 4922 then (first <- false; row(£make_row(stmt,num_columns)))
4861   - else if £go_to_next_row(stmt)
4862   - then row(£make_row(stmt,num_columns))
4863   - else no_more_row.
  4923 + else if £go_to_next_row(stmt) is
  4924 + {
  4925 + no_more_row then no_more_row,
  4926 + row then row(£make_row(stmt,num_columns)),
  4927 + error then error(sqlite3(£sqlite3_errcode(db),£sqlite3_errmsg(db)))
  4928 + }.
  4929 +
4864 4930  
4865 4931 define Result(Int32,£StructPtr(SQLite3Stmt))
4866 4932 £prepare
... ... @@ -4883,15 +4949,15 @@ public define Result(SQLite3Error, One -&gt; SQLite3Row)
4883 4949 {
4884 4950 error(i) then error(sqlite3(i,£sqlite3_errmsg(db1))),
4885 4951 ok(stmt) then
4886   - if £go_to_next_row(stmt)
4887   - then
4888   - (
4889   - with first = var((Bool)true),
4890   - ok(£make_cursor(stmt,first))
4891   - )
4892   - else
4893   - ok((One _) |-> no_more_row)
4894   - }.
  4952 + if £go_to_next_row(stmt) is
  4953 + {
  4954 + no_more_row then ok((One _) |-> no_more_row),
  4955 + row then with first = var((Bool)true),
  4956 + ok(£make_cursor(db1,stmt,first)),
  4957 + error then error(sqlite3(£sqlite3_errcode(db1),£sqlite3_errmsg(db1)))
  4958 + }
  4959 + }.
  4960 +
4895 4961  
4896 4962  
4897 4963  
... ...
anubis_distrib/library/system/files.anubis
... ... @@ -37,7 +37,7 @@ define ResultCopy
37 37 copy_ok
38 38 else if read(source, read_length, 10) is
39 39 {
40   - failure then copy_error,
  40 + failure then copy_error,
41 41 success(buffer) then
42 42 if write( target , buffer) is
43 43 {
... ...
anubis_distrib/library/system/logger.anubis
... ... @@ -42,7 +42,7 @@ public define One logFileError( Logger al, String lvlStr, String msg) =
42 42 success(st) then
43 43 with currentTime = (UTime)now,
44 44 if currentTime is utime(sec,micro) then
45   - if convert_time(sec) is date_and_time(y, month, d, h, min, s, _, _) then
  45 + if convert_time(sec) is date_and_time(y, month, d, h, min, s, _, _, _) then
46 46 with finalStr = "[" +integer_to_string(y) +
47 47 zero_pad_n(2, month+1) +
48 48 zero_pad_n(2, d) + "-" +
... ... @@ -59,7 +59,7 @@ public define One logFileError( Logger al, String lvlStr, String msg) =
59 59 public define One logConsoleError( String lvlStr, String msg) =
60 60 with currentTime = (UTime)now,
61 61 if currentTime is utime(sec,micro) then
62   - if convert_time(sec) is date_and_time(y, month, d, h, min, s, _, _) then
  62 + if convert_time(sec) is date_and_time(y, month, d, h, min, s, _, _, _) then
63 63 print( "[" +integer_to_string(y) +
64 64 zero_pad_n(2, month+1) +
65 65 zero_pad_n(2, d) + "-" +
... ...
anubis_distrib/library/system/string.anubis
... ... @@ -54,7 +54,7 @@ public define String
54 54 else
55 55 s.
56 56  
57   -define List(Int8)
  57 +define (List(Int8), List(Int8))
58 58 in_word
59 59 (
60 60 List(Int8) so_far,
... ... @@ -62,10 +62,10 @@ define List(Int8)
62 62 ) =
63 63 if current is
64 64 {
65   - [] then so_far,
  65 + [] then (so_far, []),
66 66 [h . t] then
67 67 if h = 32 then
68   - so_far
  68 + (so_far, t)
69 69 else
70 70 in_word([h . so_far], t)
71 71 }.
... ... @@ -77,12 +77,12 @@ define Maybe(List(Int8))
77 77 ) =
78 78 if current is
79 79 {
80   - [] then failure,
81   - [h . t] then
  80 + [] then failure,
  81 + [h . t] then
82 82 if h = 32 then //we skip 32 ASCII code is space
83 83 search_first_char(t)
84 84 else
85   - success(in_word([h], t))
  85 + if in_word([h], t) is (word, _) then success(word)
86 86 }.
87 87  
88 88 public define Maybe(String)
... ... @@ -109,7 +109,41 @@ public define Maybe(String)
109 109 failure then failure,
110 110 success(s) then first_word(s)
111 111 }.
112   -
  112 +
  113 +define Maybe(List(String))
  114 + list_word
  115 + (
  116 + List(Int8) input,
  117 + List(String) string_so_far
  118 + ) =
  119 + if input is
  120 + {
  121 + [] then //we have touch the end of int8 list
  122 + if string_so_far is
  123 + {
  124 + [] then failure, //if the list of string is empty we have failed to find out words
  125 + [_._] then success(reverse(string_so_far))
  126 + },
  127 + [ h . t ] then
  128 + if h = 32 then
  129 + list_word(t, string_so_far)
  130 + else
  131 + if in_word([h], t) is (word, so_far) then
  132 + list_word(so_far, [implode(reverse(word)). string_so_far])
  133 + }.
  134 +
  135 +public define Maybe(List(String))
  136 + list_word
  137 + (
  138 + String input,
  139 + Int32 start
  140 + )=
  141 + if sub_string(input, start, length(input) - start) is
  142 + {
  143 + failure then failure,
  144 + success(s) then list_word(explode(s),[])
  145 + }.
  146 +
113 147 /**
114 148 * convert the content of Int32 into string
115 149 * for example if the content of that integer is
... ...
anubis_distrib/library/tools/basis.anubis
... ... @@ -1875,6 +1875,7 @@ public define Int32 minute(Int32 t) = minute(convert_time(t)).
1875 1875 public define Int32 second(Int32 t) = second(convert_time(t)).
1876 1876 public define Int32 week_day(Int32 t) = week_day(convert_time(t)).
1877 1877 public define Int32 year_day(Int32 t) = year_day(convert_time(t)).
  1878 +public define Bool daylight_saving_time(Int32 t) = daylight_saving_time(convert_time(t)).
1878 1879  
1879 1880 public define Int32
1880 1881 date_and_time
... ... @@ -1884,9 +1885,10 @@ public define Int32
1884 1885 Int32 d,
1885 1886 Int32 h,
1886 1887 Int32 mi,
1887   - Int32 s
  1888 + Int32 s,
  1889 + Bool dst
1888 1890 ) =
1889   - convert_time(date_and_time(y,mo,d,h,mi,s,0,0)).
  1891 + convert_time(date_and_time(y,mo,d,h,mi,s,0,0,dst)).
1890 1892  
1891 1893  
1892 1894 *** (11.2) Calculations with UTime.
... ...
anubis_distrib/library/web/file_manager.anubis
... ... @@ -163,7 +163,7 @@ define String
163 163 (
164 164 Int32 t
165 165 ) =
166   - if convert_time(t) is date_and_time(year,month,day,hour,min,sec,wday,yday) then
  166 + if convert_time(t) is date_and_time(year,month,day,hour,min,sec,wday,yday,dst) then
167 167 integer_to_string(year)+" "+format_month(month)+" "+zero_pad_2(day)+" "+
168 168 zero_pad_2(hour)+":"+zero_pad_2(min)+":"+zero_pad_2(sec).
169 169  
... ...
anubis_distrib/library/web/http_server.anubis
... ... @@ -737,7 +737,7 @@ define ServerDescription
737 737 define String
738 738 make_current_journal_file_name
739 739 =
740   - if convert_time(now) is date_and_time(y,m,d,h,_,_,_,_) then
  740 + if convert_time(now) is date_and_time(y,m,d,h,_,_,_,_,_) then
741 741 integer_to_string(y)+"_"+
742 742 zero_pad_2(m)+"_"+
743 743 zero_pad_2(d)+"_"+
... ...
anubis_distrib/library/web/multihost_http_server.anubis
1   -
  1 +
2 2 *Project* The Anubis Project
3 3  
4 4 *Title* A Multi Host HTTP/HTTPS Server
... ... @@ -897,7 +897,7 @@ define String
897 897 define String
898 898 make_current_journal_file_name
899 899 =
900   - if convert_time(now) is date_and_time(y,m,d,h,_,_,_,_) then
  900 + if convert_time(now) is date_and_time(y,m,d,h,_,_,_,_,_) then
901 901 integer_to_string(y)+"_"+
902 902 zero_pad_2(m)+"_"+
903 903 zero_pad_2(d)+"_"+
... ... @@ -3678,4 +3678,4 @@ global define One
3678 3678  
3679 3679  
3680 3680  
3681   -
3682 3681 \ No newline at end of file
  3682 +
... ...
anubis_distrib/linux_install/bin/anbexec
No preview for this file type
anubis_distrib/linux_install/bin/anubis
No preview for this file type
anubis_distrib/linux_install/prepare_package/Makefile
1 1  
2 2 minnum = 7
3   -relnum = 11
4   -bldnum = 0
  3 +relnum = 12
  4 +bldnum = 2
5 5  
6 6 package:
7 7 cd ../.. && tar --exclude=CVS -chzf anubis_files.tar.gz library en fr server_certs trusted_certs
... ...