From f2d3a29762480015be4da4dcc1f57e9eee1c1614 Mon Sep 17 00:00:00 2001 From: C?dric RICARD Date: Sat, 9 Mar 2013 00:53:59 +0100 Subject: [PATCH] folder layout --- CXM_errors.anubis | 41 +++++++++++++++++++++++++++++++++++++++++ CXM_message_constants.anubis | 153 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ calexium_lib/CXM_errors.anubis | 41 ----------------------------------------- calexium_lib/CXM_message_constants.anubis | 153 --------------------------------------------------------------------------------------------------------------------------------------------------------- calexium_lib/database/alter_table.anubis | 306 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ calexium_lib/database/db_types.anubis | 76 ---------------------------------------------------------------------------- calexium_lib/database/db_utils.anubis | 319 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- calexium_lib/database/migration.anubis | 211 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- calexium_lib/database/migration_common.anubis | 195 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- calexium_lib/database/migration_common_sqlite3.anubis | 192 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ calexium_lib/database/migration_sqlite3.anubis | 204 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ calexium_lib/database/settings.anubis | 93 --------------------------------------------------------------------------------------------- calexium_lib/database/settings_sqlite3.anubis | 132 ------------------------------------------------------------------------------------------------------------------------------------ calexium_lib/database/sqlite_foreign_key.anubis | 143 ----------------------------------------------------------------------------------------------------------------------------------------------- calexium_lib/mail/authentication.anubis | 98 -------------------------------------------------------------------------------------------------- calexium_lib/mail/lexers/enhanced_status.anubis | 355 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- calexium_lib/mail/send_mail.anubis | 204 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ calexium_lib/mail/smtp_client.anubis | 697 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- calexium_lib/mail/smtp_server_extensions.anubis | 90 ------------------------------------------------------------------------------------------ calexium_lib/net_services/CXM_generic_client.anubis | 277 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- calexium_lib/net_services/CXM_generic_protocol.anubis | 169 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- calexium_lib/net_services/CXM_net_services.anubis | 190 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- calexium_lib/net_services_protocols/ftp_client.anubis | 181 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- calexium_lib/net_services_protocols/logger_service.anubis | 397 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- calexium_lib/net_services_protocols/pkg_updater_protocol.anubis | 12 ------------ calexium_lib/web/CXM_common.anubis | 215 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- calexium_lib/web/CXM_cookies.anubis | 691 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- calexium_lib/web/CXM_dojo.anubis | 832 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- calexium_lib/web/CXM_generic_form.anubis | 471 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- calexium_lib/web/CXM_generic_login.anubis | 116 -------------------------------------------------------------------------------------------------------------------- calexium_lib/web/CXM_generic_table.anubis | 786 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ calexium_lib/web/CXM_html.anubis | 2395 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- calexium_lib/web/CXM_http_get_common.anubis | 305 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- calexium_lib/web/CXM_jquery.anubis | 36 ------------------------------------ calexium_lib/web/CXM_json.anubis | 169 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- calexium_lib/web/CXM_making_a_web_site.anubis | 4521 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- calexium_lib/web/CXM_mime.anubis | 70 ---------------------------------------------------------------------- calexium_lib/web/CXM_multihost_http_server.anubis | 3994 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- calexium_lib/web/CXM_urllib.anubis | 154 ---------------------------------------------------------------------------------------------------------------------------------------------------------- calexium_lib/web/CXM_web_arg_encode.anubis | 349 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- calexium_lib/web/CXM_web_dump.anubis | 70 ---------------------------------------------------------------------- calexium_lib/web/counter.anubis | 113 ----------------------------------------------------------------------------------------------------------------- database/alter_table.anubis | 306 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ database/db_types.anubis | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ database/db_utils.anubis | 319 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ database/migration.anubis | 211 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ database/migration_common.anubis | 195 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ database/migration_common_sqlite3.anubis | 192 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ database/migration_sqlite3.anubis | 204 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ database/settings.anubis | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ database/settings_sqlite3.anubis | 132 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ database/sqlite_foreign_key.anubis | 143 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ mail/authentication.anubis | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ mail/lexers/enhanced_status.anubis | 355 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ mail/send_mail.anubis | 204 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ mail/smtp_client.anubis | 697 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ mail/smtp_server_extensions.anubis | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ net_services/CXM_generic_client.anubis | 277 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ net_services/CXM_generic_protocol.anubis | 169 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ net_services/CXM_net_services.anubis | 190 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ net_services_protocols/ftp_client.anubis | 181 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ net_services_protocols/logger_service.anubis | 397 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ net_services_protocols/pkg_updater_protocol.anubis | 12 ++++++++++++ web/CXM_common.anubis | 215 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ web/CXM_cookies.anubis | 691 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ web/CXM_dojo.anubis | 832 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ web/CXM_generic_form.anubis | 471 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ web/CXM_generic_login.anubis | 116 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ web/CXM_generic_table.anubis | 786 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ web/CXM_html.anubis | 2395 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ web/CXM_http_get_common.anubis | 305 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ web/CXM_jquery.anubis | 36 ++++++++++++++++++++++++++++++++++++ web/CXM_json.anubis | 169 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ web/CXM_making_a_web_site.anubis | 4521 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ web/CXM_mime.anubis | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ web/CXM_multihost_http_server.anubis | 3994 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ web/CXM_urllib.anubis | 154 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ web/CXM_web_arg_encode.anubis | 349 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ web/CXM_web_dump.anubis | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ web/counter.anubis | 113 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 80 files changed, 20022 insertions(+), 20022 deletions(-) create mode 100644 CXM_errors.anubis create mode 100644 CXM_message_constants.anubis delete mode 100644 calexium_lib/CXM_errors.anubis delete mode 100644 calexium_lib/CXM_message_constants.anubis delete mode 100644 calexium_lib/database/alter_table.anubis delete mode 100644 calexium_lib/database/db_types.anubis delete mode 100644 calexium_lib/database/db_utils.anubis delete mode 100644 calexium_lib/database/migration.anubis delete mode 100644 calexium_lib/database/migration_common.anubis delete mode 100644 calexium_lib/database/migration_common_sqlite3.anubis delete mode 100644 calexium_lib/database/migration_sqlite3.anubis delete mode 100644 calexium_lib/database/settings.anubis delete mode 100644 calexium_lib/database/settings_sqlite3.anubis delete mode 100644 calexium_lib/database/sqlite_foreign_key.anubis delete mode 100644 calexium_lib/mail/authentication.anubis delete mode 100644 calexium_lib/mail/lexers/enhanced_status.anubis delete mode 100644 calexium_lib/mail/send_mail.anubis delete mode 100644 calexium_lib/mail/smtp_client.anubis delete mode 100644 calexium_lib/mail/smtp_server_extensions.anubis delete mode 100644 calexium_lib/net_services/CXM_generic_client.anubis delete mode 100644 calexium_lib/net_services/CXM_generic_protocol.anubis delete mode 100644 calexium_lib/net_services/CXM_net_services.anubis delete mode 100644 calexium_lib/net_services_protocols/ftp_client.anubis delete mode 100644 calexium_lib/net_services_protocols/logger_service.anubis delete mode 100644 calexium_lib/net_services_protocols/pkg_updater_protocol.anubis delete mode 100644 calexium_lib/web/CXM_common.anubis delete mode 100644 calexium_lib/web/CXM_cookies.anubis delete mode 100644 calexium_lib/web/CXM_dojo.anubis delete mode 100644 calexium_lib/web/CXM_generic_form.anubis delete mode 100644 calexium_lib/web/CXM_generic_login.anubis delete mode 100644 calexium_lib/web/CXM_generic_table.anubis delete mode 100644 calexium_lib/web/CXM_html.anubis delete mode 100644 calexium_lib/web/CXM_http_get_common.anubis delete mode 100644 calexium_lib/web/CXM_jquery.anubis delete mode 100644 calexium_lib/web/CXM_json.anubis delete mode 100644 calexium_lib/web/CXM_making_a_web_site.anubis delete mode 100644 calexium_lib/web/CXM_mime.anubis delete mode 100644 calexium_lib/web/CXM_multihost_http_server.anubis delete mode 100644 calexium_lib/web/CXM_urllib.anubis delete mode 100644 calexium_lib/web/CXM_web_arg_encode.anubis delete mode 100644 calexium_lib/web/CXM_web_dump.anubis delete mode 100644 calexium_lib/web/counter.anubis create mode 100644 database/alter_table.anubis create mode 100644 database/db_types.anubis create mode 100644 database/db_utils.anubis create mode 100644 database/migration.anubis create mode 100644 database/migration_common.anubis create mode 100644 database/migration_common_sqlite3.anubis create mode 100644 database/migration_sqlite3.anubis create mode 100644 database/settings.anubis create mode 100644 database/settings_sqlite3.anubis create mode 100644 database/sqlite_foreign_key.anubis create mode 100644 mail/authentication.anubis create mode 100644 mail/lexers/enhanced_status.anubis create mode 100644 mail/send_mail.anubis create mode 100644 mail/smtp_client.anubis create mode 100644 mail/smtp_server_extensions.anubis create mode 100644 net_services/CXM_generic_client.anubis create mode 100644 net_services/CXM_generic_protocol.anubis create mode 100644 net_services/CXM_net_services.anubis create mode 100644 net_services_protocols/ftp_client.anubis create mode 100644 net_services_protocols/logger_service.anubis create mode 100644 net_services_protocols/pkg_updater_protocol.anubis create mode 100644 web/CXM_common.anubis create mode 100644 web/CXM_cookies.anubis create mode 100644 web/CXM_dojo.anubis create mode 100644 web/CXM_generic_form.anubis create mode 100644 web/CXM_generic_login.anubis create mode 100644 web/CXM_generic_table.anubis create mode 100644 web/CXM_html.anubis create mode 100644 web/CXM_http_get_common.anubis create mode 100644 web/CXM_jquery.anubis create mode 100644 web/CXM_json.anubis create mode 100644 web/CXM_making_a_web_site.anubis create mode 100644 web/CXM_mime.anubis create mode 100644 web/CXM_multihost_http_server.anubis create mode 100644 web/CXM_urllib.anubis create mode 100644 web/CXM_web_arg_encode.anubis create mode 100644 web/CXM_web_dump.anubis create mode 100644 web/counter.anubis diff --git a/CXM_errors.anubis b/CXM_errors.anubis new file mode 100644 index 0000000..f9ea1ee --- /dev/null +++ b/CXM_errors.anubis @@ -0,0 +1,41 @@ +/* + * Created by PyramIDE. + * User: ricard + * Date: 16/09/2007 + * Time: 21:10 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ + +public type GeneralError: + ok, + unknown(Word32 val), + bad_type, + bad_value, + bad_parameters, + no_init, + unknown_command, + wrong_authentification, // Wrong login or password + access_denied, // login ok but no suffisiant right to access to this area. Can be use with wrong authentification too... + io_error, // general error on reading or writing from/to IO (file, socket, etc...) + cant_start_process. // A execute to an external process has failed + +public define Word32 + to_Word32 + ( + GeneralError e + ) = + if e is + { + ok then 0, + unknown(val) then val, + bad_type then 0x1, + bad_value then 0x2, + bad_parameters then 0x3, + no_init then 0x4, + unknown_command then 0x5, + wrong_authentification then 0x6, + access_denied then 0x7, + io_error then 0x8, + cant_start_process then 0x9, + }. diff --git a/CXM_message_constants.anubis b/CXM_message_constants.anubis new file mode 100644 index 0000000..5bc2359 --- /dev/null +++ b/CXM_message_constants.anubis @@ -0,0 +1,153 @@ +/* + * + * User: David RENE + * Date: 07/04/2007 + * Time: 16:06 + * (c) Calexium + * + */ + +public define Word32 _NO_NAME_MSG = 0x00000000. + +// **************** MAILBOX PROTOCOL *************** + +public define Word32 _C_SCAN_FOR_BOXES = 0x33770001. // Ask Boxes to publish their informations +public define Word32 _C_PUBLISH_BOX_STATUS = 0x33770002. // Used by Boxes to publish their informations +public define Word32 _C_SHUTDOWN_BOX = 0x33770003. // Used to ask a box to shutdown +public define Word32 _CXM_SET_BOX_NETWORK_PARAMS = 0x33770004. // Define network configuration of boxes +public define Word32 _CXM_RESET_ADMIN_PWD = 0x33770005. // Ask the MailFountain to reset the admin pwd. +public define Word32 _CXM_FULL_RESET = 0x33770006. // Ask the MailFountain to proceed to a full reset of its data. After that, the MailFountain is totally empty (mail, config, domain, logs, etc...) +public define Word32 _CXM_FORCE_PUBLISH_MF_CONFIG = 0x33770007. // Ask the MailFountain to proceed a Config publishing to DomainManager + + // **************** PACKAGE BUILDER *************** + +public define Word32 _CXM_PKG_MSG_BASIS = 0x33770400. // +public define Word32 _CXM_PKG_CONTAINER = 0x33770401. +public define Word32 _CXM_PKG_HEADER_PART = 0x33770402. // Header Message for Script +public define Word32 _CXM_PKG_SCRIPT_PART = 0x33770403. // Main Message for Script +public define Word32 _CXM_PKG_S_ADD_FILE = 0x33770404. // script action to add file in the destination +public define Word32 _CXM_PKG_S_RUN = 0x33770405. // script action to run a command +public define Word32 _CXM_PKG_INDEX_PART = 0x33770440. // ID of package Index part +public define Word32 _CXM_PKG_IDX_ENTRY = 0x33770441. // Index entry information + + // **************** UPDATE SERVICE *************** + +public define Word32 _CXM_UPDATE_SERVICE_MSG_BASIS = 0x33770800. // +public define Word32 _CXM_UPD_SERVICE_ID = 0x33770801. +public define Word32 _CXM_UPD_HAS_UPDATE = 0x33770802. // +public define Word32 _CXM_UPD_LIST_CLASS_FILES = 0x33770803. // List the files contained in the class path +public define Word32 _CXM_UPD_GET_CLASS_FILE = 0x33770804. // get the file contained in the class path. Return info for download + + // **************** SERVICE NEGOCIATION *************** + +public define Word32 _CXM_SERVICE_NEGOCIATION_BASIS = 0x33770C00. // +public define Word32 _CXM_REQUEST_FOR_SERVICE = 0x33770C01. // +public define Word32 _CXM_LOGIN = 0x33770C02. // + + // **************** GENERIC PROTOCOL *************** + +public define Word32 _CXM_GENERIC_PROTOCOL_BASIS = 0x33771000. // +public define Word32 _CXM_ACK = 0x33771001. // +public define Word32 _CXM_ACK_RESULT_MSG = 0x33771002. // + + // **************** FTP SERVICE *************** + +public define Word32 _CXM_FTP_SERVICE_MSG_BASIS = 0x33771400. // +public define Word32 _CXM_FTP_SERVICE_ID = 0x33771401. +public define Word32 _CXM_FTP_GET_FILE = 0x33771402. +public define Word32 _CXM_FTP_START_TRANSFERT = 0x33771403. +public define Word32 _CXM_FTP_DATA = 0x33771404. + + // ************** LOGGER SERVICE ************** + +public define Word32 _CXM_LOGGER_SERVICE_MSG_BASIS = 0x33771800. // +public define Word32 _CXM_LOGGER_SERVICE_ID = 0x33771801. +public define Word32 _CXM_LOGGER_LOG = 0x33771802. + + // ************** DOMAIN SERVICE ************** + +// MF <-> DomainManager +public define Word32 _CXM_DOMAIN_SERVICE_MSG_BASIS = 0x33771C00. // +public define Word32 _CXM_DOMAIN_SERVICE_ID = 0x33771C01. +public define Word32 _CXM_DOMAIN_PUBLISH_MF_CONFIG = 0x33771C02. +public define Word32 _CXM_DOMAIN_GET_NAME = 0x33771C03. +public define Word32 _CXM_DOMAIN_GET_MY_IP = 0x33771C04. +public define Word32 _CXM_DOMAIN_PUBLISH_MY_IP = 0x33771C05. +public define Word32 _CXM_DOMAIN_PUBLISH_DYN_TEST = 0x33771C06. +public define Word32 _CXM_DOMAIN_GET_STATUS = 0x33771C07. +public define Word32 _CXM_DOMAIN_GET_DOMAIN_INFO = 0x33771C08. +public define Word32 _CXM_DOMAIN_CRITICAL_ALERT = 0x33771C09. +public define Word32 _CXM_DOMAIN_COMMAND_RESULT = 0x33771C0A. + + +// DomainManager <-> Gandi +public define Word32 _CXM_GANDI_SERVICE_ID = 0x33771D00. +public define Word32 _CXM_GANDI_CHECK_AVAILABILITY = 0x33771D01. // 'NAME' (String): Base names (without extension) of the wanted domains + // --> CXM_ACK with 'DOMAINS' (String): Array of avaiblable domains +public define Word32 _CXM_GANDI_CREATE_CONTACT = 0x33771D02. // 'CLASS' (String): + // 'FIRSTNAME', 'LASTNAME', 'ADDRESS', 'ZIPCODE', 'CITY', 'COUNTRY', 'PHONE', 'EMAIL' (String) + // --> CXM_ACK with 'CONTACT_HANDLE' (String): Created handle for this contact +public define Word32 _CXM_GANDI_CREATE_DOMAIN = 0x33771D03. // 'DOMAIN' (String): Domain full name + // 'OWNER' (String): Owner handle + // --> CXM_ACK with 'DOMAIN_HANDLE' (String): Created handle for this domain + // ************** MF INSTALLER SERVICE ************** + +public define Word32 _CXM_INSTALLER_SERVICE_MSG_BASIS= 0x33772000. +public define Word32 _CXM_INSTALLER_SERVICE_ID = 0x33772001. +public define Word32 _CXM_INSTALLER_REGISTER_APP_ID = 0x33772002. +public define Word32 _CXM_INSTALLER_GET_NEW_SERIALS = 0x33772003. +public define Word32 _CXM_INSTALLER_CONFIRM_SERIALS_PUBLICATION = 0x33772004. +public define Word32 _CXM_INSTALLER_GET_MODELS = 0x33772005. // returns the MF models list + +// ************************************************* +// ************* MF API ************* + +// ************* ACCOUNTS SERVICE ************* + +public define Word32 _CXM_ACCOUNT_SERVICE_MSG_BASIS = 0x33772100. + +// ************* MAILINGS SERVICE ************* + +public define Word32 _CXM_MAILING_SERVICE_MSG_BASIS = 0x33772200. +public define Word32 _CXM_MAILING_SERVICE_ID = 0x33772200. // same as MSG_BASIS + +public define Word32 _CXM_MAILING_CREATE_CONTACT = 0x33772201. +public define Word32 _CXM_MAILING_UPDATE_CONTACT = 0x33772202. +public define Word32 _CXM_MAILING_DELETE_CONTACT = 0x33772203. + +public define Word32 _CXM_MAILING_CREATE_MAILING = 0x33772211. +public define Word32 _CXM_MAILING_UPDATE_MAILING = 0x33772212. +public define Word32 _CXM_MAILING_DELETE_MAILING = 0x33772213. + +public define Word32 _CXM_MAILING_ADD_CONTACT_TO_MAILING = 0x33772221. +public define Word32 _CXM_MAILING_REMOVE_CONTACT_FROM_MAILING = 0x33772222. + + +// ************* DIRECTORY SERVICE ************* + +public define Word32 _CXM_DIRECTORY_SERVICE_MSG_BASIS = 0x33772300. + +// ************* BACKUP SERVICE ************* + +public define Word32 _CXM_BACKUP_SERVICE_MSG_BASIS = 0x33772400. +public define Word32 _CXM_BACKUP_SERVICE_ID = 0x33772401. +public define Word32 _CXM_BACKUP_GET_STATUS = 0x33772402. /// Get backup status for a given MF (can subscribe, subscribed, subscription end date...) +public define Word32 _CXM_BACKUP_STARTING_BACKUP = 0x33772403. /// Notify BackupService that backup process is starting +public define Word32 _CXM_BACKUP_FINISHING_BACKUP = 0x33772404. /// Notify BackupService that backup process is finishing +public define Word32 _CXM_BACKUP_STARTING_RESTORE = 0x33772405. /// Notify BackupService that restore process is starting +public define Word32 _CXM_BACKUP_FINISHING_RESTORE = 0x33772406. /// Notify BackupService that restore process is finishing + +// ************* STATISTICS SERVICE ************* + +public define Word32 _CXM_STATS_SERVICE_MSG_BASIS = 0x33772500. + +// ************* SUPERVISER SERVICE ************* + +public define Word32 _CXM_SUPERVISER_SERVICE_MSG_BASIS = 0x33772600. +public define Word32 _CXM_SUPERVISER_SERVICE_ID = 0x33772600. +public define Word32 _CXM_SUPERVISER_GET_STATUS = 0x33772601. + +// ************************************************* +// ************* KERO_PBX API ************* + +public define Word32 _CXM_KERO_PBX_MSG_BASIS = 0x33780000. // Ask Boxes to publish their informations diff --git a/calexium_lib/CXM_errors.anubis b/calexium_lib/CXM_errors.anubis deleted file mode 100644 index f9ea1ee..0000000 --- a/calexium_lib/CXM_errors.anubis +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Created by PyramIDE. - * User: ricard - * Date: 16/09/2007 - * Time: 21:10 - * - * To change this template use Tools | Options | Coding | Edit Standard Headers. - */ - -public type GeneralError: - ok, - unknown(Word32 val), - bad_type, - bad_value, - bad_parameters, - no_init, - unknown_command, - wrong_authentification, // Wrong login or password - access_denied, // login ok but no suffisiant right to access to this area. Can be use with wrong authentification too... - io_error, // general error on reading or writing from/to IO (file, socket, etc...) - cant_start_process. // A execute to an external process has failed - -public define Word32 - to_Word32 - ( - GeneralError e - ) = - if e is - { - ok then 0, - unknown(val) then val, - bad_type then 0x1, - bad_value then 0x2, - bad_parameters then 0x3, - no_init then 0x4, - unknown_command then 0x5, - wrong_authentification then 0x6, - access_denied then 0x7, - io_error then 0x8, - cant_start_process then 0x9, - }. diff --git a/calexium_lib/CXM_message_constants.anubis b/calexium_lib/CXM_message_constants.anubis deleted file mode 100644 index 5bc2359..0000000 --- a/calexium_lib/CXM_message_constants.anubis +++ /dev/null @@ -1,153 +0,0 @@ -/* - * - * User: David RENE - * Date: 07/04/2007 - * Time: 16:06 - * (c) Calexium - * - */ - -public define Word32 _NO_NAME_MSG = 0x00000000. - -// **************** MAILBOX PROTOCOL *************** - -public define Word32 _C_SCAN_FOR_BOXES = 0x33770001. // Ask Boxes to publish their informations -public define Word32 _C_PUBLISH_BOX_STATUS = 0x33770002. // Used by Boxes to publish their informations -public define Word32 _C_SHUTDOWN_BOX = 0x33770003. // Used to ask a box to shutdown -public define Word32 _CXM_SET_BOX_NETWORK_PARAMS = 0x33770004. // Define network configuration of boxes -public define Word32 _CXM_RESET_ADMIN_PWD = 0x33770005. // Ask the MailFountain to reset the admin pwd. -public define Word32 _CXM_FULL_RESET = 0x33770006. // Ask the MailFountain to proceed to a full reset of its data. After that, the MailFountain is totally empty (mail, config, domain, logs, etc...) -public define Word32 _CXM_FORCE_PUBLISH_MF_CONFIG = 0x33770007. // Ask the MailFountain to proceed a Config publishing to DomainManager - - // **************** PACKAGE BUILDER *************** - -public define Word32 _CXM_PKG_MSG_BASIS = 0x33770400. // -public define Word32 _CXM_PKG_CONTAINER = 0x33770401. -public define Word32 _CXM_PKG_HEADER_PART = 0x33770402. // Header Message for Script -public define Word32 _CXM_PKG_SCRIPT_PART = 0x33770403. // Main Message for Script -public define Word32 _CXM_PKG_S_ADD_FILE = 0x33770404. // script action to add file in the destination -public define Word32 _CXM_PKG_S_RUN = 0x33770405. // script action to run a command -public define Word32 _CXM_PKG_INDEX_PART = 0x33770440. // ID of package Index part -public define Word32 _CXM_PKG_IDX_ENTRY = 0x33770441. // Index entry information - - // **************** UPDATE SERVICE *************** - -public define Word32 _CXM_UPDATE_SERVICE_MSG_BASIS = 0x33770800. // -public define Word32 _CXM_UPD_SERVICE_ID = 0x33770801. -public define Word32 _CXM_UPD_HAS_UPDATE = 0x33770802. // -public define Word32 _CXM_UPD_LIST_CLASS_FILES = 0x33770803. // List the files contained in the class path -public define Word32 _CXM_UPD_GET_CLASS_FILE = 0x33770804. // get the file contained in the class path. Return info for download - - // **************** SERVICE NEGOCIATION *************** - -public define Word32 _CXM_SERVICE_NEGOCIATION_BASIS = 0x33770C00. // -public define Word32 _CXM_REQUEST_FOR_SERVICE = 0x33770C01. // -public define Word32 _CXM_LOGIN = 0x33770C02. // - - // **************** GENERIC PROTOCOL *************** - -public define Word32 _CXM_GENERIC_PROTOCOL_BASIS = 0x33771000. // -public define Word32 _CXM_ACK = 0x33771001. // -public define Word32 _CXM_ACK_RESULT_MSG = 0x33771002. // - - // **************** FTP SERVICE *************** - -public define Word32 _CXM_FTP_SERVICE_MSG_BASIS = 0x33771400. // -public define Word32 _CXM_FTP_SERVICE_ID = 0x33771401. -public define Word32 _CXM_FTP_GET_FILE = 0x33771402. -public define Word32 _CXM_FTP_START_TRANSFERT = 0x33771403. -public define Word32 _CXM_FTP_DATA = 0x33771404. - - // ************** LOGGER SERVICE ************** - -public define Word32 _CXM_LOGGER_SERVICE_MSG_BASIS = 0x33771800. // -public define Word32 _CXM_LOGGER_SERVICE_ID = 0x33771801. -public define Word32 _CXM_LOGGER_LOG = 0x33771802. - - // ************** DOMAIN SERVICE ************** - -// MF <-> DomainManager -public define Word32 _CXM_DOMAIN_SERVICE_MSG_BASIS = 0x33771C00. // -public define Word32 _CXM_DOMAIN_SERVICE_ID = 0x33771C01. -public define Word32 _CXM_DOMAIN_PUBLISH_MF_CONFIG = 0x33771C02. -public define Word32 _CXM_DOMAIN_GET_NAME = 0x33771C03. -public define Word32 _CXM_DOMAIN_GET_MY_IP = 0x33771C04. -public define Word32 _CXM_DOMAIN_PUBLISH_MY_IP = 0x33771C05. -public define Word32 _CXM_DOMAIN_PUBLISH_DYN_TEST = 0x33771C06. -public define Word32 _CXM_DOMAIN_GET_STATUS = 0x33771C07. -public define Word32 _CXM_DOMAIN_GET_DOMAIN_INFO = 0x33771C08. -public define Word32 _CXM_DOMAIN_CRITICAL_ALERT = 0x33771C09. -public define Word32 _CXM_DOMAIN_COMMAND_RESULT = 0x33771C0A. - - -// DomainManager <-> Gandi -public define Word32 _CXM_GANDI_SERVICE_ID = 0x33771D00. -public define Word32 _CXM_GANDI_CHECK_AVAILABILITY = 0x33771D01. // 'NAME' (String): Base names (without extension) of the wanted domains - // --> CXM_ACK with 'DOMAINS' (String): Array of avaiblable domains -public define Word32 _CXM_GANDI_CREATE_CONTACT = 0x33771D02. // 'CLASS' (String): - // 'FIRSTNAME', 'LASTNAME', 'ADDRESS', 'ZIPCODE', 'CITY', 'COUNTRY', 'PHONE', 'EMAIL' (String) - // --> CXM_ACK with 'CONTACT_HANDLE' (String): Created handle for this contact -public define Word32 _CXM_GANDI_CREATE_DOMAIN = 0x33771D03. // 'DOMAIN' (String): Domain full name - // 'OWNER' (String): Owner handle - // --> CXM_ACK with 'DOMAIN_HANDLE' (String): Created handle for this domain - // ************** MF INSTALLER SERVICE ************** - -public define Word32 _CXM_INSTALLER_SERVICE_MSG_BASIS= 0x33772000. -public define Word32 _CXM_INSTALLER_SERVICE_ID = 0x33772001. -public define Word32 _CXM_INSTALLER_REGISTER_APP_ID = 0x33772002. -public define Word32 _CXM_INSTALLER_GET_NEW_SERIALS = 0x33772003. -public define Word32 _CXM_INSTALLER_CONFIRM_SERIALS_PUBLICATION = 0x33772004. -public define Word32 _CXM_INSTALLER_GET_MODELS = 0x33772005. // returns the MF models list - -// ************************************************* -// ************* MF API ************* - -// ************* ACCOUNTS SERVICE ************* - -public define Word32 _CXM_ACCOUNT_SERVICE_MSG_BASIS = 0x33772100. - -// ************* MAILINGS SERVICE ************* - -public define Word32 _CXM_MAILING_SERVICE_MSG_BASIS = 0x33772200. -public define Word32 _CXM_MAILING_SERVICE_ID = 0x33772200. // same as MSG_BASIS - -public define Word32 _CXM_MAILING_CREATE_CONTACT = 0x33772201. -public define Word32 _CXM_MAILING_UPDATE_CONTACT = 0x33772202. -public define Word32 _CXM_MAILING_DELETE_CONTACT = 0x33772203. - -public define Word32 _CXM_MAILING_CREATE_MAILING = 0x33772211. -public define Word32 _CXM_MAILING_UPDATE_MAILING = 0x33772212. -public define Word32 _CXM_MAILING_DELETE_MAILING = 0x33772213. - -public define Word32 _CXM_MAILING_ADD_CONTACT_TO_MAILING = 0x33772221. -public define Word32 _CXM_MAILING_REMOVE_CONTACT_FROM_MAILING = 0x33772222. - - -// ************* DIRECTORY SERVICE ************* - -public define Word32 _CXM_DIRECTORY_SERVICE_MSG_BASIS = 0x33772300. - -// ************* BACKUP SERVICE ************* - -public define Word32 _CXM_BACKUP_SERVICE_MSG_BASIS = 0x33772400. -public define Word32 _CXM_BACKUP_SERVICE_ID = 0x33772401. -public define Word32 _CXM_BACKUP_GET_STATUS = 0x33772402. /// Get backup status for a given MF (can subscribe, subscribed, subscription end date...) -public define Word32 _CXM_BACKUP_STARTING_BACKUP = 0x33772403. /// Notify BackupService that backup process is starting -public define Word32 _CXM_BACKUP_FINISHING_BACKUP = 0x33772404. /// Notify BackupService that backup process is finishing -public define Word32 _CXM_BACKUP_STARTING_RESTORE = 0x33772405. /// Notify BackupService that restore process is starting -public define Word32 _CXM_BACKUP_FINISHING_RESTORE = 0x33772406. /// Notify BackupService that restore process is finishing - -// ************* STATISTICS SERVICE ************* - -public define Word32 _CXM_STATS_SERVICE_MSG_BASIS = 0x33772500. - -// ************* SUPERVISER SERVICE ************* - -public define Word32 _CXM_SUPERVISER_SERVICE_MSG_BASIS = 0x33772600. -public define Word32 _CXM_SUPERVISER_SERVICE_ID = 0x33772600. -public define Word32 _CXM_SUPERVISER_GET_STATUS = 0x33772601. - -// ************************************************* -// ************* KERO_PBX API ************* - -public define Word32 _CXM_KERO_PBX_MSG_BASIS = 0x33780000. // Ask Boxes to publish their informations diff --git a/calexium_lib/database/alter_table.anubis b/calexium_lib/database/alter_table.anubis deleted file mode 100644 index 8dba8a6..0000000 --- a/calexium_lib/database/alter_table.anubis +++ /dev/null @@ -1,306 +0,0 @@ - - *Project* Anubis - - *Title* SQLite Alter table function - - *Copyright* Copyright (c) Cédric Ricard 2007. - - - - *Author* Cédric Ricard - - *Created* 2007 02 17 - *Satus* Released - *Compatibility* 1.7.10 - -read tools/basis.anubis -read data_base/db_tools.anubis -read data_base/alter_table.anubis -read system/logger.anubis -read system/string.anubis - - - -public define Maybe(One) - alter_table - ( - Database db, - String tableName, - String newTableQuery, - Logger log - ). - - - - - - --- That's all for the public part ! -------------------------------------------------- - -define String - to_String - ( - DbEntityType type - ) = - if type is - { - table then "table", - view then "view", - index then "index", - trigger then "trigger" - }. - -define One - print_list - ( - List(String) l - ) = - if l is - { - [] then print(" <<<\n"), - [h . t] then print(h + ", "); print_list(t) - }. - -define Maybe(One) - my_sql_query - ( - Database db, - String sql, - Logger log - ) = - if sql_query(db, sql) is - { - error(sql_error) then logError(log, "SQL ERROR: " + sql_error.text + "\n ...executing query [" + sql + "]"); failure, - ok(_,_,_) then success(unique) - }. - -define Maybe(String) - get_original_query - ( - Database db, - String dbName, // alias for attached database, 'main' for main database. - DbEntityType object_type, - String tableName, - Logger log - ) = - if sql_query(db, "SELECT sql FROM " + dbName + ".sqlite_master where (type='"+to_String(object_type)+"') and tbl_name='" + tableName + "'") is - { - error(sql_error) then logError(log, "alter_table/get_original_query ERROR '" + sql_error.text + "'"); failure, - ok(_,table_cursor,_) then - if table_cursor(unique) is - { - error(sql_error) then logError(log, "alter_table/get_original_query ERROR '" + sql_error.text + "'"); failure, - no_more_row then failure, //can't find the table in sqlite_master, because the table is new - row(current) then success(text(current)(0)) - } - }. - -define Bool - has_rows - ( - Database db, - String tableName, - Logger log - ) = - if sql_query(db, "SELECT count(*) FROM " + tableName) is - { - error(sql_error) then logError(log, "has_rows query ERROR '" + sql_error.text + "'"); false, - ok(_,table_cursor,_) then - if table_cursor(unique) is - { - error(sql_error) then logError(log, "has_row run ERROR '" + sql_error.text + "'"); false, - no_more_row then false, - row(current) then db_integer(current)(0) /= 0 - } - }. - -define List(String) - alter_table_extract_columns_list_sub - ( - Int -> SQLite3Datum row, - Int colIndex - ) = - if row(colIndex) is text(name) then [name . alter_table_extract_columns_list_sub(row, colIndex+1)] - else []. - -define List(String) - alter_table_extract_columns_list - ( - SQLite3HeadersOrRow -> SQLite3Row table_cursor, - Logger log - ) = - if table_cursor(headers) is - { - error(sql_error) then logError(log, "alter_table_extract_columns_list ERROR '" + sql_error.text + "'"); [], - no_more_row then [], - row(headers) then alter_table_extract_columns_list_sub(headers, 0) - }. - -define String - alter_table_extract_column_string - ( - One -> DbRow table_cursor, - List(String) oldColumns, - Logger log - ) = - if table_cursor(unique) is - { - error(sql_error) then logError(log, "alter_table_extract_columns_list ERROR '" + sql_error.text + "'"); "", - no_more_row then /*logDebug(log, "Extract columns answers 'no more row'");*/ "", - row(row) then - if row(1) is db_text(name) then - with test = (String name2) |-> logDebug(log, "name: " + name + " / name2: " + name2); if name = name2 then true else false, - colString = alter_table_extract_column_string(table_cursor, oldColumns, log), - if find_element(oldColumns, test) is - { - failure then colString, - success(_) then logDebug(log, "found: " + name); - if is_empty(colString) then name else name + ", " + colString - } - else "" - }. - -// false = different, true = same -define Bool - compare_creation_queries - ( - String tableName, - String query1, - String query2, - ) = - if find(tableName, query1, 0) is - { - failure then false, - success(p1) then - if find(tableName, query2, 0) is - { - failure then false, - success(p2) then - if sub_string(query1, p1, length(query1) - p1) is - { - failure then false, - success(s1) then - if sub_string(query2, p2, length(query2) - p2) is - { - failure then false, - success(s2) then s1 = s2 - } - } - } - }. - -public define Maybe(One) - alter_table - ( - Database db, - String dbName, // alias for attached database, 'main' for main database. - String tableName, - String newTableQuery, - Logger log - ) = - with fullTableName = dbName + "." + tableName, - if get_original_query(db, dbName, table, tableName, log) is - { - failure then - logInfo(log, "Creating table '" + fullTableName + "'... "); - if sql_query(db, newTableQuery) is error(sql_error) - then logError(log, "ERROR : " + sql_error.text); failure - else logInfo(log, " --> ok."); success(unique), - success(originalTableQuery) then - if compare_creation_queries(tableName, originalTableQuery, newTableQuery) = false then - logInfo(log, "Updating table '" + fullTableName + "' on database... "); - println(originalTableQuery); - println(newTableQuery); - if has_rows(db, fullTableName, log) is - { - false then - if my_sql_query(db, "DROP TABLE " + fullTableName, log) is failure - then failure - else if my_sql_query(db, newTableQuery, log ) is - { - failure then failure, - success(_) then logInfo(log, " --> ok."); success(unique) - }, - true then - with tempNameTable = tableName + "_temp", - forget(sql_query(db, "DROP TABLE " + tempNameTable)); - if my_sql_query(db, "CREATE TEMP TABLE " + tempNameTable + " AS SELECT * from " + fullTableName, log) is failure then failure else - if my_sql_query(db, "DROP TABLE " + fullTableName, log) is failure then failure else - if my_sql_query(db, newTableQuery , log) is failure then failure else - if sql_query(db, "SELECT * FROM " + tempNameTable) is - { - error(sql_error) then logError(log, "alter_table: select * tempTable ERROR '" + sql_error.text + "'"); failure, - ok(get_cols,table_cursor2,_) then - with oldColumns = get_cols(unique), - //print_list(oldColumns); - if sql_query(db, "PRAGMA " + dbName + ".table_info(" + tableName + ")") is - { - error(sql_error) then logError(log, "alter_table: pragma table_info() ERROR '" + sql_error.text + "'"); failure, - ok(_,table_cursor3,_) then - with newColumnsStr = alter_table_extract_column_string(table_cursor3, oldColumns, log), - sql = "INSERT INTO " + fullTableName + " (" + newColumnsStr + ") SELECT " + newColumnsStr + " FROM " + tempNameTable, - if sql_query(db, sql) is - { - error(sql_error) then logError(log, "alter_table ERROR '" + sql_error.text + "'\n\tquery = [" + sql + "]"); failure, - ok(_,_,_) then logInfo(log, " --> ok."); success(unique) - } - } - } - } - else - success(unique) - }. - -public define Maybe(One) - alter_table - ( - Database db, - String tableName, - String newTableQuery, - Logger log - ) = - alter_table(db, "main", tableName, newTableQuery, log). - - -public define Maybe(One) - alter_view - ( - Database db, - String dbName, // alias for attached database, 'main' for main database. - String viewName, - String newViewQuery, - Logger log - ) = - with fullViewName = dbName + "." + viewName, - if get_original_query(db, dbName, view, viewName, log) is - { - failure then - logInfo(log, "Creating view '" + fullViewName + "'... "); - if sql_query(db, newViewQuery) is error(sql_error) - then logError(log, "ERROR : " + sql_error.text); failure - else logInfo(log, " --> ok."); success(unique), - success(originalViewQuery) then - if compare_creation_queries(viewName, originalViewQuery, newViewQuery) = false then - logInfo(log, "Updating view '" + fullViewName + "' on database... "); - println(originalViewQuery); - println(newViewQuery); - if my_sql_query(db, "DROP VIEW " + fullViewName, log) is failure - then failure - else if my_sql_query(db, newViewQuery, log ) is - { - failure then failure, - success(_) then logInfo(log, " --> ok."); success(unique) - } - else - success(unique) - }. - -public define Maybe(One) - alter_view - ( - Database db, - String viewName, - String newViewQuery, - Logger log - ) = - alter_view(db, "main", viewName, newViewQuery, log). - diff --git a/calexium_lib/database/db_types.anubis b/calexium_lib/database/db_types.anubis deleted file mode 100644 index 688da57..0000000 --- a/calexium_lib/database/db_types.anubis +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Created by PyramIDE. - * User: Totoro - * Date: 14/11/2011 - * Time: 22:41 - * - * To change this template use Tools | Options | Coding | Edit Standard Headers. - */ -read tools/basis.anubis - -public type DB_id: - none, - db_id(Int value). - -public type DB_datetime: - datetime(String datetime). - -public type DB_date: - date(String date). - -public type DB_integer: - db_integer(Int value). - - -public define String - to_String - ( - DB_id idx - )= - if idx is - { - none then "none", - db_id(idx) then abs_to_decimal(idx) - }. - -public define String - to_String - ( - DB_date d - )= - date(d). - - - -public define String - to_String - ( - DB_datetime d - )= - datetime(d). - - - -public define String - to_DBString - ( - Bool value - )= - if value then "1" else "0". - -public define Int - to_DBInt - ( - Bool value - )= - if value then 1 else 0. - -public type SQLite3_update_field: - field(String column, SQLite3Bind bind). - - - * Some Bind helper * - - - - diff --git a/calexium_lib/database/db_utils.anubis b/calexium_lib/database/db_utils.anubis deleted file mode 100644 index 5b5a4d5..0000000 --- a/calexium_lib/database/db_utils.anubis +++ /dev/null @@ -1,319 +0,0 @@ -/* - * - * User: David RENE - * Date: 11/12/2007 - * Time: 01:16 - * (c) Calexium - * - */ - -read tools/basis.anubis -read system/logger.anubis -read system/string.anubis -read data_base/db_tools.anubis -read data_base/sqlite.anubis - -read calexium_lib/database/db_types.anubis -read calexium_lib/net_services_protocols/logger_service.anubis - -public define Int one_year_seconds = 365 * 86400. // amount of seconds during 1 year -// public define Int one_month_seconds = 31 * 86400. -public define Int one_week_seconds = 7 * 86400. // amount of seconds during 1 week -public define Int one_day_seconds = 86400. // amount of seconds during 1 day - -define String - __utime_to_string - ( - UTime t - ) = - to_decimal(t.seconds) + "." + zero_pad_n(6, t.microseconds ) + " s". - -define One - __logLongQueries - ( - UTime t0, - String sql_query - ) = - with t = unow - t0, - if t.seconds > 0 then - logTrace("SQL", logMask("sql_profiling"), "[SQL] " + __utime_to_string(t) + " executing [" + sql_query + "]") - else - unique. - -public define Result(DbError, One) - sql_transaction - ( - Database db, - String sql_command, - String message - ) = -// logDebug(debug_log, "Entering into transaction [" + message + "]."); - with t0 = unow, - if db_do_transaction( - db, - (One _) |-> - if db_query(db, sql_command) is - { - error(err) then logError("DB", db_error(err,message));failure //error in the SQL request - ok(_,cursor,_) then success(unique) - }, - success( (DbError err) |-> logError("DB", db_error(err,message))), - 60000, // max 60s - 100, // retry every 100 ms - (DbError _) |-> false - ) is - { - error(err_and_result) then -// logDebug(debug_log, "Exiting from transaction [" + message + "] with error."); - __logLongQueries(t0, sql_command); - if err_and_result is (err, mb_result) then error(err), - ok(_) then -// logDebug(debug_log, "Exiting from transaction [" + message + "]."); - __logLongQueries(t0, sql_command); - ok(unique) - }. - - - -public define DbQueryResult - sql_query_timeout - ( - Database db, //database handle - String sql_query, //sql query itself - List(DbBind) initial_bindings, - String msg //message to be shown if an error occure - ) = - //we try with 30 sec of timeout - with t0 = unow, - if sql_query_timeout(db, sql_query, initial_bindings, 60, 100, (DbError _) |-> false) is - { - error(sql_error) then logError("DB", db_error(sql_error,msg) + " executing [" + sql_query + "]"); - __logLongQueries(t0, sql_query); - error(sql_error), - ok(headers, cursor, reset) then - __logLongQueries(t0, sql_query); - ok(headers, cursor, reset) - }. - - public define DbQueryResult - sql_query_timeout - ( - Database db, //database handle - String sql_query, //sql query itself - String msg //message to be shown if an error occure - ) = - sql_query_timeout(db, sql_query, [], msg). - -public define Maybe(One -> DbRow) - sql_query_timeout - ( - Database db, //database handle - String sql_query, //sql query itself - String msg //message to be shown if an error occure - ) = - if sql_query_timeout(db, sql_query, [], msg) is - { - error(_) then failure, - ok(_,cursor,_) then success(cursor) - }. - -// deprecated. Use one of the previous ones. -public define SQLite3QueryResult - sql_query_timeout - ( - SQLite3DataBase db, //database handle - String sql_query, //sql query itself - List(SQLite3Bind) initial_bindings, - String msg //message to be shown if an error occure - ) = - //we try with 30 sec of timeout - with t0 = unow, - if sql_query_timeout(db, sql_query, initial_bindings, 60, 100) is - { - error(sql_error) then logError("DB", db_error(sql_error,msg) /*+ " executing [" + sql_query + "]"*/); - //println(" executing [" + sql_query + "]"); - __logLongQueries(t0, sql_query); - error(sql_error), - ok(headers, cursor, reset) then - __logLongQueries(t0, sql_query); - ok(headers, cursor, reset) - }. - -public define SQLite3QueryResult - sql_query_timeout - ( - SQLite3DataBase db, //database handle - String sql_query, //sql query itself - String msg //message to be shown if an error occure - ) = - sql_query_timeout(db, sql_query, [], msg). - -// -- Extractors HELPERS --------------- - -public define List(String) - db_get_string_list - ( - One -> DbRow table_cursor, - List(String) so_far - ) = - if table_cursor(unique) is - { - error(sql_error) then logError("DB", db_error(sql_error, "db_get_string_list")); reverse(so_far), - no_more_row then reverse(so_far), //can't find the symbol in the table, because the row is empty - row(explorer) then - with s = text(explorer)(0), - db_get_string_list(table_cursor, [s . so_far]) - }. - -// sqlite3 API -public define List(String) - db_get_string_list - ( - One -> SQLite3Row table_cursor, - List(String) so_far - ) = - if table_cursor(unique) is - { - error(sql_error) then logError("DB", db_error(sql_error, "db_get_string_list")); reverse(so_far), - no_more_row then reverse(so_far), //can't find the symbol in the table, because the row is empty - row(explorer) then - with s = text(explorer)(0), - db_get_string_list(table_cursor, [s . so_far]) - }. - -// sqlite3 API -public define List(Int) - db_get_integer_list - ( - One -> SQLite3Row table_cursor, - List(Int) so_far - ) = - if table_cursor(unique) is - { - error(sql_error) then logError("DB", db_error(sql_error, "db_get_integer_list")); reverse(so_far), - no_more_row then reverse(so_far), //can't find the symbol in the table, because the row is empty - row(explorer) then - with s = (Int)db_integer(explorer)(0), - db_get_integer_list(table_cursor, [s . so_far]) - }. - - -public define List(Int) - db_get_integer_list - ( - One -> DbRow table_cursor, - List(Int) so_far - ) = - if table_cursor(unique) is - { - error(sql_error) then logError("DB", db_error(sql_error, "db_get_integer_list")); reverse(so_far), - no_more_row then reverse(so_far), //can't find the symbol in the table, because the row is empty - row(explorer) then - with s = (Int)db_integer(explorer)(0), - db_get_integer_list(table_cursor, [s . so_far]) - }. - - - Help to construct clause and a list of bind according to list of SQLite3_update_field. - This is useful when we want to construct a SQL query with only needs fields. - - -public define (List(SQLite3Bind), String) - make_clause_and_binds - ( - List(SQLite3_update_field) fields, - List(SQLite3Bind) so_far, - List(String) clause - )= - if fields is - { - [] then (so_far, join(", ",clause)), - [ h . t ] then - if h is field(column, bind) then - make_clause_and_binds(t, [bind . so_far], [column+" = :v_"+column . clause]) - }. - - - extended version of bind for SQLite3. - -public define SQLite3Bind - bind_Int_or_NULL - ( - String name, - Int value - )= - if value = 0 then - bind_NULL(name) - else - bind_Int(name, value). - -public define SQLite3Bind - bind_String_or_NULL - ( - String name, - String value - )= - if value = "" then - bind_NULL(name) - else - bind_String(name, value). - -public define SQLite3Bind - bind_Datetime - ( - String name, - DB_datetime dt - )= - bind_String(name, datetime(dt)). - -public define SQLite3Bind - bind_Date - ( - String name, - DB_date d - )= - bind_String(name, date(d)). - -public define SQLite3Bind - bind_Bool - ( - String name, - Bool value - )= - bind_Int(name, to_DBInt(value)). - - -// -- Migration HELPERS --------------- - - public define DbBind - bind_String - ( - String name, - String value - ) = - db_bind(force(sub_string(name, 1, length(name) - 1), name), db_text(value)). - - public define DbBind - bind_ByteArray - ( - String name, - ByteArray value - ) = - db_bind(force(sub_string(name, 1, length(name) - 1), name), db_blob(value)). - - public define DbBind - bind_Int - ( - String name, - Int value - ) = - db_bind(force(sub_string(name, 1, length(name) - 1), name), db_integer(value)). - - public define DbBind - bind_NULL - ( - String name, - ) = - db_bind(force(sub_string(name, 1, length(name) - 1), name), null). - - diff --git a/calexium_lib/database/migration.anubis b/calexium_lib/database/migration.anubis deleted file mode 100644 index f770208..0000000 --- a/calexium_lib/database/migration.anubis +++ /dev/null @@ -1,211 +0,0 @@ -/* - * Created by PyramIDE. - * User: Steve Marechal - * Date: 25/11/2008 - * Time: 11:29 - * - */ - -read tools/basis.anubis -read system/files.anubis -read system/logger.anubis -read system/string.anubis -read data_base/db_tools.anubis - -read calexium_lib/database/db_utils.anubis -read calexium_lib/database/alter_table.anubis -read calexium_lib/net_services_protocols/logger_service.anubis - - read mf_constants.anubis - - read settings.anubis -read migration_common.anubis - - read tools/mf_loggers.anubis - -define String dir_save_database = "/db_backup/". - - -/** - * Compare two version string. Returns -1 if first is lower than second, 1 if first is greater than second, and 0 if equals. - */ -public define Int - compare_db_version - ( - String version1, - String version2 - ) = - with compare = (List(String) v1, List(String) v2) |-compare-> (Int) - if v1 is - { - [] then - if v2 is - { - [] then 0, - [h2 . t2] then -1 - }, - [h1 . t1] then - if v2 is - { - [] then 1, - [h2 . t2] then - if h1 = h2 then compare(t1, t2) - else - with v1i = force_Type(decimal_scan(h1), 0), - v2i = force_Type(decimal_scan(h2), 0), - if v1i < v2i then -1 - else if v1i > v2i then 1 - else 0 - }, - }, - compare(split(version1, '.'), split(version2, '.')). - -public define Maybe(One) - backup_database - ( - Logger logger, -// String current_version, - String db_path, - String main_db_name, - List(String) other_db_names, - ) - = -// with should_copy = if file_exists(db_path + main_db_name) then -// if sqlite3_open(db_path + main_db_name) is -// { -// error(sql_error) then false, // maybe not created yet -// ok(Database db) then -// with ver = get_version_settings(db), -// ver != current_version -// } -// else false, - - //if should_copy then - with dir_save = db_path + dir_save_database, - if (Maybe(String))make_directory(dir_save) is - { - failure then logError(logger, "Can't create directory '"+db_path + dir_save_database+"'"); failure, - success(_) then - with copy_with_log = (String src, String dst) |-> - if file_exists(src) then - if copy_file(src, dst) is - { - cant_read_file then logError(logger, "Can't read source file '" + src + "'."); failure, - cant_create_file then logError(logger, "Can't create destination file '" + dst + "'."); failure, - copy_error then logError(logger, "Can't copy file '" + src + "' to file '" + dst + "'."); failure, - copy_file_mode_error then logError(logger, "Can't get file mode for source file '" + src + "'."); failure, - copy_file_times_error then logError(logger, "Can't set file times into file '" + dst + "'."); failure, - copy_ok(_) then logInfo(logger, "File '" + dst + "' saved"); success(unique) - } - else success(unique), - with copy_db = (List(String) names) |-copy_db-> - if names is - { - [] then success(unique), - [h . t] then - if copy_with_log(db_path + h, dir_save + h) is - { - failure then failure, - success(_) then copy_db(t) - } - }, - copy_db([main_db_name . other_db_names]) - } - //else success(unique) - . - - - - - - -public type Migration: - migration(String version, - (Database, Logger) -> Maybe(One) migrate_to, - (Database, Logger) -> Maybe(One) create_tables, - (Database, Logger) -> Maybe(One) create_indexes, - ). - - - -define Maybe(One) - do_migration_loop - ( - Database db, - Logger logger, - String current_version, - String db_ver, - List(Migration) migrations, - Maybe(Migration) need_to_create_table, // success in case of new DB or when no migration have been done - (Database, String) -> One update_db_version, - ) = - if migrations is - { - [] then - if need_to_create_table is - { - failure then - update_db_version(db, current_version); - success(unique), - success(last) then - if last is migration(_, _, create_tables, create_indexes) then - if create_tables(db, logger) is success(_) then - if create_indexes(db, logger) is success(_) then - update_db_version(db, current_version); - success(unique) - else - failure - else - failure - }, - [h . t] then - if h is migration(version, migrate_to, _, _) then - if compare_db_version(db_ver, version) < 0 then - logInfo(logger, "Migrating Database from version " + db_ver + " to version " + version); - if migrate_to(db, logger) is failure then - failure - else - do_migration_loop(db, logger, current_version, version, t, failure, update_db_version) - else - do_migration_loop(db, logger, current_version, db_ver, t, success(h), update_db_version), - }. - - - -public define Maybe(One) - do_migration - ( - Database db, - Logger logger, - String current_version, - (Database) -> String get_db_version, - (Database, String) -> One update_db_version, - List(Migration) all_migrations, - )= - if is_empty_database(db) then // new empty database - logInfo(logger, "No database found. Creating a new one..."); - do_migration_loop(db, logger, current_version, "", [], last(all_migrations), update_db_version) - else - ( - with db_version = get_db_version(db), - do_migration_loop(db, logger, current_version, db_version, all_migrations, failure, update_db_version) - ). - -public define Maybe(One) - do_create_indexes - ( - Database db, - Logger logger, - String current_version, - List(Migration) all_migrations, - )= - if last(all_migrations) is - { - failure then logCriticalError(logger, "Index creation: migration list is empty!"); failure, - success(last_migration) then - if last_migration is migration(_, _, _, create_indexes) then - if create_indexes(db, logger) is success(_) then - success(unique) - else - failure - }. diff --git a/calexium_lib/database/migration_common.anubis b/calexium_lib/database/migration_common.anubis deleted file mode 100644 index c9d2d3e..0000000 --- a/calexium_lib/database/migration_common.anubis +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Created by PyramIDE. - * User: ricard - * Date: 03/12/2008 - * Time: 13:07 - * - */ - -read tools/basis.anubis -read system/logger.anubis -read data_base/db_tools.anubis -read alter_table.anubis -read sqlite_foreign_key.anubis - -read calexium_lib/database/db_utils.anubis -read calexium_lib/net_services_protocols/logger_service.anubis - - read ezmailbox_constants.anubis - - -public type DbTable: - table(String name, String create_query), - table(String db_name, String name, String create_query), - view(String name, String create_query). - - -public define Bool - is_table_exists - ( - Database db, - String dbName, - String table_name - )= - if sql_query_timeout(db, "SELECT * FROM " + dbName + ".sqlite_master WHERE type ='table' AND name = :table_name", [db_bind("table_name", db_text(table_name))], "is_table_exists("+table_name+")") is - { - error(_) then false, //error in the SQL request - ok(_, cursor, _) then - if cursor(unique) is - { - error(_) then false, - no_more_row then false, - row(current) then true - } - }. - -public define Bool - is_table_exists - ( - Database db, - String table_name - )= - is_table_exists(db, "main", table_name). - -public define Bool - is_empty_database - ( - Database db, - String dbName, - )= - if sql_query_timeout(db, "SELECT * FROM " + dbName + ".sqlite_master", [], "is_empty_database("+dbName+")") is - { - error(_) then true, //error in the SQL request - ok(_, cursor, _) then - if cursor(unique) is - { - error(_) then true, - no_more_row then true, - row(current) then false - } - }. - -public define Bool - is_empty_database - ( - Database db, - )= - is_empty_database(db, "main"). - -public define Maybe(One) - drop_all_triggers - ( - Database db, - Logger log - ) = - if db_query(db, "SELECT name FROM sqlite_master WHERE type = 'trigger'", []) is - { - error(err) then logError(log, db_error(err, "drop_all_triggers")); failure, - ok(_, cursor, _) then - with drop_trigger = (String name) |-> if db_query(db, "DROP TRIGGER " + name, []) is - { - error(err2) then logError(log, db_error(err2, "Failed to drop trigger '" + name + "'")), - ok(_, cursor, _) then unique - }, - map_forget(drop_trigger, db_get_string_list(cursor, [])); - success(unique) - }. - -public define Maybe(One) - create_tables - ( - Database db, - Logger logger, - List(DbTable) tables, - String version_string - ) = - if tables is - { - [] then success(unique), - [h . t] then - if h is - { - table(table_name, create_string) then - if alter_table(db, table_name, create_string, logger) is - { - failure then logError(logger, "Version "+version_string+": Can't create '"+table_name+"' table"); failure, - success(_) then create_tables(db, logger, t, version_string) - }, - table(db_name, table_name, create_string) then - if alter_table(db, db_name, table_name, create_string, logger) is - { - failure then logError(logger, "Version "+version_string+": Can't create '"+db_name+"."+table_name+"' table"); failure, - success(_) then create_tables(db, logger, t, version_string) - }, - view(view_name, create_string) then - if alter_view(db, view_name, create_string, logger) is - { - failure then logError(logger, "Version "+version_string+": Can't create '"+view_name+"' view"); failure, - success(_) then create_tables(db, logger, t, version_string) - }, - } - }. - - -public define Maybe(One) - create_indexes - ( - Database db, - Logger logger, - List(String) indexes, - String version_string - )= - if indexes is - { - [] then success(unique), - [h . t] then - if sql_query_timeout(db, h, "Version "+version_string+": create indexes") is - { - failure then failure, - success(_) then - create_indexes(db, logger, t, version_string) - } - }. - - -public define One - make_foreign_key - ( - Database db, - String table_name, - String field_name, - String foreign_table_name, - String foreign_field_name, - Bool fk_null, - Bool fk_cascade, - Logger log - ) = - if (Maybe(One))make_foreign_key(db, table_name, field_name, foreign_table_name, foreign_field_name, fk_null, fk_cascade, log) is - { - failure then - logError(log, "Can't create foreign key constraint between '"+table_name+"' and '"+foreign_table_name+"' tables"), - success(_) then - unique - }. - -public define Maybe(One) - make_foreign_keys - ( - Database db, - Logger logger, - List((String, String, String, String, FK_Null, FK_Cascade)) relations, - String version_string - )= - if relations is - { - [] then success(unique), - [h . t] then - if h is (table_name, field_name, foreign_table_name, foreign_field_name, fk_null, fk_cascade) then - if (Maybe(One))make_foreign_key(db, table_name, field_name, foreign_table_name, foreign_field_name, fk_null, fk_cascade, logger) is - { - failure then - logError(logger, "Version "+version_string+": Can't create foreign key constraint between '"+table_name+"' and '"+foreign_table_name+"' tables"); failure, - success(_) then - make_foreign_keys(db, logger, t, version_string) - } - }. diff --git a/calexium_lib/database/migration_common_sqlite3.anubis b/calexium_lib/database/migration_common_sqlite3.anubis deleted file mode 100644 index 91ace4b..0000000 --- a/calexium_lib/database/migration_common_sqlite3.anubis +++ /dev/null @@ -1,192 +0,0 @@ -/* - * Created by PyramIDE. - * User: ricard - * Date: 03/12/2008 - * Time: 13:07 - * - */ - -read tools/basis.anubis -read system/logger.anubis -read data_base/sqlite.anubis -read data_base/alter_table.anubis //for sqlite3 version of alter_table -read data_base/db_types.anubis //FK... -read data_base/sqlite_foreign_key.anubis - -read calexium_lib/database/db_utils.anubis -read calexium_lib/net_services_protocols/logger_service.anubis - -public type DbTable: - table(String name, String create_query), - table(String db_name, String name, String create_query), - view(String name, String create_query). - - -public define Bool - is_table_exists - ( - SQLite3DataBase db, - String dbName, - String table_name - )= - if sql_query_timeout(db, "SELECT * FROM " + dbName + ".sqlite_master WHERE type ='table' AND tbl_name =:table_name", [bind_String(":table_name", table_name)], "is_table_exists("+table_name+")") is - { - error(_) then false, //error in the SQL request - ok(_, cursor, _) then - if cursor(unique) is - { - error(_) then false, - no_more_row then false, - row(current) then true - } - }. - -public define Bool - is_table_exists - ( - SQLite3DataBase db, - String table_name - )= - is_table_exists(db, "main", table_name). - -public define Bool - is_empty_database - ( - SQLite3DataBase db, - String dbName, - )= - if sql_query_timeout(db, "SELECT * FROM " + dbName + ".sqlite_master", [], "is_empty_database("+dbName+")") is - { - error(_) then true, //error in the SQL request - ok(_, cursor, _) then - if cursor(unique) is - { - error(_) then true, - no_more_row then true, - row(current) then false - } - }. - -public define Bool - is_empty_database - ( - SQLite3DataBase db, - )= - is_empty_database(db, "main"). - -public define Maybe(One) - drop_all_triggers - ( - SQLite3DataBase db, - Logger log - ) = - if sqlite3_query(db, "SELECT name FROM sqlite_master WHERE type = 'trigger'", []) is - { - error(err) then logError(log, db_error(err, "drop_all_triggers")); failure, - ok(_, cursor, _) then - with drop_trigger = (String name) |-> if sqlite3_query(db, "DROP TRIGGER " + name, []) is - { - error(err2) then logError(log, db_error(err2, "Failed to drop trigger '" + name + "'")), - ok(_, cursor, _) then unique - }, - map_forget(drop_trigger, db_get_string_list(cursor, [])); - success(unique) - }. - -public define Maybe(One) - create_tables - ( - SQLite3DataBase db, - Logger logger, - List(DbTable) tables, - String version_string - ) = - if tables is - { - [] then success(unique), - [h . t] then - if h is - { - table(table_name, create_string) then - if alter_table(db, table_name, create_string, logger) is - { - failure then logError(logger, "Version "+version_string+": Can't create '"+table_name+"' table"); failure, - success(_) then create_tables(db, logger, t, version_string) - }, - table(db_name, table_name, create_string) then - if alter_table(db, db_name, table_name, create_string, logger) is - { - failure then logError(logger, "Version "+version_string+": Can't create '"+db_name+"."+table_name+"' table"); failure, - success(_) then create_tables(db, logger, t, version_string) - }, - view(view_name, create_string) then - if alter_view(db, view_name, create_string, logger) is - { - failure then logError(logger, "Version "+version_string+": Can't create '"+view_name+"' view"); failure, - success(_) then create_tables(db, logger, t, version_string) - }, - } - }. - - -public define Maybe(One) - create_indexes - ( - SQLite3DataBase db, - Logger logger, - List(String) indexes, - String version_string - )= - if indexes is - { - [] then success(unique), - [h . t] then - if sql_query_timeout(db, h, [], "Version "+version_string+": create indexes") is - { - error(_) then failure, - ok(_,_,_) then create_indexes(db, logger, t, version_string) - } - }. - - -public define One - make_foreign_key - ( - SQLite3DataBase db, - String table_name, - String field_name, - String foreign_table_name, - String foreign_field_name, - Bool fk_null, - Bool fk_cascade, - Logger log - ) = - if (Maybe(One))make_foreign_key(db, table_name, field_name, foreign_table_name, foreign_field_name, fk_null, fk_cascade, log) is - { - failure then - logError(log, "Can't create foreign key constraint between '"+table_name+"' and '"+foreign_table_name+"' tables"), - success(_) then - unique - }. - -public define Maybe(One) - make_foreign_keys - ( - SQLite3DataBase db, - Logger logger, - List((String, String, String, String, FK_Null, FK_Cascade)) relations, - String version_string - )= - if relations is - { - [] then success(unique), - [h . t] then - if h is (table_name, field_name, foreign_table_name, foreign_field_name, fk_null, fk_cascade) then - if (Maybe(One))make_foreign_key(db, table_name, field_name, foreign_table_name, foreign_field_name, fk_null, fk_cascade, logger) is - { - failure then - logError(logger, "Version "+version_string+": Can't create foreign key constraint between '"+table_name+"' and '"+foreign_table_name+"' tables"); failure, - success(_) then - make_foreign_keys(db, logger, t, version_string) - } - }. diff --git a/calexium_lib/database/migration_sqlite3.anubis b/calexium_lib/database/migration_sqlite3.anubis deleted file mode 100644 index 259a023..0000000 --- a/calexium_lib/database/migration_sqlite3.anubis +++ /dev/null @@ -1,204 +0,0 @@ -/* - * Created by PyramIDE. - * User: David René - * Date: 31/08/2011 - * Time: 2:09 - * - */ - -read tools/basis.anubis -read system/files.anubis -read system/logger.anubis -read system/string.anubis -read data_base/sqlite.anubis -read calexium_lib/database/alter_table.anubis -read calexium_lib/net_services_protocols/logger_service.anubis - -read migration_common_sqlite3.anubis - - -define String dir_save_database = "/db_backup/". - - -/** - * Compare two version string. Returns -1 if first is lower than second, 1 if first is greater than second, and 0 if equals. - */ -public define Int - compare_db_version - ( - String version1, - String version2 - ) = - with compare = (List(String) v1, List(String) v2) |-compare-> (Int) - if v1 is - { - [] then - if v2 is - { - [] then 0, - [h2 . t2] then -1 - }, - [h1 . t1] then - if v2 is - { - [] then 1, - [h2 . t2] then - if h1 = h2 then compare(t1, t2) - else - with v1i = force_Type(decimal_scan(h1), 0), - v2i = force_Type(decimal_scan(h2), 0), - if v1i < v2i then -1 - else if v1i > v2i then 1 - else 0 - }, - }, - compare(split(version1, '.'), split(version2, '.')). - -public define Maybe(One) - backup_database - ( - Logger logger, -// String current_version, - String db_path, - String main_db_name, - List(String) other_db_names, - ) - = -// with should_copy = if file_exists(db_path + main_db_name) then -// if sqlite3_open(db_path + main_db_name) is -// { -// error(sql_error) then false, // maybe not created yet -// ok(Database db) then -// with ver = get_version_settings(db), -// ver != current_version -// } -// else false, - - //if should_copy then - with dir_save = db_path + dir_save_database, - if (Maybe(String))make_directory(dir_save) is - { - failure then logError(logger, "Can't create directory '"+db_path + dir_save_database+"'"); failure, - success(_) then - with copy_with_log = (String src, String dst) |-> - if file_exists(src) then - if copy_file(src, dst) is - { - cant_read_file then logError(logger, "Can't read source file '" + src + "'."); failure, - cant_create_file then logError(logger, "Can't create destination file '" + dst + "'."); failure, - copy_error then logError(logger, "Can't copy file '" + src + "' to file '" + dst + "'."); failure, - copy_file_mode_error then logError(logger, "Can't get file mode for source file '" + src + "'."); failure, - copy_file_times_error then logError(logger, "Can't set file times into file '" + dst + "'."); failure, - copy_ok(_) then logInfo(logger, "File '" + dst + "' saved"); success(unique) - } - else success(unique), - with copy_db = (List(String) names) |-copy_db-> - if names is - { - [] then success(unique), - [h . t] then - if copy_with_log(db_path + h, dir_save + h) is - { - failure then failure, - success(_) then copy_db(t) - } - }, - copy_db([main_db_name . other_db_names]) - } - //else success(unique) - . - - - - - - -public type Migration: - migration(String version, - (SQLite3DataBase, Logger) -> Maybe(One) migrate_to, - (SQLite3DataBase, Logger) -> Maybe(One) create_tables, - (SQLite3DataBase, Logger) -> Maybe(One) create_indexes, - ). - - - -define Maybe(One) - do_migration_loop - ( - SQLite3DataBase db, - Logger logger, - String current_version, - String db_ver, - List(Migration) migrations, - Maybe(Migration) need_to_create_table, // success in case of new DB or when no migration have been done - (SQLite3DataBase, String) -> One update_db_version, - ) = - if migrations is - { - [] then - if need_to_create_table is - { - failure then - update_db_version(db, current_version); - success(unique), - success(last) then - if last is migration(_, _, create_tables, create_indexes) then - if create_tables(db, logger) is success(_) then - if create_indexes(db, logger) is success(_) then - update_db_version(db, current_version); - success(unique) - else - failure - else - failure - }, - [h . t] then - if h is migration(version, migrate_to, _, _) then - if compare_db_version(db_ver, version) < 0 then - logInfo(logger, "Migrating Database from version " + db_ver + " to version " + version); - if migrate_to(db, logger) is failure then - failure - else - do_migration_loop(db, logger, current_version, version, t, failure, update_db_version) - else - do_migration_loop(db, logger, current_version, db_ver, t, success(h), update_db_version), - }. - -/* SQLite 3 version */ -public define Maybe(One) - do_migration - ( - SQLite3DataBase db, - Logger logger, - String current_version, - (SQLite3DataBase) -> String get_db_version, - (SQLite3DataBase, String) -> One update_db_version, - List(Migration) all_migrations, - )= - if is_empty_database(db) then // new empty database - logInfo(logger, "No database found. Creating a new one..."); - do_migration_loop(db, logger, current_version, "", [], last(all_migrations), update_db_version) - else - ( - with db_version = get_db_version(db), - do_migration_loop(db, logger, current_version, db_version, all_migrations, failure, update_db_version) - ). - -public define Maybe(One) - do_create_indexes - ( - SQLite3DataBase db, - Logger logger, - String current_version, - List(Migration) all_migrations, - )= - if last(all_migrations) is - { - failure then logCriticalError(logger, "Index creation: migration list is empty!"); failure, - success(last_migration) then - if last_migration is migration(_, _, _, create_indexes) then - if create_indexes(db, logger) is success(_) then - success(unique) - else - failure - }. diff --git a/calexium_lib/database/settings.anubis b/calexium_lib/database/settings.anubis deleted file mode 100644 index c1f4738..0000000 --- a/calexium_lib/database/settings.anubis +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Created by PyramIDE. - * User: Steve Marechal - * Date: 09/12/2008 - * Time: 17:19 - */ - -read tools/basis.anubis -read data_base/db_tools.anubis - -read calexium_lib/database/db_utils.anubis - - -public define Maybe(String) - select_settings - ( - Database db, - String var, - )= - if sql_query_timeout(db, "SELECT var_value FROM settings WHERE var_name=" + db_make_sql_string(var) + ";", "select_settings") is - { - failure then failure, //error in the SQL request - success(table_cursor) then - if table_cursor(unique) is - { - error(_) then failure, - no_more_row then failure, //can't find the var_value in the table, because the row is empty - row(current) then success(text(current)(0)) - } - }. - -public define String - select_settings - ( - Database db, - String var, - String default - )= - if select_settings(db, var) is - { - failure then default, //error in the SQL request - success(value) then value - }. - -public define Int - select_settings - ( - Database db, - String var, - Int default - )= - if select_settings(db, var) is - { - failure then default, //error in the SQL request - success(value) then - if decimal_scan(value) is - { - failure then default, - success(v) then v - } - }. - -public define Bool - select_settings - ( - Database db, - String var, - Bool default - )= - if select_settings(db, var) is - { - failure then default, //error in the SQL request - success(value) then - if decimal_scan(value) is - { - failure then default, - success(v) then v!=0 - } - }. - -public define One - update_settings - ( - Database db, - String var, - String value - )= - if select_settings(db, var) is success(_) then - forget(sql_query_timeout(db, "UPDATE settings SET var_value = @value WHERE var_name = @name;", [bind_String("@name", var), bind_String("@value", value)], "update_settings")) - else - forget(sql_query_timeout(db, "INSERT INTO settings (var_name, var_value) VALUES (@name, @value)", [bind_String("@name", var), bind_String("@value", value)], "update_settings")) - . - diff --git a/calexium_lib/database/settings_sqlite3.anubis b/calexium_lib/database/settings_sqlite3.anubis deleted file mode 100644 index 89b2096..0000000 --- a/calexium_lib/database/settings_sqlite3.anubis +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Created by PyramIDE. - * User: Totoro - * Date: 11/08/2012 - * Time: 17:44 - * - * To change this template use Tools | Options | Coding | Edit Standard Headers. - */ - -read tools/basis.anubis -read data_base/sqlite.anubis -read data_base/db_tools.anubis -read calexium_lib/database/db_utils.anubis - - -public define Maybe(String) - select_settings - ( - SQLite3DataBase db, - String var, - )= - if sql_query_timeout(db, "SELECT var_value FROM settings WHERE var_name=" + db_make_sql_string(var) + ";", [], "select_settings") is - { - error(_) then failure, //error in the SQL request - ok(_, cursor, _) then - if cursor(unique) is - { - error(_) then failure, - no_more_row then failure, //can't find the var_value in the table, because the row is empty - row(current) then success(text(current)(0)) - } - }. - -public define String - select_settings - ( - SQLite3DataBase db, - String var, - String default - )= - if select_settings(db, var) is - { - failure then default, //error in the SQL request - success(value) then value - }. - -public define Int - select_settings - ( - SQLite3DataBase db, - String var, - Int default - )= - if select_settings(db, var) is - { - failure then default, //error in the SQL request - success(value) then - if decimal_scan(value) is - { - failure then default, - success(v) then v - } - }. - -public define Bool - select_settings - ( - SQLite3DataBase db, - String var, - Bool default - )= - if select_settings(db, var) is - { - failure then default, //error in the SQL request - success(value) then - if value = "true" then true - else if value = "false" then false - // old values - else if value = "1" then true - else if value = "0" then false - // failback - else if decimal_scan(value) is - { - failure then default, - success(v) then v!=0 - } - }. - -public define One - update_settings - ( - SQLite3DataBase db, - String var, - Bool value - )= - with bool_str = if value is true then "true" else "false", - with binds = (List(SQLite3Bind))[bind_String(":name", var), bind_String(":value", bool_str)], - if select_settings(db, var) is success(_) then - forget(sql_query_timeout(db, "UPDATE settings SET var_value = :value WHERE var_name = :name;", binds, "update_settings")) - else - forget(sql_query_timeout(db, "INSERT INTO settings (var_name, var_value) VALUES (:name, :value)", binds, "update_settings")) - . - -public define One - update_settings - ( - SQLite3DataBase db, - String var, - Int value - )= - with binds = (List(SQLite3Bind))[bind_String(":name", var), bind_Int(":value", value)], - if select_settings(db, var) is success(_) then - forget(sql_query_timeout(db, "UPDATE settings SET var_value = :value WHERE var_name = :name;", binds, "update_settings")) - else - forget(sql_query_timeout(db, "INSERT INTO settings (var_name, var_value) VALUES (:name, :value)", binds, "update_settings")) - . - - -public define One - update_settings - ( - SQLite3DataBase db, - String var, - String value - )= - with binds = (List(SQLite3Bind))[bind_String(":name", var), bind_String(":value", value)], - if select_settings(db, var) is success(_) then - forget(sql_query_timeout(db, "UPDATE settings SET var_value = :value WHERE var_name = :name;", binds, "update_settings")) - else - forget(sql_query_timeout(db, "INSERT INTO settings (var_name, var_value) VALUES (:name, :value)", binds, "update_settings")) - . - diff --git a/calexium_lib/database/sqlite_foreign_key.anubis b/calexium_lib/database/sqlite_foreign_key.anubis deleted file mode 100644 index 88b32f3..0000000 --- a/calexium_lib/database/sqlite_foreign_key.anubis +++ /dev/null @@ -1,143 +0,0 @@ - - *Project* Anubis - - *Title* SQLite Foreign Key functions - - *Copyright* Copyright (c) Cédric Ricard 2007. - - - - *Author* Cédric Ricard - - *Created* 2007 12 21 - *Satus* Released - *Compatibility* 1.8.4 - -read tools/basis.anubis -read data_base/sqlite.anubis -read data_base/db_tools.anubis -read system/logger.anubis -read data_base/db_types.anubis - - - -define Maybe(One) - my_sql_query - ( - Database db, - String sql, - Logger log - ) = - if sql_query(db, sql) is - { - error(sql_error) then logError(log, "SQL ERROR: " + sql_error.text + "\n ...executing query [" + sql + "]"); failure, - ok(_,_,_) then success(unique) - }. - -public define Maybe(One) - alter_trigger - ( - Database db, - String trigger_name, - String sql, - Logger log - ) = - if sql_query(db, "SELECT sql FROM sqlite_master WHERE type = 'trigger' AND name = " + db_make_sql_string(trigger_name)) is - { - error(sql_error) then logError(log, "SQL ERROR: " + sql_error.text + "\n ...looking for trigger named [" + trigger_name + "]"); failure, - ok(_,cursor,_) then - if cursor(unique) is - { - error(sql_error) then logError(log, "alter_trigger ERROR '" + sql_error.text + "'"); failure, - no_more_row then my_sql_query(db, sql, log), - row(current) then - with old_sql = text(current)(0), - if old_sql /= sql then - logDebug(log, "Old trigger was:\n" + old_sql + "\n"); - logDebug(log, "New trigger is:\n" + sql + "\n"); - logInfo(log, "Updating trigger '" + trigger_name + "'..."); - forget(my_sql_query(db, "DROP TRIGGER [" + trigger_name + "]", log)); - if my_sql_query(db, sql, log) is success(_) then logInfo (log, " --> ok."); success(unique) - else logError(log, " --> error!"); failure - else - success(unique) - } - }. - - - -public define Maybe(One) - make_foreign_key - ( - Database db, - String table_name, - String field_name, - String foreign_table_name, - String foreign_field_name, - FK_Null fk_null, - FK_Cascade fk_cascade, - Logger log - ) = - with constrait_name = table_name + "__" + field_name + "__" + foreign_table_name, - sql_create = - "CREATE TRIGGER [fki__" + constrait_name + "] \n" - + "BEFORE INSERT ON [" + table_name + "] \n" - + "FOR EACH ROW BEGIN \n" - + " SELECT RAISE(ROLLBACK, 'insert on table \"" + table_name + "\" violates foreign key constraint \"fki__" + constrait_name + "\"') \n" - + " WHERE " + (if fk_null is null then " NEW.[" + field_name + "] IS NOT NULL AND \n" else "\n") - + " (SELECT [" + foreign_field_name + "] FROM [" + foreign_table_name + "] WHERE [" + foreign_field_name + "] = NEW.[" + field_name + "]) IS NULL; \n" - + "END", - sql_update = - "CREATE TRIGGER [fku__" + constrait_name + "] \n" - + "BEFORE UPDATE ON [" + table_name + "] \n" - + "FOR EACH ROW BEGIN \n" - + " SELECT RAISE(ROLLBACK, 'update on table \"" + table_name + "\" violates foreign key constraint \"fku__" + constrait_name + "\"') \n" - + " WHERE " + (if fk_null is null then " NEW.[" + field_name + "] IS NOT NULL AND \n" else "\n") - + " (SELECT [" + foreign_field_name + "] FROM [" + foreign_table_name + "] WHERE [" + foreign_field_name + "] = NEW.[" + field_name + "]) IS NULL; \n" - + "END", - sql_delete = - "CREATE TRIGGER [fkd__" + constrait_name + "] \n" - + "BEFORE DELETE ON [" + foreign_table_name + "] \n" - + "FOR EACH ROW BEGIN \n" - + if fk_cascade is { - delete_in_cascade then - " DELETE from [" + table_name + "] WHERE [" + field_name + "] = OLD.[" + foreign_field_name + "];\n", - block_if_children then - " SELECT RAISE(ROLLBACK, 'delete on table \"" + foreign_table_name + "\" violates foreign key constraint \"fku__" + constrait_name + "\"') \n" - + " WHERE (SELECT [" + field_name + "] FROM [" + table_name + "] WHERE [" + field_name + "] = OLD.[" + foreign_field_name + "]) IS NOT NULL; \n" - } - + "END", - if alter_trigger(db, "fki__" + constrait_name, sql_create, log) is failure - then failure - else if alter_trigger(db, "fku__" + constrait_name, sql_update, log) is failure - then failure - else if alter_trigger(db, "fkd__" + constrait_name, sql_delete, log) is failure - then failure - else - success(unique). - - - -public define Maybe(One) - make_foreign_key - ( - Database db, - String table_name, - String field_name, - String foreign_table_name, - String foreign_field_name, - Bool field_can_be_null, - Bool delete, //delete_in_cascade ? - Logger log - ) = - make_foreign_key - ( - db, - table_name, - field_name, - foreign_table_name, - foreign_field_name, - if field_can_be_null then null else not_null, - if delete then delete_in_cascade else block_if_children, - log - ). diff --git a/calexium_lib/mail/authentication.anubis b/calexium_lib/mail/authentication.anubis deleted file mode 100644 index 8fb3a1a..0000000 --- a/calexium_lib/mail/authentication.anubis +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Created by PyramIDE. - * User: ricard - * Date: 07/03/2009 - * Time: 21:42 - * - * To change this template use Tools | Options | Coding | Edit Standard Headers. - */ - -read tools/basis.anubis -read system/bytearray.anubis -read system/string.anubis - - /** Give a timestamp according to RFC2822. this sort of timestamp - * is use for CRAM authentication (Challenge Reponse Authentication Mechanism) - * this time timestamp must unique and not predictable to ensure security - * mechanism of authentication. - * @param dummy One meaning nothing - * @return Sring of the timestamp - */ -public define String - get_time_stamp - ( - String domain - )= - with time = (UTime) unow, - "<"+virtual_machine_id+"."+time.seconds+"@mail."+domain+">". - - /** - */ -public define Bool - apop_md5 - ( - String time_stamp, - String password, - String given_hash - ) = - with my_stamp = time_stamp + password, - my_hash = to_lower(to_ascii(md5(to_byte_array(my_stamp)))), -// print("time_stamp "+ time_stamp + "\n"); -// print("given_hash " + given_hash + "\n"); -// print("my_hash " + my_hash + "\n"); - if to_lower(given_hash) = my_hash then - true - else - false. - - - -define String - hmac_md5_compute - ( - ByteArray data, //message to be cripted - ByteArray key //this is share secret key (i.e. password) - ) = - with ba_data = constant_byte_array(64, 0), - ba_ipad = constant_byte_array(64, 0x36), - ba_opad = constant_byte_array(64, 0x5c), - //put key into ByteArray - //but if key is longer than 64 bytes, then we must apply md5 on it and put it into ByteArray - with ba_key = fill_ByteArray(ba_data, if length(key) > 64 then md5(key) else key), - key_ipad = ba_key : ba_ipad, // XOR key with ipad - key_opad = ba_key : ba_opad, // XOR key with opad - to_lower(to_ascii(md5(key_opad + (md5(key_ipad + data))))). // md5(K (+) ipad) and merge with data - - -public define Bool - hmac_md5_check - ( - ByteArray data, //message to be cripted - ByteArray key, //this is share secret key (i.e. password) - String given_digest //The hash given by the user who want to be authenticated - ) = - if to_lower(given_digest) = hmac_md5_compute(data, key) then -// print("HMAC-MD5 Success \n"); - true - else -// print("HMAC-MD5 Failed \n"); -// print(" My Hash = " + my_hash + "\n"); -// print("User Hash = " + given_digest + "\n"); - false. - -public define Bool - hmac_md5_check - ( - String data, //message to be cripted - String key, //this is share secret key (i.e. password) - String given_digest //The hash given by the user who want to be authenticated - ) = - hmac_md5_check(to_byte_array(data), to_byte_array(key), given_digest). - -public define String - hmac_md5_compute - ( - String data, //message to be cripted - String key //this is share secret key (i.e. password) - ) = - hmac_md5_compute(to_byte_array(data), to_byte_array(key)). diff --git a/calexium_lib/mail/lexers/enhanced_status.anubis b/calexium_lib/mail/lexers/enhanced_status.anubis deleted file mode 100644 index d308513..0000000 --- a/calexium_lib/mail/lexers/enhanced_status.anubis +++ /dev/null @@ -1,355 +0,0 @@ -/* - * - * User: David RENE - * Date: 30/05/2008 - * Time: 03:30 - * (c) Calexium - * - */ - - - - -read tools/basis.anubis - - - We want to test email addresses. Below is a regular expression for that - purpose. Actually, this expression is too nave. A real one would be more complicated. - - -read tools/streams.anubis -read system/string.anubis - -type LM_TokenOrError_EnhancedStatus: - end_of_file, - token(List(Word8)), - error. - -type LM_LexerState_EnhancedStatus: ... - -type LM_Match_EnhancedStatus: - match(List(Word8) characters, - (LM_LexerState_EnhancedStatus,List(Word8)) -> (LM_LexerState_EnhancedStatus,LM_TokenOrError_EnhancedStatus) action, - Bool aeol, - Bool abol). - -type LM_LexerState_EnhancedStatus: - lexer_state(Stream input, - List(Word8) unput, // in natural order - List(Word8) more, // in reverse order - LM_LexerState_EnhancedStatus -> (LM_LexerState_EnhancedStatus,LM_TokenOrError_EnhancedStatus) lexer, - Bool at_end_of_line, - Bool at_beginning_of_line, - Maybe(LM_Match_EnhancedStatus) match). - -define LM_LexerState_EnhancedStatus - lm_initial_state - ( - Stream input, - LM_LexerState_EnhancedStatus -> (LM_LexerState_EnhancedStatus,LM_TokenOrError_EnhancedStatus) lexer - ) = - lexer_state(input,[],[],lexer,false,true,failure). - -define (LM_LexerState_EnhancedStatus,Word8) - lm_next_char - ( - LM_LexerState_EnhancedStatus ls - ) = - if ls is lexer_state(input,unput,more,lex,aeol,abol,match) then - if unput is - { - [ ] then - if read_byte(input) is - { - failure then - (lexer_state(input, - [], - more, - lex, - true, - aeol, - match), - -1), - - success(c) then - (lexer_state(input, - [], - [c . more], - lex, - c = '\n', - aeol, - match), - c), - }, - - [h . t] then - (lexer_state(input, - t, - [h . more], - lex, - h = '\n', - aeol, - match), - h) - }. - -define LM_LexerState_EnhancedStatus - lm_remember_match - ( - (LM_LexerState_EnhancedStatus,List(Word8)) -> (LM_LexerState_EnhancedStatus,LM_TokenOrError_EnhancedStatus) action, - LM_LexerState_EnhancedStatus ls - ) = - if ls is lexer_state(input,unput,more,lex,aeol,abol,m) then - with chars = if m is - { - failure then [], - success(match) then - if match is match(chars,_,_,_) then chars - }, - lexer_state(input, - unput, - [], - lex, - aeol, - abol, - success(match(append(more,chars),action,aeol,abol))). - -define (LM_LexerState_EnhancedStatus,LM_TokenOrError_EnhancedStatus) - lm_find_match - ( - LM_LexerState_EnhancedStatus ls - ) = - if ls is lexer_state(input,unput,more,lex,_,_,mb_m) then - if mb_m is - { - failure then (ls,error), - success(m) then - if m is match(chars,action,aeol,abol) then - action(lexer_state(input, - append(more,unput), - [], - lex, - aeol, - abol, - failure), - reverse(chars)) - }. - -define LM_LexerState_EnhancedStatus - change_lexer - ( - LM_LexerState_EnhancedStatus ls, - LM_LexerState_EnhancedStatus -> (LM_LexerState_EnhancedStatus,LM_TokenOrError_EnhancedStatus) lex - ) = - if ls is lexer_state(input,unput,more,_,aeol,abol,mb_m) then - lexer_state(input,unput,more,lex,aeol,abol,mb_m). - -define LM_LexerState_EnhancedStatus - clear_abol - ( - LM_LexerState_EnhancedStatus ls - ) = - if ls is lexer_state(input,unput,more,lex,aeol,_,mb_m) then - lexer_state(input,unput,more,lex,aeol,false,mb_m). - - Declarations of all lexer states. - - -public define (LM_LexerState_EnhancedStatus,LM_TokenOrError_EnhancedStatus) enhanced_status_tester(LM_LexerState_EnhancedStatus ls). -define (LM_LexerState_EnhancedStatus,LM_TokenOrError_EnhancedStatus) enhanced_status_tester_state_1(LM_LexerState_EnhancedStatus ls). -define (LM_LexerState_EnhancedStatus,LM_TokenOrError_EnhancedStatus) enhanced_status_tester_state_2(LM_LexerState_EnhancedStatus ls). -define (LM_LexerState_EnhancedStatus,LM_TokenOrError_EnhancedStatus) enhanced_status_tester_state_3(LM_LexerState_EnhancedStatus ls). -define (LM_LexerState_EnhancedStatus,LM_TokenOrError_EnhancedStatus) enhanced_status_tester_state_4(LM_LexerState_EnhancedStatus ls). -define (LM_LexerState_EnhancedStatus,LM_TokenOrError_EnhancedStatus) enhanced_status_tester_state_5(LM_LexerState_EnhancedStatus ls). -define (LM_LexerState_EnhancedStatus,LM_TokenOrError_EnhancedStatus) enhanced_status_tester_state_6(LM_LexerState_EnhancedStatus ls). -define (LM_LexerState_EnhancedStatus,LM_TokenOrError_EnhancedStatus) enhanced_status_tester_state_7(LM_LexerState_EnhancedStatus ls). -define (LM_LexerState_EnhancedStatus,LM_TokenOrError_EnhancedStatus) enhanced_status_tester_state_8(LM_LexerState_EnhancedStatus ls). -define (LM_LexerState_EnhancedStatus,LM_TokenOrError_EnhancedStatus) enhanced_status_tester_action_0 - (LM_LexerState_EnhancedStatus ls, List(Word8) text). -define (LM_LexerState_EnhancedStatus,LM_TokenOrError_EnhancedStatus) enhanced_status_tester_action_1 - (LM_LexerState_EnhancedStatus ls, List(Word8) text). -define (LM_LexerState_EnhancedStatus,LM_TokenOrError_EnhancedStatus) enhanced_status_tester_action_2 - (LM_LexerState_EnhancedStatus ls, List(Word8) text). - - - Lexer states. - - -public define (LM_LexerState_EnhancedStatus,LM_TokenOrError_EnhancedStatus) - enhanced_status_tester - ( - LM_LexerState_EnhancedStatus ls, - ) = - if at_beginning_of_line(ls) - then enhanced_status_tester_state_3(clear_abol(ls)) else - if lm_next_char(ls) is (ls,c) then - if c = -1 then enhanced_status_tester_state_1(ls) else - if c = 50 then enhanced_status_tester_state_4(ls) else - if (52 +=< c & c +=< 53) then enhanced_status_tester_state_4(ls) else - lm_find_match(ls). - - -define (LM_LexerState_EnhancedStatus,LM_TokenOrError_EnhancedStatus) - enhanced_status_tester_state_1 - ( - LM_LexerState_EnhancedStatus ls, - ) = - with ls = lm_remember_match(enhanced_status_tester_action_2,ls), - if lm_next_char(ls) is (ls,c) then - lm_find_match(ls). - - -define (LM_LexerState_EnhancedStatus,LM_TokenOrError_EnhancedStatus) - enhanced_status_tester_state_2 - ( - LM_LexerState_EnhancedStatus ls, - ) = - if lm_next_char(ls) is (ls,c) then - lm_find_match(ls). - - -define (LM_LexerState_EnhancedStatus,LM_TokenOrError_EnhancedStatus) - enhanced_status_tester_state_3 - ( - LM_LexerState_EnhancedStatus ls, - ) = - with ls = lm_remember_match(enhanced_status_tester_action_1,ls), - if lm_next_char(ls) is (ls,c) then - lm_find_match(ls). - - -define (LM_LexerState_EnhancedStatus,LM_TokenOrError_EnhancedStatus) - enhanced_status_tester_state_4 - ( - LM_LexerState_EnhancedStatus ls, - ) = - if lm_next_char(ls) is (ls,c) then - if c = 46 then enhanced_status_tester_state_5(ls) else - if c = 50 then enhanced_status_tester_state_4(ls) else - if (52 +=< c & c +=< 53) then enhanced_status_tester_state_4(ls) else - lm_find_match(ls). - - -define (LM_LexerState_EnhancedStatus,LM_TokenOrError_EnhancedStatus) - enhanced_status_tester_state_5 - ( - LM_LexerState_EnhancedStatus ls, - ) = - if lm_next_char(ls) is (ls,c) then - if c = 46 then enhanced_status_tester_state_5(ls) else - if (48 +=< c & c +=< 57) then enhanced_status_tester_state_6(ls) else - lm_find_match(ls). - - -define (LM_LexerState_EnhancedStatus,LM_TokenOrError_EnhancedStatus) - enhanced_status_tester_state_6 - ( - LM_LexerState_EnhancedStatus ls, - ) = - if lm_next_char(ls) is (ls,c) then - if c = 46 then enhanced_status_tester_state_7(ls) else - if (48 +=< c & c +=< 57) then enhanced_status_tester_state_6(ls) else - lm_find_match(ls). - - -define (LM_LexerState_EnhancedStatus,LM_TokenOrError_EnhancedStatus) - enhanced_status_tester_state_7 - ( - LM_LexerState_EnhancedStatus ls, - ) = - if lm_next_char(ls) is (ls,c) then - if c = 46 then enhanced_status_tester_state_7(ls) else - if (48 +=< c & c +=< 57) then enhanced_status_tester_state_8(ls) else - lm_find_match(ls). - - -define (LM_LexerState_EnhancedStatus,LM_TokenOrError_EnhancedStatus) - enhanced_status_tester_state_8 - ( - LM_LexerState_EnhancedStatus ls, - ) = - with ls = lm_remember_match(enhanced_status_tester_action_0,ls), - if lm_next_char(ls) is (ls,c) then - if (48 +=< c & c +=< 57) then enhanced_status_tester_state_8(ls) else - lm_find_match(ls). - - -define (LM_LexerState_EnhancedStatus,LM_TokenOrError_EnhancedStatus) - enhanced_status_tester_action_0 - ( - LM_LexerState_EnhancedStatus ls, - List(Word8) text - ) = - (ls,token(text)). - - -define (LM_LexerState_EnhancedStatus,LM_TokenOrError_EnhancedStatus) - enhanced_status_tester_action_1 - ( - LM_LexerState_EnhancedStatus ls, - List(Word8) text - ) = - /* default action */ enhanced_status_tester(ls) . - - -define (LM_LexerState_EnhancedStatus,LM_TokenOrError_EnhancedStatus) - enhanced_status_tester_action_2 - ( - LM_LexerState_EnhancedStatus ls, - List(Word8) text - ) = - /* default action */ (ls,end_of_file) . - - - Since '@' is a normal character, a string needs to contain exactly one '@' for being - accepted. What is accepted before and after this '@' is described by: - - [a-zA-Z]+(\.[a-zA-Z]+)* - - The first part: [a-zA-Z]+ means ``at least one letter''. The last part: (\.[a-zA-Z]+)* - means: ``a dot followed by at least one letter, and this may be repeated any number of - times (including zero)''. - - - This part of the source file is the 'postambule' (just Anubis text, which is copied 'as - is' to the lexer_maker output file). - - The above stuff produces a function named 'email_tester' into the lexer_maker output - file. This function is used below: - -define Maybe(String) - _extract_enhanced_status - ( - List(String) lines - ) = - if lines is - { - [ ] then failure, - [h . t] then - with ls = lexer_state(make_stream(h),[],[],enhanced_status_tester,true,false,failure), - if enhanced_status_tester(ls) is (_,result) then - if result is - { - end_of_file then _extract_enhanced_status(t), - token(tok) then success(implode(tok)) - error then _extract_enhanced_status(t) - } - }. - -public define Maybe(String) - extract_enhanced_status - ( - List(String) lines - ) = - if lines is - { - [ ] then failure, - [h . t] then - if _extract_enhanced_status(split_by_token(h, ' ')) is - { - failure then extract_enhanced_status(t), - success(r) then success(r) - } - }. - - diff --git a/calexium_lib/mail/send_mail.anubis b/calexium_lib/mail/send_mail.anubis deleted file mode 100644 index 1d261f0..0000000 --- a/calexium_lib/mail/send_mail.anubis +++ /dev/null @@ -1,204 +0,0 @@ -/* - * Created by PyramIDE. - * User: ricard - * Date: 22/12/2008 - * Time: 17:49 - * - */ - - -read tools/basis.anubis -read tools/connections.anubis -read tools/printable_tree.anubis -read network/dns.anubis -read network/tools.anubis -read system/files.anubis -read system/string.anubis -read system/data_io.anubis -read system/logger.anubis - -read calexium_lib/net_services_protocols/logger_service.anubis - -read lexers/enhanced_status.anubis -read smtp_server_extensions.anubis -read authentication.anubis -read smtp_client.anubis - -public define String send_mail_log = "SendMail". -public define LogMask send_mail_mask = logMask("send_mail"). - -define Int _sendmail_time_out = 300. //5 minutes of timeout - - public type SendMailResult: - ok, - error, - reply(Int code, String enhanced_status, List(String) lines). - -public type Str_HostName: - str_host_name(String str). - -public type Str_Sender: - str_sender(String str). - -public type Str_Recipient: - str_recipient(String str). - -public type Str_UID: - str_UID(String str). - -public type Send_Param: - send_param( Str_HostName host_name, - Str_Sender sender, - Str_Recipient recipient, - List(Data_IO) mail_parts, - SmtpAuth auth, - Str_UID mail_uid, - Int last_smtp_code //0 means it's the first time - ). - - - - -define Result(SmtpClientResult, One) - sm_MAIL_FROM - ( - RWStream conn, - Send_Param param, - SmtpClientSession sm_session, - (Int) -> One progress_report, - (LogLevel, String) -> One logger - ) = - with enhanced_status = sm_session.enhanced_status, - //send MAIL FROM - if send_mail_from(conn, param.sender.str, sm_session, _sendmail_time_out, logger) is - { - error(result) then error(result), - ok(_) then - //send RCPT TO - if send_recipient(conn, param.recipient.str, sm_session, _sendmail_time_out, logger) is - { - error(result) then error(result), - ok(_) then - //send DATA - if send_data(conn, sm_session, _sendmail_time_out, logger) is - { - error(result) then error(result), - ok(_) then - if send_content(conn, param.mail_parts, sm_session, _sendmail_time_out, progress_report, logger) is - { - error(result) then error(result), - ok(_) then - send_quit(conn, sm_session, _sendmail_time_out, logger); - logger(logTrace, "SENT Mail FROM "+param.sender.str+" TO "+param.recipient.str); - ok(unique) - } - } - } - }. - - - Apply the whole protocol: - - // we can have a list of part file in param type. This can be very useful when we want - // to send file as mailing. For the mailing, in each mail, only the header is different of the - // other mails. The body part is the same. Then, the mailing sender can generate the header in one - // file and keep the body in other file wich can be given to send_mail function as last file in the list -public define Result(SmtpClientResult, One) - send_mail - ( - RWStream conn, - Send_Param param, - (SmtpClientSession, Send_Param) -> Result(SmtpClientResult, Send_Param) prepare_mail_callback, - (Int) -> One progress_report, - (LogLevel, String) -> One logger - ) = - // - // Our connection to the SMTP server is opened. We just have to apply the protocol. - // - if receive_reply(conn, false, _sendmail_time_out, logger) is - { - error then error(error), - timeout then error(timeout), - no_auth_method then error(no_auth_method), - bad_reply then error(bad_reply), - reply(code, status, lines) then - if code = 220 then - //send EHLO - if send_ehlo(conn, param.host_name.str, _sendmail_time_out, logger) is - { - error(result) then error(result), - ok(sm_session) then - if do_auth(conn, param.auth, sm_session, _sendmail_time_out, logger) is - { - error(auth_result) then error(auth_result), - ok(_) then - if prepare_mail_callback(sm_session, param) is - { - error(prepare_result) then error(prepare_result), - ok(new_param) then sm_MAIL_FROM(conn, new_param, sm_session, progress_report, logger) - } - } - } - else if code = 550 then - //some server answer "550 5.7.1 Client host rejected: cannot find your reverse hostname, [88.181.64.17]" - //before anything, then we try to extract the enhanced status if exists for relaying the mail with the ISP - logger(logDebug, "Converting a 550 error for connection to a 432 error as distant server may be temporary overloaded."); - error(reply(432, status, lines)) - else - error(reply(code, status, lines)) - }. - -public define Result(SmtpClientResult, One) - send_mail - ( - RWStream conn, - Send_Param param, - (SmtpClientSession, Send_Param) -> Result(SmtpClientResult, Send_Param) prepare_mail_callback, - ) = - send_mail(conn, - param, - prepare_mail_callback, - (Int _) |-> unique, - (LogLevel level, String txt) |-> if level is logTrace then logTrace(send_mail_log, send_mail_mask, txt) - else log(level, send_mail_log, txt) - ). - -public define Result(SmtpClientResult, One) - send_mail - ( - RWStream conn, - Send_Param param, - ) = - send_mail(conn, - param, - (SmtpClientSession sm_session, Send_Param param) |-> ok(param) - ). - -public define Result(SmtpClientResult, One) - send_mail - ( - String server, - Word32 port, - Send_Param param, - )= - if resolve_address(server) is - { - failure then - logWarning(send_mail_log,"IP address NOT found for Mail server ["+server+"]"); - error(error), - - success(ip_addr) then - with ip_txt = ip_addr_to_string(ip_addr), - logTrace(send_mail_log, send_mail_mask, "send_mail: Trying to connect to "+ip_txt); - - if (Result(NetworkConnectError,RWStream))connect(ip_addr, port) is - { - error(e) then - logTrace(send_mail_log, send_mail_mask, "send_mail: Can't connect to "+ip_txt); - error(error), - - ok(server_conn) then - send_mail(server_conn, param), - } - }. - diff --git a/calexium_lib/mail/smtp_client.anubis b/calexium_lib/mail/smtp_client.anubis deleted file mode 100644 index 555fc31..0000000 --- a/calexium_lib/mail/smtp_client.anubis +++ /dev/null @@ -1,697 +0,0 @@ -/* - * Created by PyramIDE. - * User: ricard - * Date: 10/03/2009 - * Time: 18:00 - * - */ - -read tools/basis.anubis -read tools/connections.anubis -read tools/printable_tree.anubis -read network/tools.anubis -read system/files.anubis -read system/string.anubis -read system/data_io.anubis -read system/logger.anubis - -read lexers/enhanced_status.anubis -read smtp_server_extensions.anubis -read authentication.anubis - -define ByteArray crlf_dot_crlf = to_byte_array(implode([13,10,'.',13,10])). - -public type SmtpClientResult: - error, - timeout, - no_auth_method, - bad_reply, - reply(Int code, String enhanced_status, List(String) lines). - -public type SmtpClientSession: - smtp_client_session( - Bool enhanced_status, - Maybe(Int) supported_size, - List(String) ehlo_answer - ). - -public type SmtpAuth: - none, - login( String login, - String password). - - /** - * make_sm_session - */ -define SmtpClientSession - make_smtp_client_session - ( - List(String) lines, //lines given in ehlo stage - (LogLevel, String) -> One logger - ) = - //looking for ENHANCEDSTATUSCODES - with session_enhanced_status = has_smtp_extension(lines, enhanced_status_codes), - //looking for SIZE - with session_size = if get_smtp_extension_value(lines, size) is - { - failure then failure, - success(str_value) then - if decimal_scan(str_value) is - { - failure then failure, - success(value) then - logger(logTrace, "smtp server with SIZE "+value); - success(value) - } - }, - smtp_client_session(session_enhanced_status, session_size, lines). - - -type Command_Result: - failure, - timeout, - success(String). - -define Command_Result - receive_command - ( - RStream conn, - List(Word8) so_far, - Word8 previous, - Int time_out, - (LogLevel, String) -> One logger - ) = - if read_network_byte(conn, time_out) is - { - failure then logger(logTrace, "receive_command read_network_byte 0 failure");failure, - timeout then logger(logWarning, "[send_mail] receive_command timeout"); timeout, - success(c) then - if c = 10 & previous = 13 then // - with result = implode(reverse(so_far)), - logger(logTrace, "<-S-"+result); - success(result) - else - if previous = 13 then - receive_command(conn, so_far, c, time_out, logger) - else - receive_command(conn, [previous . so_far], c, time_out, logger) - }. - -define Command_Result - receive_command - ( - RStream conn, - List(Word8) so_far, - Int time_out, - (LogLevel, String) -> One logger - ) = - if read_network_byte(conn, time_out) is - { - failure then logger(logTrace, "receive_command read_network_byte 0 failure"); failure, - timeout then (if time_out = 0 then unique else logger(logWarning, "[send_mail] receive_command timeout")); timeout, - success(c) then receive_command(conn,[], c, time_out, logger) - }. - - -define SmtpClientResult - reply_handling - ( - Int code, - List(String) lines, - Bool enhanced_status - ) = - with result = if enhanced_status then - if extract_enhanced_status(lines) is - { - failure then "", - success(enh) then enh - } - else - "", - reply(code, result, lines). - - -define SmtpClientResult - receive_reply - ( - RStream conn, - List(String) so_far, - Bool enhanced_status, - Int time_out, - (LogLevel, String) -> One logger - ) = - if receive_command(conn, [], time_out, logger) is - { - failure then logger(logError, "receive_reply: error receiving command"); error, - timeout then (if time_out > 0 then logger(logError, "receive_reply: timeout receiving command") else unique); timeout, - success(line) then - //check if we must read another line by presence of hyphen after the reply code - //220-bla bla bla - //220 end of bla bla - if length(line) =< 3 then - if decimal_scan(line) is - { - failure then logger(logError, "receive_reply: can't extract reply code from '" + line + "'"); bad_reply, - success(code) then reply_handling(code, reverse(so_far), enhanced_status) - } - else if nth(3, line) is - { - failure then logger(logError, "receive_reply: error getting 4th character from '" + line +"'"); bad_reply, - success(char) then - if char = '-' then - receive_reply(conn, [line . so_far], enhanced_status, time_out, logger) - else - //decode the code - if sub_string(line, 0, 3) is - { - failure then logger(logError, "receive_reply: error extracting reply code from '" + line+"'"); bad_reply, // should never occure - success(code_str) then - if decimal_scan(code_str) is - { - failure then logger(logError, "receive_reply: can't extract reply code from '" + code_str + "'"); bad_reply, //unreadable code - success(code) then - reply_handling(code , reverse([line . so_far]), enhanced_status) - } - } - } - }. - -public define SmtpClientResult - receive_reply - ( - RWStream conn, - Bool enhanced_status, - Int timeout, - (LogLevel, String) -> One logger - ) = - receive_reply(weaken(conn), [], enhanced_status, timeout, logger). - - -define Result(SmtpClientResult, $T) - check_smtp_result - ( - SmtpClientResult result, - Int expected_code, - (SmtpClientResult) -> $T get_success_value - ) = - if result is reply(code, status, lines) then - if code = expected_code then - ok(get_success_value(result)) - else - error(result) - else - error(result). - - Sending a piece of text (String) from the begining. - -public define Maybe(One) - smtp_send_line - ( - RWStream conn, - String text, - (LogLevel, String) -> One logger - ) = - if reliable_write(tcp(conn),[text + crlf]) is - { - failure then logger(logError, "smtp_send_line: error writing '" + text + "'"); failure, - success(_) then - logger(logTrace, "-C->"+text);success(unique) - } . - -// helper -/** - * Allows to send a SMTP command very simply. - * You just need to provide the expected result code, and a function that extract data from reply. - * This function will be called only in case of success. Else, the answer is returned verbatim. - */ -public define Result(SmtpClientResult, $T) - smtp_send_command - ( - RWStream conn, - String command, - Int expected_code, - SmtpClientResult -> $T get_success_value, - SmtpClientSession session, - Int timeout, - (LogLevel, String) -> One logger - ) = - if smtp_send_line(conn, command, logger) is - { - failure then logger(logError, "error sending '" + command + "'"); error(error), - success(_) then check_smtp_result(receive_reply(conn, session.enhanced_status, timeout, logger), expected_code, get_success_value) - }. - -/** - * Allows to send a SMTP command very simply. - * You just need to provide the expected result code. No data is returned in cas of success. - * Else, the answer is returned verbatim. - */ -public define Result(SmtpClientResult, One) - smtp_send_command - ( - RWStream conn, - String command, - Int expected_code, - SmtpClientSession session, - Int time_out, - (LogLevel, String) -> One logger - ) = - if smtp_send_line(conn, command, logger) is - { - failure then logger(logError, "error sending '" + command + "'"); error(error), - success(_) then check_smtp_result(receive_reply(conn, session.enhanced_status, time_out, logger), expected_code, (SmtpClientResult _) |-> unique) - }. - - - // Try to send the 'HELO' command and get the reply. Return 'true' if you cannot. - -public define Result(SmtpClientResult, SmtpClientSession) - send_ehlo - ( - RWStream conn, - String our_host_name, - Int time_out, - (LogLevel, String) -> One - logger - ) = - if smtp_send_line(conn,"EHLO "+our_host_name, logger) is - { - failure then logger(logError, "send_ehlo: error sending EHLO"); error(error), - success(_) then - with rep = with result = receive_reply(conn, false, time_out, logger), - if result is reply(code, status, lines) then - if code = 250 then - ok(make_smtp_client_session(lines, logger)) - - //we manage the 500 error, that mean the remote server is not ESMTP - //hence we try we with HELO, the old manner RFC 821 - else if code = 500 | code = 502 then - if smtp_send_line(conn,"HELO "+our_host_name, logger) is - { - failure then logger(logError, "send_ehlo: error sending HELO"); error(error), - success(_) then - with result2 = receive_reply(conn, false, time_out, logger), - if result2 is reply(code, status, lines) then - if code = 250 then ok(make_smtp_client_session(lines, logger)) - else error(result2) - else - error(result2) - } - else - error(result) - else - error(result), - if rep is error(result) then - if result is reply(code, status, lines) then - if code = 550 then // some server simply refuse us because it's temporary overloaded (especially try when sending mailings) - logger(logDebug, "Converting a 550 error for EHLO to a 432 error as distant server may be temporary overloaded."); - error(reply(432, status, lines)) - else - rep - else - rep - else - rep - }. - - The same one for 'MAIL FROM': - -define String - check_email_syntax - ( - String email - ) = - if nth(0, email) is - { - failure then "<>", - success(b) then - if b = '<' then email - else "<" + email + ">" - }. - - -public define Result(SmtpClientResult, One) - send_mail_from - ( - RWStream conn, - String sender, - SmtpClientSession session, - Int timeout, - (LogLevel, String) -> One logger - ) = - with rfc_sender = check_email_syntax(sender), - smtp_send_command(conn, "MAIL FROM:"+rfc_sender, 250, session, timeout, logger). -// if smtp_send_line(conn,"MAIL FROM:"+rfc_sender, logger) is -// { -// failure then logger(logError, "error sending 'MAIL FROM:" + rfc_sender + "'"); error(error), -// success(_) then check_smtp_result(receive_reply(conn, session.enhanced_status, timeout, logger), 250, unique) -// }. - - The same one for 'RCPT TO': - -public define Result(SmtpClientResult, One) - send_recipient - ( - RWStream conn, - String recipient, - SmtpClientSession session, - Int timeout, - (LogLevel, String) -> One logger - ) = - with rfc_recipient = check_email_syntax(recipient), - smtp_send_command(conn, "RCPT TO:"+rfc_recipient, 250, session, timeout, logger). -// if smtp_send_line(conn,"RCPT TO:"+rfc_recipient, logger) is -// { -// failure then logger(logError, "error sending 'RCPT TO:"+rfc_recipient+"'"); error, -// success(_) then check_smtp_result(receive_reply(conn, session.enhanced_status, timeout, logger), 250, unique) -// }. - - Try to send 'DATA' and get the reply. Answer 'true' if you cannot. - -public define Result(SmtpClientResult, One) - send_data - ( - RWStream conn, - SmtpClientSession session, - Int timeout, - (LogLevel, String) -> One logger - ) = - smtp_send_command(conn, "DATA", 354, session, timeout, logger). -// if smtp_send_line(conn,"DATA", logger) is -// { -// failure then logger(logError, "error sending DATA"); error, -// success(_) then check_smtp_result(receive_reply(conn, session.enhanced_status, timeout, logger), 250, unique) -// }. - - - - - The same for the content of the message. We need base64 encoding. - -read tools/base64.anubis -type SendContentResult: - smtp_reply(SmtpClientResult), - copy_error(Int written), - copy_ok(Int written). - -define Maybe(One) - sm_flush - ( - ByteArray buffer, - WStream target, - Int buffer_start_time, - (LogLevel, String) -> One logger - )= - if write( target , buffer) is - { - failure then failure, - success(nb_write) then - if now - buffer_start_time > 120 then - // security to avoid queue blocking - logger(logError, "sm_flush: TIMEOUT sending a " + length(buffer) + " byte-length buffer (taking more than 2 minutes). SendMail canceled."); - failure - else - with buffer_size = length(buffer), - if nb_write = buffer_size then - success(unique) - else - with new_buffer = extract(buffer, nb_write, buffer_size), - sm_flush(new_buffer, target, buffer_start_time, logger) - }. - -define SendContentResult - sm_copy_Data_IO_to_Stream - ( - Data_IO source, - RWStream target, - SmtpClientSession session, - Int start_time, - Int so_far, - Int last_reply_check, - (Int) -> One progress_report, - (LogLevel, String) -> One logger - ) = - if last_reply_check + 60 < now then - if receive_reply(weaken(target), [], session.enhanced_status, 0, logger) is - { - error then copy_error(so_far), - timeout then - sm_copy_Data_IO_to_Stream(source, target, session, start_time, so_far, now, progress_report, logger) - no_auth_method then copy_error(so_far), // impossible - bad_reply then copy_error(so_far), - reply(code, status, lines) then - smtp_reply(reply(code, status, lines)) - } - else - if read_line(source, 1024) is - { - error then logger(logError, "send_content: failed to read input data_io"); copy_error(so_far), - timeout then logger(logError, "send_content: timeout reading input data_io"); copy_error(so_far), - eof then copy_ok(so_far), - ok(line) then - with buffer = to_byte_array((if nth(0, line) is success(char) then if char = '.' then "." + line else line else line)), - if sm_flush( buffer, weaken(target), now, logger ) is - { - failure then copy_error(so_far), - success(_) then - with len = length(line) + 2, // 2 is for the CRLF - progress_report(so_far + len); - sm_copy_Data_IO_to_Stream(source, target, session, start_time, so_far + len, last_reply_check, progress_report, logger) - }, - }. - -define SendContentResult - sm_copy_Data_IO_List_to_Stream - ( - List(Data_IO) io_list, - RWStream target, - SmtpClientSession session, - Int start_time, - Int so_far, - (Int) -> One progress_report, - (LogLevel, String) -> One logger - )= - if io_list is - { - [] then copy_ok(so_far), - [ h . t ] then - if rewind(h)(unique) then - with result = sm_copy_Data_IO_to_Stream(h, target, session, start_time, 0, now, progress_report, logger), - if result is copy_ok(written) then - sm_copy_Data_IO_List_to_Stream(t, target, session, start_time, so_far + written, progress_report, logger) - else - result - else - copy_error(so_far) - }. - -public define Result(SmtpClientResult, One) - send_content - ( - RWStream conn, - List(Data_IO) mail_part, - SmtpClientSession session, - Int timeout, - (Int) -> One progress_report, - (LogLevel, String) -> One logger - ) = - with start_time = now, - if sm_copy_Data_IO_List_to_Stream(mail_part, conn, session, now, 0, progress_report, logger) is - { - smtp_reply(reply) then error(reply) - copy_error(written) then - with finish_time = now, - logger(logError, "send_content: error sending data"); - logger(logTrace, "send_content: "+written+" bytes sent in "+finish_time - start_time+" second(s)"); - if written > 1024000 then - logger(logInfo, "send_content: may be due to over sized mail. Convert it to 452 error."); - error(reply(452, "", ["Error sending big email (more than 1 Mb)"])) - else - error(error), - copy_ok(size) then - if reliable_write(tcp(conn), [crlf_dot_crlf]) is - { - failure then logger(logError, "send_content: error writing CRLF.CRLF"); error(error), - success(_) then - with finish_time = (Int)now, - logger(logTrace, "mail sent "+size+" bytes in "+finish_time - start_time+" second(s)"); - check_smtp_result(receive_reply(conn, session.enhanced_status, timeout, logger), 250, (SmtpClientResult _) |-> unique) - } - }. - - - Almost the same for 'QUIT': - -public define One - send_quit - ( - RWStream conn, - SmtpClientSession session, - Int timeout, - (LogLevel, String) -> One logger - ) = - forget(smtp_send_command(conn, "QUIT", 221, session, timeout, logger)). - -// if smtp_send_line(conn,"QUIT", logger) is -// { -// failure then logger(logWarning, "error sending QUIT"), -// success(_) then forget(receive_reply(conn, session.enhanced_status, timeout, logger)) -// }. - -define List(String) - get_auth_method - ( - List(String) lines, - List(String) so_far - )= - if lines is - { - [] then so_far, - [h . t] then - if sub_string(h, 4, 4) is - { - failure then get_auth_method(t, so_far), - success(s) then - with current = if insensitive_equal(s, "AUTH") then - force_Type(list_word(h,9),[]) - else - [], - get_auth_method(t, current + so_far) - } - }. - -public define Result(SmtpClientResult, One) - do_auth_plain - ( - RWStream conn, - String login, - String password, - SmtpClientSession session, - Int timeout, - (LogLevel, String) -> One logger - )= - - with plain_str = "AUTH PLAIN "+ to_string(base64_encode(to_byte_array("") - + constant_byte_array(1,0) - + to_byte_array(login) - + constant_byte_array(1,0) - + to_byte_array(password), - false)), - smtp_send_command(conn, plain_str, 235, session, timeout, logger). -// if smtp_send_line(conn, plain_str, logger) is -// { -// failure then error, -// success(_) then check_smtp_result(receive_reply(conn, session.enhanced_status, timeout, logger), 235, unique) -//// { -//// error then error -//// timeout then timeout, -//// reply(code, status, lines) then -//// if code = 235 then -//// ok(235, lines) -//// else -//// reply_handling(code,lines,enhanced_status), -//// ok(code, lines) then ok(code, lines) -//// } -// }. - -public define Result(SmtpClientResult, One) - do_auth_login - ( - RWStream conn, - String login, - String password, - SmtpClientSession session, - Int timeout, - (LogLevel, String) -> One logger - )= - if smtp_send_command(conn, "AUTH LOGIN", 334, session, timeout, logger) is - { - error(result) then error(result), - ok(_) then - if smtp_send_command(conn, base64_encode(login, false), 334, session, timeout, logger) is - { - error(result) then error(result), - ok(_) then - smtp_send_command(conn, base64_encode(password, false), 235, session, timeout, logger) - } - }. - -public define Result(SmtpClientResult, One) - do_auth_cram_md5 - ( - RWStream conn, - String login, - String password, - SmtpClientSession session, - Int timeout, - (LogLevel, String) -> One logger - )= - with get_challenge = (SmtpClientResult result) |-> - if result is - { - error then "", - timeout then "", - no_auth_method then "", - bad_reply then "", - reply(code, status, lines) then - if lines is [h . _] then - if split(h, ' ') is [_ . t] then - if t is [challenge . _] then - //println("challenge : " + challenge); - base64_decode(challenge) - else "" - else "" - else "", - }, - if smtp_send_command(conn, "AUTH CRAM-MD5", 334, get_challenge, session, timeout, logger) is - { - error(result) then error(result), - ok(challenge) then - with digest = hmac_md5_compute(challenge, password), -// println("challenge: " + challenge); -// println("decoded : " + login + " " + digest); - smtp_send_command(conn, base64_encode(login + " " + digest, false), 235, session, timeout, logger) - }. - -public define Result(SmtpClientResult, One) - do_login - ( - RWStream conn, //tcp connection - List(String) auth_list, //list of available authentication method - String login, - String password, - SmtpClientSession session, - Int timeout, - (LogLevel, String) -> One logger - )= - if member(auth_list, "CRAM-MD5", insensitive_equal) then - do_auth_cram_md5(conn, login, password, session, timeout, logger) - else if member(auth_list, "PLAIN", insensitive_equal) then - do_auth_plain(conn, login, password, session, timeout, logger) - else if member(auth_list, "LOGIN", insensitive_equal) then - do_auth_login(conn, login, password, session, timeout, logger) - - else - logger(logError, "do_login: none of CRAM-MD5, LOGIN or PLAIN method available"); error(no_auth_method). - -public define Result(SmtpClientResult, One) - do_auth - ( - RWStream conn, //tcp connection - SmtpAuth auth, //authentication method to use for that session - SmtpClientSession session, - Int timeout, - (LogLevel, String) -> One logger - )= - if auth is - { - none then ok(unique), //no need to authenticate, this is a "panties festival" - login(user, password) then - with auth_list = get_auth_method(session.ehlo_answer, []), - if auth_list is - { - [] then logger(logError, "do_auth error"); error(no_auth_method), - [_ . _] then do_login(conn, auth_list, user, password, session, timeout, logger) - } - }. - diff --git a/calexium_lib/mail/smtp_server_extensions.anubis b/calexium_lib/mail/smtp_server_extensions.anubis deleted file mode 100644 index 3482d35..0000000 --- a/calexium_lib/mail/smtp_server_extensions.anubis +++ /dev/null @@ -1,90 +0,0 @@ -/* - * - * User: David RENE - * Date: 30/05/2008 - * Time: 01:18 - * (c) Calexium - * - */ - -read tools/basis.anubis -read system/string.anubis - -public type SMTP_Extension_verb: - smtp_extension_verb - ( - String verb - ). - -public define SMTP_Extension_verb enhanced_status_codes = smtp_extension_verb("ENHANCEDSTATUSCODES"). -public define SMTP_Extension_verb size = smtp_extension_verb("SIZE"). - -define Bool - has_smtp_extension - ( - List(String) lines, //left lines given in ehlo stage - Int length, - String search_ext - )= - if lines is - { - [] then false, - [h . t] then - if sub_string(h, 4, length) is - { - failure then has_smtp_extension(t, length, search_ext), - success(s) then - if insensitive_equal(s, search_ext) then - true - else - has_smtp_extension(t, length, search_ext), - } - }. - -public define Bool - has_smtp_extension - ( - List(String) lines, //left lines given in ehlo stage - SMTP_Extension_verb search_ext - )= - has_smtp_extension(lines, length(search_ext.verb), search_ext.verb). - -define Maybe(String) - get_smtp_extension_value - ( - List(String) lines, //left lines given in ehlo stage - Int len, - String search_ext - )= - if lines is - { - [] then failure, - [h . t] then - if sub_string(h, 4, len) is - { - failure then get_smtp_extension_value(t, len, search_ext), - success(s) then - if insensitive_equal(s, search_ext) then - sub_string(h, 5+len, length(h)-(5+len)) - else - get_smtp_extension_value(t, len, search_ext), - } - }. - - /** - * return the value of wanted smtp extension name - * for "SIZE 10000" it return 10000. - * if the smtp verb doesn't exist, it return failure - */ - -public define Maybe(String) - get_smtp_extension_value - ( - List(String) lines, //left lines given in ehlo stage - SMTP_Extension_verb search_ext - )= - if has_smtp_extension(lines, length(search_ext.verb), search_ext.verb) then - get_smtp_extension_value(lines, length(search_ext.verb), search_ext.verb) - else - failure. - diff --git a/calexium_lib/net_services/CXM_generic_client.anubis b/calexium_lib/net_services/CXM_generic_client.anubis deleted file mode 100644 index ee16108..0000000 --- a/calexium_lib/net_services/CXM_generic_client.anubis +++ /dev/null @@ -1,277 +0,0 @@ -/* - * Created by PyramIDE. - * User: ricard - * Date: 02/02/2008 - * Time: 11:47 - * - * To change this template use Tools | Options | Coding | Edit Standard Headers. - */ - - -read tools/basis.anubis -read system/muscle.anubis -read system/data_io.anubis -read system/convert.anubis -read system/string.anubis -read system/message_queue.anubis -read system/message_transceiver.anubis -read tools/connections.anubis - -read calexium_lib/CXM_message_constants.anubis -read calexium_lib/net_services/CXM_net_services.anubis -read calexium_lib/net_services/CXM_generic_protocol.anubis - -// --Generic types--------------------------------------------------------------------- -public type NetServiceAnswer: - netservice_error (Word32 cmd, - Word32 result_code, - String result_string), - netservice_ok (Word32 cmd, - Maybe(Message) result_msg). - -// --Generic functions--------------------------------------------------------------------- - - -/** - * Sends the message to the server then parses the answer and returns the RESULT message on CMD success. - */ -public define Maybe(NetServiceAnswer) - generic_send_message - ( - MessageQueue queue, - Message msg_to_send, - Int timeout, - (String) -> One logger - )= - queue.add_Message_to_send(msg_to_send); - if queue.get_next_received_Message(timeout) is - { - timeout then logger("["+queue.get_name(unique)+"]: receive timeout");failure, - closed then logger("["+queue.get_name(unique)+"]: socket closed");failure, - msg(msg) then - if find_int32(msg, "CMD") is - { - failure then logger("["+queue.get_name(unique)+"]: CMD field not found"); failure, - success(cmd) then - if find_int32(msg, "STATUS") is - { - failure then logger("["+queue.get_name(unique)+"]: STATUS field not found"); failure, - success(v) then - if v = _CXM_OK then - success(netservice_ok(cmd, find_message(msg, "RESULT"))) - else - with error_string = if find_string(msg, "STATUS_MSG") is success(s) then s else "", - success(netservice_error(cmd, v, error_string)) - } - } - }. - -public define Maybe($T) - simple_handler - ( - MessageQueue queue, - String timestamp, - Int timeout, - Message msg_to_send, - (Message, MessageQueue, String) -> Maybe($T) handler, - (String) -> One logger - ) = - if generic_send_message(queue, msg_to_send, timeout, logger) is - { - failure then failure, - success(net_result) then - if net_result is - { - netservice_error(cmd, err_code, err_str) then - logger("["+queue.get_name(unique)+"]: message status ERROR [0x" + to_hexa(err_code) + ", '" + err_str + "']"); - failure, - netservice_ok(cmd, mb_msg) then - if mb_msg is - { - failure then logger("["+queue.get_name(unique)+"]: can't find RESULT message."); failure, - success(result) then handler(result, queue, timestamp) - } - } - }. - -public define Maybe(One) - no_result_handler - ( - MessageQueue queue, - Int timeout, - Message msg_to_send, - (String) -> One logger - ) = - if generic_send_message(queue, msg_to_send, timeout, logger) is - { - failure then failure, - success(net_result) then - if net_result is - { - netservice_error(cmd, err_code, err_str) then - logger("["+queue.get_name(unique)+"]: message status ERROR [0x" + to_hexa(err_code) + ", '" + err_str + "']"); - failure, - netservice_ok(cmd, mb_msg) then - if mb_msg is - { - failure then unique, - success(result) then logger("An unattended RESULT msg was found. Ignoring it...") - }; - success(unique) - } - }. - -public define (MessageQueue, String) -> Maybe($T) - make_generic_handler - ( - Int timeout, - Message msg_to_send, - (Message, MessageQueue, String) -> Maybe($T) handler, - (String) -> One logger - ) = - (MessageQueue queue, String timestamp) |-> - simple_handler(queue, timestamp, timeout, msg_to_send, handler, logger). - -define Maybe($T) - generic_request_for_service - ( - MessageQueue queue, - Word32 service_id, - Word32 service_version, - (MessageQueue, String) -> Maybe($T) handler, - (String) -> One logger - )= - with test_msg = message(_CXM_REQUEST_FOR_SERVICE), - forget(add_int32(test_msg, "SERVICE", service_id)); - forget(add_int32(test_msg, "VERSION", service_version)); - queue.add_Message_to_send(test_msg); - if queue.get_next_received_Message(10) is - { - timeout then logger("["+queue.get_name(unique)+"]: requesting service receive timeout");failure, - closed then logger("["+queue.get_name(unique)+"]: requesting service socket closed");failure, - msg(msg) then - if find_int32(msg, "STATUS") is - { - failure then logger("["+queue.get_name(unique)+"]: requesting service STATUS not found");failure, - success(v) then - if v = _CXM_OK then - if find_message(msg, "RESULT") is - { - failure then logger("["+queue.get_name(unique)+"]: requesting service RESULT not found");failure, - success(result) then - with timestamp = if find_string(result, "TIMESTAMP") is - { - failure then logger("["+queue.get_name(unique)+"]: requesting service TIMESTAMP not found"); "", - success(timestamp) then timestamp - }, - handler(queue, timestamp) - } - else - logger("["+queue.get_name(unique)+"]: the requested service is not available on server.");failure - } - }. - -public define Maybe($T) - generic_connect_to_net_service - ( - String queue_name, - Word32 server, - Word32 port, - Word32 service_id, - Word32 service_version, - (MessageQueue, String) -> Maybe($T) handler, - (String) -> One logger - ) - = - if connect( server, port) is - { - error(_) then logger(queue_name + ": Can't connect to domain manager ["+ip_addr_to_string(server)+":"+port+"]");failure, - ok(conn) then -// println("[" + virtual_machine_id + "] netservices create queue"); - with queue = create_MessageQueue(queue_name), - message_transceiver(tcp(conn), queue); -// println("[" + virtual_machine_id + "] netservices generic_request_for_service()"); - with result = generic_request_for_service(queue, service_id, service_version, handler, logger), -// println("[" + virtual_machine_id + "] netservices client quit"); - queue.quit(unique); - result - }. - -define Word32 - get_ip - ( - String url_or_ip, - (String) -> One logger - ) = - //logInfo(debug_log,"Try to resolve URL [" + url_or_ip+ "]."); - if ip_address(url_or_ip) is success(ip) then - //logInfo(debug_log,"Try to resolve URL OK ip"+ip); - ip - else if dns(url_or_ip) is ok(ip_adr) then - //logInfo(debug_log,"Try to resolve URL OK dns"+ip_adr); - ip_adr - else - logger("Can't resolve URL [" + url_or_ip+ "]. Using localhost."); - ip_address((127,0,0,1)). - - -public define Maybe(Word32) - get_ip - ( - String url_or_ip - ) = - //logInfo(debug_log,"Try to resolve URL [" + url_or_ip+ "]."); - if ip_address(url_or_ip) is success(ip) then - //logInfo(debug_log,"Try to resolve URL OK ip"+ip); - success(ip) - else if dns(url_or_ip) is ok(ip_adr) then - //logInfo(debug_log,"Try to resolve URL OK dns"+ip_adr); - success(ip_adr) - else - println("Can't resolve URL [" + url_or_ip+ "]. Using localhost."); - failure. - - /* Same version as above, but server is string containing IP or URL - * It's resolve by get_ip and call generic_connect_to_net_service with IP - */ - -public define Maybe($T) - generic_connect_to_net_service - ( - String queue_name, - String server, - Word32 port, - Word32 service_id, - Word32 service_version, - (MessageQueue, String) -> Maybe($T) handler, - (String) -> One logger - ) - = generic_connect_to_net_service(queue_name, get_ip(server, logger), port, service_id, service_version, handler, logger). - - -public define Maybe($T) - generic_connect_to_net_service_SSL - ( - String queue_name, - String server_name, - Word32 server_ip, - Word32 port, - (Maybe(X509)) -> Bool accept_policy, // your policy for accepting the server certificate in - // case of an invalid, non trusted or missing certificate - Word32 service_id, - Word32 service_version, - (MessageQueue, String) -> Maybe($T) handler, - (String) -> One logger - ) - = - if open_SSL_connection( server_name, server_ip, port, accept_policy) is - { - error(_) then logger(queue_name + ": Can't connect to domain manager ["+ip_addr_to_string(server_ip)+":"+port+"]");failure, - ok(conn) then - with queue = create_MessageQueue(queue_name), - message_transceiver(ssl(conn), queue); - with result = generic_request_for_service(queue, service_id, service_version, handler, logger), - queue.quit(unique); - //logInfo(debug_log,"domain_manager client quit"); - result - }. diff --git a/calexium_lib/net_services/CXM_generic_protocol.anubis b/calexium_lib/net_services/CXM_generic_protocol.anubis deleted file mode 100644 index 433f9d8..0000000 --- a/calexium_lib/net_services/CXM_generic_protocol.anubis +++ /dev/null @@ -1,169 +0,0 @@ -/* - * - * User: David RENE - * Date: 25/04/2007 - * Time: 16:20 - * (c) Calexium - * - */ - -read system/muscle.anubis -read system/data_io.anubis -read system/string.anubis -read tools/basis.anubis -read system/message_queue.anubis -read calexium_lib/CXM_message_constants.anubis - -public define Word32 _CXM_OK = 0. -public define Word32 _CXM_ERROR = 1. -public define Word32 _CXM_UNKNOW_CMD = 2. -public define Word32 _CXM_UNKNOW_SERVICE = 3. -public define Word32 _CXM_MISSING_REQUIRED_FIELD = 4. -public define Word32 _CXM_FORBIDDEN = 5. -public define Word32 _CXM_BAD_AUTHENTICATION = 6. -public define Word32 _CXM_TEMPORARY_ERROR = 7. // When received, the client should try later - -public type ProtocolResult: - failure, - timeout, - unknow_cmd, - error, - error(Word32, String), - ok, - ok_msg(Message). - -public define One - send_ACK_error - ( - MessageQueue queue, - Word32 cmd_id, - Word32 error_code, - String error_string, - )= - with err_msg = message(_CXM_ACK), - forget(add_int32(err_msg, "CMD", cmd_id)); - forget(add_int32(err_msg, "STATUS", error_code)); - (if error_string /= "" then forget(add_string(err_msg, "STATUS_MSG", error_string)) - else unique); - forget(queue.add_Message_to_send(err_msg)). - -public define One - send_ACK_error - ( - MessageQueue queue, - Word32 cmd_id - )= - send_ACK_error(queue, cmd_id, _CXM_ERROR, ""). - -public define One - send_ACK_ok - ( - MessageQueue queue, - Word32 cmd_id - )= - with ok_msg = message(_CXM_ACK), - forget(add_int32(ok_msg, "CMD", cmd_id)); - forget(add_int32(ok_msg, "STATUS", _CXM_OK)); - forget(queue.add_Message_to_send(ok_msg)) - . - -public define One - send_ACK_ok - ( - MessageQueue queue, - Word32 cmd_id, - Message result - )= - with ok_msg = message(_CXM_ACK), - forget(add_int32(ok_msg, "CMD", cmd_id)); - forget(add_int32(ok_msg, "STATUS", _CXM_OK)); - forget(add_message(ok_msg, "RESULT", result)); - forget(queue.add_Message_to_send(ok_msg)) - . - -public define One - send_result - ( - MessageQueue queue, - Word32 cmd_id, - Maybe(Message) mb_msg - )= - if mb_msg is - { - failure then send_ACK_error(queue, cmd_id), - success(msg) then send_ACK_ok(queue, cmd_id, msg) - }. - -public define One - send_result - ( - MessageQueue queue, - Word32 cmd_id, - Result((Word32, String), Message) mb_msg - )= - if mb_msg is - { - error(err) then - if err is (err_code, err_string) then - send_ACK_error(queue, cmd_id, err_code, err_string), - ok(msg) then send_ACK_ok(queue, cmd_id, msg) - }. - -public define One - send_result - ( - MessageQueue queue, - Word32 cmd_id, - Bool result - )= - if result then - send_ACK_ok(queue, cmd_id) - else - send_ACK_error(queue, cmd_id). - -public define ProtocolResult - wait_for_reply - ( - MessageQueue mQ, - Word32 wait_cmd, - Int t_out - ) = - if mQ.get_next_received_Message(t_out) is - { - timeout then timeout, - closed then failure, //println("wait_for_reply closed"); - - msg(_msg) then - if *_msg.what = _CXM_ACK then - if find_int32(_msg, "CMD") is - { - failure then failure, //println("wait_for_reply CMD"); - success(cmd) then -// println("wait_for_reply CMD="+to_hexa(cmd)); - if find_int32(_msg, "STATUS") is - { - failure then failure, //println("wait_for_reply STATUS"); - success(status) then - if cmd = wait_cmd then - ( - if status = _CXM_OK then - if find_message(_msg, "RESULT") is - { - failure then ok, - success(ok_message) then ok_msg(ok_message) - } - else if status = _CXM_ERROR then - error - else if status = _CXM_UNKNOW_CMD then - unknow_cmd - else - error(status, if find_string(_msg, "STATUS_MSG") is success(txt) then txt else "") - ) - else - failure //println("wait_for_reply "); - } - } - else - failure //println("wait_for_reply not ACK"); - }. - diff --git a/calexium_lib/net_services/CXM_net_services.anubis b/calexium_lib/net_services/CXM_net_services.anubis deleted file mode 100644 index dcf687b..0000000 --- a/calexium_lib/net_services/CXM_net_services.anubis +++ /dev/null @@ -1,190 +0,0 @@ -/* - * - * User: David RENE - * Date: 25/04/2007 - * Time: 11:01 - * (c) Calexium - * - */ -read tools/basis.anubis -read system/convert.anubis -read system/string.anubis -read system/muscle.anubis -read system/data_io.anubis -read system/message_queue.anubis -read system/message_transceiver.anubis -read CXM_generic_protocol.anubis -read calexium_lib/CXM_message_constants.anubis - -public type NetService: - net_service( - Word32 version, - Word32 id, - String name, - (MessageQueue, String, String) -> One handler // Parameters are MessageQueue, peer IP and timestamp string - ). - -define One - print_services - ( - List(NetService) net_services - ) = - map_forget((NetService net_s)|-> - println(" id : 0x"+ to_hexa(net_s.id)); - println(" version : " + to_String(net_s.version)); - println(" name : "+ net_s.name ); - println("----------------------------------------") - ,net_services). - - /** Try to find the service_id in services_list. If the service is found in that list - * the corresponding NetService object is return - */ -define Maybe(NetService) - find_service - ( - List(NetService) services_list, - Word32 service_id, - Word32 service_version - )= - if services_list is - { - [] then failure, - [h . t] then - if h.id = service_id & h.version >=+ service_version then - success(h) - else - find_service(t, service_id, service_version) - }. - - /** Check if the muscle message msg has the correct fields for requesting a net_services - * if we found "service" and "version" fields on the message, we try to find if the service - * referenced in "service" is available in net_services list - */ -define Maybe(NetService) - has_service - ( - MessageQueue queue, - Message msg, - List(NetService) net_services - )= - if find_int32(msg, "SERVICE") is - { - failure then //send_ACK_error(queue, _CXM_REQUEST_FOR_SERVICE); failure, - // old names... should be removed soon - if find_int32(msg, "service") is - { - failure then send_ACK_error(queue, _CXM_REQUEST_FOR_SERVICE); failure, - success(service_id) then - if find_int32(msg, "version") is - { - failure then send_ACK_error(queue, _CXM_REQUEST_FOR_SERVICE);failure, - success(service_version) then find_service(net_services, service_id, service_version) - } - } - - success(service_id) then - if find_int32(msg, "VERSION") is - { - failure then send_ACK_error(queue, _CXM_REQUEST_FOR_SERVICE);failure, - success(service_version) then find_service(net_services, service_id, service_version) - } - }. - -define String - get_time_stamp - = - with time = (UTime) unow, - "<"+virtual_machine_id+"@"+time.seconds+">". - - /** This message_received function just handle the negociation process the available net_services. - * In other words, it only recognize the _CXM_REQUEST_FOR_SERVICE message and try to launch the - * corresponding servcice - */ - -define One - service_negociation - ( - MessageQueue queue, - Message msg, - List(NetService) net_services, - String peer - )= - //println("Service NEGOCIATION [" + to_hexa(*msg.what) + "] received"); - if * msg.what = _CXM_REQUEST_FOR_SERVICE then - if has_service(queue, msg, net_services) is - { - failure then - send_ACK_error(queue, _CXM_REQUEST_FOR_SERVICE, _CXM_UNKNOW_SERVICE, "Unknown service") - success(net_service) then - with result = message(0), - timestamp = get_time_stamp, - forget(add_string(result, "TIMESTAMP", timestamp)); - send_ACK_ok(queue, _CXM_REQUEST_FOR_SERVICE, result); - net_service.handler(queue, peer, timestamp) - } - else - send_ACK_error(queue, *msg.what, _CXM_UNKNOW_CMD, "Unknown command [" + (*msg.what) + "]") - . - - /** - * this function unflatten muscle message and give the correct message to service_negociation function - */ -define One - message_receiver - ( - MessageQueue queue, - List(NetService) net_services, - String peer - ) = - if queue.quit_requested(unique) then - unique - else - //println("PRE SERVICE message_receiver "+"["+virtual_machine_id + "]"); - if queue.get_next_received_Message(1) is - { - timeout then //println("PRE timeout"); - message_receiver(queue, net_services, peer), - closed then //println("PRE closed"); - unique, - msg(msg) then unique; //println("PRE negociation"); - service_negociation(queue, msg, net_services, peer); - message_receiver(queue, net_services, peer) - }. - -define Server -> (RWStream) -> One - net_services_handler - ( - List(NetService) net_services, - ) = - (Server server) |-> (RWStream conn) |-> - if remote_IP_address_and_port(conn) is (num_peer,_) then - //convert IP address of the client to string - with peer = ip_addr_to_string(num_peer), - //println("NET SERVICES Accepting connection with "+peer); - - //now managing the list of SERVICES - with queue = create_MessageQueue("CXM Net Services"), - message_transceiver(conn, queue); - message_receiver(queue, net_services, peer). - - -public define Maybe(Server) - start_net_services - ( - List(NetService) net_services, - Word32 network_port, - )= - if start_server(0, - network_port, - net_services_handler(net_services), - (One u) |-> unique) is - { - cannot_create_the_socket then println("Cannot create the listening socket."); failure, - cannot_bind_to_port then println("Cannot bind to port " + network_port ); failure, - cannot_listen_on_port then println("Cannot listen on port " + network_port); failure, - ok(server) then - println("Net services started on port " + network_port); - println("------ Available services ------"); - print_services(net_services); - success(server) - }. diff --git a/calexium_lib/net_services_protocols/ftp_client.anubis b/calexium_lib/net_services_protocols/ftp_client.anubis deleted file mode 100644 index c30d964..0000000 --- a/calexium_lib/net_services_protocols/ftp_client.anubis +++ /dev/null @@ -1,181 +0,0 @@ -/* - * - * User: David RENE - * Date: 11/05/2007 - * Time: 22:34 - * (c) Calexium - * - * To change this template use Tools | Options | Coding | Edit Standard Headers. - */ - -read calexium_lib/CXM_message_constants.anubis -read calexium_lib/net_services/CXM_generic_protocol.anubis -read calexium_lib/net_services/CXM_generic_client.anubis //for get_ip -read system/message_queue.anubis -read system/message_transceiver.anubis -read system/muscle.anubis -read system/files.anubis -read tools/basis.anubis -read network/dns.anubis - -define Maybe(One) - receive_data - ( - MessageQueue mQ, - WStream fd, - Int so_far, - Int left_read - )= - //println("receive_data "); - if mQ.get_next_received_Message(30) is - { - timeout then failure, - closed then failure, - msg(_msg) then - with last_block = if find_bool(_msg, "End") is {failure then false, success(r) then r}, - if find_raw(_msg, "Data") is - { - failure then println("Can't find raw Data"); send_ACK_error(mQ, _CXM_FTP_DATA); failure, - success(data) then - if write(fd, data) is - { - failure then println("Can't write into file"); send_ACK_error(mQ, _CXM_FTP_DATA);failure, - success(len) then - send_ACK_ok(mQ, _CXM_FTP_DATA); - if last_block then - println("File received successfully"); - //TODO this is a big hack, we must check if all data are sent from the mQ - sleep(10000); - success(unique) - else -// println("Bytes received : " + (so_far + len)); - receive_data(mQ, fd, so_far + len, left_read - len) - } - } - } - . - -define Maybe(One) - start_get_file_transtert - ( - MessageQueue mQ, - String local_file, - Int size - )= - make_directories(local_file); - if file(local_file, new) is - { - failure then println("Can't create \""+local_file+"\" file"); failure, - success(fd) then //the local file is open - with start = message(_CXM_FTP_START_TRANSFERT), - mQ.add_Message_to_send(start); - receive_data(mQ, weaken(fd), 0, size) - } - . - -define Maybe(One) - get_file - ( - MessageQueue mQ, - String remote_file, - String local_file, - Bool ftp - )= - with get_file_msg = message(_CXM_FTP_GET_FILE), - if add_string(get_file_msg, "FileName", remote_file) is - { - failure then failure, - success(_) then - ( if ftp then - println("get_file FTP_DIR"); - forget(add_bool(get_file_msg, "FTP_DIR", true)) - else - unique - ); - mQ.add_Message_to_send(get_file_msg); - if wait_for_reply(mQ, _CXM_FTP_GET_FILE, 30) is - { - failure then println("get_file failure");failure, - timeout then println("get_file timeout");failure, - unknow_cmd then println("get_file unknow_cmd");failure, - error then println("get_file remote error msg");failure, - error(c,m) then println("get_file remote error [" + c + "] msg '" + m + "'");failure, - ok then println("get_file ok");failure, - ok_msg(msg)then - if find_int32(msg, "FileSize") is - { - failure then println("file size not found"); failure, - success(size) then println("file size "+size); - start_get_file_transtert(mQ, local_file, to_Int(size)) - } - } - }. - - -define Bool - request_for_service - ( - MessageQueue queue - )= - with test_msg = message(_CXM_REQUEST_FOR_SERVICE), - forget(add_int32(test_msg, "service", _CXM_FTP_SERVICE_ID)); - forget(add_int32(test_msg, "version", 1)); - queue.add_Message_to_send(test_msg); - if queue.get_next_received_Message(30) is - { - timeout then println("request_for_service receive timeout");false, - closed then println("request_for_service socket closed");false, - msg(msg) then - if find_int32(msg, "STATUS") is - { - failure then println("status not found");false, - success(v) then - if v = _CXM_OK then - true - else - false - } - }. - -public define Maybe(One) - ftp_get_file - ( - String server, - Word32 ip_port, - String remote_file, - String local_file, - Bool ftp, - ) = - if get_ip(server) is success(ip_adr) then - if connect( ip_adr, ip_port) is - { - error(_) then println("can't connect to ftp server"); failure, - ok(conn) then - with queue = create_MessageQueue("ftp_get_file"), - message_transceiver(conn, queue); - println("request for ftp service"); - if request_for_service(queue) then - with result = get_file(queue, remote_file, local_file, ftp), - queue.quit(unique);result - else - queue.quit(unique); - println("Service not found");failure - } - else - println("server "+server+" DNS error");failure - . - - /* Exists for backward compatibility. - * The last argument set to false (no ftp directory on the remote, pickup on collection dir) - */ - -public define Maybe(One) - ftp_get_file - ( - String server, - Word32 ip_port, - String remote_file, - String local_file, - ) = - ftp_get_file(server, ip_port, remote_file, local_file, false). - diff --git a/calexium_lib/net_services_protocols/logger_service.anubis b/calexium_lib/net_services_protocols/logger_service.anubis deleted file mode 100644 index 9e9636c..0000000 --- a/calexium_lib/net_services_protocols/logger_service.anubis +++ /dev/null @@ -1,397 +0,0 @@ -/* - * - * User: David RENE - * Date: 29/07/2007 - * Time: 02:04 - * (c) Calexium - * - */ - -read tools/basis.anubis -read system/muscle.anubis -read system/data_io.anubis -read system/convert.anubis -read system/string.anubis -read system/logger.anubis -read system/message_queue.anubis -read system/message_transceiver.anubis - -read calexium_lib/CXM_message_constants.anubis -read calexium_lib/net_services/CXM_net_services.anubis -read calexium_lib/net_services/CXM_generic_protocol.anubis - -// Special non-existing file. This is a work arround for a impossibility to define global configuration in anubis. -// So this file allows you to specify on which UDP port the logger server is listening. -// You have to provide this file in your base source directory (or any other folder which is scanned by the compilater, -// and you define a function named 'logger_port' which simply return the port number as an Word32. -// Example: -// public define Word32 logger_port = 33610. - read logger_config.anubis - -// previous 'read' replaced by an empty declaration. Should be defined into main source file. -public define Word32 logger_port. - -public define Word32 logger_srv_version = 1. - - /** - * has_update scan the given message for finding corresponding available update - * package for the application. The request message come with AppId field which contain - * package or application signature and CurrentVersion field which is current version - * installed on the requester. - * - * --- REQUEST message format - * msg [_CXM_UPD_HAS_UPDATE] - * string "AppId" = hash or unique signature of the package - * string "CurrentVersion" = current version installed on the remote caller - * - * --- ANSWER message format - * - * ERROR case message format - * msg [_CXM_ACK] - * int32 "CMD" = _CXM_UPD_HAS_UPDATE - * int32 "STATUS" = _CXM_ERROR - * - * OK without update available - * msg [_CXM_ACK] - * int32 "CMD" = _CXM_UPD_HAS_UPDATE - * int32 "STATUS" = _CXM_OK - * msg "RESULT" [_CXM_ACK_RESULT_MSG] - * int32 "PackageStatus" = no_update // numerical value = 0 - * - */ - -define Bool - process_log - ( - Logger log, - Message msg - )= - if find_string(msg, "LogString") is - { - failure then logError(log, "process_log can't find LogString");false, - success(log_string) then - if find_int32(msg, "Level") is - { - failure then logError(log, "process_log can't find Level");false, - success(int_level) then - if find_int32(msg, "Thread") is - { - failure then logError(log, "process_log can't find Level");false, - success(thread_id) then - with level = get_LogLevel_from_value(to_Int(int_level)), - if level is logTrace then - if find_string(msg, "LogMask") is - { - failure then logError(log, "process_log can't find LogMask");false, - success(log_mask) then logTrace(log, logMask(log_mask), log_string, thread_id); true - } - else doLog(log, log_string, level, thread_id); true -// { -// logNone then true, -// logCriticalError then logCriticalError(log, log_string); true, -// logError then logError(log, log_string); true, -// logWarning then logWarning(log, log_string); true, -// logInfo then logInfo(log, log_string); true, -// logDebug then logDebug(log, log_string); true -// logTrace then -// if find_string(msg, "LogMask") is -// { -// failure then logError(log, "process_log can't find LogMask");false, -// success(log_mask) then logTrace(log, logMask(log_mask),log_string); true -// } -// } - } - } - }. - -define Bool - process_log - ( - List(Logger) logs, - Message msg - )= - if find_string(msg, "LogName") is - { - failure then println("process_log can't find LogName");false, - success(log_name) then - if get_logger(logs, log_name) is - { - failure then println("can't find log ["+log_name+"]");false, - success(log) then process_log(log, msg) - } - }. - - /** message_received is the principal - */ - /* - define One - message_received - ( - MessageQueue queue, - List(Logger) logs, - Message msg - )= - with msg_what = *msg.what, - if msg_what = _CXM_LOGGER_LOG then - send_result(queue, _CXM_LOGGER_LOG, process_log(logs, msg)) - else - println("wrong message_received is not _CXM_LOGGER_LOG ");unique - . - - define One - logger_handler - ( - MessageQueue queue, - List(Logger) logs - )= - if queue.get_next_received_Message(1) is - { - timeout then //println("logger_handler timeout ["+queue.get_name(unique)+"]"); - logger_handler(queue, logs), - closed then //println("logger_handler closed ["+queue.get_name(unique)+"]"); - unique, - msg(msg) then //println("logger_handler msg received ["+queue.get_name(unique)+"]"); - message_received(queue, logs, msg); - logger_handler(queue, logs) - }. - - public define NetService - logger_service - ( - List(Logger) logs - )= - net_service( - logger_srv_version, - _CXM_LOGGER_SERVICE_ID, //id of the service declared in CXM_message_constants - "Logger service", //human readable name of the service - ( - MessageQueue queue, - String peer - ) |-> logger_handler(queue, logs)). - - */ - /****************** LOCAL UDP SERVICE *************/ - - -public define String - data_preview - ( - ByteArray data, - Int max - ) = - with l = length(data), - firsts_bytes = extract(data, 0, max), - "Length=" + l + "; String='"+to_string(firsts_bytes)+"' Buffer=[" + to_ascii(firsts_bytes) + (if l > max then "...]" else "]"). - - -define (UDP_Socket, ByteArray, Truncation, Word32, Word32) -> One - make_udp_handler - ( - List(Logger) logs, - Logger debug_logger - ) = - ( - UDP_Socket socket, - ByteArray data, - Truncation truncation, - Word32 ip_address, - Word32 ip_port - ) |-> - with ip = ip_addr_to_string(ip_address), - logTrace(debug_logger, logMask("Logger"), "LoggerServer: data received (" + length(data) + " bytes) from IP " + ip + "... "); - if receive_message_from_io(make_data_io(data)) is - { - failure then logWarning(debug_logger, "LoggerServer: Bad data packet received from IP " + ip + ": " + data_preview(data, 20)), - success(msg) then - if *msg.what = _CXM_LOGGER_LOG then - forget(process_log(logs, msg)) - else - println("LoggerService: wrong message_received. [" + to_hexa(*msg.what) + "] is not _CXM_LOGGER_LOG ") - }. - -define One - my_notify - ( - One dummy - ) = - unique. - -public define Maybe(UDP_Server) - start_logger_server - ( - List(Logger) logs, - Logger debug_logger - ) = - if start_udp_server(0, - logger_port, - make_udp_handler(logs, debug_logger), - 8*1024, - my_notify) is - { - cannot_create_the_socket then logError(debug_logger, "Cannot create the listening socket."); failure, - cannot_bind_address_port then logError(debug_logger, "Cannot bind to port " + logger_port + ".");failure, - access_denied then logError(debug_logger, "Cannot listen on port " + logger_port + ".");failure, - ok(server) then logInfo(debug_logger, "LocalLog Server started on port " + logger_port + "."); success(server) - }. - - - /****************** CLIENT PART *******************/ - -define One - local_net_logger - ( - String logger_server, - Message log_message - )= - forget(send_message_by_udp(log_message, ip_address((127,0,0,1)), logger_port)). - - -define Message - create_log_msg - ( - String logger_name, - String log_string, - Int level - )= - with string = if length(log_string) > 1024 then (if sub_string(log_string, 0, 1024) is success(s) then s else "?") + "..." - else log_string, - with log_msg = message(_CXM_LOGGER_LOG), - forget(add_string(log_msg, "LogName", logger_name)); - forget(add_string(log_msg, "LogString", string)); - forget(add_int32(log_msg, "Level", truncate_to_Word32(level))); - forget(add_int32(log_msg, "Thread", virtual_machine_id)); - log_msg - . -*/ - -// HACK Begin of Hacked version - define String debug_log = "Debug". - define String config_log = "Config". - define String incoming_log = "Incoming". - define String outgoing_log = "Outgoing". - define String pop3_log = "POP3". - define String mailing_log = "Mailing". - define String errors_log = "Errors". - define String security_log = "Security". - define String spams_log = "Spams". - define String api_log = "MF_API". - define String internal_log = "INTERNAL". - - - define String - get_log_file - ( - String log_name - ) = - if log_name = debug_log then "debug.log" - else if log_name = "SendMail" then "debug.log" - else if log_name = config_log then "config.log" - else if log_name = incoming_log then "incoming.log" - else if log_name = outgoing_log then "outgoing.log" - else if log_name = pop3_log then "pop3.log" - else if log_name = mailing_log then "mailing.log" - else if log_name = errors_log then "errors.log" - else if log_name = "DB" then "errors.log" - else if log_name = "SQL" then "sql_profiling.log" - else if log_name = security_log then "security.log" - else if log_name = spams_log then "spams.log" - else if log_name = api_log then "api.log" - else if log_name = internal_log then "internal" - else "unknown.log". - - - define One - local_net_logger - ( - String logger_server, - One _ - )= - unique. - - define One - create_log_msg - ( - String logger_name, - String log_string, - Int level - )= - with log = createLogger(logger_name, 8, "/var/MailFountain/log/" + get_log_file(logger_name), logTrace, logTrace), - logLevel = get_LogLevel_from_value(level), - protect - doLog(log, log_string, logLevel, virtual_machine_id). - -// HACK End of Hacked version - - - -public define One - log( - LogLevel level, - String logger_name, - String log_string - )= - local_net_logger("127.0.0.1", create_log_msg(logger_name, log_string, get_log_level_value(level))). - -public define One - logNone( - String logger_name, - String log_string - )= - local_net_logger("127.0.0.1", create_log_msg(logger_name, log_string, 0)). - -public define One - logCriticalError( - String logger_name, - String log_string - )= - local_net_logger("127.0.0.1", create_log_msg(logger_name, log_string, 1)). - -public define One - logError( - String logger_name, - String log_string - )= - local_net_logger("127.0.0.1", create_log_msg(logger_name, log_string, 2)). - -public define One - logWarning( - String logger_name, - String log_string - )= - local_net_logger("127.0.0.1", create_log_msg(logger_name, log_string, 3)). - -public define One - logInfo( - String logger_name, - String log_string - )= - local_net_logger("127.0.0.1", create_log_msg(logger_name, log_string, 4)). - -public define One - logDebug( - String logger_name, - String log_string - )= - local_net_logger("127.0.0.1", create_log_msg(logger_name, log_string, 5)). - -public define One - logTrace( - String logger_name, - LogMask log_mask, - String log_string - )= - with log_msg = create_log_msg(logger_name, log_string, 6), - forget(add_string(log_msg, "LogMask", log_mask.mask)); - local_net_logger("127.0.0.1", log_msg). - -// HACK hacked version - public define One - logTrace( - String logger_name, - LogMask log_mask, - String log_string - )= - if log_mask is logMask(mask) then - if mask = "send_mail" | mask = "smtp" | mask = "sql_profiling" then - local_net_logger("127.0.0.1", create_log_msg(logger_name, log_string, 6)) - else unique. diff --git a/calexium_lib/net_services_protocols/pkg_updater_protocol.anubis b/calexium_lib/net_services_protocols/pkg_updater_protocol.anubis deleted file mode 100644 index a1cbc45..0000000 --- a/calexium_lib/net_services_protocols/pkg_updater_protocol.anubis +++ /dev/null @@ -1,12 +0,0 @@ -/* - * - * User: David RENE - * Date: 26/04/2007 - * Time: 19:08 - * (c) Calexium - * - */ - - -public define Word32 no_update = 0. -public define Word32 update_available = 1. diff --git a/calexium_lib/web/CXM_common.anubis b/calexium_lib/web/CXM_common.anubis deleted file mode 100644 index aa627bb..0000000 --- a/calexium_lib/web/CXM_common.anubis +++ /dev/null @@ -1,215 +0,0 @@ - - *Project* The Anubis Project - *Title* Some common stuff for the web. - - *Copyright* Copyright (c) Alain Prouté 2003. - - - - *Author* Alain Prouté - - *Public* - *Name* HTTP_header - *Description* - -read system/string.anubis - -/** - * The type 'HTTP_header' describes HTTP headers, which are just pairs '(name,value)'. - */ -public type HTTP_header: - http_header(String name, - String value). - - -public define Maybe(String) - http_header_value - ( - List(HTTP_header) l, - String name - ) = - if l is - { - [ ] then failure, - [h . t] then if h is - { - http_header(n, v) then //print("DEBUG: http_header_value --> HEADER = " + n + ":" + v + "\n"); - if insensitive_equal(name, n) then success(v) - else http_header_value(t, name), - } - }. - - *Name* Web_arg - *Description* - - The type 'Web_arg' describes 'web arguments'. A web argument is either a pair - '(name,value)' (for example it may be 'web_arg("password","foobar")', if the client - clicks on the submit button of a form containing a password input field named - 'password'), or an uploaded file. In this last case, it is a triplet containing the - name of the file upload input field, the value of this input field (name of the - uploaded file), and the name of the temporary file as saved by the server in its - 'upload temporary directory'; see 'web/http_server.anubis' and the 'upload' Web_item in - 'web/html.anubis'). - -public type Web_arg: - web_arg(String name, - String value), - upload (String name, // name of corresponding 'upload' Web_item - String value, // name of uploaded file - String temp_file_path). // temporary file path (relative to server directory) - - - *Name* Web_arg_value - *Description* - Of course, within the body of a 'web page' operation, you may want to recover the value - of a particular web argument. To that end, use the operation 'web_arg_value', which - takes 2 argument: - - - the list of all web arguments (the operand of the web page operation), - - the name of the argument whose value is wanted. - - This operation has the following return type: - -public type Web_arg_value: - not_found, - found(String value). - - *Name* Web_arg_value - *Description* - If the requested argument name is not found in the list, 'not_found' is - returned. Otherwise, the value returned by 'web_arg_value' has the form 'found(v)', - where 'v' is the value of the argument. - - The operation 'web_arg_value' is defined below. - -public define Web_arg_value - web_arg_value - ( - List(Web_arg) l, - String name - ) = - if l is - { - [ ] then not_found, - [h . t] then if h is - { - web_arg(n,v) then - if name=n - then found(v) - else web_arg_value(t,name), - - upload(n,v,tfn) then - if name=n - then found(v) - else web_arg_value(t,name) - } - }. - -public define Web_arg_value - web_arg_value_not_null - ( - List(Web_arg) lwa, - String name, - ) = - if web_arg_value(lwa, name) is - { - not_found then not_found - found(str) then - if str = "" then - not_found - else - found(str) - }. - - *Ignore* - -public define Maybe((String,String)) - file_upload_value - ( - List(Web_arg) l, - String name - ) = - if l is - { - [ ] then failure, - [h . t] then if h is - { - web_arg(_,_) then file_upload_value(t,name), - upload(n,v,tfn) then - if n = name - then success((v,tfn)) - else file_upload_value(t,name) - } - }. - -public define List((String,String)) - file_upload_value - ( - List(Web_arg) l, - String name, - List((String,String)) new_list - ) = - if l is - { - [ ] then new_list, - [h . t] then if h is - { - web_arg(_,_) then file_upload_value(t,name, new_list), - upload(n,v,tfn) then - if n = name - then file_upload_value(t,name, [(v,tfn) . new_list]) - else file_upload_value(t,name, new_list) - } - }. - - -public type Redirection: - redirect(String required_uri, // URI required by the client - String required_host, // value of 'Host' HTTP header sent by the client - String corresponding_uri). // URI which will be served to the client - -public type Redirections: - redirection_list(List(Redirection) redirections), - redirection_fn((String input_uri, // URI required by the client - String host) -> String f). // value of 'Host' HTTP header sent by the client - - - Now, you may also want to recover web argument values which have been encoded (by - 'web_arg_encode'). In this case, use the following: - -read CXM_web_arg_encode.anubis - - -public define Maybe($T) - decode_web_arg_value - ( - List(Web_arg) l, - String name - ) = - if web_arg_value(l,name) is - { - not_found then failure, - found(v) then web_arg_decode(v) - }. - -public define List(String) - web_arg_list_values - ( - List(Web_arg) l, - String name - ) = - if l is - { - [] then [], - [h . t] then - if h is web_arg(n, v) then - if n = name then - [ v . web_arg_list_values(t, name)] - else - web_arg_list_values(t, name) - else - web_arg_list_values(t, name) - - } - . - diff --git a/calexium_lib/web/CXM_cookies.anubis b/calexium_lib/web/CXM_cookies.anubis deleted file mode 100644 index b2da482..0000000 --- a/calexium_lib/web/CXM_cookies.anubis +++ /dev/null @@ -1,691 +0,0 @@ - - *Project* The Anubis Project - - *Title* Managing Cookies. - - *Copyright* Copyright (c) Alain Prouté 2001. - - - *Author* Alain Prouté - - - - -read tools/basis.anubis -read system/string.anubis -read CXM_common.anubis -read CXM_html.anubis -read CXM_http_get_common.anubis - - - *Overview* - Cookies are defined in RFC 2109. Here is the corresponding Anubis type: - - Each cookie has an server name (the name of the server who constructed the cookie), a - name, a value, and several attributes. - -public type Cookie: - cookie(String server_name, // of the server who sent the cookie - String name, // of the cookie - String value, // of the cookie - // attributes: - Maybe(String) comment, // cookies may have human readable comments - Maybe(String) domain, // domain name as sent by the server - Int validity, // cookie still valid if this is > now - Maybe(String) path, // server path for which the cookie is valid - Bool secure, // if true, do not send this cookie over an insecure link - Int version). // Cookie version (normally 1: rfc 2109) - - - Cookies are sent by servers through 'Set-Cookie' HTTP headers. The function - 'get_cookies' retrieves a list of cookies from a list of HTTP headers. - -public define List(Cookie) - get_cookies - ( - String server_name, // name of server who sent the cookies - List(HTTP_header) headers // HTTP headers sent by this server - ). - -public define Maybe(Cookie) - find_cookie - ( - String name, - List(Cookie) cookies - ). - - - - - - Normally, this function is used on the list of HTTP headers returned by either - 'http_get' of 'https_get'. - - - Before they can be sent back to their origin server, cookies must be reformated, in - order to produce 'Cookie' HTTP headers: - -public define List(HTTP_header) - reformat_cookies - ( - String server_name, - String uri, - List(Cookie) cookies - ). - - The result of 'reformat_cookies' may be appended to the list of headers given as - argument to 'http_get' or to 'https_get'. - - In the meantime, you may examine and maybe discard cookies, you may 'save' them into a - file, and 'retrieve' them later. - - - - - ------- That all for the public part. ------------------------------------------------- - - - Here is the syntax of a 'Set-Cookie' header (according to RFC 2109): - - set-cookie = "Set-Cookie:" cookies - cookies = 1#cookie - cookie = NAME "=" VALUE *(";" cookie-av) - NAME = token - VALUE = value - value = token | quoted-string - cookie-av = "Comment" "=" value - | "Domain" "=" value - | "Max-Age" "=" value - | "Path" "=" value - | "Secure" - | "Version" "=" 1*DIGIT - - - According to RFC 2616 (obsolating RFC 2068) defining HTTP 1.1, 'control characters' are - 0 to 31 and DEL (127). A 'separator' is one of: - - ( ) < > @ , ; : \ " / [ ] ? = { } 32(space) and 9(tab) " - - Now, a token is a non empty sequence of ASCII characters (0 to 127), but not including - any control character or any separator. As a consequence, characters admissible in a - 'RFC 2616 token' are: - - 33 ! - 35 to 39 # $ & ' - 42 43 * + - 45 46 - . - 48 to 57 0 ... 9 - 65 to 90 A ... Z - 94 to 122 ^ _ ` a ... z - 124 126 | ~ - -define Bool - is_token_char - ( - Word8 c - ) = - if c +< 33 then false else - if c +< 34 then true else - if c +< 35 then false else - if c +< 40 then true else - if c +< 42 then false else - if c +< 44 then true else - if c +< 45 then false else - if c +< 47 then true else - if c +< 48 then false else - if c +< 58 then true else - if c +< 65 then false else - if c +< 91 then true else - if c +< 94 then false else - if c +< 123 then true else - if c +< 124 then false else - if c = 124 then true else - c = 126. - - - From the grammar, it is clear that atomic entities (called 'tokens' by YACC) are: - - - tokens (in the sens of RFC 2616) some of which have to be recognized as keywords - - quoted strings - - equal sign - - colon - - semi-colon - - Hence, the following type: - -public type Atom: - end_of_input, - error, - comment, - domain, - max_age, - path, - secure, - version, - token(String), - quoted_string(String), - equals, - colon, - semi_colon. - - -variable List(Atom) unput_atoms = []. - -define One - unput_atom - ( - Atom a - ) = - unput_atoms <- [a . *unput_atoms]. - -define Atom - recognize_keyword - ( - String s - ) = - with l = to_lower(s), - if l = "comment" then comment else - if l = "domain" then domain else - if l = "max-age" then max_age else - if l = "path" then path else - if l = "secure" then secure else - if l = "version" then version else - token(s). - - -variable String input = "". From which cookies will be read. -variable Int index = 0. Current position within 'input'. - -define Maybe(Word8) - next_char - = - if nth(*index,*input) is - { - failure then failure, - success(c) then - index <- *index+1; - success(c) - }. - -define One - unput_char - = - index <- *index-1. - -define Atom - read_token - ( - List(Word8) so_far // contains at least 1 character - ) = - if next_char is - { - failure then recognize_keyword(implode(reverse(so_far))), - success(c) then - if is_token_char(c) - then read_token([c . so_far]) - else unput_char; recognize_keyword(implode(reverse(so_far))) - }. - -define Atom - read_quoted_string - ( - List(Word8) so_far - ) = - if next_char is - { - failure then quoted_string(implode(reverse(so_far))), - success(c) then - if c = '\"' - then quoted_string(implode(reverse(so_far))) - else read_quoted_string([c . so_far]) - }. - -define Bool - is_blank - ( - Word8 c - ) = - c +=< ' '. - - Reading an atom from the input: - -define Atom - read_atom - = - if *unput_atoms is - { - [ ] then - if next_char is - { - failure then end_of_input, - success(c) then - if is_blank(c) then read_atom else // skip blanks - if is_token_char(c) then read_token([c]) else - if c = '\"' then read_quoted_string([]) else - if c = '=' then equals else - if c = ':' then colon else - if c = ';' then semi_colon else - error - }, - [h . t] then - unput_atoms <- t; h - }. - - - Reading an attribute-value pair. - -type AttrVal: - comment(String), - domain(String), - max_age(String), - path(String), - secure, - version(String). - -define String - read_eq_value - = - with e = read_atom, - if e is equals then - ( - with a = read_atom, - if a is token(n) then n else - if a is quoted_string(s) then s else - unput_atom(a); "" - ) - else unput_atom(e); "". - - -define Maybe(AttrVal) - read_attr_val - = - if read_atom is semi_colon then - with a = read_atom, - if a is - { - end_of_input then failure, - error then failure, - comment then success(comment(read_eq_value)), - domain then success(domain(read_eq_value)), - max_age then success(max_age(read_eq_value)), - path then success(path(read_eq_value)), - secure then success(secure), - version then success(version(read_eq_value)), - token(_) then unput_atom(a); failure, - quoted_string(_) then unput_atom(a); failure, - equals then unput_atom(a); failure, - colon then unput_atom(a); failure, - semi_colon then unput_atom(a); failure, - } - else failure. - - - Getting attributes from a List(AttrVal). - -define Maybe(String) - get_comment - ( - List(AttrVal) l - ) = - if l is - { - [ ] then failure, - [h . t] then if h is comment(c) - then success(c) - else get_comment(t) - }. - -define Maybe(String) - get_domain - ( - List(AttrVal) l - ) = - if l is - { - [ ] then failure, - [h . t] then if h is domain(s) - then success(s) - else get_domain(t) - }. - -define Int - get_validity - ( - List(AttrVal) l - ) = - if l is - { - [ ] then 0, - [h . t] then if h is max_age(a) - then if decimal_scan(a) is - { - failure then 0, - success(n) then n+now - } - else get_validity(t) - }. - -define Maybe(String) - get_path - ( - List(AttrVal) l - ) = - if l is - { - [ ] then failure, - [h . t] then if h is path(p) - then success(p) - else get_path(t) - }. - -define Bool - get_secure - ( - List(AttrVal) l - ) = - if l is - { - [ ] then false, - [h . t] then if h is secure - then true - else get_secure(t) - }. - -define Int - get_version - ( - List(AttrVal) l - ) = - if l is - { - [ ] then 0, - [h . t] then if h is version(v) - then if decimal_scan(v) is - { - failure then 0, - success(n) then n - } - else get_version(t) - }. - - - Reading a cookie: - -variable String server_name = "". - -define Maybe(Cookie) - read_cookie_n_e_v - ( - String name, - String value, - List(AttrVal) so_far - ) = - if read_attr_val is - { - failure then success(cookie( - *server_name, - name, - value, - get_comment(so_far), - get_domain(so_far), - get_validity(so_far), - get_path(so_far), - get_secure(so_far), - get_version(so_far) - )), - - success(av) then read_cookie_n_e_v(name,value,[av . so_far]) - }. - -define Maybe(Cookie) - read_cookie_n_e - ( - String name - ) = - with a = read_atom, - if a is token(value) then read_cookie_n_e_v(name,value,[]) else - if a is quoted_string(value) then read_cookie_n_e_v(name,value,[]) else - unput_atom(a); failure. - -define Maybe(Cookie) - read_cookie_n - ( - String name - ) = - with a = read_atom, - if a is equals - then read_cookie_n_e(name) - else unput_atom(a); failure. - - -define Maybe(Cookie) - read_cookie - = - with a = read_atom, - if a is token(name) - then read_cookie_n(name) - else unput_atom(a); failure. - - -define List(Cookie) - read_cookies - ( - List(Cookie) so_far - ) = - if read_cookie is - { - failure then so_far, - success(c) then read_cookies([c . so_far]) - }. - - -define List(Cookie) - get_cookies - ( - String svn, - HTTP_header h - ) = - if h is http_header(n,v) then - if to_lower(n) = "set-cookie" - then ( - unput_atoms <- []; - input <- v; - index <- 0; - server_name <- svn; - read_cookies([]) - ) - else []. - -public define List(Cookie) - get_cookies - ( - String server_name, - List(HTTP_header) headers - ) = - if headers is - { - [ ] then [ ], - [h . t] then - append(get_cookies(server_name,h),get_cookies(server_name,t)) - }. - -define List(Cookie) - server_get_cookies - ( - HTTP_header h - ) = - if h is http_header(n,v) then - if to_lower(n) = "cookie" - then ( - unput_atoms <- []; - input <- v; - index <- 0; - server_name <- ""; - read_cookies([]) - ) - else []. - -public define List(Cookie) - server_get_cookies - ( - // String server_name, - List(HTTP_header) headers - ) = - if headers is - { - [ ] then [ ], - [h . t] then - append(server_get_cookies(h), server_get_cookies(t)) - }. - -public define Maybe(Cookie) - find_cookie - ( - String name, - List(Cookie) cookies - ) - = - if cookies is - { - [] then failure, - [h . t] then - if h is cookie(s, n, v, _, _, _, _, _, _) then - if name = n then success(h) - else find_cookie(name, t) - }. - -public define String - get_cookie_value - ( - String name, - List(Cookie) cookies - ) - = - if find_cookie(name, cookies) is - { - failure then "", - success(c) then if c is cookie(_, _, v, _, _, _, _, _, _) then v - }. - - *** Reformating cookies. ************************************************************** - - Cookies should be resent reformated according to the following grammar (copy-pasted - from RFC 2109): - - cookie = "Cookie:" cookie-version - 1*((";" | ",") cookie-value) - cookie-value = NAME "=" VALUE [";" path] [";" domain] - cookie-version = "$Version" "=" value - NAME = attr - VALUE = value - path = "$Path" "=" value - domain = "$Domain" "=" value - - -define HTTP_header - reformat_cookie - ( - Cookie c - ) = - if c is cookie(sn,n,v,mbc,mbd,vld,mbp,sec,ver) then - http_header("Cookie", - "$Version=" + to_decimal(ver) + - ";" + n + "=\"" + v + "\"" + - if mbp is - { - failure then "", - success(p) then ";$Path=\"" + p + "\"" - } + - if mbd is - { - failure then "", - success(d) then ";$Domain=\"" + d + "\"" - } - ). - - - According to RFC 2109, a cookie may be sent to a server if: - - (1) server name in the cookie is the name of the server, - (2) if 'Path' attribute is present, its value must match the URI, - (3) the cookie is still valid (validity = 0 means indefinitely valid). - - define Bool - path_match - ( - Maybe(String) cookie_path, - String uri - ) = - if cookie_path is - { - failure then true, - success(p) then - - }. - - - Checking if the path matches: - - -define Bool - path_match - ( - Maybe(String) mbp, - String uri - ) = - true. - - - The next function verifies if a cookie satisfies the rules. - -define Bool - may_resend_cookie - ( - String server_name, - String uri, - Cookie c - ) = - if c is cookie(sn,n,v,mbc,mbd,vld,mbp,sec,ver) then - if sn = server_name - then ( - if path_match(mbp,uri) - then ( - if vld = 0 then true else vld > now - ) - else false - ) - else false. - - - The next function reformat all cookies which satisfy the 'resend' rules. - -public define List(HTTP_header) - reformat_cookies - ( - String server_name, - String uri, - List(Cookie) cookies - ) = - if cookies is - { - [ ] then [ ], - [h . t] then - if may_resend_cookie(server_name,uri,h) - then [reformat_cookie(h) . reformat_cookies(server_name,uri,t)] - else reformat_cookies(server_name,uri,t) - }. - - - - - - See test_cookies.anubis for a test of this program. - - - - - - - - - diff --git a/calexium_lib/web/CXM_dojo.anubis b/calexium_lib/web/CXM_dojo.anubis deleted file mode 100644 index 329b8fc..0000000 --- a/calexium_lib/web/CXM_dojo.anubis +++ /dev/null @@ -1,832 +0,0 @@ -/* - * Created by PyramIDE. - * User: Steve Marechal - * Date: 11/06/2008 - * Time: 09:54 - * - */ - -read tools/basis.anubis -read tools/base64.anubis -read locale/L3LanguageInfo.anubis -read system/string.anubis -read system/logger.anubis - -read calexium_lib/web/CXM_common.anubis -read calexium_lib/web/CXM_making_a_web_site.anubis -read calexium_lib/web/CXM_multihost_http_server.anubis -read calexium_lib/net_services_protocols/logger_service.anubis - -public type Dojo_Grid_Data : - grid_data(String). - -public type Position_Direction: - brup, - brleft, - blup, - blright, - trdown, - trleft, - tldown, - tlright. - -define String - pos_dir_to_str - ( - Position_Direction pos - )= - if pos is - { - brup then "br-up", - brleft then "br-left", - blup then "bl-up", - blright then "bl-right", - trdown then "tr-down", - trleft then "tr-left", - tldown then "tl-down", - tlright then "tl-right" - }. - - - -public define HTML_Off_Form - dojo_button - ( - String name, - String execute, - String id, - ) - = - literal(" - ") -. - -public type Input_Type: - file, - text, - password. - -public type InputDial: - input_dial(HtmlId id, Input_Type input_type, String label, Maybe(String) class), - input_date(HtmlId id, String label), - input_combo(HtmlId id, String label, List((WebArgValue,String)) list_data), - input_check(HtmlId id, String label, Bool checked), - input_hidden(HtmlId id, WebArgValue value). - - -define List(HTML_Off_Form) - format_list_data - ( - List((WebArgValue,String)) list_data, - List(HTML_Off_Form) result_list - )= - if list_data is - { - [] then result_list, - [h . t] then - if h is (wa, label) then - format_list_data(t, [literal("") . result_list]) - }. - -public define HTML_Off_Form - dojo_combobox - ( - WebArgName the_name, - HtmlId the_id, - String label, - List((WebArgValue,String)) list_data, - )= - sequence([ - literal(" - ") - ]). - -define HTML_Off_Form - _maybe_label - ( - String label_text, - HtmlId html_id - ) = - if length(label_text) > 0 then literal("") - else literal(""). - -public define HTML_Off_Form - dojo_checkbox - ( - WebArgName the_name, - HtmlId the_id, - String label, - WebArgValue val, - Bool checked, - )= - sequence([ - _maybe_label(label, the_id), - literal(""), - ]). - - -define HTML_Off_Form - input_in_dialog - ( - InputDial input_data - )= - if input_data is - { - input_dial(html_id, input, label, class) then - sequence([ - literal("
"), - literal("
") - ]), - - input_date(html_id, label) then - sequence([ - literal("
"), - literal("
-
" - ) - ]), - - input_combo(the_id, label, list_data) then - sequence([ - literal("
"), - dojo_combobox(wan(the_id.id), the_id, label, list_data), - literal("
") - ]), - - input_check(the_id, label, checked) then - sequence([ - literal("
"), - dojo_checkbox(wan(the_id.id), the_id, label, wav("1"), checked), - literal("
"), - ]), - - input_hidden(the_id, val) then - literal(""), - } -. - -define List(HTML_Off_Form) - inputs_in_dialog - ( - List(InputDial) inputs_data - )= - if inputs_data is - { - [] then [], - [h . t] then [input_in_dialog(h) . inputs_in_dialog(t)] - }. - -public define HTML_Off_Form - dijit_dialog - ( - String name, - String dialog_id, - String execute, - String ok_label, - Maybe(String) cancel, - List(InputDial) inputs_data, - Maybe(String) do_cancel - ) - = - sequence([ - div([attr("dojoType", "dijit.Dialog"), id(dialog_id), title(name), attr("execute", execute)], - sequence([ - sequence(inputs_in_dialog(inputs_data)), - literal("" + - if cancel is - { - failure then "", - success(cancel_label) then "" - }), - literal("
") - ]) - ) - ]) -. - -public define HTML_Off_Form - dojo_dialog - ( - String name, - String dialog_id, - String execute, - String ok_label, - Maybe(String) cancel, - List(InputDial) inputs_data, - Maybe(String) do_cancel - ) - = - sequence[ - dojo_button(name,"dijit.byId('"+dialog_id+"').show()", dialog_id + "_button"), - dijit_dialog(name, dialog_id, execute, ok_label, cancel, inputs_data, do_cancel) - ] -. - - - - -public type DojoGridEditor: - inputEditor, - boolEditor, - selectEditor(List(String) options), - alwaysOnEditor. - -public type DojoGridDefaultColumn: - dojo_grid_default_column( - String styles, - Maybe(String) width, - Maybe(DojoGridEditor) editor). - -public type DojoGridColumn: - dojo_grid_column( String label, - String field_name, - Maybe(String) width, - Maybe(DojoGridEditor) editor). - -public type DojoGridView: - dojo_grid_view( - Maybe(DojoGridDefaultColumn) default_column, - List(DojoGridColumn) columns). - -public type DojoGridLayout: - dojo_grid_layout( - Maybe(String) selectable_row_header_width, - List(DojoGridView) views). - -define String to_String(DojoGridEditor editor) = - "editor: " + - if editor is - { - inputEditor then "dojox.grid.editors.Input", - boolEditor then "dojox.grid.editors.Bool", - selectEditor(options) then "dojox.grid.editors.Select, options: [" + join(",", map((String o) |-> "\"" + o + "\"", options)) + "]", - alwaysOnEditor then "dojox.grid.editors.AlwaysOn" - }. - -define String to_String(DojoGridView view) = - "{ " + (if view.default_column is success(col) then - (if col is dojo_grid_default_column(styles, mb_width, mb_editor) then - "defaultCell: {" - + "styles: \"" + styles + "\"" - + (if mb_width is success(w) then ", width=\"" + w + "\"" else "") - + (if mb_editor is success(e) then ", " + to_String(e) else "") - + "}, ") - else "") - + "cells: [[" + join(",", map((DojoGridColumn col) |-> - if col is dojo_grid_column(label, field, mb_width, mb_editor) then - "{" - + "name: \"" + label + "\"" - + "field: \"" + field + "\"" - + (if mb_width is success(w) then ", width=\"" + w + "\"" else "") - + (if mb_editor is success(e) then ", " + to_String(e) else "") - + "}", - view.columns)) + "]]" - +"}". - - -public define String - dojo_make_grid_script - ( - HtmlId html_id, - DojoGridLayout layout, - String layout_name, - String store_name, - Bool can_edit - ) - = -"". - -public define HTML_Off_Form - dojo_make_grid_script - ( - HtmlId html_id, - List(String) columns, - Bool can_edit - ) - = - literal( -""). - -public define HTML_Off_Form - dojo_grid - ( - HtmlId html_id, - Int rowsPerPage, - List(Table_Option) attributes, - )= - table([attr("dojoType", "dojox.grid.DataGrid"), attr("id", html_id.id), attr("jsId", html_id.id), - class("soria"), attr("singleClickEdit", "true"), attr("rowsPerPage", to_decimal(rowsPerPage)) . attributes], - empty, [], empty). - - -public define HTML_Off_Form - dojo_grid - ( - HtmlId html_id, - List(CoreAttrs) attributes, -// List(GridColumn) columns, - String colum1, - String colum2, - String colum3, - String colum4, - Bool can_edit - ) - = - sequence([ - literal( - -""), - div_empty([id(html_id.id) . attributes /*attr("dojoType", "dojox.Grid"), */]), - ]). -//
"). - - -public define HTML_Off_Form - dojo_message_box - ( - HTML_Off_Form name1, - HTML_Off_Form name2, - ) - = - sequence([ - literal("
"), - div([class("message_box")], - sequence([ - div([id("node3"), class("box nopad hidden")], name1), - div([id("node4"), class("box two nopad")], name2), - ])), - literal("
"), - ]). - - - -public define HTML_Off_Form - dojo_tooltip - ( - String title, - String keyword, - ) = - actioner(same,same, link([id("dojo_tip_" + keyword),class("dojoToolTip")],title, success(title)), "show_address_mailing", [("address_mailing", keyword)], []). - //actioner(same, same, push_button([id("dojo_tip_" + keyword), class("in"), event(onclick,"new_search(this)")], keyword), "", [], []). - - -public type BorderContainerRegion: - center, - top, - bottom, - leading, - trailing, - left, - right. - -define String - to_String - ( - BorderContainerRegion region - )= - if region is - { - center then "center", - top then "top", - bottom then "bottom", - leading then "leading", - trailing then "trailing", - left then "left", - right then "right" - }. - -public type BorderContainerDesign: - headline, - sidebar. - -define String - to_String - ( - BorderContainerDesign design - )= - if design is - { - headline then "headline", - sidebar then "sidebar" - }. - - -public define HTML_Off_Form - dojo_ContentPane - ( - List(CoreAttrs) attributes, - BorderContainerRegion region, - Bool splitter, - HTML_Off_Form content - ) = - div([ attr("dojoType", "dijit.layout.ContentPane"), - attr("region", to_String(region)), - attr("splitter", if splitter then "true" else "false") . attributes ], - content). - -public define HTML_In_Form - dojo_ContentPane - ( - List(CoreAttrs) attributes, - BorderContainerRegion region, - Bool splitter, - HTML_In_Form content - ) = - div([ attr("dojoType", "dijit.layout.ContentPane"), - attr("region", to_String(region)), - attr("splitter", if splitter then "true" else "false") . attributes ], - content). - -public define HTML_Off_Form - dojo_TabContainer - ( - List(CoreAttrs) attributes, - HTML_Off_Form content - ) = - div([attr("dojoType", "dijit.layout.TabContainer") . attributes ], - content). - - -public define HTML_Off_Form - dojo_BorderContainer - ( - List(CoreAttrs) attributes, - Maybe(String) the_title, - BorderContainerDesign design, - Bool live_splitter, - Bool persist, - Bool closable, - String container, - HTML_Off_Form content - ) = - with the_attributes = (List(CoreAttrs)) [attr("dojoType", "dijit.layout.BorderContainer"), attr("dojoAttachPoint", container), - attr("design", to_String(design)), attr("liveSplitters", live_splitter), attr("persist", persist), - attr("closable",closable) . attributes ], - total_attributes = if the_title is - { - failure then the_attributes, - success(t) then [title(t) . the_attributes] - }, - div(total_attributes, content). - -public define HTML_In_Form - dojo_BorderContainer - ( - List(CoreAttrs) attributes, - Maybe(String) the_title, - BorderContainerDesign design, - Bool live_splitter, - Bool persist, - Bool closable, - String container, - HTML_In_Form content - ) = - with the_attributes = (List(CoreAttrs)) [attr("dojoType", "dijit.layout.BorderContainer"), attr("dojoAttachPoint", container), - attr("design", to_String(design)), attr("liveSplitters", live_splitter), attr("persist", persist), - attr("closable",closable) . attributes ], - total_attributes = if the_title is - { - failure then the_attributes, - success(t) then [title(t) . the_attributes] - }, - div(total_attributes, content). - -public define HTML_Off_Form - dojo_tree - ( - List(CoreAttrs) attributes, - )= - div_empty(attributes). - - - -public define HTML_Off_Form - dojo_Toolbar - ( - List(CoreAttrs) attributes, - HTML_Off_Form content - )= - div([attr("dojoType", "dijit.Toolbar") . attributes ], - content). - - -public define HTML_Off_Form - dojo_tooltip - ( - List(CoreAttrs) attributes, - List(Text_Option) txt_attr, - HtmlId html_id, - String label, - HTML_Off_Form tooltip_content, - )= - sequence([ - text([id(html_id.id) . txt_attr], label), - div([id(html_id.id + "_tt"), attr("connectId", html_id.id), attr("dojoType", "dijit.Tooltip") . attributes], tooltip_content) - ]). - - -public define HTML_Off_Form - dojo_button - ( - HtmlId html_id, -// Maybe(String) class, - String name, - String iconclass, - Maybe(String) tip_msg, - String execute, - )= - literal(" - " + - if tip_msg is - { - failure then "", - success(tip) then - "" + tip + "" - }). - -public define HTML_In_Form - dojo_button - ( - HtmlId html_id, -// Maybe(String) class, - String name, - String iconclass, - Maybe(String) tip_msg, - String execute, - )= - literal(" - " + - if tip_msg is - { - failure then "", - success(tip) then - "" + tip + "" - }). - - -public define HTML_Off_Form - dojo_declaration - ( - String name, - List(CoreAttrs) attributes, - HTML_Off_Form content - )= - div([attr("dojoType", "dijit.Declaration"), attr("widgetClass", name) . attributes ], - content). - - -public define HTML_In_Form - dojo_declaration - ( - String name, - List(CoreAttrs) attributes, - HTML_In_Form content - )= - div([attr("dojoType", "dijit.Declaration"), attr("widgetClass", name) . attributes ], - content). - -public define HTML_Off_Form - dojo_editor - ( - List(CoreAttrs) attributes, - HtmlId html_id, - WebArgName input_name, - HTML_Off_Form text, - )= - div([id(html_id.id), attr("name", input_name.name), attr("dojoType", "dijit.Editor") - ,attr("extraPlugins", "['|', 'foreColor','hiliteColor',{name:'dojox.editor.plugins.FontChoice', command:'fontName', generic:true},'fontSize','formatBlock','|','createLink','insertImage']") - . attributes], text). - - public define HTML_In_Form - dojo_button - ( - HtmlId html_id, - String name, - String iconclass, - Maybe(String) tip_msg, - String execute, - )= - literal(" - " + - if tip_msg is - { - failure then "", - success(tip) then - "" + tip + "" - }). - -public define HTML_In_Form - dojo_checkbox - ( - List(InputAttrs) attributes, - WebArgName name, - HtmlId id, - String label, - WebArgValue val, - Bool checked, - )= - check_box_r([attr("dojoType", "dijit.form.CheckBox") . attributes] , label, id, name, val, checked). - -public define HTML_In_Form - dojo_combobox - ( - List(InputAttrs) attributes, - WebArgName name, - HtmlId id, - String label, - List((WebArgValue,String)) list_data, - InitialValue selected, - )= - // selector_c([attr("dojoType", "dijit.form.ComboBox") . attributes], label, id, name, 1, list_data, selected, non_mandatory). - selector_c(attributes, label, id, name, 1, list_data, selected). - -public define HTML_Off_Form - dojo_toaster - ( - List(CoreAttrs) attributes, - HtmlId html_id, - String message_topic, - Position_Direction position_direction, - Bool separator, - Maybe(Int) duration - )= - div(append(append(if separator then [attr("separator","<hr>")] - else [], - if duration is - { - failure then [], - success(dur) then [attr("duration", abs_to_decimal(dur))] - }), - [attr("dojoType", "dojox.widget.Toaster"), attr("messageTopic", message_topic), - attr("positionDirection", pos_dir_to_str(position_direction)), id(html_id.id) - . attributes ]), - literal("")). - -public define HTML_Off_Form - dojo_progressBar - ( - List(CoreAttrs) attributes, - List(Text_Option) attributes_text, - HtmlId html_id, - String label - )= - sequence([ - text([id("text_" + html_id.id), class("progress_bar") . attributes_text], label), - div([id(html_id.id), class("progress_bar"), attr("indeterminate", "true"), attr("dojoType", "dijit.ProgressBar") . attributes], literal("")) - ]). - -public define HTML_Off_Form - dojo_progressBar - ( - List(CoreAttrs) attributes, - List(Text_Option) attributes_text, - HtmlId html_id, - String label, - Int progress, - Int maximum - )= - sequence([ - text([id("text_" + html_id.id), class("progress_bar") . attributes_text], label), - div([id(html_id.id), - class("progress_bar"), - attr("maximum", abs_to_decimal(maximum)), - attr("progress", abs_to_decimal(progress)), - attr("dojoType", "dijit.ProgressBar") . attributes], literal("")) - ]). - -define Maybe(Int) - string_to_month - ( - String month_s - )= - with month = to_lower(month_s), - if month = "jan" then success(1) - else if month = "feb" then success(2) - else if month = "mar" then success(3) - else if month = "apr" then success(4) - else if month = "may" then success(5) - else if month = "jun" then success(6) - else if month = "jul" then success(7) - else if month = "aug" then success(8) - else if month = "sep" then success(9) - else if month = "oct" then success(10) - else if month = "nov" then success(11) - else if month = "dec" then success(12) - else failure - . - - -// 'Thu Jan 14 2010 00:00:00 GMT+0100' must be replaced by '2010-01-14 00:00:00' - - - -public define Maybe(String) - dojo_date_to_db_datetime - ( - String data - )= - with list_data = split_by_token(data, ' '), - if nth(2, list_data) is - { - failure then failure, - success(day) then - if nth(1, list_data) is - { - failure then failure, - success(month) then - if nth(3, list_data) is - { - failure then failure, - success(year) then - if nth(4, list_data) is - { - failure then failure, - success(hour) then - if string_to_month(month) is - { - failure then failure, - success(month_int) then - success(year+"-"+month_int+"-"+day+" "+hour) - } - } - } - } - }. - -public define List(HTML_Head_Tag) - dojo_defaults - = - [ - // js(js_file("js/dojo/dojo.js", [attr("djConfig", "parseOnLoad: true, isDebug: " + (if debug_mode then "true" else "false") + ", usePlainJson: true")])), - js(js_file("js/dojo/dojo/dojo.js", [attr("djConfig", "parseOnLoad: true, isDebug: false, usePlainJson: true")])), - js(js_file("js/dojo/dijit/dijit.js")), - css(css_file("js/dojo/dojo/resources/dojo.css")) - ]. - - -public define List(HTML_Head_Tag) - dojo_init - ( - String web_dir, - String theme_name - ) - = - with theme_name = - if file_exists(web_dir+"js/dojo/dijit/themes/"+theme_name+"/"+theme_name+".css")then theme_name else "claro", - [ css(css_file("js/dojo/dijit/themes/"+theme_name+"/"+theme_name+".css")) . - [ css(css_file("js/dojo/dijit/themes/"+theme_name+"/"+theme_name+"_rtl.css")) . dojo_defaults ] - ] - . diff --git a/calexium_lib/web/CXM_generic_form.anubis b/calexium_lib/web/CXM_generic_form.anubis deleted file mode 100644 index 36b73e1..0000000 --- a/calexium_lib/web/CXM_generic_form.anubis +++ /dev/null @@ -1,471 +0,0 @@ - - - - *Project* The Anubis Project - - *Title* - - *Copyright* Copyright (c) Alain Prouté 2005. - - - *Author* Alain Prouté - - - - In this file we rationalize the construction of forms. - - - -read CXM_making_a_web_site.anubis -read tools/basis.anubis - - -public type Mandatory: // used to mark fields as mandatory. - mandatory, - non_mandatory. - -public type Width: - small, - narrow, - wide, - custom(Int). - -public type FormFieldWidth: - auto, - custom(Int). - - - - Sorts of fields that you can put in a form: - -public type FormField: - - //--- title field --------------------------------------------------------------------- - title (String text), - title (Int text_size, - String text), - title_f (List(Text_Option) -> HTML_In_Form), - - //--- message field ------------------------------------------------------------------- - message (Result(String,String) msg), - message_f (Result(List(Text_Option) -> HTML_In_Form,List(Text_Option) -> HTML_In_Form)), - - //--- text input field ---------------------------------------------------------------- - input (WebArgName web_arg_name, - String tag, - Width width, - InitialValue init_value, - Mandatory mandatory), - input (WebArgName web_arg_name, - Width width, - InitialValue init_value), - input_f (WebArgName web_arg_name, - List(Text_Option) -> HTML_In_Form tag, - Width width, - InitialValue init_value, - Mandatory mandatory), - - //--- password input field ------------------------------------------------------------ - password_input (WebArgName web_arg_name, - String tag, - Mandatory mandatory), - password_input_f (WebArgName web_arg_name, - List(Text_Option) -> HTML_In_Form tag, - Mandatory mandatory), - - //--- explanation field --------------------------------------------------------------- - explain (String text), - explain (String text, - FormFieldWidth width), - explain_f (List(Text_Option) -> HTML_In_Form), - - //--- selector field ------------------------------------------------------------------ - selector (WebArgName web_arg_name, - String tag, - List(String) items, - Maybe(InitialValue) selected, - Mandatory mandatory), - selector_f (WebArgName web_arg_name, - List(Text_Option) -> HTML_In_Form, - List(String) items, - Maybe(InitialValue) selected, - Mandatory mandatory), - selector_c (WebArgName web_arg_name, - String tag, - List((WebArgValue,String)) items, - Maybe(InitialValue) selected, - Mandatory mandatory), - - - - //--- checkbox field ------------------------------------------------------------------ - checkbox (WebArgName web_arg_name, - String tag, - Bool checked, - Mandatory mandatory), - // the same one, but with the tag on the right of the checkbox - checkboxr (WebArgName web_arg_name, - String tag, - Bool checked, - Mandatory mandatory), - checkbox_f (WebArgName web_arg_name, - List(Text_Option) -> HTML_In_Form, - Bool checked, - Mandatory mandatory), - - //--- radio-button field -------------------------------------------------------------- - radio_button (WebArgName web_arg_name, - WebArgValue web_arg_value, - String tag, - Bool checked, - Mandatory mandatory), - // the same one, but with the tag on the right of the radio_button - radio_buttonr (WebArgName web_arg_name, - WebArgValue web_arg_value, - String tag, - Bool checked, - Mandatory mandatory), - - //--- text area field ----------------------------------------------------------------- - text_area (WebArgName web_arg_name, - InitialValue initial_text), - text_area (WebArgName web_arg_name, - String tag, - InitialValue initial_text), - text_area (WebArgName web_arg_name, - String tag, - InitialValue initial_text, - Int width, - Int height), - - //--- fields table -------------------------------------------------------------------- - fields_table (String tag, - List(FormField) fields), - - //--- fields line --------------------------------------------------------------------- - fields_line (String tag, - List(FormField) fields), - fields_line (List(FormField) fields), - - //--- preview field ------------------------------------------------------------------- - preview (String html_text), - - //--- submit button ------------------------------------------------------------------- - submit (String action_name, - Maybe(String) label, - String button_text, - List((String,String)) extra_operands). - - - Convenience functions: - -public define FormField title(List(Text_Option) -> HTML_In_Form f) = title_f(f). -public define FormField - message(Result(List(Text_Option) -> HTML_In_Form,List(Text_Option) -> HTML_In_Form) f) = message_f(f). -public define FormField input(WebArgName web_arg_name, - List(Text_Option) -> HTML_In_Form tag, - Width width, - InitialValue init_value, - Mandatory mandatory) - = input_f(web_arg_name,tag,width,init_value,mandatory). -public define FormField password_input(WebArgName web_arg_name, - List(Text_Option) -> HTML_In_Form tag, - Mandatory mandatory) - = password_input_f(web_arg_name,tag,mandatory). -public define FormField explain(List(Text_Option) -> HTML_In_Form f) = explain_f(f). -public define FormField selector(WebArgName web_arg_name, - List(Text_Option) -> HTML_In_Form f, - List(String) items, - Maybe(InitialValue) selected, - Mandatory mandatory) - = selector_f(web_arg_name,f,items,selected,mandatory). -public define FormField checkbox(WebArgName web_arg_name, - List(Text_Option) -> HTML_In_Form f, - Bool checked, - Mandatory mandatory) - = checkbox_f(web_arg_name,f,checked,mandatory). - - Make the form itself with: - -public define HTML_Off_Form - generic_form - ( - String form_name, - RGB background_color, - Int width, - List(FormField) fields - ). - - - - --- That's all for the public part ! -------------------------------------------------- - -// TO DO update code of CXM generic form -define HTML_Row(HTML_In_Form) - format_form_field - ( - FormField ff - ) = - with star = (Mandatory m) |-> (HTML_In_Form)text([color(rgb(255,0,0)),size(12)], - if m is - { - mandatory then "*", - non_mandatory then "" - }), - row( - if ff is - { - title(t) then (List(HTML_Cell(HTML_In_Form))) - [ - cell([columns(3),h_center],text([size(16),bold,color(rgb(0,0,0))],t)) - ], - - title(s,t) then (List(HTML_Cell(HTML_In_Form))) - [ - cell([columns(3),h_center],text([size(s),bold,color(rgb(0,0,0))],t)) - ], - - title_f(t) then (List(HTML_Cell(HTML_In_Form))) - [ - cell([columns(3),h_center],t([size(16),bold,color(rgb(0,0,0))])) - ], - - message(r) then (List(HTML_Cell(HTML_In_Form))) if r is - { - error(msg) then [cell([columns(3),h_center], - text([size(10),color(rgb(240,0,0))],msg))] - ok(msg) then [cell([columns(3),h_center], - text([size(10),color(rgb(0,150,0))],msg))] - }, - - message_f(r) then (List(HTML_Cell(HTML_In_Form))) if r is - { - error(msg) then [cell([columns(3),h_center], - msg([size(10),color(rgb(240,0,0))]))] - ok(msg) then [cell([columns(3),h_center], - msg([size(10),color(rgb(0,150,0))]))] - }, - - input(wan,tag,w,init,mand) then (List(HTML_Cell(HTML_In_Form))) - [ - cell([right ], text([size(10)],tag)), - cell([width(7) ], star(mand)), - cell([left ], text_input([], "",htmlId(""), wan, init,if w is - { - small then 10, - narrow then 50, - wide then 70, - custom(n) then n - })) - ], - - input(wan,w,init) then (List(HTML_Cell(HTML_In_Form))) - [ - cell([left,columns(3) ], text_input([], "", htmlId(""), wan,init,if w is - { - small then 10, - narrow then 30, - wide then 70, - custom(n) then n - })) - ], - - input_f(wan,tag,w,init,mand) then (List(HTML_Cell(HTML_In_Form))) - [ - cell([right ], tag([size(10)])), - cell([width(7) ], star(mand)), - cell([left ], text_input([], "", htmlId(""),wan,init,if w is - { - small then 15, - narrow then 30, - wide then 70, - custom(n) then n - })) - ], - - password_input(wan,tag,mand) then (List(HTML_Cell(HTML_In_Form))) - [ - cell([right ], text([size(10)],tag)), - cell([width(7) ], star(mand)), - cell([left ], password_input([], "",htmlId(""), wan, init(""), 30)) - ], - - password_input_f(wan,tag,mand) then (List(HTML_Cell(HTML_In_Form))) - [ - cell([right ], tag([size(10)])), - cell([width(7) ], star(mand)), - cell([left ], password_input([], "",htmlId(""), wan, init(""), 30)) - ], - - explain(t) then (List(HTML_Cell(HTML_In_Form))) - [ - cell([columns(3),h_center], - table([nude],[row(cell([width(500)], - paragraph([/*justified,*/size(10),color(rgb(0,100,0))],literal(t))))])) - ], - - explain(t,w) then (List(HTML_Cell(HTML_In_Form))) - [ - cell([columns(3),h_center], - table([nude],[row(cell( - if w is - { - auto then [], - custom(i) then [width(i)] - }, - paragraph([/*justified,*/size(10),color(rgb(0,100,0))], literal(t))))])) - ], - - explain_f(t) then (List(HTML_Cell(HTML_In_Form))) - [ - cell([columns(3),h_center], - table([nude],[row(cell([width(500)], - t([/*justified,*/size(10),color(rgb(0,100,0))])))])) - ], - - selector(wan,tag,items,selected,mand) then (List(HTML_Cell(HTML_In_Form))) - [ - cell([right ], text([size(10)],tag)), - cell([width(7)], star(mand)), - cell([left ], if selected is - { - failure then selector([], "", htmlId(""), wan,1,items) - success(sel) then selector([], "", htmlId(""), wan,1,items, sel) - }) - ], - - selector_f(wan,tag,items,selected,mand) then (List(HTML_Cell(HTML_In_Form))) - [ - cell([right ], tag([size(10)])), - cell([width(7)], star(mand)), - cell([left ], if selected is - { - failure then selector([], "", htmlId(""), wan,1,items) - success(sel) then selector([], "", htmlId(""), wan,1,items, sel) - }) - ], - - selector_c(wan,tag,items,selected,mand) then (List(HTML_Cell(HTML_In_Form))) - [ - cell([right ], text([size(10)],tag)), - cell([width(7)], star(mand)), - cell([left ], if selected is - { - failure then selector_c([], "", htmlId(""), wan,1,items) - success(sel) then selector_c([], "", htmlId(""), wan,1,items,sel) - }) - ], - - checkbox(wan,tag,checked,mand) then (List(HTML_Cell(HTML_In_Form))) - [ - cell([right ], text([size(10)],tag)), - cell([width(7)], star(mand)), - cell([left ], check_box([], "",htmlId(""),wan, wav(wan.name),checked)) - ], - - checkboxr(wan,tag,checked,mand) then (List(HTML_Cell(HTML_In_Form))) - [ - cell([right ], check_box([], "",htmlId(""),wan, wav(wan.name),checked)), - cell([width(7)], star(mand)), - cell([left ], text([size(10)],tag)) - ], - - checkbox_f(wan,tag,checked,mand) then (List(HTML_Cell(HTML_In_Form))) - [ - cell([right ], tag([size(10)])), - cell([width(7)], star(mand)), - cell([left ], check_box([], "",htmlId(""),wan,wav(wan.name),checked)) - ], - - radio_button(wan,wav,tag,checked,mand) then (List(HTML_Cell(HTML_In_Form))) - [ - cell([right ], text([size(10)],tag)), - cell([width(7)], star(mand)), - cell([left ], radio_button([], "", htmlId(""), wan, wav, checked)) - ], - - radio_buttonr(wan,wav,tag,checked,mand) then (List(HTML_Cell(HTML_In_Form))) - [ - cell([right ], radio_button([], "", htmlId(""), wan, wav, checked)), - cell([width(7)], star(mand)), - cell([left ], text([size(10)],tag)) - ], - - text_area(wan,tx) then (List(HTML_Cell(HTML_In_Form))) - [ - cell([h_center,columns(3)],text_area([wrap_lines],wan,tx,75,10)) - ], - - text_area(wan,tag,tx) then (List(HTML_Cell(HTML_In_Form))) - [ - cell([right,top], text([size(10)],tag)), - cell([width(7)], text([],"")), - cell([h_center],text_area([wrap_lines],wan,tx,75,10)) - ], - - text_area(wan,tag,tx,w,h) then (List(HTML_Cell(HTML_In_Form))) - [ - cell([right,top], text([size(10)],tag)), - cell([width(7)], text([],"")), - cell([h_center],text_area([wrap_lines],wan,tx,w,h)) - ], - - fields_table(tag,fields) then (List(HTML_Cell(HTML_In_Form))) - [ - cell([right,top], text([size(10)],tag)), - cell([width(7)], text([],"")), - cell([left,top], table([],map((FormField ff2) |-> format_form_field(ff2),fields))) - ], - - fields_line(tag,fields) then (List(HTML_Cell(HTML_In_Form))) - [ - cell([right,top], text([size(10)],tag)), - cell([width(7)], text([],"")), - cell([left,top], table([nude],[row([], //border(0,0,3,rgb(0,0,0)) - map((FormField ff2) |-> cell([top],table([nude],[format_form_field(ff2)])),fields))])) - ], - - fields_line(fields) then (List(HTML_Cell(HTML_In_Form))) - [ - cell([left,top,columns(3)], table([nude],[row([], - map((FormField ff2) |-> cell([top],table([nude],[format_form_field(ff2)])),fields))])) - ], - - preview(html_text) then (List(HTML_Cell(HTML_In_Form))) - [ - cell([top,left,columns(3),background_color(rgb(255,255,255))], - table([border(0,8,0,rgb(0,0,0))], - [row(cell([left,top,height(200)],literal(html_text)))])) - ], - - submit(action_name,mb_label,button_text,extra_operands) then (List(HTML_Cell(HTML_In_Form))) - [ - cell([columns(3),right],actioner(same, - if mb_label is - { - failure then same, - success(n) then same(n) - }, - submit([], button_text), - action_name, - extra_operands)) - ] - }). - - - -// TO DO update code of CXM generic form -public define HTML_Off_Form - generic_form - ( - String form_name, - RGB bg_color, - Int w, - List(FormField) fields - ) = - table([border(0,0,5,bg_color),percentage_width(100), - background_color(bg_color)],[row(cell([h_center], - form(form_name,[],table([border(0,2,0,bg_color)], - map(format_form_field, fields)))))]). - - diff --git a/calexium_lib/web/CXM_generic_login.anubis b/calexium_lib/web/CXM_generic_login.anubis deleted file mode 100644 index f1db55d..0000000 --- a/calexium_lib/web/CXM_generic_login.anubis +++ /dev/null @@ -1,116 +0,0 @@ - - - - - Rationalisation de la gestion des logins et des mots de passe - -read CXM_common.anubis -read CXM_making_a_web_site.anubis -read CXM_generic_form.anubis - - - - - *** (1) Connection sur site sécurisée - - ou formulaire de saisie du login et du mot de passe - - - Le formulaire de saisie du login et du mot de passe pour se connecter à un site https - se compose : - .1. d'un éventuel message pour alerter que la paire (login,passwd) est erronée, - .2. du formulaire proprement dit pour lequel il faut donner : - - le titre du formulaire - - les textes figurant devant les 2 texts input - - le text du bouton submit - - le nom de l'action, - - la couleur de fond - - - -public define HTML_Off_Form - login_form - ( - String wrong_message, - RGB background_color, - String title_text, - String pseudo_text, - String passwd_text, - String submit_text, - String login_action - ). - - - - - *** (2) Vérification de la saisie - - -public define Maybe($User) - check_login_passwd - ( - String -> Maybe($User) check_pseudo, - $User -> ByteArray get_passwd, - List(Web_arg) lwa - ). - - - - --- That's all for the public part ! -------------------------------------------------- - - - - *** [1] Connection sur site sécurisée - -public define HTML_Off_Form - login_form - ( - String wrong_message, - RGB background_color, - String title_text, - String pseudo_text, - String passwd_text, - String submit_text, - String login_action - ) = - generic_form - ("login_form",background_color,700, - [ - title (title_text), - explain (wrong_message), - input ("pseudo",pseudo_text,narrow,"",mandatory), - password_input ("passwd",passwd_text,mandatory), - submit (login_action,failure,submit_text,[]) - ]). - - - - *** [2] Vérification de la saisie - -public define Maybe($User) - check_login_passwd - ( - String -> Maybe($User) check_pseudo, - $User -> ByteArray get_passwd, - List(Web_arg) lwa - ) = - if web_arg_value(lwa,"pseudo") is - { - not_found then failure, - found(ps) then - if web_arg_value(lwa,"passwd") is - { - not_found then failure, - found(pwd) then - if check_pseudo(ps) is - { - failure then failure, - success(user) then - if sha1(to_byte_array(pwd))=get_passwd(user) - then success(user) - else failure - } - }}. - - - diff --git a/calexium_lib/web/CXM_generic_table.anubis b/calexium_lib/web/CXM_generic_table.anubis deleted file mode 100644 index 9f9dfc8..0000000 --- a/calexium_lib/web/CXM_generic_table.anubis +++ /dev/null @@ -1,786 +0,0 @@ - - *Project* The Anubis Project - - *Title* Generic table page. - - *Copyright* Copyright (c) Alain Prouté 2004. - - - *Author* Alain Prouté - *Author* Olivier Duvernois - - - - ---------------------------------------------------------------------------------------- - - - - -read tools/basis.anubis -read CXM_common.anubis -read CXM_making_a_web_site.anubis - - - The purpose is to print on a html browser a table from a List($Data) using the function - 'generic_table()' describe below. - - Note : the explanations are only given for HTML_Item and its components. But they are - also available for HTML_Form and HTML_Element and their components. - - - A table may have the following look : - - +-----+----------+--------+-----------------------+ ............... - | | | | name 3 | - | num | name1 | name2 |-----------+-----------+ columns_name - | | | | name 31 | name 32 | - +-----+----------+--------+-----------+-----------+ ............... - | 1 | data11 | data12 | data131 | data132 | line 1 with background color a - +-----+----------+--------+-----------+-----------+ ............... - | 2 | data21 | data22 | data231 | data232 | line 2 with background color b - +-----+----------+--------+-----------+-----------+ ............... - | 3 | data31 | data32 | data331 | data332 | line 3 with background color a - +-----+----------+--------+-----------+-----------+ ............... - - | n | datan1 | datan2 | datan31 | datan32 | line n with background color ? - +-----+----------+--------+-----------+-----------+ ............... - |total| total1 | | | total32 | total line - +-----+----------+--------+-----------+-----------+ ............... - - For the total-line, assuming that datax1 to dataxn and datax32 to datan32 are numbers - (Int, Float or Maybe(Float)). - - - The columns name are just a List(Item_Row). - - The column 'num' is in the case you want to enumerate your data. The existence of this - column depends on the line function. - - Lines are given by the function : (RGB color,Int num,$Data d) -> Item_Row - - where : - (RGB)color is the color of the background of the row (the 'a color' or 'b - color'); - - (Int)num the number of the data (to enumerate). - - So, this function must be written something like : - - (RGB color, Int num,$Data d) |-> - row([background_color(color)], // and of course possibly other row-options - [ - cell([], (Int -> $HTML)(num) ) - . ($Data -> List(Cell))d // how data is printed in cells - ]). - - But, for the above convenient function with no enumeration, you can only write : - - (RGB color, $Data d) |-> - row([background_color(color)], // and of course possibly other row-options - ($Data -> List(Cell))d // how data is printed in cells - ). - - - If you want to sum by column your data, use the following type : - -public type Total_Line($Data,$Upplet,$Row): - no_total, - total - ( - ($Upplet,$Data) -> $Upplet sum_functions, - $Upplet -> $Row print_total_line, - $Upplet initial_value - ). - - $Row is for HTML_Row($HTML). - $Upplet represents the components of $Data that will be sum. - - Example : - with the above sheme table, $Data is something like : - type $Data - data - ( - Data1 d1, - Data2 d2 - Data3 d3 - ). - and type Data3: - data3 - ( - Data31 d31, - Data32 d32 - ). - - So $Upplet will be (Data1,Data32) : sums are wanted for those 2 datum - - The function ($Upplet,$Data) -> $Upplet will be written like : - ($Upplet u,$Data d) -> if u is (u1,u2) then (u1+d1(d), u2+d32(d3(d))) - - (if of course (Data1 + Data1) and (Data32 + Data32) are defined). - - - - - Several columns - - ------------------- - - If you want to print your data on sevaral columns (i.e. considering the above table - scheme as a column), you must specify the number of columns. You will obtain : - - Here is a List($Data) : l = [a,b,c,d,e,f,g,h,i,j,k,l,m]; - and f : (RGB,Int,$Data) -> Item_Row - You want to print this list on 3 columns. - The result will be : - - - +-----------+-----------+-----------+ - | col.names | col.names | col.names | - +-----------+-----------+-----------+ - | f(a) | f(f) | f(k) | - +-----------+-----------+-----------+ - | f(b) | f(g) | f(l) | - +-----------+-----------+-----------+ Each column is a table as defined - | f(c) | f(h) | f(m) | above. - +-----------+-----------+-----------+ - | f(d) | f(i) | | - +-----------+-----------+-----------+ - | f(e) | f(j) | | - +-----------+-----------+-----------+ - - - If several columns are required, it's also asked for spaces between two colums. - - So use the following type : - -public type HowManyColumns: - _1, - several (Int col_nb, - Int spacer). - - - - - - Now the Generic table definition - - ------------------------------------ - - Here is the most customizable generic table. Below, they are some convenience functions. - -public define HTML_Off_Form - generic_table - ( - List($Data) data, - List(Table_Option) lto, - List(HTML_Row(HTML_Off_Form)) columns_name, - HowManyColumns number_of_columns, - (RGB,Int,$Data) -> HTML_Row(HTML_Off_Form) line_format, - RGB a_color, - RGB b_color, - Total_Line($Data,$Upplet,HTML_Row(HTML_Off_Form)) total_line - ). - -public define HTML_In_Form - generic_table - ( - List($Data) data, - List(Table_Option) lto, - List(HTML_Row(HTML_In_Form)) columns_name, - HowManyColumns number_of_columns, - (RGB,Int,$Data) -> HTML_Row(HTML_In_Form) line_format, - RGB a_color, - RGB b_color, - Total_Line($Data,$Upplet,HTML_Row(HTML_In_Form)) total_line - ). - - - - Note : - List(Table_Option) : if you choose 'nude' (i.e. border(0,0,0)), don't forget a - horizontal spacer between the cells contain in the 'line_format' row. If you don't put - any, each data will be closer to the next one. - - - - - Convenience functions - - ------------------------- - - 1/ Table without multicolumns, enumeration and total-line: - -public define HTML_Off_Form - generic_table - ( - List($Data) data, - List(Table_Option) lto, - List(HTML_Row(HTML_Off_Form)) columns_name, - (RGB,$Data) -> HTML_Row(HTML_Off_Form) line_format, - RGB a_color, - RGB b_color - ). - -public define HTML_In_Form - generic_table - ( - List($Data) data, - List(Table_Option) lto, - List(HTML_Row(HTML_In_Form)) columns_name, - (RGB,$Data) -> HTML_Row(HTML_In_Form) line_format, - RGB a_color, - RGB b_color - ). - - - - 2/ Table with total-line and without multicolumns, enumeration. - - -public define HTML_Off_Form - generic_table - ( - List($Data) data, - List(Table_Option) lto, - List(HTML_Row(HTML_Off_Form)) columns_name, - (RGB,$Data) -> HTML_Row(HTML_Off_Form) line_format, - RGB a_color, - RGB b_color, - Total_Line($Data,$Upplet,HTML_Row(HTML_Off_Form)) total_line - ). - -public define HTML_In_Form - generic_table - ( - List($Data) data, - List(Table_Option) lto, - List(HTML_Row(HTML_In_Form)) columns_name, - (RGB,$Data) -> HTML_Row(HTML_In_Form) line_format, - RGB a_color, - RGB b_color, - Total_Line($Data,$Upplet,HTML_Row(HTML_In_Form)) total_line - ). - - - 3/ Table with multicolumns, enumeration, but without total - -public define HTML_Off_Form - generic_table - ( - List($Data) data, - List(Table_Option) lto, - List(HTML_Row(HTML_Off_Form)) columns_name, - HowManyColumns number_of_columns, - (RGB,Int,$Data) -> HTML_Row(HTML_Off_Form) line_format, - RGB a_color, - RGB b_color - ). - -public define HTML_In_Form - generic_table - ( - List($Data) data, - List(Table_Option) lto, - List(HTML_Row(HTML_In_Form)) columns_name, - HowManyColumns number_of_columns, - (RGB,Int,$Data) -> HTML_Row(HTML_In_Form) line_format, - RGB a_color, - RGB b_color - ). - - - - 4/ Table with multicolumns and without enumeration & total - -public define HTML_Off_Form - generic_table - ( - List($Data) data, - List(Table_Option) lto, - List(HTML_Row(HTML_Off_Form)) columns_name, - HowManyColumns number_of_columns, - (RGB,$Data) -> HTML_Row(HTML_Off_Form) line_format, - RGB a_color, - RGB b_color - ). - -public define HTML_In_Form - generic_table - ( - List($Data) data, - List(Table_Option) lto, - List(HTML_Row(HTML_In_Form)) columns_name, - HowManyColumns number_of_columns, - (RGB,$Data) -> HTML_Row(HTML_In_Form) line_format, - RGB a_color, - RGB b_color - ). - - - --- That's all for public part. ------------------------------------------------------------------------- - - - When the datum $Data must be presented on several columns, the initial list must be - re-composed : sot the type Print_Table. - -type Print_Table($Data): - print_table - ( - $Data data, - Int num - ). - - - *** Transform List($Data) into List(Print_Table($Data)) - - -define (List(Print_Table($Data)),List($Data)) - get_n_elements - ( - List($Data) l, - List(Print_Table($Data)) result, - Int n, - Int ct, // counter - Int num - ) = - if l is - { - [] then (reverse(result),[]), - [h . t] then - if ct = n - then (reverse([print_table(h,num+1) . result]),t) - else get_n_elements(t,[print_table(h,num+1) . result],n,ct+1,num+1) - }. - - -define List(List(Print_Table($Data))) - short_lists - ( - List($Data) l, - Int nb, // number of element of short list - Int ct // counter for numbering data (initialized at 0) - ) = - if get_n_elements(l,[],nb,1,ct) is (result,unused) - then if unused is - { - [] then [result], - [_ . _] then [result . short_lists(unused,nb,ct+nb)] - }. - - - - Generic row - - --------------- - -define (List(HTML_Row($HTML)),$Upplet) - generic_rows - ( - List(Print_Table($Data)) lpt, - (RGB,Int,$Data) -> HTML_Row($HTML) line_format, - RGB a_color, - RGB b_color, - ($Upplet,$Data) -> $Upplet do_sum, - List(HTML_Row($HTML)) rows, - $Upplet sum - ) = - if lpt is - { - [] then (reverse(rows),sum), - [h . t] then - generic_rows(t,line_format,b_color,a_color,do_sum, - [line_format(a_color,num(h),data(h)) . rows],do_sum(sum,data(h))) - }. - - - - - HTML_In_Form - - ---------------- - -define List(HTML_Cell(HTML_In_Form)) - generic_cells - ( - List(List(Print_Table($Data))) print_data, - List(Table_Option) lto, - List(HTML_Row(HTML_In_Form)) names, - (RGB,Int,$Data) -> HTML_Row(HTML_In_Form) line_format, - RGB a_color, - RGB b_color, - ($Upplet,$Data) -> $Upplet do_sum, - $Upplet -> HTML_Row(HTML_In_Form) total_line, - $Upplet value, - Int spacer - ) = - if print_data is - { - [] then (List(HTML_Cell(HTML_In_Form))) [], - [h . t] then - if generic_rows(h,line_format,a_color,b_color,do_sum,(List(HTML_Row(HTML_In_Form)))[],value) is - (rows,new_value) then - if t is [] - then [cell([top],table(lto,names+rows+[total_line(new_value)]))] - else [ - cell([top],table(lto,append(names,rows))) - . if spacer = 0 - then generic_cells - (t,lto,names,line_format,a_color,b_color,do_sum,total_line,new_value,spacer) - else [cell([width(spacer)],text([],"")) - . generic_cells - (t,lto,names,line_format,a_color,b_color,do_sum,total_line,new_value,spacer)] - ] - }. - -public define Int - Int x (mod Int y) - = - if x / y is - { - failure then 0, - success(result) then - if result is (q, r) then r - }. - - - -public define HTML_In_Form - generic_table - ( - List($Data) l, - List(Table_Option) lto, - List(HTML_Row(HTML_In_Form)) names, - HowManyColumns hm_col, - (RGB,Int,$Data) -> HTML_Row(HTML_In_Form) line_format, - RGB a_color, - RGB b_color, - Total_Line($Data,$Upplet,HTML_Row(HTML_In_Form)) total_line - ) = - table([], - if l is [] - then [] - else - with nbl = length(l), - [ - row([], - if total_line is - { - no_total then - with col_nb = if hm_col is - { - _1 then 1, - several(n,_) then n - }, - with spacer = if hm_col is - { - _1 then 0, - several(n,sp) then sp - }, - generic_cells - (short_lists(l,nbl\col_nb + if (nbl (mod col_nb)) > 0 then 1 else 0,0), - lto,names,line_format,a_color,b_color, - (One u,$Data d) |-> unique,(One _) |-> row([],[]),unique,spacer), - total(sum_fct,total_line,init) then - with col_nb = if hm_col is - { - _1 then 1, - several(n,_) then n - }, - with spacer = if hm_col is - { - _1 then 0, - several(n,sp) then sp - }, - generic_cells - ( - short_lists(l,nbl\col_nb + if (nbl (mod col_nb)) > 0 then 1 else 0,0), - lto,names,line_format,a_color,b_color, - sum_fct,total_line,init,spacer - ) - }) - ]). - - - - HTML_Off_Form - - ---------------- - -define List(HTML_Cell(HTML_Off_Form)) - generic_cells - ( - List(List(Print_Table($Data))) print_data, - List(Table_Option) lto, - List(HTML_Row(HTML_Off_Form)) names, - (RGB,Int,$Data) -> HTML_Row(HTML_Off_Form) line_format, - RGB a_color, - RGB b_color, - ($Upplet,$Data) -> $Upplet do_sum, - $Upplet -> HTML_Row(HTML_Off_Form) total_line, - $Upplet value, - Int spacer - ) = - if print_data is - { - [] then (List(HTML_Cell(HTML_Off_Form))) [], - [h . t] then - if generic_rows(h,line_format,a_color,b_color,do_sum,(List(HTML_Row(HTML_Off_Form)))[],value) is - (rows,new_value) then - if t is [] - then [cell([top],table(lto,(names+rows+[total_line(new_value)])))] - else [ - cell([top],table(lto,append(names,rows))) - . if spacer =0 - then generic_cells - (t,lto,names,line_format,a_color,b_color,do_sum,total_line,new_value,spacer) - else [cell([width(spacer)],text([],"")) - . generic_cells - (t,lto,names,line_format,a_color,b_color,do_sum,total_line,new_value,spacer)] - ] - }. - -public define HTML_Off_Form - generic_table - ( - List($Data) l, - List(Table_Option) lto, - List(HTML_Row(HTML_Off_Form)) names, - HowManyColumns hm_col, - (RGB,Int,$Data) -> HTML_Row(HTML_Off_Form) line_format, - RGB a_color, - RGB b_color, - Total_Line($Data,$Upplet,HTML_Row(HTML_Off_Form)) total_line - ) = - table([], - with nbl = length(l), - [ - row([], - if total_line is - { - no_total then - with col_nb = if hm_col is - { - _1 then 1, - several(n,_) then n - }, - with spacer = if hm_col is - { - _1 then 0, - several(n,sp) then sp - }, - generic_cells - ( - short_lists(l,nbl\col_nb + if (nbl (mod col_nb)) > 0 then 1 else 0,0), - lto,names,line_format,a_color,b_color, - (One u,$Data d) |-> unique,(One _) |-> row([],[]),unique,spacer - ), - total(sum_fct,total_line,init) then - with col_nb = if hm_col is - { - _1 then 1, - several(n,_) then n - }, - with spacer = if hm_col is - { - _1 then 0, - several(n,sp) then sp - }, - generic_cells - ( - short_lists(l,nbl\col_nb + if (nbl (mod col_nb)) > 0 then 1 else 0,0), - lto,names,line_format,a_color,b_color, - sum_fct,total_line,init,spacer - ) - }) - ]). - - - - - Convenience functions : - -public define HTML_Off_Form - generic_table - ( - List($Data) data, - List(Table_Option) lto, - List(HTML_Row(HTML_Off_Form)) columns_name, - (RGB,$Data) -> HTML_Row(HTML_Off_Form) line_format, - RGB a_color, - RGB b_color - ) = - generic_table - ( - (List($Data)) data, - (List(Table_Option)) lto, - (List(HTML_Row(HTML_Off_Form))) columns_name, - (HowManyColumns) _1, - ((RGB,Int,$Data) -> HTML_Row(HTML_Off_Form)) (RGB r,Int n,$Data d) |-> line_format(r,d), - (RGB) a_color, - (RGB) b_color, - (Total_Line($Data,$Data,HTML_Row(HTML_Off_Form))) no_total - ). - -public define HTML_In_Form - generic_table - ( - List($Data) data, - List(Table_Option) lto, - List(HTML_Row(HTML_In_Form)) columns_name, - (RGB,$Data) -> HTML_Row(HTML_In_Form) line_format, - RGB a_color, - RGB b_color - ) = - generic_table - ( - (List($Data)) data, - (List(Table_Option)) lto, - (List(HTML_Row(HTML_In_Form))) columns_name, - (HowManyColumns) _1, - ((RGB,Int,$Data) -> HTML_Row(HTML_In_Form)) (RGB r,Int n,$Data d) |-> line_format(r,d), - (RGB) a_color, - (RGB) b_color, - (Total_Line($Data,$Data,HTML_Row(HTML_In_Form))) no_total - ). - - - 2/ Table with total-line and without multicolumns, enumeration. - - -public define HTML_Off_Form - generic_table - ( - List($Data) data, - List(Table_Option) lto, - List(HTML_Row(HTML_Off_Form)) columns_name, - (RGB,$Data) -> HTML_Row(HTML_Off_Form) line_format, - RGB a_color, - RGB b_color, - Total_Line($Data,$Upplet,HTML_Row(HTML_Off_Form)) total_line - ) = - generic_table - ( - (List($Data)) data, - (List(Table_Option)) lto, - (List(HTML_Row(HTML_Off_Form))) columns_name, - (HowManyColumns) _1, - ((RGB,Int,$Data) -> HTML_Row(HTML_Off_Form)) (RGB r,Int n,$Data d) |-> line_format(r,d), - (RGB) a_color, - (RGB) b_color, - (Total_Line($Data,$Upplet,(HTML_Row(HTML_Off_Form)))) total_line - ). - -public define HTML_In_Form - generic_table - ( - List($Data) data, - List(Table_Option) lto, - List(HTML_Row(HTML_In_Form)) columns_name, - (RGB,$Data) -> HTML_Row(HTML_In_Form) line_format, - RGB a_color, - RGB b_color, - Total_Line($Data,$Upplet,HTML_Row(HTML_In_Form)) total_line - ) = - generic_table - ( - (List($Data)) data, - (List(Table_Option)) lto, - (List(HTML_Row(HTML_In_Form))) columns_name, - (HowManyColumns) _1, - ((RGB,Int,$Data) -> HTML_Row(HTML_In_Form)) (RGB r,Int n,$Data d) |-> line_format(r,d), - (RGB) a_color, - (RGB) b_color, - (Total_Line($Data,$Upplet,(HTML_Row(HTML_In_Form)))) total_line - ). - - - - - 3/ Table with multicolumns, enumeration, but without total - -public define HTML_Off_Form - generic_table - ( - List($Data) data, - List(Table_Option) lto, - List(HTML_Row(HTML_Off_Form)) columns_name, - HowManyColumns number_of_columns, - (RGB,Int,$Data) -> HTML_Row(HTML_Off_Form) line_format, - RGB a_color, - RGB b_color - ) = - generic_table - ( - (List($Data)) data, - (List(Table_Option)) lto, - (List(HTML_Row(HTML_Off_Form))) columns_name, - (HowManyColumns) number_of_columns, - ((RGB,Int,$Data) -> HTML_Row(HTML_Off_Form)) (RGB r,Int n,$Data d) |-> line_format(r,n,d), - (RGB) a_color, - (RGB) b_color, - (Total_Line($Data,$Data,(HTML_Row(HTML_Off_Form)))) no_total - ). - - -public define HTML_In_Form - generic_table - ( - List($Data) data, - List(Table_Option) lto, - List(HTML_Row(HTML_In_Form)) columns_name, - HowManyColumns number_of_columns, - (RGB,Int,$Data) -> HTML_Row(HTML_In_Form) line_format, - RGB a_color, - RGB b_color - ) = - generic_table - ( - (List($Data)) data, - (List(Table_Option)) lto, - (List(HTML_Row(HTML_In_Form))) columns_name, - (HowManyColumns) number_of_columns, - ((RGB,Int,$Data) -> HTML_Row(HTML_In_Form)) (RGB r,Int n,$Data d) |-> line_format(r,n,d), - (RGB) a_color, - (RGB) b_color, - (Total_Line($Data,$Data,(HTML_Row(HTML_In_Form)))) no_total - ). - - - - 4/ Table with multicolumns and without enumeration & total - -public define HTML_Off_Form - generic_table - ( - List($Data) data, - List(Table_Option) lto, - List(HTML_Row(HTML_Off_Form)) columns_name, - HowManyColumns number_of_columns, - (RGB,$Data) -> HTML_Row(HTML_Off_Form) line_format, - RGB a_color, - RGB b_color - ) = - generic_table - ( - (List($Data)) data, - (List(Table_Option)) lto, - (List(HTML_Row(HTML_Off_Form))) columns_name, - (HowManyColumns) number_of_columns, - ((RGB,Int,$Data) -> HTML_Row(HTML_Off_Form)) (RGB r,Int n,$Data d) |-> line_format(r,d), - (RGB) a_color, - (RGB) b_color, - (Total_Line($Data,$Data,(HTML_Row(HTML_Off_Form)))) no_total - ). - - -public define HTML_In_Form - generic_table - ( - List($Data) data, - List(Table_Option) lto, - List(HTML_Row(HTML_In_Form)) columns_name, - HowManyColumns number_of_columns, - (RGB,$Data) -> HTML_Row(HTML_In_Form) line_format, - RGB a_color, - RGB b_color - ) = - generic_table - ( - (List($Data)) data, - (List(Table_Option)) lto, - (List(HTML_Row(HTML_In_Form))) columns_name, - (HowManyColumns) number_of_columns, - ((RGB,Int,$Data) -> HTML_Row(HTML_In_Form)) (RGB r,Int n,$Data d) |-> line_format(r,d), - (RGB) a_color, - (RGB) b_color, - (Total_Line($Data,$Data,(HTML_Row(HTML_In_Form)))) no_total - ). - - - - diff --git a/calexium_lib/web/CXM_html.anubis b/calexium_lib/web/CXM_html.anubis deleted file mode 100644 index 0ad8cdc..0000000 --- a/calexium_lib/web/CXM_html.anubis +++ /dev/null @@ -1,2395 +0,0 @@ - - *Project* The Anubis Project - *Title* Producing HTML/Javascript code. - - *Copyright* Copyright (c) Alain Prouté 2001. - -read tools/basis.anubis -read system/string.anubis -read tools/printable_tree.anubis - - - *** Managing Web Arguments. - - When a client submits a form, he sends informations to the server. This information is - transformed by the server into a list of data of type 'Web_arg'. This is the reason why - a 'web page' operation always has a unique argument of type 'List(Web_arg)'. - - The type 'Web_arg' is defined in 'web/common.anubis' as follows: - - public type Web_arg: - web_arg(String name, - String value), - upload (String name, - String value, - String temp_file_path). - -read CXM_common.anubis - - In other words, a 'web argument' is just a pair made of the name of the argument, and - the value of the argument, and both are character strings. 'upload' will be explained - later. - - - The next variable is a multipurpose counter (used to generate unique names). - -variable Int web_count = 0. - -define Int - new_web_count - = - web_count <- *web_count+1; - *web_count. - - - Names for Web colors. - -public type Web_color_name: - aliceblue, - antiquewhite1, - antiquewhite2, - antiquewhite3, - antiquewhite4, - aquamarine1, - aquamarine2, - aquamarine3, - aquamarine4, - azure1, - azure2, - azure3, - azure4, - yellow. - - - and so on ... (see below why I did not do more). - - - - Web colors. - -public type Web_color: - rgb(Word8,Word8,Word8), /* give the color by its components */ - _(Web_color_name). /* or by its name */ - - - - - The following produces '' tags, which are put in the head of the document. - -public type WebMeta: - keywords(List(String)), - refresh(String url, Int delay), // in seconds - meta(String name, String content), - http_equiv(String name, String content). - - - - - - ******************************************************* - * Web items * - * (the many kinds of things one may put in a page) * - ******************************************************* - - -public type Web_item: - [ ], /* empty (invisible) item */ - ... this is a cross recursive type. - - - - - Options for web page body. - -public type LayerDisposition: - horizontal, - vertical. - -public type FollowPathCommand: // this type is used by the Web_body_option 'follow_path'. - pos(Int x, // x coordinate of position - Int y, // y coordinate of position - Int image_number, // the image to display at that position - Int delay). // wait that milliseconds before leaving this position - -public type Web_body_option: - background_color(Web_color), /* color for the background */ - // - // 'psychedelic_background' produces a background color which is continuously changing. - // 'average' is the average luminosity of the color. 'amplitude' is the maximal variation - // the luminosity around the average. 'delay' is the number of milliseconds between two - // color changes. For example, you may try 'psychedelic_background(200,50,1000)', which - // produces a background whose color changes very slowly (this is not tiring) among rather - // light pastel colors. - // - psychedelic_background(Int average, /* average light (0 to 255) */ - Int amplitude, /* amplitude of variation of light */ - Int delay), /* in milliseconds */ - background_image(String file_name), /* name of image file for the background */ - // - // 'scrolling_layer' produces a layer above the page which is scrolling continuously either - // vertically or horizontally. The 'content' is indefinitly repeated. - // - scrolling_layer(LayerDisposition, - Int steps, /* number of pixels of each move */ - Int margin, /* measured from left or top in pixels */ - Int delay, /* milliseconds for one move */ - Web_item content, /* content of layer (will be repeated) */ - Int period), /* number of pixels between two instances of 'content' */ - // - // 'bounce' shows its content above the page and let it move and bounce on the edges of a rectangle. - // The rectangle is determined by the last 4 arguments. - // - bounce(Web_item content, - Int left, - Int right, - Int top, - Int bottom), - // - // put something over the page in any position you want: - // - over(Web_item content, - Int left, - Int top), - // - // follow_path: let a changing image follow a path on the screen. This gadget shows - // an image following a polygonal path on the screen. The image may change at regular - // intervals, thus providing extra animation. The images are displayed in the order - // they are given in the first argument. When the last image has been displayed, the - // first image is displayed again, and so on. The path is a sequence of absolute positions - // on screen (actually in the browser's window or frame), which is followed in the - // order given in the 'path' argument. If 'loop' is true, the path is followed again and again. - // Otherwise, it is followed only once. If you want to make a closed loop, the last - // position must be the same as the first one. 'steps' is the number of pixels of distance - // between two successive positions of the image, and 'delay' the number of milliseconds - // between two successive positions. 'change_every' is the number of steps (a 'step' is - // passing from one position to the next one) after which the displayed image is replaced - // by the next image. - // - // Each position 'pos(x,y,i,d)' has 4 parameters. 'x' and 'y' are the coordinates of the - // position in the browser's window or frame. 'i' is the number of the image to display - // at this position (i.e. the rank of the image in the list 'filename'. The first one has - // rank 0). 'd' is the delay in milliseconds to wait before leaving that position. - // - follow_path(List(String) filenames, /* the changing images which follows the path */ - Int change_every, /* number of steps betwen two changes */ - List(FollowPathCommand) path, /* the polygonal path and commands */ - Bool loop, /* if true do it repeatedly, otherwise only once */ - Int steps, /* approximative distance (in pixels) between two - successive positions */ - Int delay), /* milliseconds between two successive positions */ - - load_image(String name), /* load an image (for next page), which is not displayed */ - left_margin(Int), /* left margin for document */ - top_margin(Int), /* top margin for document */ - margin_width(Int), - margin_height(Int), - reload_frame(String name, /* name of target frame */ - String url), /* url to load in this frame */ - onload(String function_name). /* nom de la fonction javascript (sans les '()') */ - -public type BodyOnload: - reload_frame(String name, String url). - -variable List(BodyOnload) body_onloads = [ ]. - -define One - add_body_onload - ( - BodyOnload item - ) = - body_onloads <- [item . *body_onloads]. - -define Printable_tree - format - ( - BodyOnload item - ) = - if item is - { - reload_frame(name,url) then (Printable_tree) - [ " window.open('",url,"','",name,"');" ] - }. - -define Printable_tree - format - ( - List(BodyOnload) l - ) = - if l is - { - [ ] then (Printable_tree)[ ], - [h . t] then (Printable_tree) - [format(h) . format(t)] - }. - - ----- Body of a web page. -------------------------------------------- -public type Page_body: - body(List(Web_body_option), /* list of body options */ - Web_item content). /* the content of the page */ - - -public type VFrame: - frame(Int height, - Printable_tree url, - String name). - ----- Web pages. ----------------------------------------------------- -public type Web_page: - web_page(String title, /* title appearing on top of browser */ - List(WebMeta) meta_tags, - Printable_tree head_scripts, /* scripts à placer dans la balise head */ - Page_body body), /* body of page */ - standard_frameset(String title, - List(WebMeta) meta_tags, - Int height, /* height of 'top menu' (pixels) */ - Int width, /* width of 'left menu' (pixels) */ - Printable_tree main). /* url for main */ - - +---------+--------------------------+ - | | ^ | - |<-width->| top height | - | | v | - | left +--------------------------+ - | | | - | | main | - | | | - | | | - | | | - +---------+--------------------------+ - - Note: top and left frames must be loaded through the Web_body_option 'reload_frame'. - - -public define Web_page - web_page - ( - String title, - Page_body body - ) = - web_page(title,[],[], body). - -public define Web_page - web_page - ( - String title, - List(WebMeta) meta_tags, - Page_body body - ) = - - web_page(title, meta_tags, [], body). - - public define Web_page -web_page - ( - String title, - Printable_tree head_scripts, - Page_body body - ) = - - web_page(title, [], head_scripts, body). - -public define Web_page -standard_frameset - ( - String title, - Int height, - Int width, - Printable_tree main - ) = - - standard_frameset(title, [], height, width, main). - - -variable Printable_tree scripts = []. - -define One - add_script - ( - Printable_tree script - ) = - scripts <- [*scripts . script]. - - - - ---- Non empty web items. ------------------------------------------- - - We have already seen the empty web item. Together with the following one, it enables to - make (pseudo-)lists of web items, which will be presented one after the other (from - left to right) in the browser's window. - -public type Web_item: - [Web_item . Web_item],... - - - A web item may be a simple string or a simple integer: - -public type Web_item: - text(String), - text_pt(Printable_tree), - text_nowrap(String), - text_nowrap_pt(Printable_tree), - par(String), - preformated_text(String text), - integer(Int), - float(Float,Int),... - - - You may want to center a web item in a page. Just enclose it into - 'center(...)': - -public type Web_item: - center(Web_item),... - - - You may want to write characters of a given item with a big font: - -public type Web_item: - bigger(Int,Web_item), - smaller(Int,Web_item), - bold(Web_item), - italic(Web_item), - big(Web_item), - very_big(Web_item),... - - - Most of the previous are subsumed by 'style': - -public type WebStyle: - background_image(String file_name), - background_color(Web_color color), - background_transparent, - background_repeat_horizontal, // repeat the background image only horizontally - background_repeat_vertical, - background_no_repeat, - color(Web_color color), - float_to_left, // the web item will float to the left and text will wrap around - float_to_right, - font_family(String font_name), // "verdana" "helvetica" "times" etc... - font_size(Int size), - italic, - oblique, - small_capitals, - bold, - bolder, - lighter, - line_height(Int height), - text_center, - text_left, - text_right, - text_justify, - text_underline, - text_blink, - text_line_through, - width(Int n). - - - -public type Web_item: - style(List(WebStyle) styles, Web_item content),... - - -public type Web_item: - spacer(Int width, Int height), - image(String file_name), /* image */ - image_d(String file_name, String description), - image_pt(Printable_tree file_name), - on_image(String file_name, Web_item content), - turning_images(NonEmptyList(String) filenames, Int millisecs),... - - - - A 'rollover' has the same role as a submit button or link, but it is prettier. It is - made of two images. The first one 'image_on' determines the aspect of the button when - the mouse cursor is on it. The other one 'image_off' determines the aspect of the - button when the mouse cursor is anywhere else. The two images should be of the same - size, otherwise bad effects may occur. The last operand 'description' is a small text - which describes the role of the button. It appears in a bubble in the browser's window. - -public type Web_item: - rollover(List(String) preload_images, // images to preload before the rollover is effective - String url, // URL with possible web arguments - String target, - String image_on, // file name of 'highlighted' image - String image_off, // file name of 'non highlighted' image - String description), // short behavior description - rollover(List(String) preload_images, - String url, - String target, - String image_on, - String image_off, - Int width, - Int height, - String description), ... - - - Mouse sensitive images are images with predefined zones which are clickable. When - clicking in a zone, the specified corresponding URL is loaded by the browser. If two - zones overlap, the first one (in the order they are defined) is selected. - - Zones are of 3 sorts: rectangles, circles and polygons. Point's coordinates are - specified as pairs of integers (of anonymous agglomeration type (Int,Int)). The - first coordinate counts pixels from the left of the image. The second coordinate counts - pixels from the top of the image. With polygons, you can construct zones which are - almost as complicated as you want. You may also construct a zone as the overlapping of - several zones with the same URL. - -public type Mouse_Sensitive_Zone: - rectangle - ( - (Int,Int) left_top, - (Int,Int) right_bottom, - String url - ), - circle - ( - (Int,Int) center, - Int radius, - String url - ), - polygon - ( - List((Int,Int)) vertices, - String url - ). - -public type Web_item: - mouse_sensitive_image(String image_file_name, // the image itself - List(Mouse_Sensitive_Zone) zones),... - - - In project: mouse sensitive images, whose zones behave like submission buttons (to be - used within a form). - - -public type Web_item: - background_sound(String sound_file_name, - Bool loop),... - - - - ************************* - * FORMS * - ************************* - - - Use 'forms' in order to get informations back from the client. The constructor 'form' - take 2 arguments: - - - the name of the form, which must be the name of an Anubis web - page. Indeed, when the user will submit the form, this page will - be sent to him. - - the content of the form, which may be any web item, but which - normally (amongh other things) contains input fields and a - submit button. - -public type Web_item: - form(Printable_tree name, - Web_item content), - form_target(Printable_tree name, - Web_item content, - String target), - form(Printable_tree name, - String label_name, - Web_item content), - form_name(String form_name, // option name de form - Web_item content),... - - public define Web_item -form - ( - Printable_tree name, - Web_item content - ) = - - form("", name, content). - - Within a form, you may put 'text input fields', that the client may - edit. The constructor 'text_input' has the following arguments: - - - name of input field. This will be the name of the correponding - web argument in the Anubis web page referred to by the form. - - size of field (as it appears on client screen), - - initial value of field (the text that appears in the field, when - the client downloads the page). - - - public type Text_Input_Option - -public type Web_item: - text_input(String name, /* text field to be documented by user */ - Int size, - String initial_value),... - - public define Web_item - text_input - ( - String name, - Int size, - String initial_value - ) = - - - text_input( (List(Text_Input_Option)) [], name, size, initial_value). - - -public type Web_item: - password_input(String name, - Int size), - text_area(String name, - Int columns, - Int rows, - String initial_text), - upload(String name, Int size),... - - - - -public type Web_item: - submit(String button_text), /* submit button with text on it */ - submit_pt(Printable_tree button_text), - submit(String name, String text), - submit_close(String name, String text), - submit_pt2(String name, Printable_tree text), - image_submit(String name, String image_file_name), - image_submit(String name, String value, String image_file, Web_item content), - hl_image_submit(String action_name, - String value, - String image_name, - String image_file, - String hl_image_file), - text_submit(String name, String value, String text), - web_submit(String web_args, Web_item content), - button(String name, String text, String on_click_fonction, Int width, Int height),... - - -public type Web_item: /* mark the form with an information */ - mark(String name, String value), - mark_pt(String name, Printable_tree value),... - -public type Web_item: - close_button, /* button that closes the window */ - close_button(String image_file_name), ... - - - - ********************************* - * LABELS * - ********************************* - - - A 'label' is just a name that you may give to a position in a document. Use the - following invisible Web_item 'label' to this end. Now, you can also create links in - the same document, which, when clicked by the user, scroll the document, so that the - position whose name is the given label is shown just at the top of the browser's - window. - -public type Web_item: - label(String label_name), /* give a name to a position in the page */ - go_to_label(String label_name, /* a link for jumping to a label */ - Web_item content),... - - - - ******************************** - * TABLES * - ******************************** - - - A web item may be a table. A table is produced by the constructor - 'table' from the type 'Web_item'. This constructor takes 2 - arguments: - - - a list of 'table options', - - a list of 'table rows'. - - Of course, you use as many options as you want, including - none (if you do not want any option, put the empty list '[ ]' as - this argument). Some options have precedence over others. For example - a background image will hide the background color. - - Table options are defined below: - -public type Table_option: - - /* use a color as a background for the table, if you want it to - be different from the background of the page */ - background_color(Web_color), - - /* or use an image as the background of the table */ - background_image(String file_name), - - /* draw a border line around the table (and around each cell in - the table). You may also specify a geometry (in pixels) for the - border. This makes the 'in relief' part of the border appear - more or less wide. You may also specify a color for the border. */ - border, - nude, /* equivalent to 'border(0,0,0)' (below) */ - border(Int, /* width of exterior (pixels) */ - Int, /* width of top */ - Int), /* width of interior */ - border_color(Web_color), - absolute_width(Int). - - - - A 'table row' is made of a list of 'row options', and a list of - 'cells'. A 'cell' itself has a list of 'cell options', and a web item, - which is its content. We begin by the description of options. - - -public type Row_option: - /* following concerns the horizontal positions of items within the - cells of the row */ - left, - h_center, - right, - /* the following concerns the vertical positions of items, within - the cells of the row */ - top, - v_center, - bottom, - absolute_height(Int), - base_line, - /* set the background color of all cells in the row */ - background_color(Web_color). - - - -public type Cell_option: - /* all row options are available for individual cells, and apply - here only to one cell. */ - left, - h_center, - right, - top, - v_center, - bottom, - base_line, - background_color(Web_color), - /* you can set the width of the cell either absolutely (in pixels) - or as a percentage of the width of the table. */ - background_image(String file_name), - absolute_width(Int), - relative_width(Int), - absolute_height(Int), - relative_height(Int), - /* a cell may span over several columns or rows in the table */ - columns(Int), - rows(Int), - nowrap. - - -public type Cell: - cell(List(Cell_option), - Web_item). - -public type Table_row: - row(List(Row_option), - List(Cell)). - -public define Table_row row(Web_item i) = row([],[cell([],i)]). -public define Table_row row(Cell c) = row([],[c]). -public define Table_row row(List(Cell) l) = row([],l). - - -public type Web_item: - table(List(Table_option), - List(Table_row)),... - -public type Web_item: - list(List(Web_item)),... - -public type Web_item: - link(String name, Web_item), - link(String name, String target, Web_item),... - -public type Web_item: - link_for_download(String filename, Web_item),... // the filename is relative to the public directory - -public type Web_item: - mail_to(String addr, Web_item),... - - -public type Web_item: - select(String name, - Int size, - List(String) choices), - select(String name, - Int size, - List(String) choices, - String selected), - immediate_select(String name, // selection will immediately submit the form - Int size, - List(String) choices),... - - -public type Web_item: - radio_button (Printable_tree name, String value), - checked_radio_button (Printable_tree name, String value), - check_box (Printable_tree name, String value), - checked_box (Printable_tree name, String value),... - - -public type Web_item: - link_to_window(Printable_tree name, Web_item), - link_to_window(Printable_tree name, String window_name, Web_item), - link_to_window_with_ticket(String name, - String web_args, - String window_name, - Web_item content, - Int width, - Int height), - link_to_window_with_ticket_and_scroll - (String name, - String web_args, - String window_name, - Web_item content, - Int width, - Int height), - link_to_window_with_ticket_and_scroll - (String name, - String label_name, - String web_args, - String window_name, - Web_item content, - Int width, - Int height), - link_to_frame (Printable_tree name, String frame_name, Web_item). - - - ----- Formating operations (Anubis --> HTML/Javascript) --------------------------- - - Stupid operation formating a web color name. - -public define String - format - ( - Web_color_name n - ) = - if n is - { - aliceblue then "aliceblue", - antiquewhite1 then "antiquewhite1", - antiquewhite2 then "antiquewhite2", - antiquewhite3 then "antiquewhite3", - antiquewhite4 then "antiquewhite4", - aquamarine1 then "aquamarine1", - aquamarine2 then "aquamarine2", - aquamarine3 then "aquamarine3", - aquamarine4 then "aquamarine4", - azure1 then "azure1", - azure2 then "azure2", - azure3 then "azure3", - azure4 then "azure4", - yellow then "yellow", - }. - - Anubis really needs some system of 'macros' to avoid this... - - - Formating a web color. - -public define String - format - ( - Web_color wc - ) = - if wc is - { - rgb(r,g,b) then "\"#" + to_hexa(r) + to_hexa(g) + to_hexa(b) + "\"", - _(c) then format(c) - }. - -public define String - format_without_quotes - ( - Web_color wc - ) = - if wc is - { - rgb(r,g,b) then "#" + to_hexa(r) + to_hexa(g) + to_hexa(b) + "", - _(c) then format(c) - }. - -define Printable_tree - format - ( - Web_color c - ) = [(String)format(c)]. - -public define String - format_without_sharp - ( - Web_color wc - ) = - if wc is - { - rgb(r,g,b) then "" + to_hexa(r) + to_hexa(g) + to_hexa(b) + "", - _(c) then format(c) - }. - -define Printable_tree - format_without_sharp - ( - Web_color c - ) = [(String)format_without_sharp(c)]. - - - define Printable_tree - [Word32 x . Printable_tree t] - = - [to_Int(x) . t]. - -define Printable_tree - psychedelic_bg - ( - Int average, - Int amplitude, - Int delay - ) = - with ampl = if amplitude >= 120 then 120 else - if amplitude =< 1 then 1 else amplitude, - with aver = if average+ampl >= 254 then 254-ampl - else if average-ampl =< 1 then 1+ampl else average, - [ ""]. - - -define List(Web_body_option) - replace_background_init - ( - List(Web_body_option) l, - Int average, - Int amplitude, - Int delay - ) = - if l is - { - [ ] then [ ], - [h . t] then - if h is background_color(_) - then [background_color(rgb(truncate_to_Word8(average+amplitude), - truncate_to_Word8(average), - truncate_to_Word8(average-amplitude))) - . replace_background_init(t,average,amplitude,delay)] - else [h . replace_background_init(t,average,amplitude,delay)] - }. - -define Maybe((Int,Int,Int)) - get_psy - ( - List(Web_body_option) l - ) = - if l is - { - [ ] then failure, - [h . t] then - if h is psychedelic_background(a,f,d) - then success((a,f,d)) - else get_psy(t) - }. - -define List(Web_body_option) - prepare - ( - List(Web_body_option) l - ) = - if get_psy(l) is - { - failure then l, - success(op) then if op is (a,f,d) then - replace_background_init(l,a,f,d) - }. - - -public define Printable_tree - format - ( - String c_ticket, - String s_ticket, - Web_item i - ). - -define Printable_tree - move_layer_command - ( - String property, - Int n, - Int num, - Int i, - Int period - ) = - if i >= num then [ ] else - [" if (document.layers)", - " { document.nslay",n,"_",i,".",property,"=layp",n,"+(",((i-1)),"); } ", - " else ", - " { ielay",n,"_",i,".style.",property,"=layp",n,"+(",(i-1)*period,"); } " - . move_layer_command(property,n,num,i+1,period)]. - -define Printable_tree - format_layers - ( - LayerDisposition disp, - Int margin, - Web_item content, - Int n, - Int num, - Int i, - Int period - ) = - if i >= num then [ ] else - ["", - "
", - format("","",content), - "
" . format_layers(disp,margin,content,n,num,i+1,period)]. - -define Printable_tree - s_layer - ( - LayerDisposition disp, - Int steps, - Int margin, - Int delay, - Web_item content, - Int period, - Int num - ) = - with n = new_web_count, - [ "", - format_layers(disp,margin,content,n,num,0,period), - ]. - - -define Printable_tree - over - ( - Web_item i, - Int left, - Int top - ) = - with n = new_web_count, - [ "", - "
", - format("","",i), - "
" - ]. - -define Printable_tree - bnce - ( - Web_item i, - Int left, - Int right, - Int top, - Int bottom - ) = - with n = new_web_count, - [ "", - "", - "
", - format("","",i), - "
" - ]. - - -define Printable_tree - folp_switch - ( - Int n, - Int i, - List(FollowPathCommand) path, - Bool loop, - Int steps - ) = - if path is - { - [ ] then [ ], - [p0 . t0] then if p0 is pos(x0,y0,i0,d0) then - if t0 is - { - [ ] then if loop - then [" default: ", - " folpx",n,"=",x0,"; folpy",n,"=",y0,"; ", - " folpseg",n,"=0; ", - " folpwait",n,"=",d0,";", - " if(document.layers)", - " document.nslay",n,".document.folpim",n,".src=folpimages",n,"[",i0,"].src;", - " else document.folpim",n,".src=folpimages",n,"[",i0,"].src;", - " folpstpmax",n," = 0;", - " folpstp",n,"=0;", - " folpdx",n,"=0; ", - " folpdy",n,"=0; ", - " break;"] - else [" default: folpend",n,"=1; break; "], - [p1 . t1] then if p1 is pos(x1,y1,i1,d1) then - [ " case ",i,": ", - " folpx",n,"=",x0,"; folpy",n,"=",y0,"; ", - " folpseg",n,"=",i+1,"; ", - " folpwait",n,"=",d0,";", - " if(document.layers)", - " document.nslay",n,".document.folpim",n,".src=folpimages",n,"[",i0,"].src;", - " else document.folpim",n,".src=folpimages",n,"[",i0,"].src;", - " folpstpmax",n," = ", - "Math.round(Math.sqrt(Math.pow(",x1,"-",x0,",2)+Math.pow(",y1,"-",y0,",2))/",steps,");", - " folpstp",n,"=0;", - " folpdx",n,"=((",x1,"-",x0,")/folpstpmax",n,"); ", - " folpdy",n,"=((",y1,"-",y0,")/folpstpmax",n,"); ", - " break; " - . folp_switch(n,i+1,t0,loop,steps) ] - }}. - -define Printable_tree - set_folpimages - ( - Int n, - List(String) filenames, - Int i, - ) = - if filenames is - { - [ ] then [ ], - [h . t] then - [ " folpimages",n,"[",i,"].src=\"",h,"\";" - . set_folpimages(n,t,i+1)] - }. - -define Printable_tree - follow_path - ( - List(String) filenames, - Int change_every, - List(FollowPathCommand) path, - Bool loop, - Int steps, - Int delay - ) = - if filenames is - { - [ ] then (print("Error in usage of 'follow_path': 'filenames' must be non empty."); []), - [im1 . other_ims] then - if steps < 1 then (print("Error in usage of 'follow_path': 'step' must be >= 1."); [ ]) else - if path is - { - [ ] then [ ], - [p0 . t0] then if p0 is pos(x0,y0,i0,d0) then - if t0 is - { - [ ] then - (print("Error in usage of 'follow_path': 'path' must have at least 2 positions."); []), - [p1 . t1] then if p1 is pos(x1,y1,i1,d1) then - with n = new_web_count, - [ - "", - "
", - "", - "
", - "", - ] - }}}. - - -public type ImageToLoad: - simple(String image_name), - with_rollover(String image_name, - String rollover_name). - -variable List(ImageToLoad) images_to_load = []. - -public define Printable_tree - format - ( - Web_body_option o - ) = - if o is - { - background_color(c) then [" bgcolor=" , (String)format(c)], - psychedelic_background(a,f,d) then add_script(psychedelic_bg(a,f,d)); [ ], - background_image(n) then [" background=", n], - scrolling_layer(disp,st,m,t,c,p) then add_script(s_layer(disp,st,m,t,c,p,2000\p)); [ ], - bounce(i,l,r,t,b) then add_script(bnce(i,l,r,t,b)); [ ], - over(i,l,t) then add_script(over(i,l,t)); [ ], - follow_path(li,ns,p,l,s,d) then add_script(follow_path(li,ns,p,l,s,d)); [ ], - load_image(n) then images_to_load <- [simple(n) . *images_to_load]; [ ], - left_margin(n) then [" leftmargin=", n], - top_margin(n) then [" topmargin=", n], - margin_width(n) then [" marginwidth=", n], - margin_height(n) then [" marginheight=", n], - reload_frame(n,url) then add_body_onload(reload_frame(n,url)); [ ], - onload(n) then [" onLoad=\"", n, "()\""] - }. - -define Printable_tree - preload_list - ( - List(ImageToLoad) images, - Int n, - ) = - if images is - { - [ ] then [ ], - [h . t] then - [" preloaded_images[",n,"].src = '",image_name(h),"';", - if h is - { - simple(_) then [], - with_rollover(n1,r) then - [" preloaded_images[",n1,"].onload = 'allow_rollover(\"",r,"\")';"] - } - . preload_list(t,n-1)] - }. - -define Printable_tree - load_image_script - ( - List(ImageToLoad) images - ) = - if images is - { - [ ] then [ ], - [_ . _] then - [ - "" - ] - }. - - -public define Printable_tree format(String c_ticket, - String s_ticket, - Web_item i). - - -public define Printable_tree - format(List(Table_option) l) = - if l is - { - [ ] then [ ], - [h . t] then [if h is - { - background_color(c) then [" bgcolor=", (String)format(c)], - background_image(f) then [" background=",f], - border then [" border"], - nude then [" border=\"0\" cellspacing=\"0\" cellpadding=\"0\""], - border(e,top,i) then [" border=",e," cellspacing=",top," cellpadding=",i], - border_color(c) then [" bordercolor=", (String)format(c)], - absolute_width(n) then [" width=",n] - }, format(t)] - }. - - - -public define Printable_tree - format(List(Row_option) l) = - if l is - { - [ ] then [ ], - [first . others] then [if first is - { - left then [" align=left"], - h_center then [" align=center"], - right then [" align=right"], - top then [" valign=top"], - v_center then [" valign=center"], - bottom then [" valign=bottom"], - absolute_height(n) then [" height=\"",n,"\""], - base_line then [" valign=baseline"], - background_color(c) then [" bgcolor=",(String)format(c)] - }, - format(others)] - }. - - - - -public define Int - percentage(Int n) = - if n < 0 then 0 - else if n > 100 then 100 - else n. - - public define Int percentage(Int n) = n. - - - - -public define Printable_tree - format - ( - List(Web_body_option) l - ) = - if l is - { - [ ] then [ ], - [h . t] then [format(h) . format(t)] - }. - - - - -public define Printable_tree - format(List(Cell_option) l) = - if l is - { - [ ] then [ ], - [first . others] then - [if first is - { - left then (Printable_tree)[" align=left"], - h_center then (Printable_tree)[" align=center"], - right then (Printable_tree)[" align=right"], - top then (Printable_tree)[" valign=top"], - v_center then (Printable_tree)[" valign=center"], - bottom then (Printable_tree)[" valign=bottom"], - base_line then (Printable_tree)[" valign=baseline"], - background_color(c) then (Printable_tree)[" bgcolor=",(String)format(c)], - background_image(n) then (Printable_tree)[" style=\"background: url(",n,")\""], - absolute_width(w) then (Printable_tree)[" width=",w], - relative_width(r) then (Printable_tree)[" width=",percentage(r),""], - absolute_height(h) then (Printable_tree)[" height=",h], - relative_height(r) then (Printable_tree)[" height=",percentage(r),""], - columns(n) then (Printable_tree)[" colspan=",n], - rows(n) then (Printable_tree)[" rowspan=",n], - nowrap then (Printable_tree)[" nowrap"] - } - . format(others)] - }. - - - -public define Printable_tree - format - ( - String c_ticket, - String s_ticket, - List(Cell) l - ) = - if l is - { - [ ] then [ ], - [first . others] then - [if first is cell(options,item) then - ["", - format(c_ticket,s_ticket,item),""], - format(c_ticket,s_ticket,others)] - }. - - -public define Printable_tree - format - ( - String c_ticket, - String s_ticket, - List(Table_row) l - ) = - if l is - { - [ ] then [ ], - [first_row . other_rows] - then [if first_row is - { - row(options,cells) then - [ "", - format(c_ticket,s_ticket,cells),""] - }, - format(c_ticket,s_ticket,other_rows)] - }. - - -public define Printable_tree - format_choices - ( - List(String) l - ) = - if l is - { - [ ] then [ ], - [h . t] then ["