Compare commits

...
393 Commits
Author SHA1 Message Date
tomasz.sowa 8d84344990 add a .clang-format file 2026-08-18 00:18:21 +02:00
tomasz.sowa 98ba7450a4 allow to force installing a clangd and qtcreator files
Add new targets to the Makefile:
- forceclangd - allow to force installing a .clangd file
- forceclangdall - force installing .clangd file in this project and in libriaries:
  pikotools, morm, ezc and tito
- forceqtcreator - force installing qtcreator files
- forceqtcreatorall - force installing qtcreator files in this project and in libraries
Existing files will be overwritten.

while here:
- update the c++ standard to c++23
2026-08-18 00:03:39 +02:00
tomasz.sowa b82a36142c allow to use multiple locale directories
remove config options:
- locale_dir
- locale_dir_default

add a config option:
- locale_dirs - a list of directories with locale files (translations)

We start reading locale from the first directory and files with the same name
in each directory are concatenated.
2026-06-21 23:36:29 +02:00
tomasz.sowa d35854691c allow to use multiple directories in html and txt templates
remove from the config:
templates_dir, templates_dir_default, txt_templates_dir, txt_templates_dir_default

add to the config:
html_templates_dirs - a list of directories with html templates
txt_templates_dirs - a list of directories with txt templates

We search from the last directory to the first one.
2026-06-21 01:59:32 +02:00
tomasz.sowa 9e1a3e336b bump version to 0.7.4 2026-06-21 01:41:09 +02:00
tomasz.sowa e897cfbd14 add FunctionBase::trigger_htmx_event() with a std::wstring parameter 2026-06-21 01:38:45 +02:00
tomasz.sowa 5a92edc6b0 add FunctionBase::trigger_htmx_event() with a string parameter 2026-06-16 01:33:36 +02:00
tomasz.sowa c32ed6ce28 update htmx to 2.0.9 2026-05-27 23:51:44 +02:00
tomasz.sowa 6631ba0641 update uikit to 3.23.10 2025-06-16 23:30:31 +02:00
tomasz.sowa 98320fe174 update uikit to 3.23.6 2025-04-29 09:22:41 +02:00
tomasz.sowa b8105cf9cc update uikit to 3.23.2 2025-03-05 12:44:15 +01:00
tomasz.sowa d7a93916e3 update uikit to 3.22.0 2025-01-13 18:47:59 +01:00
tomasz.sowa cec9dfc0e1 update htmx to 2.0.4 2024-12-21 01:28:39 +01:00
tomasz.sowa 893b3d9fff put a log about generated main content and frames 2024-12-03 10:57:41 +01:00
tomasz.sowa 7de9d1a819 put a log when a request job was not found 2024-12-03 10:34:17 +01:00
tomasz.sowa 8748a63532 update uikit to 3.21.16 2024-11-28 00:33:38 +01:00
tomasz.sowa 5eed025419 add trigger_htmx_event(...) methods to FunctionBase 2024-11-08 13:35:54 +01:00
tomasz.sowa f2e416b0f8 update htmx to 2.0.3 2024-10-09 19:50:27 +02:00
tomasz.sowa 1c7043fa3e update uikit to 3.21.13 2024-09-26 22:13:33 +02:00
tomasz.sowa 2bd4c5b35e print qt environment ids only when .qtcreator directory was created 2024-09-25 09:50:37 +02:00
tomasz.sowa f4481a84f4 fix: set a correct global working dir when generating a .clangd file 2024-09-24 23:41:35 +02:00
tomasz.sowa 4c740690e0 use a QTCreator environmentid and a profileid from a local installation
When creating QTCreator project files use local EnvironmentId
and default profile id. By default the environment id is stored
in ~/.config/QtProject/QtCreator.ini and the profile id in
~/.config/QtProject/qtcreator/profiles.xml.
2024-09-24 16:45:26 +02:00
tomasz.sowa 128c79cdc4 sort a makedepend output
Makefile.dep is sorted now - it's better when making a diff to a previous version.
2024-09-22 15:26:35 +02:00
tomasz.sowa 7082677b2f add a clangd/clangdall and qtcreator/qtcreatorall make targets
Add a clangd make target:
$ make clangd
This installs a .clangd file with configuration (includes/macros/compiler flags)
for the clandg language server.

Add a clangdall make target:
$ make clangdall
This installs a .clangd also in pikotools/ezc/morm and tito libraries.

Add a qtcreator make target:
$ make qtcreator
This installs a .qtcreator directory with QTCreator IDE project files.
In the QTCreator you can open a project by selecting the .qtcreator/winix.creator
file.

You can use 'make qtcreator' again to refresh .qtcreator/winix.files,
the rest of the project files will not be modified.

Add a qtcreatorall make target:
$ make qtcreatorall
This installs a .qtcreator directory also in pikotools/ezc/morm and tito libraries.
2024-09-22 11:43:26 +02:00
tomasz.sowa 257d8bbade change a database type to character varying(320) for a user.email field 2024-09-08 02:29:19 +02:00
tomasz.sowa a6ca71b131 check a length when validating an email
An email address has two parts:
 - the local part (before the "@") = max 64 characters
 - the domain part (after the "@") = max 255 characters
So maximum length is 64 + @ + 255 = 320 characters

https://www.rfc-editor.org/rfc/rfc5321.html#section-4.5.3.1
2024-09-08 02:05:43 +02:00
tomasz.sowa 8634716aa7 add FunctionBase::push_url_to(...) methods 2024-09-08 02:05:05 +02:00
tomasz.sowa 8a12629740 update htmx to 2.0.2 2024-08-19 15:32:56 +02:00
tomasz.sowa b07f2f7a59 remove unnecessary [end] tag 2024-08-12 02:25:47 +02:00
tomasz.sowa da90ef8e40 update uikit to 3.21.7 2024-07-20 15:20:09 +02:00
tomasz.sowa 197f684488 update htmx to 2.0.1 2024-07-20 15:15:03 +02:00
tomasz.sowa e63838faeb improve frontend of emacs, ckeditor, tinymce, nicedit, meta and env functions
Improves in emacs:
- use htmx to send content to the controller
- show txt and formatted_txt content in the second panel
- show two tabs if "tabs" winix parameter is used
- add an option to show either one or two panels
- correctly resize the editor window (F11) when two panels are shown

Improves in ckeditor:
- use htmx to send content to the controller
- do not check automatically for ckeditor update

Improves in tinymce/nicedit/meta/env:
- use htmx to send content to the controller

while here:
- change PascalCase to snake_case in meta/env controllers
- update CodeMirror editor to 5.65.16
- udpate Showdown (markdown to html converter) to 2.1.0
2024-07-20 15:13:27 +02:00
tomasz.sowa 89b37db48e update uikit to 3.21.6 2024-07-11 22:10:44 +02:00
tomasz.sowa 68e7f44a76 do not send content when there is a htmx redirect 2024-07-11 21:58:52 +02:00
tomasz.sowa 2490e2cc68 (ezc): generate only requested frames 2024-07-07 22:10:29 +02:00
tomasz.sowa b2f4c065ea remove a code to finish job requests when winix exits
Actually there was a bug and the code was not correctly waiting for the job requests.
2024-07-02 17:30:35 +02:00
tomasz.sowa 20b40597fd try harder to find the main template and a function's template
If there is no a template (main template and function template) for the current
language then try to find a template for a default language or for a first
available language.
2024-06-29 22:28:39 +02:00
tomasz.sowa 7df78838aa add assign_methods(...) functionality to the FunctionBase
in make_*() methods you can assing your controller methods in such a way:
  assign_methods(this,
    by_param(L"paramoption",                     &MyController::MyMethod3),
    by_param(L"paramoption1", L"paramoption2",   &MyController::MyMethod2),
    by_param_post(L"paramoption", L"postoption", &MyController::MyMethod1)
  );
2024-06-29 17:23:03 +02:00
tomasz.sowa b3bd9c6cf0 update htmx to 2.0.0 2024-06-27 16:37:05 +02:00
tomasz.sowa dadff8329e update uikit to 3.21.5 2024-06-27 11:46:45 +02:00
tomasz.sowa c30b7db041 add closing dialogs, redirecting and removing content functionality to the winix framework
add such new methods to FunctionBase:
- bool can_push_url_to_browser_history();
- void add_standard_models();
- void close_modal_dialogs();

- void prepare_doc_url(const wchar_t * local_url, pt::WTextStream & url);
- void prepare_doc_url(const wchar_t * local_url, std::wstring & url);
- std::wstring prepare_doc_url(const wchar_t * local_url = nullptr);
- std::wstring prepare_doc_url(const std::wstring & local_url);

- void redirect_to(const wchar_t * url, bool append_domain = true);
- void redirect_to(const std::wstring & url, bool append_domain = true);
- void redirect_to(const pt::WTextStream & url, bool append_domain = true);

- void redirect_to(const wchar_t * url, const wchar_t * frame_url, const wchar_t * dom_target);
- void redirect_to(const std::wstring & url, const std::wstring & frame_url, const std::wstring & dom_target);
- void redirect_to(pt::WTextStream & url, pt::WTextStream & frame_url, pt::WTextStream & dom_target);
- void redirect_to(pt::WTextStream & url, pt::WTextStream & frame_url, const wchar_t * dom_target);
- void redirect_to(const wchar_t * url, const wchar_t * frame_url, pt::WTextStream & dom_target);

- void retarged(const wchar_t * frame, const wchar_t * dom_target, const wchar_t * push_url = nullptr, const wchar_t * swap_algorithm = nullptr);
- void retarged(const std::wstring & frame, const std::wstring & dom_target, const std::wstring & push_url, const wchar_t * swap_algorithm = nullptr);
- void retarged(const wchar_t * frame, pt::WTextStream & dom_target, const wchar_t * push_url = nullptr, const wchar_t * swap_algorithm = nullptr);

- void remove_content(pt::WTextStream & dom_target, bool close_dialogs = false);
- void remove_content(const wchar_t * dom_target, bool has_postfix, long dom_target_postfix, bool close_dialogs = false);
- void remove_content(const wchar_t * dom_target, long dom_target_postfix, bool close_dialogs = false);
- void remove_content(const wchar_t * dom_target, bool close_dialogs = false);

- void update_content(const wchar_t * frame, pt::WTextStream & dom_target, bool close_dialogs = false);
- void update_content(const wchar_t * frame, const wchar_t * dom_target, bool has_postfix, long dom_target_postfix, bool close_dialogs = false);
- void update_content(const wchar_t * frame, const wchar_t * dom_target, long dom_target_postfix, bool close_dialogs = false);
- void update_content(const wchar_t * frame, const wchar_t * dom_target, bool close_dialogs = false);

while here:
- refactor PascalCase to snake_case in FunctionBase
- add start_request() and finish_request() methods to FunctionBase
- add has_*_access() methods to FunctionBase
- fix: FunctionBase::clear() method was not called if a request was assigned to a job
- add a WinixEzcHelper model
- allow to serialize a header if the header value is neither a string nor an integer
- refactor PascalCase to snake_case in functions: Emacs, Mkdir, Upload
2024-06-27 10:57:08 +02:00
tomasz.sowa 6aa100f12c WIP: remove the old database abstraction layer
remove such classes:
- DbBase
- DbConn
- DbTextStream
- Db

while here:
- remove: TextStream, SLog, TexTextStream
2024-06-22 18:03:54 +02:00
tomasz.sowa 5d457f3d4b (update to the new pikotools api): use a char32_t character as a main character when converting strings
Use a char32_t instead of a wchar_t type. This is needed on systems
where sizeof(wchar_t) is equal to 2.

This affects classes based on the pt::Stream such as Log and HtmlTextStream.
2024-06-01 00:33:15 +02:00
tomasz.sowa af0d34beb9 make depend 2024-05-31 00:32:56 +02:00
tomasz.sowa d122917f83 fix: correctly activate a user account 2024-05-27 18:22:47 +02:00
tomasz.sowa 612501217c update uikit to 3.20.9 2024-05-12 16:16:56 +02:00
tomasz.sowa d86ab8f9c0 update uikit to 3.20.8 2024-04-29 23:59:30 +02:00
tomasz.sowa 5a33563722 update htmx to 1.9.12 2024-04-28 19:45:16 +02:00
tomasz.sowa 1c850b12ec add a q_encode(...) method to misc 2024-04-28 16:14:57 +02:00
tomasz.sowa 140b4495df update jquery-file-upload to 10.32.0 2024-04-15 08:20:02 +02:00
tomasz.sowa 8b0b25ed0a fix: correctly flush logs when there was a db migration error 2024-04-15 06:38:23 +02:00
tomasz.sowa eacdcfb980 update htmx to 3.19.4 2024-04-11 05:52:09 +02:00
tomasz.sowa 132e7aa937 update htmx to 1.9.11 2024-03-20 03:15:05 +01:00
tomasz.sowa d9f3b69dde update uikit to 3.19.2 2024-03-20 03:07:17 +01:00
tomasz.sowa de753070a8 do not overwrite WINIX_INSTALL_DIR if already set 2024-03-11 16:59:45 +01:00
tomasz.sowa c1c6e6a588 install winix.so to a lib subdirectory 2024-03-11 16:12:13 +01:00
tomasz.sowa 291147503f update uikit to 3.19.1 2024-03-08 22:34:42 +01:00
tomasz.sowa dbf7dfab82 improve the startup help messages 2024-03-08 22:01:33 +01:00
tomasz.sowa b753464608 add some operators to the Log class
add:
virtual Log & operator<<(long double);
virtual Log & operator<<(float);
virtual Log & operator<<(long long unsigned int);
virtual Log & operator<<(unsigned int);
virtual Log & operator<<(short unsigned int);
virtual Log & operator<<(long long int);
virtual Log & operator<<(short int);
virtual Log & operator<<(bool);
virtual Log & operator<<(unsigned char);
virtual Log & operator<<(const pt::Stream &);
2024-02-13 22:29:22 +01:00
tomasz.sowa 544ef298aa update uikit to 3.18.3 2024-02-13 18:54:41 +01:00
tomasz.sowa 065a2d182f update htmx to 1.9.10 2024-01-16 23:17:14 +01:00
tomasz.sowa f4470ccbe7 allow to not set the res value from a plugin function
Add PluginInfo::has_res (bool, default true). If set to false by a plugin function
then the PluginInfo::res value is not taken into account when calculating how many plugins
have returned true or false.
2024-01-04 15:57:29 +01:00
tomasz.sowa 71ad4869ce fix: take into account hours when calculating a relative timezone dst 2023-12-27 16:25:54 +01:00
tomasz.sowa 09dc6782c8 fix: remember the first/last weekday flags from a timezone DST
If a date is given in a relative form with first/last parameters,
we must remember them in order to select the appropriate day
of the week from the appropriate year.
2023-12-24 14:55:39 +01:00
tomasz.sowa 0cebb2dc52 allow to use a first|last weekday name when defining a timezone dst
the format of a 'start' or 'end' field in a dst is:
MM-[first|last]:[monday|tuesday|wednesday|thursday|friday|saturday|sunday] HH:MM:SS
or just as beforehand: MM-DD HH:MM:SS

a sample timezone:
{
name = "tz_+01:00d"
id = "40"
offset_str = "+01:00"

dst = (

{
year = "2001"
has_dst = true
offset_str = "+01:00"
start  	   = "03-last-sunday 01:00"
end    	   = "10-last-sunday 01:00"
}

) # end of dst
}
2023-12-20 03:58:21 +01:00
tomasz.sowa 0724ca8eb3 update htmx to 1.9.9 2023-12-02 10:45:44 +01:00
tomasz.sowa 53991e54e1 update uikit to 3.17.11 2023-11-21 18:59:51 +01:00
tomasz.sowa df7ae1c6ea update uikit to 3.17.9 2023-11-16 23:10:51 +01:00
tomasz.sowa d1f5d9aa88 (winixcli): add a --sort-tables option
while here:
- add a fil_max_size filter for putting a space if the inner stream is greater than x characters
2023-11-09 10:57:11 +01:00
tomasz.sowa a54d70bed4 add a 422 Header status - Unprocessable Entity 2023-11-08 17:59:40 +01:00
tomasz.sowa bcde5c628a update uikit to 3.17.8 2023-11-07 03:56:45 +01:00
tomasz.sowa f241eb0a18 update htmx to 1.9.7 2023-11-06 04:43:20 +01:00
tomasz.sowa 74c0c936f6 make depend 2023-11-02 05:15:30 +01:00
tomasz.sowa 79babc916a add a Request::raw_post buffer
This buffer is used when a Function::NeedToCopyRawPost() method returned true.

while here:
- remove WINIX_POST_PARAMS and WINIX_RAW_POST_STRING plugin messages
2023-11-02 05:14:48 +01:00
tomasz.sowa a08bf9f804 update uikit to 3.17.5 2023-10-24 21:36:25 +02:00
tomasz.sowa 966577cd58 add QT Creator files to .gitignore 2023-10-22 23:38:38 +02:00
tomasz.sowa 8f20c8f67c update uikit to 3.17.1 2023-10-10 13:42:49 +02:00
tomasz.sowa f6c04b2d00 downgrade ckeditor to 4.22.1 as 4.23.0 requires a license key 2023-09-30 01:03:54 +02:00
tomasz.sowa 0474c76a3d update ckeditor to 4.23.0 2023-09-30 00:27:59 +02:00
tomasz.sowa 7a29a072be update jquery to 3.7.1 2023-09-30 00:13:28 +02:00
tomasz.sowa 24c2ecb8dd update htmx to 1.9.6 2023-09-30 00:06:57 +02:00
tomasz.sowa 7a1cea63bf update uikit to 3.17.0 2023-09-30 00:02:00 +02:00
tomasz.sowa e600aebaae add a RequestJobBase base class for requests jobs 2023-09-28 07:47:06 +02:00
tomasz.sowa 5e45ad3417 fix(Http): send body content for PATCH, DELETE and OPTIONS methods if exists
while here:
- use CURLOPT_UPLOAD instead of CURLOPT_PUT as the latter is depracated
2023-09-26 23:02:34 +02:00
tomasz.sowa 79e971cb76 parse the input body for the PUT and PATCH methods too 2023-09-15 10:04:25 +02:00
tomasz.sowa edee581ecf update uikit to 3.16.26 2023-08-31 02:01:47 +02:00
tomasz.sowa f7e077a7c5 add a TimeZone::PrintOffset(...) method 2023-08-29 15:02:37 +02:00
tomasz.sowa 6a9504fd5f update htmx to 1.9.5 2023-08-26 00:16:06 +02:00
tomasz.sowa 6d256e6512 fix: correctly set a Request::RunState::job_run flag to the background request
The flag should be set to the task.request and not to the cur->request.
The cur->request could have been already changed by the main thread.
2023-08-25 16:24:27 +02:00
tomasz.sowa cf383fa026 update easepick to 1.2.1 2023-08-21 13:31:02 +02:00
tomasz.sowa c86536d660 update htmx to 1.9.4 2023-08-09 22:45:59 +02:00
tomasz.sowa dba87d6213 update uikit to 3.16.24 2023-08-06 18:00:25 +02:00
tomasz.sowa 52f9d399ca add a Header::text_xml and text_xml_utf8 types 2023-07-31 17:31:22 +02:00
tomasz.sowa 7b7a962f19 update uikit to 3.16.23 2023-07-30 22:47:36 +02:00
tomasz.sowa c37722c29a update ckeditor to 4.22.1 and jquery to 3.7.0 2023-07-23 14:40:13 +02:00
tomasz.sowa ca509d3a86 update htmx to 1.9.3 2023-07-16 21:37:04 +02:00
tomasz.sowa bf79e46411 add a GetUTF8File(...) method with a pt::WTextStream & content to the misc 2023-07-04 22:59:57 +02:00
tomasz.sowa 08821eb440 update uikit to 3.16.22 2023-06-23 01:47:51 +02:00
tomasz.sowa d7878b5564 update uikit to 3.16.21 2023-06-14 03:13:44 +02:00
tomasz.sowa 0b52ae80dd update uikit to 3.16.19 2023-05-27 17:27:42 +02:00
tomasz.sowa 3e46d8b4b4 update uikit to 3.16.18 2023-05-23 14:48:28 +02:00
tomasz.sowa 1655ae3562 fix: correctly clear after a request when an exception has been thrown 2023-05-16 15:31:13 +02:00
tomasz.sowa dda325bbbf allow to compile with gcc 12 2023-05-13 16:12:02 +02:00
tomasz.sowa c326c2a095 update uikit to 3.16.17 2023-05-11 08:22:12 +02:00
tomasz.sowa bf386e2286 add a Http::set_smtp_ssl_mode(long mode) method for selecting the ssl mode 2023-05-10 14:00:33 +02:00
tomasz.sowa e822e13dc8 add support for sending emails in Http class 2023-05-10 09:01:30 +02:00
tomasz.sowa cc2c008bfd update htmx to 1.9.2 2023-05-08 06:01:20 +02:00
tomasz.sowa b8a8013d4c update uikit to 3.16.15 2023-04-15 23:50:18 +02:00
tomasz.sowa 12ed77aeb1 update htmx to 1.9.0 2023-04-13 21:45:39 +02:00
tomasz.sowa 7476048da6 make depend 2023-04-12 17:21:42 +02:00
tomasz.sowa 8a307790c0 update jquery to 3.6.4 2023-04-09 14:25:11 +02:00
tomasz.sowa a49b10ed2d allow to upload files from the ckeditor
while here:
- update ckeditor to 4.21.0
- add a Sourcedialog plugin to the ckeditor
2023-04-09 14:10:21 +02:00
tomasz.sowa 6a2da642b0 update uikit to 3.16.14 2023-04-08 09:48:12 +02:00
tomasz.sowa b836c77950 update uikit to 3.16.13 2023-04-06 07:52:03 +02:00
tomasz.sowa 2aa4eee20d update uikit to 3.16.12 2023-03-28 07:37:15 +02:00
tomasz.sowa 9ada82c4aa update uikit to 3.16.6 2023-03-12 13:50:50 +01:00
tomasz.sowa aa9b83f740 update uikit to 3.16.5 2023-03-10 19:26:26 +01:00
tomasz.sowa 4ddfd2cd3a update uikit to 3.16.3 2023-02-27 22:14:36 +01:00
tomasz.sowa d15f5e4fa4 update uikit to 3.16.1 2023-02-27 01:57:39 +01:00
tomasz.sowa 2e455f97ac add support for serializing to xml 2023-02-27 00:34:29 +01:00
tomasz.sowa f664cc1a53 update flatpickr to 4.6.13 2023-02-15 23:03:56 +01:00
tomasz.sowa ae505f3201 remove white characters from flatpickr js script 2023-02-15 22:57:41 +01:00
tomasz.sowa d5433cddf1 update jquery to 3.6.3 2023-02-14 13:05:45 +01:00
tomasz.sowa 52773a271c update ckeditor to 4.20.1 2023-02-14 12:26:36 +01:00
tomasz.sowa e9311989ab update uikit to 3.15.24 2023-02-14 00:21:16 +01:00
tomasz.sowa 7b63c01033 update uikit to 3.15.23 2023-02-02 10:43:32 +01:00
tomasz.sowa 5972b2bb39 update uikit to 3.15.22 2023-01-19 23:42:48 +01:00
tomasz.sowa f182978ea5 update htmx to 1.8.5 2023-01-19 12:49:03 +01:00
tomasz.sowa ebb8132808 update uikit to 3.15.21 2023-01-12 17:27:09 +01:00
tomasz.sowa 1bd1762258 update uikit to 3.15.20 2023-01-05 20:29:44 +01:00
tomasz.sowa 00b0e251f4 update uikit to 3.15.19 2022-12-28 10:05:03 +01:00
tomasz.sowa 14e32df8c9 fix(Http): use uninitialize_curl() in begin() method 2022-12-23 04:23:38 +01:00
tomasz.sowa aa938f05ca add methods to set a client certificate/key and the CA in the Http class 2022-12-21 14:09:31 +01:00
tomasz.sowa 4583ab28ed add primary keys definition to migration rules 2022-12-19 19:13:45 +01:00
tomasz.sowa 9c0cd6eb5e add Http::set_ssl_version() to set the available TLS version to use 2022-12-19 14:17:30 +01:00
tomasz.sowa 32c30cf536 update uikit to 3.15.18 2022-12-13 15:10:18 +01:00
tomasz.sowa a8b7a9e122 update uikit to 3.15.17 2022-12-08 12:26:50 +01:00
tomasz.sowa d07ff5b881 update uikit to 3.15.15 2022-12-05 06:57:51 +01:00
tomasz.sowa 66fae598c2 parse winixjson_* environment variables as json config options 2022-11-25 13:30:51 +01:00
tomasz.sowa 589e889822 update uikit to 3.15.14 2022-11-24 22:14:55 +01:00
tomasz.sowa 89249f1297 add Http::fetch(...) methods 2022-11-18 16:38:03 +01:00
tomasz.sowa 2bd56c87e4 update uikit to 3.15.13 2022-11-17 23:07:40 +01:00
tomasz.sowa 204688464e rename Http:put() to Http:post() and add a separate Http:put() 2022-11-17 02:47:00 +01:00
tomasz.sowa 1d0956abab update to the new pikotools api: change converting functions to the snake case 2022-11-14 03:22:48 +01:00
tomasz.sowa c2013ff47f do not use the ezc engine when sending a static file
while here:
- in send_file_mode=0 return a 404 if a static file was not correctly read
2022-11-14 00:54:50 +01:00
tomasz.sowa 624bf47c8d update htmx to 1.8.4 2022-11-07 21:01:18 +01:00
tomasz.sowa cdd395efa5 update uikit to 3.15.12 2022-11-07 20:54:41 +01:00
tomasz.sowa 47f6e2234c update htmx to 1.8.2 2022-10-26 12:44:48 +02:00
tomasz.sowa 1648092cd5 update uikit to 3.15.11 2022-10-26 12:33:11 +02:00
tomasz.sowa 99fbf6ca27 add WINIX_STARTED plugin message 2022-10-19 14:26:34 +02:00
tomasz.sowa f050fc2316 make more virtual functions is BaseThread 2022-10-19 14:26:18 +02:00
tomasz.sowa 1015baf111 make depend 2022-10-17 08:16:45 +02:00
tomasz.sowa 04f0a2f808 add MoveHelper for moving winix files - copied from Mv function 2022-10-17 08:16:28 +02:00
tomasz.sowa 1da240afb9 check notitle parameter in upload winix function 2022-10-17 08:15:27 +02:00
tomasz.sowa 77a00f5989 fix: return a correct status from Dirs::AddDirectory() 2022-10-17 08:13:20 +02:00
tomasz.sowa f3d6494ae5 add the easepick - a date and time picker 2022-10-14 01:56:44 +02:00
tomasz.sowa 8edd0ef07a fix: use the base_url as a domain when creating a session cookie if a cookie domain is empty 2022-09-28 19:28:17 +02:00
tomasz.sowa 3855ea9fa7 add /usr/include/postgresql to includes paths 2022-09-23 19:53:26 +02:00
tomasz.sowa a81839fd9c make depend 2022-09-23 18:34:08 +02:00
tomasz.sowa 03035f038f use PT_HAS_MORM_LIBRARY macro when building too
while here:
- use some conditionals in the Makefile
2022-09-23 18:34:08 +02:00
tomasz.sowa baa870edbd update to uikit 3.15.10 2022-09-22 10:38:31 +02:00
tomasz.sowa c8bc23312b update uikit to 3.15.8 2022-09-16 13:29:25 +02:00
tomasz.sowa d5e6fb7c54 add Access-Control-Expose-Headers to normal cors requests too 2022-09-14 12:48:20 +02:00
tomasz.sowa 6138497fe0 change how origin header is treated
Now check whether the origin is in allowed_origins table,
and if not check allow_all_origins config parameter.

While here:
- add are_cors_preflight_requests_available - if true then preflight
  requests are available (default false)
2022-09-09 01:01:39 +02:00
tomasz.sowa 05ecac8426 add support for more cookie flags in Request::AddCookie() method
changed in config options:
- renamed: http_session_id_name to session_cookie_name
- add config options: session_cookie_path, session_cookie_domain, session_cookie_same_site,
  session_cookie_http_only, session_cookie_secure
2022-09-08 05:40:44 +02:00
tomasz.sowa 222a1c8a1f refactor the algorithm for testing the cors
while here:
- send cors headers even if the status is 404
- add: access_control_expose_headers config option - list of additional headers sent in Access-Control-Expose-Headers
- add: access_control_allow_credentials config option - if true return Access-Control-Allow-Credentials header equal "true"
2022-09-08 03:12:44 +02:00
tomasz.sowa 04164ff967 add Access-Control-Allow-Credentials for simple requests too 2022-09-07 15:25:48 +02:00
tomasz.sowa 9f64692ede set Access-Control-Allow-Credentials if available 2022-09-07 14:46:29 +02:00
tomasz.sowa 8b9ad5d079 make depend 2022-09-01 07:34:39 +02:00
tomasz.sowa bff435db9a add WINIX_SAVE_FILELOG plugin message 2022-09-01 07:34:10 +02:00
tomasz.sowa e09a93bd72 update uikit to 3.15.6 2022-09-01 03:39:02 +02:00
tomasz.sowa e378fcfe3b remove not used variables from Request 2022-08-31 21:33:54 +02:00
tomasz.sowa a7a338f28e fix(Request): allow to prepare integer headers 2022-08-31 21:25:14 +02:00
tomasz.sowa a19158cb62 add config options for testing the Origin header in cors requests
- allow_all_cors_origins - whether or not to allow all origins
- allowed_cors_origins - a list of allowed origins (used if allow_all_cors_origins is false)
2022-08-31 20:42:42 +02:00
tomasz.sowa 778ed01a55 make depend 2022-08-30 01:52:20 +02:00
tomasz.sowa 217f42b7c6 add support for preflight requ (cors) 2022-08-30 01:52:02 +02:00
tomasz.sowa a34db6505d move some methods from App to Request
methods moved: SetEnv(), ReadEnvVariables(), ReadEnvRemoteIP(), CheckSSL(), SetSubdomain()

while here:
- add the rest of http methods: put, connect, trace, patch
2022-08-29 19:20:41 +02:00
tomasz.sowa 7dc117da5e update UIkit to 3.15.5 2022-08-28 16:09:43 +02:00
tomasz.sowa b1441366f4 add Http::verify_ssl(bool verify) method 2022-08-25 05:16:23 +02:00
tomasz.sowa c730b85629 make depend 2022-08-22 16:04:10 +02:00
tomasz.sowa d3a440fa0a add Request::AddPostVar(pt::Space & space, const wchar_t * name) 2022-08-22 16:03:07 +02:00
tomasz.sowa 5f77ce619e make depend 2022-08-20 00:31:30 +02:00
tomasz.sowa 5dd34c802e add Request::job_second_id 2022-08-20 00:31:10 +02:00
tomasz.sowa 3609d94c09 update uikit to 3.15.3 2022-08-15 12:36:54 +02:00
tomasz.sowa 5dc00e95e7 make depend 2022-08-14 12:55:03 +02:00
tomasz.sowa e88615226b add Http::allow_redirects(bool allow_redirects) method 2022-08-13 20:00:15 +02:00
tomasz.sowa ca1a854fd1 fix: use CURLOPT_POSTFIELDSIZE_LARGE to tell libcurl of the post content size 2022-08-13 17:15:48 +02:00
tomasz.sowa ceb5336ca1 add support for OPTIONS http method 2022-08-11 08:04:40 +02:00
tomasz.sowa f651df6e1f update htmx to 1.8.0 2022-08-10 12:42:24 +02:00
tomasz.sowa 6266eac729 use std::wstring_view in SessionIdManager::DecodeToken(...) method 2022-08-10 12:42:16 +02:00
tomasz.sowa de972de948 fix: remove sourcedialog plugin from ckeditor 2022-08-06 04:21:53 +02:00
tomasz.sowa 55f48e4f3a update jquery to 3.6.0
while here do a check: [if not winix_has_jquery]...[end]
2022-07-31 02:03:39 +02:00
tomasz.sowa 39ab07508f update translations 2022-07-30 18:41:59 +02:00
tomasz.sowa 968660e8ca fix: set correctly request->session
The session cookie was not created because request->session pointed at
a temporary session.

While here:
- do some cleaning in App
- set request->mount too
- add fcgi_cannot_create_request_delay to the config
- fix: in mailregister plugin get model_connector from env (and not from the request)
2022-07-30 18:37:50 +02:00
tomasz.sowa 4b46ba1fe3 update uikit to 3.15.1 2022-07-30 15:37:52 +02:00
tomasz.sowa a164e6e21e fix: remove not needed Http::clear() 2022-07-30 04:14:04 +02:00
tomasz.sowa 82281b4363 add a debug mode - fill a Space structure with some info from CURLOPT_DEBUGFUNCTION
while here:
- allow to set headers from a string
- add a seek function (CURLOPT_SEEKFUNCTION)
2022-07-30 04:00:35 +02:00
tomasz.sowa 9d8d35b64f save logs after a job has finished 2022-07-30 03:35:00 +02:00
tomasz.sowa 33f6a9a213 make depend 2022-07-30 03:33:45 +02:00
tomasz.sowa e5ed1d6ae8 fix: do not use cur if login winix function if config.use_internal_loggin_mechanism is false
In the login winix function cur pointer will be null if config.use_internal_loggin_mechanism
is false, in such a case those objects are not registered as winix functions
but we have a public api
(the public api should be moved somewhere e.g. make a service layer)
2022-07-27 01:25:49 +02:00
tomasz.sowa 9e6a5b2d37 add use_internal_session_mechanism and use_internal_loggin_mechanism config options 2022-07-26 21:54:33 +02:00
tomasz.sowa c85a724fec fix(SessionIdManager): take a correct algorithm when decoding a token 2022-07-26 21:09:44 +02:00
tomasz.sowa 2e8f4d1a26 allow the SessionIdManager to use only two keys 2022-07-26 05:18:42 +02:00
tomasz.sowa 522b57ade4 fix(Jobs): change request state to prepare_to_finish in case of an error 2022-07-25 18:37:39 +02:00
tomasz.sowa d4da6aa518 let System::PutUrlProto takes a stream by a reference to pt::Stream 2022-07-25 18:36:28 +02:00
tomasz.sowa 979ef907fe allow a request to be processed in a job
Now we allow a request to be passed into a job queue,
and after the job finishes the request is passed into
a controller again. In order to achieve this we have
a requests queue in System, when we put a request
to the job this Request structure is preserved in the
queue and for a new request a new Request is added to
the queue.

while here:
- remove App::Lock()/Unlock(), use scoped locking
- fix: Plugin now has a Call method which takes ModelConnector
  and a logger (used in multithreaded environment)
- BaseThread has a main_model_connector pointer
  to the main (from the main thread) model connector
- the FastCGI structure fcgi_request moved from App to Request
- some methods for handling requests moved from App to Request
- small refactoring in main.cpp
- add Http class (a http client)
2022-07-25 14:21:21 +02:00
tomasz.sowa b2d92b85a0 make depend 2022-07-11 17:52:05 +02:00
tomasz.sowa 8d6d0ddbf8 update to the new morm::Finder interface 2022-07-11 17:51:50 +02:00
tomasz.sowa 8da76134ce make depend 2022-07-05 19:52:40 +02:00
tomasz.sowa 179daf743e make depend 2022-07-03 14:25:53 +02:00
tomasz.sowa bcb009b606 print version information if running with -v parameter 2022-07-03 14:25:23 +02:00
tomasz.sowa 327c215e5d add LICENSE file 2022-07-03 12:17:26 +02:00
tomasz.sowa b484071818 print components versions in uname winix function 2022-07-03 12:17:14 +02:00
tomasz.sowa 31e826d893 put a log message before opening the FastCGI connection socket
FCGX_OpenSocket will call exit() if there was a problem with creating the socket.
2022-06-27 20:52:09 +02:00
tomasz.sowa e29f912358 add core/postparser.cpp with implementation from core/postparser.h
now we can remove -lfcgi from winix in winixd/Makefile
2022-06-26 06:45:53 +02:00
tomasz.sowa 26226de865 global winixd/Makefile uses now 'find' for looking for *.cpp files
and we don't need Makefiles in subdirectories anymore (except plugins)
2022-06-26 06:22:27 +02:00
tomasz.sowa 56d87c4410 update uikit to 3.14.3 2022-06-19 16:06:16 +02:00
tomasz.sowa ebfa5f7405 do not try to load sessions if session_file config parameter is empty 2022-05-31 07:49:51 +02:00
tomasz.sowa ba16cf41fe move the javascript for autodeleting to a separate winix.js file 2022-05-30 05:35:49 +02:00
tomasz.sowa 01c10bad0e add use_antispam_mechanism_for_not_logged_users config option 2022-05-30 05:35:05 +02:00
tomasz.sowa 7d1fb3c04e remove Request::post_tab and add Request::http_status
Instead of Reqest::post_tab we use now Request::post_in (pt::Space).

Request::http_status will be used instead Request::status,
but at the moment is not changed in all places.
Request::status has been marked as depracated.

While here:
- Check for root dir in App and not in FunctionParser,
let FunctionParser only log the root dir.
- Read post variables after parsing url parameters,
this allows winix functions to set limits
for post input.
- Set limits when parsing input json format, new
options added to config: post_max_object_items, post_max_table_items,
post_max_all_items, post_max_nested_objects.
There are similar options in each winix function (they are in
FunctionBase).
- Some refactoring in App.
- Add config option: log_whole_http_post if true
then the whole parsed post input is logged.
- Add config option: post_json_max - max length of input stream
for parsing json.
- Add config option: templates_request_status, default request_status.html
this is an ezc template used as [content] when the request status
is not 200_ok.
- Fix: Sort winix function didn't show items to sort (fix and do some
refactoring as well)
- Properly sort items in: ImgCrop, Ls, Sort, Upload
- Remove ezc templates: err_404.html, err_per_denied.html - now
request_status.html is used.
2022-05-30 01:29:18 +02:00
tomasz.sowa 9e222f5b80 do not print white characters in log for the first migration 2022-05-28 06:10:39 +02:00
tomasz.sowa 3b5658ff8f fix: correctly sort post variables when they have the same name
In PostParser we add some prefix with a number if the name of a variable is the same,
we should use zero padding for the number to be correctly sorted.
2022-05-28 06:07:38 +02:00
tomasz.sowa 5e89c4004a make depend 2022-05-26 00:35:24 +02:00
tomasz.sowa 9602c28d96 allow lang ezc function get more than one parameter 2022-05-11 14:22:46 +02:00
tomasz.sowa 0fd680b496 update uikit to 3.14.1 2022-05-08 17:00:26 +02:00
tomasz.sowa 37d3a44b24 update uikit to 3.14.0 2022-04-30 20:23:37 +02:00
tomasz.sowa da2dec447b allow to specify how many times we can try to connect to the database at startup
add config options:
db_startup_connection_max_attempts - default 0 (infinite)
db_startup_connection_attempt_delay - delay in seconds between attempts (default 5)

BREAKING CHANGE: WINIX_PLUGIN_INIT plugin message requires to set result status,
you have to set the result status to true (env.res) if your
plugin was initialized correctly, otherwise winix will not start
2022-04-29 06:17:16 +02:00
tomasz.sowa c6c50a5d23 allow to use host database connection parameter
Add config option:
db_host (default empty) - name of host to connect to
2022-04-28 06:12:44 +02:00
tomasz.sowa 98c1e8daad allow to not change fast cgi socket permissions
New config options:
fcgi_set_socket_chmod (bool) - default true
fcgi_set_socket_owner (bool) - default true
2022-04-27 23:31:50 +02:00
tomasz.sowa f99191aa6f make depend 2022-04-26 23:46:57 +02:00
tomasz.sowa df04075f1c add methods to Request for adding and removing parameters
Added methods:
void AddParam(const std::wstring & param_name, const std::wstring & param_value);
void AddParam(const wchar_t * param_name, const wchar_t * param_value);
void RemoveParam(const wchar_t * param_name);
void RemoveParam(const std::wstring & param_name);

This is only temporarily, we will be using the pt::Space structure in the future.
2022-04-26 23:41:56 +02:00
tomasz.sowa 3d2a635e34 fix: use TextStreamBase::to_str() instead of to_string() 2022-04-25 22:05:34 +02:00
tomasz.sowa aad5db9a6a let Functions::Add() returns info whether the functions/controller has been added 2022-04-25 16:35:14 +02:00
tomasz.sowa 43ebbdaa33 add WINIX_PLUGIN_QUIT and WINIX_QUIT plugins messages
While here:
- rename WINIX_CLOSE to WINIX_PREPARE_TO_CLOSE
2022-04-25 16:34:26 +02:00
tomasz.sowa 92c7f90b95 fix: correctly propagate a migration status when the migration failed 2022-04-25 15:19:02 +02:00
tomasz.sowa aae93d018b allow to use db_hostaddr, db_port or db_conn_string config parameters to connect to PostgreSQL 2022-04-20 18:37:52 +02:00
tomasz.sowa 7a115a3970 fix(Log): treat pt::Log::Manipulators as enum and not as int 2022-04-16 21:52:53 +02:00
tomasz.sowa 64e5114947 allow to read environment variables as config parameters
Environment variables must be prefixed with winix_ to be loaded by winix.
The winix_ prefix is then removed and the key value converted to lowercase.

Sample:
evn WINIX_MY_OPTION=TEST123test winix -c config_file

This will add my_option to the config with value TEST123test.
Environment variables are read last so they will overwrite the values
from the configuration files.
2022-04-16 21:50:23 +02:00
tomasz.sowa 4f8b5e649a recognize startup parameters
Usage: winix [options]
  -c             : a path to the config file
  --config       : a path to the config file
  -h             : print usage information
  --help         : print usage information
  -?             : print usage information

While here:
- let it be possible to parse multiple configs,
- fix: some error messages were not printed at startup.
2022-04-16 18:38:30 +02:00
tomasz.sowa e0d9989d74 fix(Item): id should be of type serial 2022-04-11 23:27:49 +02:00
tomasz.sowa 0fe680ef4a fix: migration to version 2 in User model 2022-04-11 23:19:30 +02:00
tomasz.sowa e182c0a21b fix: create core schema before making a first select request
Migration uses Finder to get the current table version.
2022-04-11 23:11:00 +02:00
tomasz.sowa c8edd241d5 create core schema as a first migration 2022-04-11 20:57:49 +02:00
tomasz.sowa a544ccd1a7 fix: User model initial column name: aenv 2022-04-11 20:44:58 +02:00
tomasz.sowa 7df2205b40 update flatpickr to 4.6.11 2022-04-05 17:37:24 +02:00
tomasz.sowa 265e843d02 update uikit to 3.13.7 2022-04-05 16:59:57 +02:00
tomasz.sowa 22a8a97389 update htmx to 1.7.0 2022-04-05 16:53:46 +02:00
tomasz.sowa bb74f2a423 update uikit to 3.11.1 2022-02-08 14:13:33 +01:00
tomasz.sowa 2033168db2 Merge branch 'cli' into ajax 2022-02-08 14:01:50 +01:00
tomasz.sowa e377f144fd fix: do not send headers again after binary content 2022-02-04 18:46:46 +01:00
tomasz.sowa 234ebf8ce8 change HtmlTextStream iterators type to pt::WTextStream::iterator 2022-02-03 20:57:38 +01:00
tomasz.sowa 09cf3c9fa9 add some comments in AcceptBaseParser 2022-02-02 18:34:56 +01:00
tomasz.sowa df32899581 move AcceptEncodingParser to utils 2022-02-02 18:34:22 +01:00
tomasz.sowa 33e8df11c5 parse Accept-Language header to Request::accept_languages table 2022-02-02 18:20:32 +01:00
tomasz.sowa 75daf37bbd improve AcceptBaseParser parsing algorithm
remove AcceptParser - not needed now, AcceptBaseParser can prepare a table now
2022-02-02 17:58:27 +01:00
tomasz.sowa d0d2cfb22c move AcceptBaseParser to utils directory 2022-02-02 17:11:46 +01:00
tomasz.sowa f7b5ac0dc8 change the way how winix answer is created
Now we can return ezc content and models serialized in the same json structure,
Xml and Csv are not implemented yet.
Ezc frames are returned in 'ezc_frames' field.
Main ezc stream is returned in 'main_stream' field.
Frame url parameter can take more than one frame (names separated by commas).
Honor Accept http header (AcceptParser).

Samples:
--------
http://domain.tld/dir/controller
returns html answer from the main ezc stream

http://domain.tld/dir/controller/container:raw
returns html answer from the main ezc stream (the same as above)

http://domain.tld/dir/controller/frame:abc
returns "abc" frame as html

http://domain.tld/dir/controller/container:json
returns all serialized models to json and no ezc streams

http://domain.tld/dir/controller/container:xml
returns all serialized models to xml and no ezc streams (not implemented yet)

http://domain.tld/dir/controller/container:json/frame:abc,xyz
returns all serialized models to json and two frames in 'ezc_frames' object

http://domain.tld/dir/controller/container:json/all_frames
returns all serialized models to json and all frames in 'ezc_frames' object

http://domain.tld/dir/controller/container:json/main_stream
returns all serialized models and the main ezc stream in 'main_stream' field

http://domain.tld/dir/controller/container:json/main_stream/all_frames
returns all serialized models to json, all frames and the main stream
2022-02-01 18:44:23 +01:00
tomasz.sowa 227dd923d6 fix: correctly escape ezc stream to json/xml/csv 2022-01-28 15:54:11 +01:00
tomasz.sowa f6cb9a8aed set correct timetable dst for 'Sarajevo, Skopje, Warsaw, Zagreb'
year: 2022 and 2023
2022-01-26 22:34:13 +01:00
tomasz.sowa b615dc7e6e add cmp ezc function 2022-01-22 04:35:42 +01:00
tomasz.sowa 944560dd2b update uikit to 3.10.1 2022-01-19 15:47:11 +01:00
tomasz.sowa 1d6d29e24d add winixcli/src/winix to .gitignore 2022-01-18 19:46:12 +01:00
tomasz.sowa ff8e9e6b32 start working on winixcli
winixcli can now read a PGModeler file
and is able to generate a template through ezc

winixcli parameters:
--input-mode pgmodeler (only one parameter at the moment)
--input-file file (pgmodeler file)
--templates-dir dir_path (a path to templates directory)
--template file (template file)
2022-01-18 19:40:57 +01:00
tomasz.sowa 557555c4b3 htmx updated to 1.6.1 2021-12-08 15:19:35 +01:00
tomasz.sowa f8e1037476 uikit updated to 3.9.4 2021-11-26 21:51:01 +01:00
tomasz.sowa 35cb54324f added a new item content type: markdown
- emacs editor has an option to select markdown, now it has two planes: one for content editing and the other to show preview
- CodeMirror editor updated to 5.64.0
- to convert markdown to html we use showdown https://github.com/showdownjs/showdown (conversion is done on the client side)
2021-11-26 21:49:21 +01:00
tomasz.sowa 119497bb01 added winix_frame_is ezc winix function 2021-10-24 22:27:52 +02:00
tomasz.sowa dfd6475a81 uikit updated to 3.7.6 2021-10-24 22:27:35 +02:00
tomasz.sowa d6d5236a03 added fil_json_escape filter 2021-10-21 13:42:41 +02:00
tomasz.sowa a327a26bd5 added winix_uikit_version parameter to index_head_adder.html 2021-10-13 23:48:30 +02:00
tomasz.sowa d5ebb7ca12 changed the way how the request's answer is created,
now winix can return json, xml, csv from out_main_stream or from frames and json from models

removed from Request:
  bool send_bin_stream
  bool return_json
  bool return_info_only
  pt::Space info
  bool page_generated
  bool out_main_stream_use_html_filter
  bool out_streams_use_html_filter

added to Request:
  enum AnswerSource
  enum AnswerContainer
  AnswerSource answer_source
  AnswerContainer answer_container
  bool use_ezc_engine
  std::wstring frame
  bool send_all_frames
  bool use_html_filter

added to Config:
 // the name of the url parameter for returning all frames, e.g. https://domain.tld/mydir/myfunction/allframes
 // default: allframes
 std::wstring request_all_frames_parameter;

 // the name of the root element when serializing request answer to xml
 // default: winix
 std::wstring xml_root;

algorithm (the whole algorithm is described in core/request.h):
at the beginning of a request winix sets
   answer_source to models
   answer_container to text
   use_ezc_engine to true

next answer_container and use_ezc_engine can be changed in the following way:

1. winix will look for 'Accept' http header and depending on the header winix will set:
   (not implemented yet)

             Accept | answer_container | use_ezc_engine
	     ------------------------------------|-----------------
	     application/json | json             | false
	      application/xml | xml              | false
	              text/csv | csv              | false

2. next answer_container is set depending on 'container' url parameter
       container | answer_container
 ---------------------------------------------------------
     not present | don't change the value
            text | text
            json | json
             xml | xml
             csv | csv

use_ezc_engine is set depending on 'answer' url parameter:
          answer | use_ezc_engine
 ---------------------------------
     not present | don't change the value
            html | true
            data | false

if 'answer' is html then we take into account two more parameters:
 frame: frame_name (empty default) - if set then winix returns this specific frame
 allframes: (if present then winix returns all frames)
2021-10-13 01:27:14 +02:00
tomasz.sowa 3e46c5674c htmx updated to 1.6.0 2021-10-08 17:44:34 +02:00
tomasz.sowa c4b5565995 don't check for request->is_htmx_request for sending frames, check only "frame" url paremeter
added config parameter: request_frame_parameter, default: "frame"
2021-10-08 03:08:11 +02:00
tomasz.sowa 3f5eabeaa1 uikit updated to 3.7.5 2021-10-07 05:02:24 +02:00
tomasz.sowa 9b8e48e7b2 added static libraries: clocklet (timepicker), flatpickr and litepicker (data pickers) 2021-10-07 04:42:46 +02:00
tomasz.sowa c3122fb82f added [lang] ezc function for returning a localized string 2021-10-07 04:41:06 +02:00
tomasz.sowa 1741597d52 uikit updated to 3.7.4 2021-09-27 02:53:16 +02:00
tomasz.sowa 9c5c74ba84 added: setting a correct mime type for static files - using magic library
added: std::wstring file_mime_type to ItemContent - a mime type for static file
added: Header (core/header.h) - there will be header names defined, at the moment only content_type
added: FuncionsBase::Finish() - it is called at the end when the winix finishes
2021-09-22 00:23:25 +02:00
tomasz.sowa 26ed7b80be changed values for send_file_mode config parameter:
0 - winix will read the content of the file and send it back to the webserver
  1 - winix will use send_file_header header with a full path to the file
  2 - winix will use send_file_header header with a relative path to the file
2021-09-17 03:35:56 +02:00
tomasz.sowa 55ac9a61ed added possibility to send static files to nginx via X-Accel-Redirect header
added to config:
int send_file_mode;
    // 0 - full path to a file in send_file_header header
    // 1 - relative path to a file in send_file_header (need http_send_file_relative_prefix set) (used for nginx)
std::wstring send_file_header;
    // default: X-SENDFILE
    // for Apache set: X-SENDFILE
    // for Lighttpd set: X-LIGHTTPD-send-file
    // for Nginx set: X-Accel-Redirect
std::wstring send_file_relative_prefix;
    // relative prefix used for sending static files if send_file_mode is 1
    // default: "upload-files-internal"
2021-09-15 20:28:34 +02:00
tomasz.sowa 7673264fe1 make depend 2021-08-12 21:57:03 +02:00
tomasz.sowa 42dc43b036 added WINIX_MAKE_DATABASE_MIGRATION plugin message for making migrations from plugins 2021-08-11 22:18:14 +02:00
tomasz.sowa ef22d951a0 fixed: base class of System should be derived as public 2021-08-10 22:06:53 +02:00
tomasz.sowa e95dc834a3 uikit updated to 3.7.2 2021-08-07 21:23:47 +02:00
tomasz.sowa b424988d1b updated to the new pikotools api (api2021): HTMLFilter renamed to HTMLParser
added to config: int html_filter_white_char_mode;
  how white characters between html tags are treated
  0 - WHITE_MODE_ORIGIN - they are copied from input to output
  1 - WHITE_MODE_SINGLE_LINE - new line characters are removed
  2 - WHITE_MODE_TREE - try to create a tree (some kind of pretty printing)
  default: 2
2021-08-07 02:16:48 +02:00
tomasz.sowa 22134b6cc0 commented some method calls to html_filter 2021-07-26 03:54:02 +02:00
tomasz.sowa f861c0761e make depend 2021-07-17 13:57:39 +02:00
tomasz.sowa 1899d5ee17 BBCODEParser has been moved to pikotools library 2021-07-17 13:56:37 +02:00
tomasz.sowa 17bd48ece3 HTMLFilter has been moved to pikotools library 2021-07-17 13:42:04 +02:00
tomasz.sowa c5c02d7f44 HtmlTextStream has now pt::Stream as a based class and uses pt::WTextStream as a buffer 2021-07-16 18:17:57 +02:00
tomasz.sowa ba6159964b htmx updated to 1.5.0 2021-07-16 13:16:02 +02:00
tomasz.sowa b834971f5e uikit updated to 3.7.1 2021-07-16 12:28:38 +02:00
tomasz.sowa 9dc15d536c Makefile: removed macros: EZC_GENERATOR_HAS_PT_STREAM and EZC_GENERATOR_HAS_WINIX_STREAM 2021-07-13 01:49:58 +02:00
tomasz.sowa 2e45cb6ac9 updated to the new ezc api (Generator has three additional parameters now) 2021-07-13 01:46:07 +02:00
tomasz.sowa 2dcfeaa688 fixed: in Item do_migration_to_3(...) admin meta was called admin_meta (not meta_admin) 2021-07-07 01:04:48 +02:00
tomasz.sowa 9d65d931d0 moved some ezc functions from templates/item.cpp to Item and ItemContent
removed: templates/item.cpp
updated: some html templates which use [item] or [item_tab]
removed some old html templates: item_info.html and itam_tab_info.html
2021-07-06 21:52:29 +02:00
tomasz.sowa 746aa41111 renamed: ItemContent::meta_admin -> ItemContent::admin_meta 2021-07-03 01:18:28 +02:00
tomasz.sowa 175dd17416 added request.last_item ezc function 2021-07-03 01:14:53 +02:00
tomasz.sowa 619936c12e make depend 2021-07-01 23:35:08 +02:00
tomasz.sowa 732144df01 updated to the new morm api - models methods which take 'morm::ModelWrapper ** model_wrapper' now take 'morm::Wrapper & wrapper' 2021-07-01 23:34:49 +02:00
tomasz.sowa df3f04a951 added to misc: timespec_to_stream_with_unit() for printing times either is seconds or miliseconds 2021-06-30 16:30:11 +02:00
tomasz.sowa 0f78968579 updated ticket plugin to the new ezc api (child spaces were removed) 2021-06-29 23:42:57 +02:00
tomasz.sowa 66173c7a31 removed old meta ezc functions from gallery plugin 2021-06-28 21:34:41 +02:00
tomasz.sowa 3f934d9aec removed old meta ezc functions from menu plugin 2021-06-28 21:34:22 +02:00
tomasz.sowa df0cc131fe fixed in thread winix function: answers were not sorted correctly 2021-06-28 21:33:33 +02:00
tomasz.sowa ba60f9da8a updated group plugin to the new pikotools api (child spaces were removed) 2021-06-28 20:58:39 +02:00
tomasz.sowa 4569198b9d fixed in index_head_adder.html: winix_function_is "emacs" should be in parentheses 2021-06-27 23:43:01 +02:00
tomasz.sowa ccbbb59af7 make depend 2021-06-27 23:34:06 +02:00
tomasz.sowa 3a5af25eaf updated some html templates 2021-06-27 23:33:10 +02:00
tomasz.sowa 1d18b7fa12 - updated to the new pikotools api (child spaces were removed)
some plugins need to be fixed yet: ticket, gallery, group, menu
- added current user to default models as "user"
- renamed in User: super_user -> is_super_user, env -> admin_env, pass_hash_salted -> is_pass_hash_salted
- now Users class has a WinixModel as a base class
  some plugin calls have to be fixed yet
- added UserWrapper model with a pointer to User class
- removed from ItemContent: methods for accessing 'meta' and 'admin_meta', now ezc can iterate through Space classes
- fixed in env winix function: if there is "changeuser" parameter then we should only switch the user (not save anything)
2021-06-27 23:31:50 +02:00
tomasz.sowa 472490c239 make depend 2021-06-24 21:17:11 +02:00
tomasz.sowa b6340a30d2 updated to the new pikotools api (changes in Log) 2021-06-24 21:17:03 +02:00
tomasz.sowa bf1f0954b9 fixed: changed "%g" to "%f" when printing request/ezc times
SetNonZeroDigitsAfterComma() incorrectly terminated the string if the format was "%g" (in the case where it was used as %e)
2021-06-24 16:11:02 +02:00
tomasz.sowa 2f1cdcf379 added printing info how much time winix spent in the ezc engine
added to Request:
timespec timespec_req_stop;
timespec timespec_req_diff;
timespec timespec_ezc_engine_start;
timespec timespec_ezc_engine_stop;
2021-06-24 15:33:44 +02:00
tomasz.sowa 443c2023d9 make depend 2021-06-23 17:04:21 +02:00
tomasz.sowa 2c5062ba22 UrlEncode() methods from core/misc.h are now thread safe 2021-06-23 17:04:07 +02:00
Tomasz Sowa 99df807095 Makefile: added new macros to CFLAGS 2021-06-21 20:22:15 +02:00
tomasz.sowa 8ab07d11b1 fixed: cur.request->function->fun didn't have a model connector set when a request started 2021-06-21 16:51:35 +02:00
tomasz.sowa a1c0f6f7f0 added config option: add_header_cache_no_store_in_htmx_request
send "Cache-Control: no-store, max-age=0" http header if a request is made by htmx library (ajax)
if a webbrowser get a page from the cache then it will render just the last request without the whole html page (css, js, etc)
https://github.com/bigskysoftware/htmx/issues/497
2021-06-21 11:43:59 +02:00
tomasz.sowa 672737a0d8 added a comment in ItemContent 2021-06-20 22:27:06 +02:00
tomasz.sowa ade96bf6d3 some methods from templates/item.cpp moved to ItemContent 2021-06-20 21:22:08 +02:00
tomasz.sowa 801fc062ef added FunctionBase::Clear() which is called at the end of a request 2021-06-20 20:47:59 +02:00
tomasz.sowa f35840e7de some work in html templates: changed some functions from item_* to item.* 2021-06-20 18:12:43 +02:00
tomasz.sowa 79eda7abb0 - added to FunctionBase: bool register_default_models (default true)
if true then winix will add default models for ezc templates such as "request", "item", etc.
- some methods from templates/item.cpp moved to Item
2021-06-20 18:04:50 +02:00
tomasz.sowa e7c7324058 ItemContent::user_name(EzcEnv & env) changed to ItemContent::user(morm::ModelWrapper ** model_wrapper) and we return a User class
ItemContent::group_name(EzcEnv & env) changed to ItemContent::group(morm::ModelWrapper ** model_wrapper) and we return a Group class
added ItemContent::display_user_name(EzcEnv & env)
some functions in templates/item.cpp moved to Item
2021-06-19 23:48:12 +02:00
tomasz.sowa d8c1a81bcb removed config options: ezc_error_prefix and ezc_error_postfix
Ezc::PatternParser and Ezc::Generator use only pt::Log as a logger now
2021-06-19 20:33:35 +02:00
tomasz.sowa 94f96c11cb make depend 2021-06-18 19:18:46 +02:00
tomasz.sowa ec94dff7d7 some ezc functions from templates/item.cpp moved to Item and ItemContent
methods HasAccess() HasReadAccess() and similar moved from System to Item and ItemContent
2021-06-18 19:18:13 +02:00
tomasz.sowa ebd791a256 changed: now Request class is a model class - we have fields() method there to map fields for ezc templates (currently only dir_tab)
removed: [dir_tab] ezc statement
changed: Ls winix function loads its own dir_tab container (beforehand it was loaded by [dir_tab] ezc statement)
         it's available by [child_dirs] name
2021-06-17 21:44:29 +02:00
tomasz.sowa 4db421d6c3 make depend 2021-06-16 23:43:57 +02:00
tomasz.sowa ab89ffe096 fixed in Item: void Item::link(Ezc::FunInfo<HtmlTextStream> & env) now returns a correct directory for the item (before the current directory was returned)
added to Item: void Item::dir_link(Ezc::FunInfo<HtmlTextStream> & env)
added to WinixModel:
  Dirs * get_dirs();
  Mounts * get_mounts();
  Users * get_users();
  Groups * get_groups();
  SLog * get_session_logger(); // not finished yet
2021-06-16 23:42:23 +02:00
tomasz.sowa 53fe5c35b9 added .editorconfig file 2021-06-16 18:09:18 +02:00
tomasz.sowa f2f2c851df make depend 2021-06-16 18:09:01 +02:00
tomasz.sowa 6dddc5e948 renamed: WinixModel -> WinixModelDeprecated (this class will be removed)
added: WinixModel (models/winixmodel.h|cpp) - a class inheriting from morm::WinixModel, we have methods such as: get_config(), get_logger(), get_request()
       and this class will be a base class for our models
added: WinixModelConnector (models/winixmodelconnector.h|cpp) - a class inheriting from morm::WinixModelConnector
       this connector we are using instead of morm::ModelConnector - there are pointers to winix objects there (config, request, log)
added to Request: Ezc::Models models
removed from TemplatesFunctions: Ezc::Models ezc_models;
changed: ImgCrop winix functions is using its own item_tab vector now (not finished yet)
added: Item::is(), Item::link(), ItemContent::print_content()
2021-06-16 18:07:44 +02:00
tomasz.sowa 9688b1a26a htmx updated to 1.4.1 2021-06-09 01:56:47 +02:00
tomasz.sowa 81df52f6ca make depend 2021-05-31 18:59:49 +02:00
tomasz.sowa 6e4f8f5191 start adding support for Models objects from Ezc 2021-05-31 18:59:20 +02:00
tomasz.sowa 22de3322ae - added to Request: is_htmx_request (bool) - true if the request is made by htmx library (ajax)
- commented out using mount_page_arg_is "subject" and "info" from fun_cat.html and fun_run.html - they will be removed soon
- some improvements in fun_reply.html, fun_showthreads.html and fun_thread.html (scrolling)
2021-05-31 10:58:34 +02:00
tomasz.sowa e6fae4598c updated to the new pikotools api: [ezc out] and [out] changed to [ezc frame] or just [frame]
- when returning json streams changed "out" field to "frames"
- renamed config parameter: allow_ezc_out_in_executable_items -> allow_ezc_frames_in_executable_items
- added basic support for ajax requests in thread plugin
2021-05-28 18:36:19 +02:00
tomasz.sowa ba331dea4a added basic support for htmx (ajax)
- if there is HX-Request header present we sent only a part of the whole html
- we return only specific stream defined by [out ...] ezc statement
- the name of the stream is passed in the 'frame' parameter
  (if not present then 'content' is assumed)
- added ezc function: winix_is_htmx_request
2021-05-27 19:36:04 +02:00
tomasz.sowa 1292a56d1b added htmx 1.4.0 loaded by default in html/index_head_adder.html 2021-05-27 13:41:29 +02:00
tomasz.sowa 6a452ffed0 version changed to 0.7.3 2021-05-27 12:21:59 +02:00
Tomek fc24570062 fixed compilation: pikotools is in src subdirectory now 2021-05-27 12:04:41 +02:00
tomasz.sowa aa71abd725 some workarounds in Thread plugin (don't show stale info in html forms) 2021-05-27 10:29:26 +02:00
tomasz.sowa fb64f5e456 fixed: reply winix function (from thread plugin) didn't add a reply - system->Add() didn't set the model_connector to the item 2021-05-26 19:55:50 +02:00
tomasz.sowa 61fe6ea219 updated to the new api from ezc: changed semantic of [def] and Vars moved outside of Generator 2021-05-23 10:14:08 +02:00
tomasz.sowa d30c7254eb updated uikit to 3.6.22 2021-05-22 13:03:15 +02:00
tomasz.sowa 06be33ba5f make depend 2021-05-21 23:06:57 +02:00
tomasz.sowa b2cffa39e1 added models Thread and ThreadFiles in thread plugin 2021-05-21 23:06:48 +02:00
tomasz.sowa 86ef2529b1 fixed in some places: system->AddFile() returns bool now instead of Error 2021-05-21 17:41:16 +02:00
tomasz.sowa f1b9d1b870 updated to the new pikotools api: changed the way how child_spaces are created in Space class 2021-05-21 17:17:17 +02:00
tomasz.sowa fe67b5d72a updated to the new pikotools api: snake_case names of methods from SpaceParser 2021-05-21 04:51:58 +02:00
tomasz.sowa 27720afaf2 updated to the new pikotools api: SpaceParser::SetSpace(...) methods have been removed 2021-05-21 01:37:42 +02:00
tomasz.sowa 8bb585d97d updated to the new pikotools api: changed utf8 functions PascalCase to snake_case 2021-05-21 00:41:27 +02:00
tomasz.sowa 8c523ce8b9 make depend 2021-05-21 00:32:58 +02:00
tomasz.sowa e48a28a5c8 namespace PT renamed to pt 2021-05-20 20:59:12 +02:00
tomasz.sowa d66a36cf21 make depend 2021-05-14 03:32:03 +02:00
tomasz.sowa a94e09f0aa added support for Model migrations
now we have a table core.migration and each model (User, Group, Item, ItemContent and a new Migration) have its own
row in the table with a version number

added to config:
db_make_migration_if_needed and db_stop_if_migration_fails (need description yet)
2021-05-14 03:31:29 +02:00
tomasz.sowa 4df10de6b7 methods eq() from finder can have now a table name 2021-05-13 19:33:19 +02:00
tomasz.sowa 6d07535dad updated uikit to 3.6.21 version 2021-05-13 06:24:44 +02:00
tomasz.sowa ee354d2ded renamed in Models: map_fields() to fields(), prepare_table() to table() 2021-05-13 03:29:41 +02:00
tomasz.sowa e64bd1fba8 added more html tags to extraAllowedContent (ckeditor) 2021-05-13 03:24:37 +02:00
tomasz.sowa 031e673c51 fixed: passwd winix function: pass_encrypted was not cleared if we are not using rsa for encrypting passwords anymore 2021-05-13 02:02:15 +02:00
tomasz.sowa 801c9a2cda make depend 2021-05-11 22:22:10 +02:00
tomasz.sowa 685b3ca5ee Makefile: source files from pikotools are now in pikotools/src 2021-05-11 22:22:03 +02:00
tomasz.sowa f1af7e2eeb updated to the current pikotools api from branch api2021 2021-05-11 22:20:46 +02:00
tomasz.sowa 85f9fda984 fixed: in passwd winix function: clear password hash when using rsa encoding 2021-05-11 22:15:52 +02:00
tomasz.sowa bb513b0187 make depend 2021-04-30 01:35:40 +02:00
tomasz.sowa 4277f90bad start working on User and Group classes
- User and Group has been moved to 'models' directory
- removed UserPass struct (passwords fields were put to User struct)
not working yet, we need support for binary blobs in morm
2021-04-30 01:34:48 +02:00
tomasz.sowa ccda2bc2fd added option do_migration_to_winix_fullmorm do the config (only temporarily)
if true then we make Item::do_migration() and exit
2021-04-14 14:13:47 +02:00
tomasz.sowa 4b71530f4c added to Config:
bool Config::HasValue(const wchar_t * name, const wchar_t * value)
2021-04-12 18:55:04 +02:00
tomasz.sowa a8a9db53be remove some Lock() and Unlock() from Plugin 2021-04-11 12:09:42 +02:00
tomasz.sowa 634cf07d44 using Winix::Lock object instead of Lock() method in ThreadManager 2021-04-10 21:12:28 +02:00
tomasz.sowa 0e0c006d5a fixed: thread locking problem in Image: method Lock() was used instead of Winix::Lock object 2021-04-10 19:46:50 +02:00
tomasz.sowa 486067a4b2 clang thread sanitizer reported a data race in App::Start()
synchro.was_stop_signal was read without locking

==================
WARNING: ThreadSanitizer: data race (pid=13831)
  Write of size 1 at 0x000000dc4d18 by thread T1 (mutexes: write M44):
    #0 Winix::App::SpecialThreadForSignals(void*) /disk2Tc/home/tomek/roboczy/prog/winix/winixd/core/app.cpp:2226:31 (winix.so+0x1f7465)

  Previous read of size 1 at 0x000000dc4d18 by main thread:
    #0 Winix::App::Start() /disk2Tc/home/tomek/roboczy/prog/winix/winixd/core/app.cpp:651:18 (winix.so+0x1ee9af)
    #1 main /disk2Tc/home/tomek/roboczy/prog/winix/winixd/main/main.cpp:222:6 (winix+0x2d74c1)

  Location is global 'Winix::app' of size 65840 at 0x000000db5908 (winix+0x000000dc4d18)

  Mutex M44 (0x000000dc4d10) created at:
    #0 pthread_mutex_lock /disk2Tb/usr/src/contrib/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc:4153:3 (winix+0x2ac204)
    #1 Winix::Synchro::Lock() /disk2Tc/home/tomek/roboczy/prog/winix/winixd/core/synchro.cpp:68:12 (winix.so+0x2e5822)
    #2 Winix::Lock::Lock(Winix::Synchro*) /disk2Tc/home/tomek/roboczy/prog/winix/winixd/core/lock.cpp:53:11 (winix.so+0x295522)
    #3 Winix::FileLog::get_local_date(PT::Date const&) /disk2Tc/home/tomek/roboczy/prog/winix/winixd/core/filelog.cpp:98:8 (winix.so+0x261183)
    #4 Winix::Log::PrintDate(PT::Date const&) /disk2Tc/home/tomek/roboczy/prog/winix/winixd/core/log.cpp:80:30 (winix.so+0x295a21)
    #5 Winix::LogInfo(Winix::Log&, Winix::LogManipulators, char const*, bool, char const*) /disk2Tc/home/tomek/roboczy/prog/winix/winixd/main/main.cpp:104:6 (winix+0x2d69ec)
    #6 main /disk2Tc/home/tomek/roboczy/prog/winix/winixd/main/main.cpp:190:2 (winix+0x2d7363)

  Thread T1 (tid=100187, running) created by main thread at:
    #0 pthread_create /disk2Tb/usr/src/contrib/llvm-project/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp:962:3 (winix+0x295bb3)
    #1 Winix::App::StartThreads() /disk2Tc/home/tomek/roboczy/prog/winix/winixd/core/app.cpp:2246:2 (winix.so+0x1f7549)
    #2 main /disk2Tc/home/tomek/roboczy/prog/winix/winixd/main/main.cpp:212:6 (winix+0x2d743e)

SUMMARY: ThreadSanitizer: data race /disk2Tc/home/tomek/roboczy/prog/winix/winixd/core/app.cpp:2226:31 in Winix::App::SpecialThreadForSignals(void*)
==================
2021-04-10 17:14:51 +02:00
tomasz.sowa 35e10ed469 updated to the new Pikotools api (new Space struct) 2021-04-09 17:50:58 +02:00
tomasz.sowa 00b980e74b make depend 2021-04-09 16:02:54 +02:00
tomasz.sowa efdc0e7c97 etc/time_zones.conf changed values: "true" -> true, "false" -> false 2021-04-09 10:25:10 +02:00
tomasz.sowa 8b64d2066f changed: new space characters in etc/time_zones.conf:
( -> {
 ) -> }
2021-03-31 20:26:30 +02:00
tomasz.sowa 8d87d9a875 changed in Makefile: we have now one lib pikotools/pikotools.a
make depend
2021-03-31 20:25:09 +02:00
tomasz.sowa 8fc1848ecc uikit updated to 3.6.18 2021-03-31 20:21:24 +02:00
tomasz.sowa bbc0a67153 added support for new morm api
- field(...) methods from Model take now FT structure instead of insertable/updatable/primary_key boolean flags
- table name is set in a prepare_table() method now
- added meta and admin_meta from ItemContent (morm has a field() method with PT::Space argument now)
2021-03-11 18:48:18 +01:00
tomasz.sowa e8ba2a7bd1 fixed: incorrect status was set when editing a file
now System::EditFile() returns boolean
2021-03-11 18:42:26 +01:00
tomasz.sowa 23f1c112a4 make depend 2021-03-10 16:40:22 +01:00
tomasz.sowa 4d76e53554 in after_insert() methods: changed get_last_sequence -> get_last_sequence_for_primary_key 2021-03-09 18:16:29 +01:00
tomasz.sowa 73352e680e Make depend 2021-03-08 21:10:33 +01:00
tomasz.sowa 57aad8b454 removed from Item: update() and save() methods which take the 'url_was_changed' argument
and added ItemModelData (based on morm::ModelData) class which has 'prepare_unique_url' field,
an object of this class is passed to update(), insert() and save() methods

fixed: Dirs::CheckRootDir(): update should update childs too (privileges)

WIP: #4
2021-03-08 21:06:50 +01:00
tomasz.sowa ab5c44a2cb removed some old methods for adding/editing Item from Db 2021-02-25 00:17:07 +01:00
tomasz.sowa 3e84eb9dbf Makefile deps 2021-02-25 00:15:03 +01:00
tomasz.sowa afbe82e9f4 changed the way how prefixes are added to urls
instead at the end we adding a prefix before an extension, e.g: filename_(2).jpg
2021-02-25 00:12:45 +01:00
tomasz.sowa 51b1aed483 removed DbItemQuery and DbItemColumns which were used for database accessing for Item class 2021-02-24 22:54:36 +01:00
tomasz.sowa 32e93a04c5 Item class has been moved to a new directory 'models', a new class has been added: ItemContent
and same fields from Item were moved to ItemContent

Item
- id
- parent_id
- type (file, dir, symlink)
- url
- subject
- template (html template)
- sort_index
- content_id

ItemContent
- id
- ref -> references (renamed)
- user_id
- modification_user_id
- group_id
- privileges
- date_creation
- date_modification
- guest_name
- link_to
- link_redirect
- file_path
- file_fs
- file_type
- file_size
- has_thumb -> file_has_thumb (renamed)
- hash -> file_hash (renamed)
- hash_type -> file_hash_type (renamed)
- content -> content_raw (renamed)
- content_type -> content_raw_type (renamed)
- content_parsed
- content_parsed_type
- meta
- ameta -> meta_admin (renamed)
- modify_index (removed)

WIP: #4
2021-02-24 01:19:47 +01:00
456 changed files with 51266 additions and 38233 deletions
+252
View File
@@ -0,0 +1,252 @@
---
Language: Cpp
AccessModifierOffset: -4
AlignAfterOpenBracket: DontAlign
AlignArrayOfStructures: Left
AlignConsecutiveAssignments:
Enabled: true
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignConsecutiveBitFields:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignConsecutiveDeclarations:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
AlignFunctionPointers: false
PadOperators: false
AlignConsecutiveMacros:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignEscapedNewlines: DontAlign
AlignOperands: DontAlign
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortEnumsOnASingleLine: true
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
AttributeMacros:
- __capability
BinPackArguments: true
BinPackParameters: true
BitFieldColonSpacing: Both
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: Always
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
AfterExternBlock: true
BeforeCatch: true
BeforeElse: true
BeforeLambdaBody: true
BeforeWhile: true
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeConceptDeclarations: Always
BreakBeforeBraces: Custom
BreakBeforeInheritanceComma: false
BreakInheritanceList: AfterComma
BreakBeforeTernaryOperators: false
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: AfterColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 150
CommentPragmas: '^ IWYU pragma:'
QualifierAlignment: Left
CompactNamespaces: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: false
DeriveLineEnding: false
DerivePointerAlignment: false
DisableFormat: false
EmptyLineAfterAccessModifier: Leave
EmptyLineBeforeAccessModifier: Leave
ExperimentalAutoDetectBinPacking: false
PackConstructorInitializers: CurrentLine
BasedOnStyle: ''
ConstructorInitializerAllOnOneLineOrOnePerLine: false
AllowAllConstructorInitializersOnNextLine: true
FixNamespaceComments: true
ForEachMacros:
- forever
- foreach
- Q_FOREACH
- BOOST_FOREACH
IfMacros:
- KJ_IF_MAYBE
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^<Q.*'
Priority: 200
SortPriority: 200
CaseSensitive: true
IncludeIsMainRegex: '(Test)?$'
IncludeIsMainSourceRegex: ''
IndentAccessModifiers: false
IndentCaseLabels: false
IndentCaseBlocks: false
IndentGotoLabels: true
IndentPPDirectives: None
IndentExternBlock: Indent
IndentRequiresClause: true
IndentWidth: 4
IndentWrappedFunctionNames: false
InsertBraces: false
InsertTrailingCommas: None
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
LambdaBodyIndentation: Signature
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 3
NamespaceIndentation: None
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 4
ObjCBreakBeforeNestedBlockParam: true
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 150
PenaltyBreakBeforeFirstCallParameter: 300
PenaltyBreakComment: 500
PenaltyBreakFirstLessLess: 400
PenaltyBreakOpenParenthesis: 0
PenaltyBreakString: 600
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 50
PenaltyReturnTypeOnItsOwnLine: 300
PenaltyIndentedWhitespace: 0
PointerAlignment: Middle
PPIndentWidth: 1
ReferenceAlignment: Middle
ReflowComments: false
RemoveBracesLLVM: false
RequiresClausePosition: OwnLine
SeparateDefinitionBlocks: Leave
ShortNamespaceLines: 1
SortIncludes: CaseSensitive
SortJavaStaticImport: Before
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceAroundPointerQualifiers: Default
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: true
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: Custom
SpaceBeforeParensOptions:
AfterControlStatements: false
AfterForeachMacros: false
AfterFunctionDefinitionName: false
AfterFunctionDeclarationName: false
AfterIfMacros: false
AfterOverloadedOperator: false
AfterRequiresInClause: false
AfterRequiresInExpression: false
BeforeNonEmptyParentheses: false
SpaceBeforeRangeBasedForLoopColon: false
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: Never
SpacesInConditionalStatement: false
SpacesInContainerLiterals: false
SpacesInCStyleCastParentheses: false
SpacesInLineCommentPrefix:
Minimum: 1
Maximum: -1
SpacesInParens: Custom
SpacesInParensOptions:
ExceptDoubleParentheses: false
InConditionalStatements: true
InCStyleCasts: false
InEmptyParentheses: false
Other: false
SpacesInParentheses: true
SpacesInSquareBrackets: false
Standard: c++20
StatementAttributeLikeMacros:
- Q_EMIT
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
- Q_CLASSINFO
- Q_ENUM
- Q_ENUM_NS
- Q_FLAG
- Q_FLAG_NS
- Q_GADGET
- Q_GADGET_EXPORT
- Q_INTERFACES
- Q_MOC_INCLUDE
- Q_NAMESPACE
- Q_NAMESPACE_EXPORT
- Q_OBJECT
- Q_PROPERTY
- Q_REVISION
- Q_DISABLE_COPY
- Q_SET_OBJECT_NAME
- QT_BEGIN_NAMESPACE
- QT_END_NAMESPACE
- QML_ADDED_IN_MINOR_VERSION
- QML_ANONYMOUS
- QML_ATTACHED
- QML_DECLARE_TYPE
- QML_DECLARE_TYPEINFO
- QML_ELEMENT
- QML_EXTENDED
- QML_EXTENDED_NAMESPACE
- QML_EXTRA_VERSION
- QML_FOREIGN
- QML_FOREIGN_NAMESPACE
- QML_IMPLEMENTS_INTERFACES
- QML_INTERFACE
- QML_NAMED_ELEMENT
- QML_REMOVED_IN_MINOR_VERSION
- QML_SINGLETON
- QML_UNAVAILABLE
- QML_UNCREATABLE
- QML_VALUE_TYPE
TabWidth: 4
UseCRLF: false
UseTab: Always
WhitespaceSensitiveMacros:
- STRINGIZE
- PP_STRINGIZE
- BOOST_PP_STRINGIZE
- NS_SWIFT_NAME
- CF_SWIFT_NAME
...
+21
View File
@@ -0,0 +1,21 @@
# EditorConfig
# https://editorconfig.org/
# https://editorconfig-specification.readthedocs.io/
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
# 4 space indentation
[*.{h,cpp,html,css,js,conf,txt}]
indent_style = tab
indent_size = 4
# Tab indentation (no size specified)
[Makefile]
indent_style = tab
indent_size = 4
+6 -1
View File
@@ -3,4 +3,9 @@
.settings/
*.o
*.so
winixd/winix
/winixd/winix
/winixcli/src/winix
/winixcli/m
/.clangd
/.qtcreator/
/.qtc_clangd/
+2
View File
@@ -0,0 +1,2 @@
CompileFlags:
Add: [-pthread, -std=c++23, -I%%%CURRENT_DIR%%%/winixd, -I%%%GLOBAL_WORKING_DIR%%%/pikotools/src, -I%%%GLOBAL_WORKING_DIR%%%/ezc/src, -I%%%GLOBAL_WORKING_DIR%%%/morm/src, -I%%%GLOBAL_WORKING_DIR%%%/tito/src, -I/usr/include, -I/usr/local/include, -I/usr/local/include/postgresql, -DPT_HAS_MORM_LIBRARY, -DEZC_HAS_MORM_LIBRARY, -DMORM_HAS_EZC_LIBRARY]
+1
View File
@@ -0,0 +1 @@
-std=c23
+4
View File
@@ -0,0 +1,4 @@
#define PT_HAS_MORM_LIBRARY 1
#define EZC_HAS_MORM_LIBRARY 1
#define MORM_HAS_EZC_LIBRARY 1
+1
View File
@@ -0,0 +1 @@
[General]
+184
View File
@@ -0,0 +1,184 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 14.0.1, 2024-09-20T16:21:10. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">%%%QT_ENVIRONMENT_ID%%%</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
<value type="qlonglong">0</value>
</data>
<data>
<variable>ProjectExplorer.Project.EditorSettings</variable>
<valuemap type="QVariantMap">
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
<value type="QString" key="language">Cpp</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
</valuemap>
</valuemap>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
<value type="QString" key="language">QmlJS</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
</valuemap>
</valuemap>
<value type="qlonglong" key="EditorConfiguration.CodeStyle.Count">2</value>
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
<value type="int" key="EditorConfiguration.IndentSize">4</value>
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
<value type="int" key="EditorConfiguration.PreferAfterWhitespaceComments">0</value>
<value type="bool" key="EditorConfiguration.PreferSingleLineComments">false</value>
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
<value type="int" key="EditorConfiguration.TabSize">8</value>
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
<value type="bool" key="EditorConfiguration.UseIndenter">false</value>
<value type="int" key="EditorConfiguration.Utf8BomBehavior">2</value>
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
<value type="QString" key="EditorConfiguration.ignoreFileTypes">*.md, *.MD, Makefile</value>
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
<value type="bool" key="EditorConfiguration.skipTrailingWhitespace">true</value>
<value type="bool" key="EditorConfiguration.tintMarginArea">true</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.PluginSettings</variable>
<valuemap type="QVariantMap">
<valuemap type="QVariantMap" key="AutoTest.ActiveFrameworks">
<value type="bool" key="AutoTest.Framework.Boost">true</value>
<value type="bool" key="AutoTest.Framework.CTest">false</value>
<value type="bool" key="AutoTest.Framework.Catch">true</value>
<value type="bool" key="AutoTest.Framework.GTest">true</value>
<value type="bool" key="AutoTest.Framework.QtQuickTest">true</value>
<value type="bool" key="AutoTest.Framework.QtTest">true</value>
</valuemap>
<value type="bool" key="AutoTest.ApplyFilter">false</value>
<valuemap type="QVariantMap" key="AutoTest.CheckStates"/>
<valuelist type="QVariantList" key="AutoTest.PathFilters"/>
<value type="int" key="AutoTest.RunAfterBuild">0</value>
<value type="bool" key="AutoTest.UseGlobal">true</value>
<valuemap type="QVariantMap" key="ClangTools">
<value type="bool" key="ClangTools.AnalyzeOpenFiles">true</value>
<value type="bool" key="ClangTools.BuildBeforeAnalysis">true</value>
<value type="QString" key="ClangTools.DiagnosticConfig">Builtin.DefaultTidyAndClazy</value>
<value type="int" key="ClangTools.ParallelJobs">3</value>
<value type="bool" key="ClangTools.PreferConfigFile">true</value>
<valuelist type="QVariantList" key="ClangTools.SelectedDirs"/>
<valuelist type="QVariantList" key="ClangTools.SelectedFiles"/>
<valuelist type="QVariantList" key="ClangTools.SuppressedDiagnostics"/>
<value type="bool" key="ClangTools.UseGlobalSettings">true</value>
</valuemap>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap">
<value type="QString" key="DeviceType">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">%%%QT_DEFAULT_PROFILE_ID%%%</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">%%%CURRENT_DIR%%%</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<valuelist type="QVariantList" key="GenericProjectManager.GenericMakeStep.BuildTargets">
<value type="QString">all</value>
</valuelist>
<value type="QString" key="GenericProjectManager.GenericMakeStep.MakeCommand">/usr/local/bin/gmake</value>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">GenericProjectManager.GenericMakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<valuelist type="QVariantList" key="GenericProjectManager.GenericMakeStep.BuildTargets">
<value type="QString">clean</value>
</valuelist>
<value type="QString" key="GenericProjectManager.GenericMakeStep.MakeCommand">/usr/local/bin/gmake</value>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">GenericProjectManager.GenericMakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Default</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">GenericProjectManager.GenericBuildConfiguration</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Deploy</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.DeployConfiguration.CustomData"/>
<value type="bool" key="ProjectExplorer.DeployConfiguration.CustomDataEnabled">false</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
<value type="int" key="Analyzer.Valgrind.Callgrind.CostFormat">0</value>
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<valuelist type="QVariantList" key="CustomOutputParsers"/>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="bool" key="PE.EnvironmentAspect.PrintOnRun">false</value>
<value type="QString" key="PerfRecordArgsId">-e cpu-cycles --call-graph dwarf,4096 -F 250</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey"></value>
<value type="bool" key="ProjectExplorer.RunConfiguration.Customized">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.TargetCount</variable>
<value type="qlonglong">1</value>
</data>
<data>
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
<value type="int">22</value>
</data>
<data>
<variable>Version</variable>
<value type="int">22</value>
</data>
</qtcreator>
+1
View File
@@ -0,0 +1 @@
-std=c++23
+1
View File
@@ -0,0 +1 @@
+38
View File
@@ -0,0 +1,38 @@
#!/bin/sh
CURRENT_DIR=$(pwd)
GLOBAL_WORKING_DIR=$(realpath ${CURRENT_DIR}/..)
# ----------
has_force_arg=0
if [ $# -eq 1 ] ; then
if [ $1 == 'force' ] ; then
has_force_arg=1
fi
fi
# make sure the current directory is correct
if [ ! -d ${CURRENT_DIR}/.templates ] ; then
echo "this script should be called by make: make clangd (one level up)"
exit 1
fi
# change / to \/ in paths
CURRENT_DIR_FOR_SED=$(echo ${CURRENT_DIR} | sed 's/\//\\\//g')
GLOBAL_WORKING_DIR_FOR_SED=$(echo ${GLOBAL_WORKING_DIR} | sed 's/\//\\\//g')
if [ -f "${CURRENT_DIR}/.templates/.clangd" ] ; then
if [ $has_force_arg -eq 1 -o ! -f "${CURRENT_DIR}/.clangd" ] ; then
cat "${CURRENT_DIR}/.templates/.clangd" | \
sed -e "s/%%%CURRENT_DIR%%%/${CURRENT_DIR_FOR_SED}/g" \
-e "s/%%%GLOBAL_WORKING_DIR%%%/${GLOBAL_WORKING_DIR_FOR_SED}/g" > \
${CURRENT_DIR}/.clangd
echo "added a ${CURRENT_DIR}/.clangd file"
fi
fi
+117
View File
@@ -0,0 +1,117 @@
#!/bin/sh
CURRENT_DIR=$(pwd)
GLOBAL_WORKING_DIR=$(realpath ${CURRENT_DIR}/..)
QTCREATOR_DIR=${CURRENT_DIR}/.qtcreator
# ----------
has_force_arg=0
if [ $# -eq 1 ] ; then
if [ $1 == 'force' ] ; then
has_force_arg=1
fi
fi
# make sure the current directory is correct
if [ ! -d ${CURRENT_DIR}/.templates ] ; then
echo "this script should be called by make: make qtcreator (one level up)"
exit 1
fi
qtcreatorini=~/.config/QtProject/QtCreator.ini
qtprofiles=~/.config/QtProject/qtcreator/profiles.xml
if [ ! -f "$qtcreatorini" ] ; then
echo "I cannot find a $qtcreatorini file"
echo "this file is needed to take an EnvironmentId parameter"
echo "if QTCreator was recently installed make sure you have opened it at least once"
exit 2
fi
if [ ! -f "$qtprofiles" ] ; then
echo "I cannot find a $qtprofiles file"
echo "this file is needed to take a default profile id parameter"
echo "if QTCreator was recently installed make sure you have opened it at least once"
exit 3
fi
qtenvironmentid=`grep -F 'Settings\EnvironmentId' "$qtcreatorini" | grep -Eo '\{[a-zA-Z0-9-]+\}'`
qtdefaultprofileid=`grep -A 1 -F '<variable>Profile.Default</variable>' "$qtprofiles" | tail -n 1 | grep -Eo '\{[a-zA-Z0-9-]+\}'`
if [ -z "$qtenvironmentid" ] ; then
echo "I cannot read a Settings\EnvironmentId parameter from $qtcreatorini file"
exit 4
fi
if [ -z "$qtdefaultprofileid" ] ; then
echo "I cannot read a Profile.Default parameter from $qtprofiles file"
exit 5
fi
# change / to \/ in paths
CURRENT_DIR_FOR_SED=$(echo ${CURRENT_DIR} | sed 's/\//\\\//g')
GLOBAL_WORKING_DIR_FOR_SED=$(echo ${GLOBAL_WORKING_DIR} | sed 's/\//\\\//g')
was_qtcreator_dir=0
if [ $has_force_arg -eq 1 ] ; then
rm -rf "${QTCREATOR_DIR}"
fi
if [ -d "${QTCREATOR_DIR}" ] ; then
was_qtcreator_dir=1
else
echo "Your QTCreator EnvironmentId is: $qtenvironmentid"
echo "Your QTCreator default profile id is: $qtdefaultprofileid"
mkdir -p "${QTCREATOR_DIR}"
fi
if [ -d "${QTCREATOR_DIR}" ] ; then
if [ -d ${CURRENT_DIR}/.templates/.qtcreator ] ; then
cd ${CURRENT_DIR}/.templates/.qtcreator
if [ $? -eq 0 ] ; then
for i in * ; do
if [ ! -f "${QTCREATOR_DIR}/$i" ] ; then
cat "$i" | \
sed -e "s/%%%CURRENT_DIR%%%/${CURRENT_DIR_FOR_SED}/g" \
-e "s/%%%GLOBAL_WORKING_DIR%%%/${GLOBAL_WORKING_DIR_FOR_SED}/g" \
-e "s/%%%QT_ENVIRONMENT_ID%%%/${qtenvironmentid}/g" \
-e "s/%%%QT_DEFAULT_PROFILE_ID%%%/${qtdefaultprofileid}/g" > \
"${QTCREATOR_DIR}/$i"
fi
done
if [ $was_qtcreator_dir -eq 0 ] ; then
echo "QTCreator files generated to ${QTCREATOR_DIR} directory"
echo "In QTCreator select an 'open project...' option and find a ${QTCREATOR_DIR}/*.creator file"
fi
fi
fi
find ${QTCREATOR_DIR} -name "*.files" | while read projectfiles ; do
cd ${CURRENT_DIR}/winixd
if [ $? -eq 0 ] ; then
find ../winixd -type f \( -iname "*.cpp" -o -iname "*.h" \) | sort > ${projectfiles}
echo "file ${projectfiles} has been updated"
fi
cd ${CURRENT_DIR}/winixcli
if [ $? -eq 0 ] ; then
find ../winixcli -type f \( -iname "*.cpp" -o -iname "*.h" \) | sort >> ${projectfiles}
fi
done
fi
+24
View File
@@ -0,0 +1,24 @@
Copyright (c) 2012-2026, Tomasz Sowa
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
+84
View File
@@ -0,0 +1,84 @@
export CXX
export CXXFLAGS
export LDFLAGS
all: winixd winixcli
winixd: FORCE
$(MAKE) -C winixd
winixcli: FORCE
$(MAKE) -C winixcli
clean: FORCE
$(MAKE) -C winixd clean
$(MAKE) -C winixcli clean
cleanall: FORCE
$(MAKE) -C winixd cleanall
$(MAKE) -C winixcli clean
depend: FORCE
$(MAKE) -C winixd depend
$(MAKE) -C winixcli depend
install: FORCE
$(MAKE) -C winixd install
#$(MAKE) -C winixcli depend
clangd: FORCE
@.templates/install_clangd.sh
forceclangd: FORCE
@.templates/install_clangd.sh force
clangdall: clangd
@$(MAKE) -C ../pikotools clangd
@$(MAKE) -C ../morm clangd
@$(MAKE) -C ../ezc clangd
@$(MAKE) -C ../tito clangd
forceclangdall: forceclangd
@$(MAKE) -C ../pikotools forceclangd
@$(MAKE) -C ../morm forceclangd
@$(MAKE) -C ../ezc forceclangd
@$(MAKE) -C ../tito forceclangd
qtcreator: clangd
@.templates/install_qtcreator.sh
forceqtcreator: forceclangd
@.templates/install_qtcreator.sh force
qtcreatorall: qtcreator
@$(MAKE) -C ../pikotools qtcreator
@$(MAKE) -C ../morm qtcreator
@$(MAKE) -C ../ezc qtcreator
@$(MAKE) -C ../tito qtcreator
forceqtcreatorall: forceqtcreator
@$(MAKE) -C ../pikotools forceqtcreator
@$(MAKE) -C ../morm forceqtcreator
@$(MAKE) -C ../ezc forceqtcreator
@$(MAKE) -C ../tito forceqtcreator
FORCE:
+25
View File
@@ -0,0 +1,25 @@
export CXX
export CXXFLAGS
export LDFLAGS
all: src
src: FORCE
$(MAKE) -C src
clean: FORCE
$(MAKE) -C src clean
depend: FORCE
$(MAKE) -C src depend
FORCE:
+91
View File
@@ -0,0 +1,91 @@
sourcefiles:=$(shell find . -name "*.cpp")
objfiles:=$(patsubst %.cpp,%.o,$(sourcefiles))
GLOBAL_WORKING_DIR := $(shell pwd)/../../..
WINIX_NEEDED_MACROS = -DPT_HAS_MORM_LIBRARY \
-DEZC_HAS_MORM_LIBRARY \
-DMORM_HAS_EZC_LIBRARY
ifndef CXX
CXX = g++
endif
ifndef ADDITIONAL_CXXFLAGS
ADDITIONAL_CXXFLAGS=-O2
endif
ifndef ADDITIONAL_LDFLAGS
ADDITIONAL_LDFLAGS=-s
endif
ifndef CXXFLAGS
# /usr/include/postgresql is in Linux distros (Alpine)
CXXFLAGS = -Wall -pedantic -std=c++20 $(ADDITIONAL_CXXFLAGS) \
-I/usr/local/include \
-I/usr/include/postgresql \
-I$(GLOBAL_WORKING_DIR)/winix/winixcli \
-I$(GLOBAL_WORKING_DIR)/pikotools/src \
-I$(GLOBAL_WORKING_DIR)/morm/src \
-I$(GLOBAL_WORKING_DIR)/ezc/src \
-I$(GLOBAL_WORKING_DIR)/tito/src \
$(WINIX_NEEDED_MACROS)
endif
LDFLAGS = -L/usr/local/lib $(ADDITIONAL_LDFLAGS)
export CXX
export CXXFLAGS
export LDFLAGS
export GLOBAL_WORKING_DIR
export WINIX_NEEDED_MACROS
progname = winix
all: $(progname)
$(progname): $(objfiles) pikotools morm ezc
$(CXX) -o $(progname) $(CXXFLAGS) $(LDFLAGS) $(objfiles) $(GLOBAL_WORKING_DIR)/ezc/src/ezc.a $(GLOBAL_WORKING_DIR)/morm/src/morm.a $(GLOBAL_WORKING_DIR)/pikotools/src/pikotools.a
%.o: %.cpp
$(CXX) -c $(CXXFLAGS) -o $@ $<
.PHONY: pikotools
.PHONY: morm
.PHONY: ezc
pikotools:
$(MAKE) -C ../../../pikotools
morm:
$(MAKE) -C ../../../morm/src
ezc:
$(MAKE) -C ../../../ezc/src
clean: FORCE
rm -f $(objfiles)
rm -f $(progname)
depend:
makedepend -w 10 -Y. -I../../../pikotools/src -I../../../morm/src -I../../../ezc/src -I../../../tito/src $(WINIX_NEEDED_MACROS) -f- $(sourcefiles) | sort -u > Makefile.dep
FORCE:
-include Makefile.dep
+75
View File
@@ -0,0 +1,75 @@
./main.o: ../../../ezc/src/blocks.h
./main.o: ../../../ezc/src/cache.h
./main.o: ../../../ezc/src/expressionparser.h
./main.o: ../../../ezc/src/ezc.h
./main.o: ../../../ezc/src/functions.h
./main.o: ../../../ezc/src/funinfo.h
./main.o: ../../../ezc/src/generator.h
./main.o: ../../../ezc/src/item.h
./main.o: ../../../ezc/src/models.h
./main.o: ../../../ezc/src/objects.h
./main.o: ../../../ezc/src/outstreams.h
./main.o: ../../../ezc/src/pattern.h
./main.o: ../../../ezc/src/patternparser.h
./main.o: ../../../ezc/src/version.h
./main.o: ../../../morm/src/baseexpression.h
./main.o: ../../../morm/src/baseobjectwrapper.h
./main.o: ../../../morm/src/clearer.h
./main.o: ../../../morm/src/cursorhelper.h
./main.o: ../../../morm/src/dbconnector.h
./main.o: ../../../morm/src/dbexpression.h
./main.o: ../../../morm/src/export.h
./main.o: ../../../morm/src/fieldvaluehelper.h
./main.o: ../../../morm/src/finderhelper.h
./main.o: ../../../morm/src/flatconnector.h
./main.o: ../../../morm/src/flatexpression.h
./main.o: ../../../morm/src/ft.h
./main.o: ../../../morm/src/model.h
./main.o: ../../../morm/src/modelconnector.h
./main.o: ../../../morm/src/modelcontainerwrapper.h
./main.o: ../../../morm/src/modeldata.h
./main.o: ../../../morm/src/modelenv.h
./main.o: ../../../morm/src/morm_types.h
./main.o: ../../../morm/src/queryresult.h
./main.o: ../../../morm/src/select.h
./main.o: ../../../morm/src/spacewrapper.h
./main.o: ../../../morm/src/wrapper.h
./main.o: ../../../pikotools/src/convert/inttostr.h
./main.o: ../../../pikotools/src/convert/misc.h
./main.o: ../../../pikotools/src/convert/strtoint.h
./main.o: ../../../pikotools/src/convert/text.h
./main.o: ../../../pikotools/src/date/date.h
./main.o: ../../../pikotools/src/log/filelog.h
./main.o: ../../../pikotools/src/log/log.h
./main.o: ../../../pikotools/src/mainoptions/mainoptionsparser.h
./main.o: ../../../pikotools/src/membuffer/membuffer.h
./main.o: ../../../pikotools/src/space/space.h
./main.o: ../../../pikotools/src/textstream/stream_private.h
./main.o: ../../../pikotools/src/textstream/stream.h
./main.o: ../../../pikotools/src/textstream/textstream.h
./main.o: ../../../pikotools/src/textstream/types.h
./main.o: ../../../pikotools/src/utf8/utf8.h
./main.o: misc.h
./main.o: pgmodeler.h
./misc.o: ../../../pikotools/src/convert/inttostr.h
./misc.o: ../../../pikotools/src/convert/misc.h
./misc.o: ../../../pikotools/src/space/space.h
./misc.o: ../../../pikotools/src/textstream/stream.h
./misc.o: ../../../pikotools/src/utf8/utf8.h
./misc.o: misc.h
./pgmodeler.o: ../../../pikotools/src/convert/baseparser.h
./pgmodeler.o: ../../../pikotools/src/convert/inttostr.h
./pgmodeler.o: ../../../pikotools/src/convert/misc.h
./pgmodeler.o: ../../../pikotools/src/date/date.h
./pgmodeler.o: ../../../pikotools/src/html/htmlparser.h
./pgmodeler.o: ../../../pikotools/src/membuffer/membuffer.h
./pgmodeler.o: ../../../pikotools/src/space/space.h
./pgmodeler.o: ../../../pikotools/src/textstream/stream_private.h
./pgmodeler.o: ../../../pikotools/src/textstream/stream.h
./pgmodeler.o: ../../../pikotools/src/textstream/textstream.h
./pgmodeler.o: ../../../pikotools/src/textstream/types.h
./pgmodeler.o: ../../../pikotools/src/utf8/utf8.h
./pgmodeler.o: misc.h
./pgmodeler.o: pgmodeler.h
# DO NOT DELETE
+295
View File
@@ -0,0 +1,295 @@
/*
* This file is a part of Winix
* and is distributed under the 2-Clause BSD licence.
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
/*
* Copyright (c) 2022-2023, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <iostream>
#include "convert/strtoint.h"
#include "mainoptions/mainoptionsparser.h"
#include "pgmodeler.h"
#include "misc.h"
#include "ezc.h"
namespace Winix
{
// make a static method in MainOptionsParser?
std::wstring get_param(const pt::Space::TableType * input_mode)
{
if( input_mode && input_mode->size() > 0 )
{
pt::Space * first_par = (*input_mode)[0];
if( first_par->is_table() && first_par->table_size() > 0 )
{
return first_par->value.value_table.front()->to_wstr();
}
}
return std::wstring();
}
bool use_pgmodeler(const std::wstring & input_file, const pt::Space & input_options, pt::Space & schema, bool sort_tables)
{
PGModeler pgmodeler;
return pgmodeler.parse(input_file, schema, sort_tables);
}
typedef pt::WTextStream MyStream;
// move me to a better place
void esc_tex(wchar_t c, pt::WTextStream & str)
{
if( c == '$' )
str << L"\\$";
else
if( c == '#' )
str << L"\\#";
else
if( c == '%' )
str << L"\\%";
else
if( c == '&' )
str << L"\\&";
else
if( c == '\\' )
str << L"$\\backslash$";
else
if( c == '{' )
str << L"$\\{$";
else
if( c == '}' )
str << L"$\\}$";
else
if( c == '^' )
str << L""; // !! IMPROVE ME add \char with specific code
else
if( c == '_' )
str << L"\\_";
else
if( c == '~' )
str << L""; // !! IMPROVE ME add \char with specific code
else
if( c == '-' )
str << L"{-}";
else
if( c != 0 )
str << c;
}
void fil_tex(Ezc::FunInfo<MyStream> & env)
{
auto i = env.in.begin();
for( ; i != env.in.end() ; ++i)
{
esc_tex(*i, env.out);
}
}
void fil_max_size(Ezc::FunInfo<MyStream> & env)
{
auto i = env.in.begin();
size_t max_len = pt::to_ul(env.par);
size_t len = 0;
for( ; i != env.in.end() ; ++i)
{
if( len >= max_len )
{
env.out << ' ';
len = 0;
}
if( pt::is_white(*i) )
{
len = 0;
}
else
{
len += 1;
}
env.out << *i;
}
}
void cmp(Ezc::FunInfo<MyStream> & env)
{
if( env.params.size() >= 2 )
{
env.res = true;
for(size_t a=0 ; a < env.params.size() - 1 ; ++a)
{
if( env.params[a].str != env.params[a+1].str )
{
env.res = false;
break;
}
}
}
}
bool generate(const pt::Space & input_options, pt::Space & schema)
{
pt::WTextStream log_buffer;
pt::FileLog file_log;
pt::Log log;
file_log.init(L"log.txt", true, 4, true);
log.set_file_log(&file_log);
log.set_log_buffer(&log_buffer);
Ezc::Pattern pattern;
Ezc::PatternParser parser;
Ezc::Functions<MyStream> functions;
Ezc::Blocks blocks;
Ezc::Models models;
std::wstring dir = get_param(input_options.get_table(L"templates-dir"));
std::wstring template_file = get_param(input_options.get_table(L"template"));
if( dir.empty() )
{
std::cerr << "you have to set the templates directory with --templates-dir parameter" << std::endl;
return false;
}
if( template_file.empty() )
{
std::cerr << "you have to set the template file name with --template_file parameter" << std::endl;
return false;
}
functions.Insert("fil_tex", fil_tex);
functions.Insert("cmp", cmp);
functions.Insert("fil_max_size", fil_max_size);
parser.Directory(dir);
parser.SetBlocks(blocks);
parser.SetLogger(&log);
parser.ParseFile(template_file, pattern);
models.Add(L"schema", schema);
Ezc::Generator<MyStream, true, false> generator;
generator.SetPattern(pattern);
generator.SetFunctions(functions);
generator.SetModels(models);
MyStream str;
generator.SetLogger(log);
generator.Generate(str);
std::string tmp;
str.to_str(tmp);
std::cout << tmp << std::endl;
log << pt::Log::logsave;
return true;
}
} // namespace Winix
int main(int argc, const char ** argv)
{
using namespace Winix;
pt::MainOptionsParser parser;
pt::Space input_options, args, schema;
args.add(L"input-mode", 1);
args.add(L"input-file", 1);
args.add(L"templates-dir", 1);
args.add(L"template", 1);
pt::MainOptionsParser::Status status = parser.parse(argc, argv, input_options, args);
std::wstring input_mode = get_param(input_options.get_table(L"input-mode"));
std::wstring input_file = get_param(input_options.get_table(L"input-file"));
if( input_mode.empty() )
{
std::cout << "you have to use --input-mode parameter" << std::endl;
return 1;
}
print("input-mode", input_mode);
print("input-file", input_file);
bool sort_tables = input_options.has_key(L"sort-tables");
if( input_mode == L"pgmodeler" )
{
if( !use_pgmodeler(input_file, input_options, schema, sort_tables) )
return 3;
}
else
{
std::cerr << "unknown --input-mode parameter, available are: pgmodeler" << std::endl;
return 2;
}
generate(input_options, schema);
// for debug purposes
// std::string tmp;
// tmp = input_options.serialize_to_json_str(true);
// std::cout << tmp << std::endl;
}
+65
View File
@@ -0,0 +1,65 @@
/*
* This file is a part of Winix
* and is distributed under the 2-Clause BSD licence.
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
/*
* Copyright (c) 2022, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <iostream>
#include "misc.h"
namespace Winix
{
void print_nonl(const char * msg, const std::wstring & str)
{
std::string str_utf8;
pt::wide_to_utf8(str, str_utf8);
std::cerr << msg << ": " << str_utf8;
}
void print(const char * msg, const std::wstring & str)
{
print_nonl(msg, str);
std::cerr << std::endl;
}
void print(const char * msg, const std::wstring & str, int val)
{
print_nonl(msg, str);
std::cerr << ":" << val << std::endl;
}
}
+54
View File
@@ -0,0 +1,54 @@
/*
* This file is a part of Winix
* and is distributed under the 2-Clause BSD licence.
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
/*
* Copyright (c) 2022, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef headerfile_winixcli_src_misc
#define headerfile_winixcli_src_misc
#include "space/space.h"
namespace Winix
{
void print_nonl(const char * msg, const std::wstring & str);
void print(const char * msg, const std::wstring & str);
void print(const char * msg, const std::wstring & str, int val);
}
#endif
+150
View File
@@ -0,0 +1,150 @@
/*
* This file is a part of Winix
* and is distributed under the 2-Clause BSD licence.
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
/*
* Copyright (c) 2022-2023, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "pgmodeler.h"
#include "html/htmlparser.h"
#include "misc.h"
namespace Winix
{
PGModeler::PGModeler()
{
}
PGModeler::~PGModeler()
{
}
bool PGModeler::parse(const std::wstring & input_file, pt::Space & schema, bool sort_tables)
{
schema.clear();
pt::HTMLParser parser;
pt::HTMLParser::Status status = parser.parse_xml_file(input_file, schema, true, true);
if( status == pt::HTMLParser::Status::cant_open_file )
{
print("cannot open the input file", input_file);
return false;
}
else
if( status == pt::HTMLParser::Status::syntax_error )
{
print("syntax error", input_file, parser.get_last_parsed_line());
schema.clear();
return false;
}
else
{
if( sort_tables )
make_sort_tables(schema);
}
return true;
}
std::pair<const std::wstring*, const std::wstring*> PGModeler::get_schema_table_names(const pt::Space & table)
{
const pt::Space * schema = table.get_space(L"schema");
const std::wstring * schema_name = nullptr;
const std::wstring * table_name = nullptr;
if( schema )
{
const pt::Space * attr = schema->get_space(L"attr");
if( attr )
{
schema_name = attr->get_wstr(L"name");
}
}
const pt::Space * attr = table.get_space(L"attr");
if( attr )
{
table_name = attr->get_wstr(L"name");
}
return std::make_pair(schema_name, table_name);
}
void PGModeler::make_sort_tables(pt::Space & schema)
{
pt::Space * dbmodel = schema.get_space(L"dbmodel");
if( dbmodel )
{
pt::Space::TableType * table = dbmodel->get_table(L"table");
if( table )
{
std::sort(table->begin(), table->end(), [](const pt::Space * t1, const pt::Space * t2) -> bool {
auto t1_names = get_schema_table_names(*t1);
auto t2_names = get_schema_table_names(*t2);
if( t1_names.first && t2_names.second && t2_names.first && t2_names.second )
{
if( *t1_names.first != *t2_names.first )
{
return *t1_names.first < *t2_names.first;
}
else
{
return *t1_names.second < *t2_names.second;
}
}
else
{
return false;
}
});
}
}
}
}
+66
View File
@@ -0,0 +1,66 @@
/*
* This file is a part of Winix
* and is distributed under the 2-Clause BSD licence.
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
/*
* Copyright (c) 2022-2023, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef headerfile_winixcli_src_pgmodeler
#define headerfile_winixcli_src_pgmodeler
#include "space/space.h"
namespace Winix
{
class PGModeler
{
public:
PGModeler();
~PGModeler();
bool parse(const std::wstring & input_file, pt::Space & schema, bool sort_tables);
private:
void make_sort_tables(pt::Space & schema);
static std::pair<const std::wstring *, const std::wstring *> get_schema_table_names(const pt::Space & table);
};
}
#endif
+108 -110
View File
@@ -1,81 +1,86 @@
# Makefile for GNU make
# GNU Makefile
include Makefile.dep
# sourcefiles: all *.cpp files except ./plugins subdirectory
# objfiles: corresponding *.o files
sourcefiles:=$(shell find . -name "*.cpp" -not \( -path ./plugins/\* \))
objfiles:=$(patsubst %.cpp,%.o,$(sourcefiles))
# sourcefiles_no_main: all *.cpp files except ./plugins and ./main subdirectories
sourcefiles_no_main:=$(shell find . -name "*.cpp" -not \( -path ./plugins/\* \) -not \( -path ./main/\* \))
objfiles_no_main:=$(patsubst %.cpp,%.o,$(sourcefiles_no_main))
# https://www.gnu.org/software/make/manual/html_node/Flavors.html#Flavors
GLOBAL_WORKING_DIR := $(shell pwd)/../..
current_path := $(shell pwd)
global_relative_working_dir := $(shell relative_path $(current_path) $(GLOBAL_WORKING_DIR))
# sourcefiles_main: all *.cpp files from ./main subdirectory
sourcefiles_main:=$(shell find main -name "*.cpp")
objfiles_main:=$(patsubst %.cpp,%.o,$(sourcefiles_main))
ifeq ($(CXX), g++)
CXX = g++6
endif
WINIX_PLUGINS_MAKEDEPEND_INCLUDES = -I../../../../winix/winixd \
-I../../../../pikotools/src \
-I../../../../morm/src \
-I../../../../ezc/src \
-I../../../../tito/src
WINIX_NEEDED_MACROS = -DPT_HAS_MORM_LIBRARY \
-DEZC_HAS_MORM_LIBRARY \
-DMORM_HAS_EZC_LIBRARY
ifndef CXX
ifeq ($(OSTYPE), FreeBSD)
CXX = clang++
else
CXX = g++6
CXX = g++
endif
endif
# CXX = g++-4.8
ifndef CXXFLAGS
CXXFLAGS = -Wall -O0 -g -fPIC -pthread -std=c++20 -I/usr/local/include -I/usr/include/postgresql -DEZC_HAS_SPECIAL_STREAM
# /usr/include/postgresql is in Linux distros (Alpine)
CXXFLAGS = -Wall -pedantic -O2 -std=c++20 -fPIC -pthread \
-I/usr/local/include \
-I/usr/include/postgresql \
-I../../winix/winixd \
-I../../pikotools/src \
-I../../morm/src \
-I../../ezc/src \
-I../../tito/src \
$(WINIX_PLUGINS_MAKEDEPEND_INCLUDES) \
$(WINIX_NEEDED_MACROS)
endif
ifndef AR
AR = ar
endif
winix_include_paths = -I$(global_relative_working_dir)/winix/winixd -I$(global_relative_working_dir)/ezc/src -I$(global_relative_working_dir)/tito/src -I$(global_relative_working_dir)/morm/src -I$(global_relative_working_dir)/pikotools
ifndef LDFLAGS
LDFLAGS = -L/usr/local/lib
LDFLAGS = -L/usr/local/lib -s
endif
# for make install
winix_install_dir = /usr/local/winix
ifndef WINIX_INSTALL_DIR
WINIX_INSTALL_DIR=/usr/local/winix
endif
ifeq ($(WINIX_INSTALL_DIR),)
$(error WINIX_INSTALL_DIR env variable cannot be empty)
endif
export CXX
export CXXFLAGS
export LDFLAGS
export GLOBAL_WORKING_DIR
export WINIX_PLUGINS_MAKEDEPEND_INCLUDES
export WINIX_NEEDED_MACROS
all: winix winix.so plugins
all: winix.so plugins winix
winix: $(objfiles_main) winix.so
$(CXX) -o winix $(CXXFLAGS) $(LDFLAGS) $(objfiles_main) winix.so -lcurl
winix.so: $(winix.src.files)
@cd core ; $(MAKE) -e
@cd db ; $(MAKE) -e
@cd functions ; $(MAKE) -e
@cd notify ; $(MAKE) -e
@cd templates ; $(MAKE) -e
@cd $(GLOBAL_WORKING_DIR)/ezc/src ; $(MAKE) -e
@cd $(GLOBAL_WORKING_DIR)/tito/src ; $(MAKE) -e
@cd $(GLOBAL_WORKING_DIR)/pikotools ; $(MAKE) -e
@cd $(GLOBAL_WORKING_DIR)/morm/src ; $(MAKE) -e
$(CXX) -shared -rdynamic -Wl,-whole-archive -o winix.so $(CXXFLAGS) $(winix_include_paths) core/*.o db/*.o functions/*.o templates/*.o notify/*.o $(GLOBAL_WORKING_DIR)/ezc/src/ezc.a $(GLOBAL_WORKING_DIR)/tito/src/tito.a $(GLOBAL_WORKING_DIR)/pikotools/convert/convert.a $(GLOBAL_WORKING_DIR)/pikotools/utf8/utf8.a $(GLOBAL_WORKING_DIR)/pikotools/space/space.a $(GLOBAL_WORKING_DIR)/pikotools/mainparser/mainparser.a $(GLOBAL_WORKING_DIR)/pikotools/date/date.a $(GLOBAL_WORKING_DIR)/pikotools/log/log.a $(GLOBAL_WORKING_DIR)/morm/src/morm.a $(LDFLAGS) -lfcgi -lpq -lz -lpthread -lcurl -Wl,-no-whole-archive
winix: winix.so $(winix.src.files)
@cd main ; $(MAKE) -e
$(CXX) -o winix $(CXXFLAGS) $(LDFLAGS) main/*.o winix.so -lfcgi
winix.so: $(objfiles_no_main)
@cd ../../pikotools ; $(MAKE) -e
@cd ../../morm ; $(MAKE) -e
@cd ../../ezc ; $(MAKE) -e
@cd ../../tito ; $(MAKE) -e
$(CXX) -shared -rdynamic -Wl,-whole-archive -o winix.so $(CXXFLAGS) $(objfiles_no_main) ../../pikotools/src/pikotools.a ../../morm/src/morm.a ../../ezc/src/ezc.a ../../tito/src/tito.a $(LDFLAGS) -lfcgi -lpq -lz -lpthread -lmagic -Wl,-no-whole-archive
plugins: FORCE
@@ -90,15 +95,17 @@ plugins: FORCE
@cd plugins/seo ; $(MAKE) -e
%.o: %.cpp
$(CXX) -c $(CXXFLAGS) -o $@ $<
FORCE:
clean:
@cd core ; $(MAKE) -e clean
@cd db ; $(MAKE) -e clean
@cd functions ; $(MAKE) -e clean
@cd templates ; $(MAKE) -e clean
@cd notify ; $(MAKE) -e clean
clean: FORCE
rm -f $(objfiles)
rm -f winix.so
rm -f winix
@cd plugins/stats ; $(MAKE) -e clean
@cd plugins/thread ; $(MAKE) -e clean
@cd plugins/ticket ; $(MAKE) -e clean
@@ -108,75 +115,66 @@ clean:
@cd plugins/export ; $(MAKE) -e clean
@cd plugins/mailregister ; $(MAKE) -e clean
@cd plugins/seo ; $(MAKE) -e clean
@cd $(GLOBAL_WORKING_DIR)/ezc/src ; $(MAKE) -e clean
@cd $(GLOBAL_WORKING_DIR)/tito/src ; $(MAKE) -e clean
@cd $(GLOBAL_WORKING_DIR)/pikotools ; $(MAKE) -e clean
@cd $(GLOBAL_WORKING_DIR)/morm/src ; $(MAKE) -e clean
@cd main ; $(MAKE) -e clean
rm -f winix.so
rm -f winix
cleanall: clean
@cd ../../pikotools ; $(MAKE) -e clean
@cd ../../morm ; $(MAKE) -e clean
@cd ../../ezc ; $(MAKE) -e clean
@cd ../../tito ; $(MAKE) -e clean
depend:
@cd core ; $(MAKE) -e depend
@cd db ; $(MAKE) -e depend
@cd functions ; $(MAKE) -e depend
@cd templates ; $(MAKE) -e depend
@cd notify ; $(MAKE) -e depend
@cd plugins/stats ; $(MAKE) -e depend
@cd plugins/thread ; $(MAKE) -e depend
@cd plugins/ticket ; $(MAKE) -e depend
@cd plugins/gallery ; $(MAKE) -e depend
@cd plugins/group ; $(MAKE) -e depend
@cd plugins/menu ; $(MAKE) -e depend
@cd plugins/export ; $(MAKE) -e depend
@cd plugins/mailregister ; $(MAKE) -e depend
@cd plugins/seo ; $(MAKE) -e depend
@cd $(GLOBAL_WORKING_DIR)/ezc/src ; $(MAKE) -e depend
@cd $(GLOBAL_WORKING_DIR)/tito/src ; $(MAKE) -e depend
@cd $(GLOBAL_WORKING_DIR)/pikotools ; $(MAKE) -e depend
@cd main ; $(MAKE) -e depend
echo -n "winix.src.files = " > Makefile.dep
find -E . -type f -regex ".*\.h|.*\.cpp" | xargs -I foo echo -n foo " " >> Makefile.dep
# use $(global_relative_working_dir) here to put relative paths to Makefile.dep
find -E $(global_relative_working_dir)/ezc/src -type f -regex ".*\.h|.*\.cpp" | xargs -I foo echo -n foo " " >> Makefile.dep
find -E $(global_relative_working_dir)/tito/src -type f -regex ".*\.h|.*\.cpp" | xargs -I foo echo -n foo " " >> Makefile.dep
find -E $(global_relative_working_dir)/pikotools -type f -regex ".*\.h|.*\.cpp" | xargs -I foo echo -n foo " " >> Makefile.dep
find -E $(global_relative_working_dir)/morm/src -type f -regex ".*\.h|.*\.cpp" | xargs -I foo echo -n foo " " >> Makefile.dep
makedepend -w 10 -Y. -I../../pikotools/src -I../../morm/src -I../../ezc/src -I../../tito/src $(WINIX_NEEDED_MACROS) -f- $(sourcefiles) | sort -u > Makefile.dep
@cd plugins/stats ; $(MAKE) -e depend
@cd plugins/thread ; $(MAKE) -e depend
@cd plugins/ticket ; $(MAKE) -e depend
@cd plugins/gallery ; $(MAKE) -e depend
@cd plugins/group ; $(MAKE) -e depend
@cd plugins/menu ; $(MAKE) -e depend
@cd plugins/export ; $(MAKE) -e depend
@cd plugins/mailregister ; $(MAKE) -e depend
@cd plugins/seo ; $(MAKE) -e depend
@cd ../../pikotools ; $(MAKE) -e depend
@cd ../../morm ; $(MAKE) -e depend
@cd ../../ezc ; $(MAKE) -e depend
@cd ../../tito ; $(MAKE) -e depend
install: all
# installing binaries
rm -Rf $(winix_install_dir)/bin
mkdir -p $(winix_install_dir)/bin
cp winix $(winix_install_dir)/bin
cp winix.so $(winix_install_dir)/bin
# installing the main binary
rm -Rf $(WINIX_INSTALL_DIR)/bin
mkdir -p $(WINIX_INSTALL_DIR)/bin
cp winix $(WINIX_INSTALL_DIR)/bin
# installing the winix.so library
rm -Rf $(WINIX_INSTALL_DIR)/lib
mkdir -p $(WINIX_INSTALL_DIR)/lib
cp winix.so $(WINIX_INSTALL_DIR)/lib
# etc configs
rm -Rf $(winix_install_dir)/etc
mkdir -p $(winix_install_dir)/etc
cp -rf etc/* $(winix_install_dir)/etc/
rm -Rf $(WINIX_INSTALL_DIR)/etc
mkdir -p $(WINIX_INSTALL_DIR)/etc
cp -rf etc/* $(WINIX_INSTALL_DIR)/etc/
# html templates
rm -Rf $(winix_install_dir)/html
mkdir -p $(winix_install_dir)/html
cp -rf html/* $(winix_install_dir)/html/
rm -Rf $(WINIX_INSTALL_DIR)/html
mkdir -p $(WINIX_INSTALL_DIR)/html
cp -rf html/* $(WINIX_INSTALL_DIR)/html/
# txt templates
rm -Rf $(winix_install_dir)/txt
mkdir -p $(winix_install_dir)/txt
cp -rf txt/* $(winix_install_dir)/txt/
rm -Rf $(WINIX_INSTALL_DIR)/txt
mkdir -p $(WINIX_INSTALL_DIR)/txt
cp -rf txt/* $(WINIX_INSTALL_DIR)/txt/
# locales
rm -Rf $(winix_install_dir)/locale
mkdir -p $(winix_install_dir)/locale
cp -rf locale/* $(winix_install_dir)/locale/
rm -Rf $(WINIX_INSTALL_DIR)/locale
mkdir -p $(WINIX_INSTALL_DIR)/locale
cp -rf locale/* $(WINIX_INSTALL_DIR)/locale/
# plugins
rm -Rf $(winix_install_dir)/plugins
mkdir -p $(winix_install_dir)/plugins
find plugins/ -name "*.so" | xargs -I foo cp foo $(winix_install_dir)/plugins/
# deleting subversion directories
find $(winix_install_dir) -type d -name ".svn" | xargs -I foo rm -fr foo
rm -Rf $(WINIX_INSTALL_DIR)/plugins
mkdir -p $(WINIX_INSTALL_DIR)/plugins
find plugins/ -name "*.so" | xargs -I foo cp foo $(WINIX_INSTALL_DIR)/plugins/
# removing privileges for others
find $(winix_install_dir) -exec chmod o-r,o-x,o-w "{}" "+"
find $(WINIX_INSTALL_DIR) -exec chmod o-r,o-x,o-w "{}" "+"
-include Makefile.dep
+18028 -1
View File
File diff suppressed because one or more lines are too long
-24
View File
@@ -1,24 +0,0 @@
include Makefile.o.dep
current_path := $(shell pwd)
global_relative_working_dir := $(shell relative_path $(current_path) $(GLOBAL_WORKING_DIR))
winix_include_paths = -I$(global_relative_working_dir)/winix/winixd -I$(global_relative_working_dir)/ezc/src -I$(global_relative_working_dir)/tito/src -I$(global_relative_working_dir)/morm/src -I$(global_relative_working_dir)/pikotools
all: $(o)
%.o: %.cpp
$(CXX) -c $(CXXFLAGS) $(winix_include_paths) $<
depend:
makedepend -Y. $(winix_include_paths) -f- *.cpp > Makefile.dep
echo -n "o = " > Makefile.o.dep
ls -1 *.cpp | xargs -I foo echo -n foo " " | sed -E "s/([^\.]*)\.cpp[ ]/\1\.o/g" >> Makefile.o.dep
clean:
rm -f *.o
include Makefile.dep
File diff suppressed because it is too large Load Diff
-1
View File
@@ -1 +0,0 @@
o = acceptbaseparser.o app.o basethread.o bbcodeparser.o compress.o config.o crypt.o dircontainer.o dirs.o filelog.o groups.o htmlfilter.o httpsimpleparser.o image.o ipbancontainer.o item.o job.o lastcontainer.o loadavg.o lock.o log.o misc.o mount.o mountparser.o mounts.o plugin.o plugindata.o postmultiparser.o rebus.o request.o run.o session.o sessioncontainer.o sessionidmanager.o sessionmanager.o sessionparser.o slog.o synchro.o system.o threadmanager.o timezone.o timezones.o user.o users.o winixbase.o winixmodel.o winixrequest.o winixsystem.o
+737 -1177
View File
File diff suppressed because it is too large Load Diff
+43 -91
View File
@@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2010-2018, Tomasz Sowa
* Copyright (c) 2010-2024, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -46,27 +46,23 @@
#include <fcgiapp.h>
#include "sessionmanager.h"
#include "db/db.h"
#include "functions/functions.h"
#include "templates/templates.h"
#include "compress.h"
#include "postparser.h"
#include "cookieparser.h"
#include "postmultiparser.h"
#include "acceptencodingparser.h"
#include "space/jsontospaceparser.h"
#include "utils/acceptencodingparser.h"
#include "winixrequest.h"
#include "log/log.h"
#include "filelog.h"
#include "models/winixmodelconnector.h"
namespace Winix
{
class App
{
public:
@@ -77,16 +73,19 @@ public:
bool DropPrivileges();
void InitLoggers();
Log & GetMainLog();
void InitPlugins();
bool InitializePlugins();
bool Init();
bool InitializeRequestForFastCGI(Request & request);
void SetRequestDependency(Request & request);
void InitializeNewRequest(Request & request);
void PutRequestToJob();
void Start();
void Close();
void LogUserGroups();
bool Demonize();
void SetStopSignal();
bool WasStopSignal();
bool Lock();
void Unlock();
Synchro * GetSynchro();
void StartThreads();
void WaitForThreads();
@@ -96,22 +95,11 @@ public:
// pointers to the current request and a session
Cur cur;
// temporary one request object
// current request
Request req;
// users sessions
SessionManager session_manager;
// database (DEPRACATED)
Db db;
DbConn db_conn;
/*
model
*/
// an unique id for each request
size_t request_id;
// ...
System system;
@@ -124,9 +112,6 @@ public:
bool stdout_is_closed;
/*
view
*/
Templates templates;
@@ -135,44 +120,32 @@ public:
private:
enum Header
{
h_200,
h_404,
h_403
};
PostParser post_parser;
PostMultiParser post_multi_parser;
PT::JSONToSpaceParser post_json_parser;
std::string post_buffer;
pt::SpaceParser space_parser;
CookieParser cookie_parser;
AcceptBaseParser accept_base_parser;
AcceptEncodingParser accept_encoding_parser;
Compress compress;
FCGX_Request fcgi_request;
int fcgi_socket;
Synchro synchro;
pthread_t signal_thread;
std::string socket_to_send_on_exit;
std::string send_data_buf;
PT::SpaceToJSON json_generic_serializer;
TextStream<std::wstring> json_out_stream;
std::string aheader_name, aheader_value;
std::wstring html_filtered;
std::string output_8bit;
BinaryPage compressed_output;
std::wstring cookie_id_string;
std::wstring http_header;
std::string http_header_8bit;
pt::WTextStream post_log_tmp_buffer;
morm::ModelConnector model_connector; // main thread model connector, each thread has its own connector
std::wstring http_header_name;
std::wstring http_header_value;
pt::WTextStream empty_response;
WinixModelConnector model_connector; // main thread model connector, each thread has its own connector
morm::JSONConnector json_connector;
morm::XMLConnector xml_connector;
morm::PostgreSQLConnector postgresql_connector;
// objects for main thread
WinixBase winix_base;
WinixModel winix_model;
WinixModelDeprecated winix_model;
WinixSystem winix_system;
WinixRequest winix_request;
// ///////////////////////
@@ -182,19 +155,22 @@ private:
//////////////////////////
// log_buffer for the main thread
PT::WTextStream log_buffer;
pt::WTextStream log_buffer;
// logger only for App object
// logger only for the main thread
Log log;
// file logger, one object for every Log objects
// file logger, one object for all Log objects
FileLog file_log;
bool InitFCGI(char * sock, char * sock_user, char * sock_group);
bool InitFCGIChmodChownSocket(char * sock, char * sock_user, char * sock_group);
bool AddSystemThreads();
bool InitFCGIChmodChownSocket(const char * sock);
bool DropPrivileges(char * user, char * group);
bool DropPrivileges(const char * user, uid_t uid, gid_t gid, bool additional_groups);
bool CheckAccessFromPlugins();
void MakeRenameMeToABetterName();
bool AddRootDir();
void ProcessRequestThrow();
void ProcessRequest();
void BaseUrlRedirect(int code, bool add_subdomain);
@@ -202,59 +178,31 @@ private:
void CheckIfNeedSSLredirect();
void SetLocale();
void CheckPostRedirect();
void MakePage();
void Make();
void AddDefaultModels();
void SaveSessionsIfNeeded(); // !! IMPROVE ME wywalic do menagera sesji??
void LogAccess();
void SendData(const BinaryPage & page, FCGX_Stream * out);
void CreateJSONAnswer();
void ReadRequest();
void SendTextAnswer();
void SendBinaryAnswer();
void SendAnswer();
void LogEnvironmentVariables();
void LogEnvironmentHTTPVariables();
void ParseAcceptHeader(const wchar_t * header_name, const std::wstring & env, std::vector<HeaderValue> & container, size_t max_len);
void ParseAcceptHeader();
void ParseAcceptLanguageHeader();
void SetEnv(const char * name, std::wstring & env);
void ReadEnvVariables();
void ReadEnvHTTPVariables();
bool SaveEnvHTTPVariable(const char * env);
void ReadEnvRemoteIP();
void ReadPostJson();
void ReadInputPostToBuffer();
void ParsePostJson();
void ReadPostJson(bool copy_raw_post);
void ReadPostVars();
void CheckIE();
void CheckKonqueror();
void CheckRequestMethod();
void CheckSSL();
void SetSubdomain();
Header GetHTTPStatusCode();
void PrepareSessionCookie();
void FilterContent();
void CheckHtmx();
bool IsRequestedFrame();
void SendHeaders();
void SendCookies();
bool AddHeader(const wchar_t * name, const wchar_t * value);
bool AddHeader(const std::wstring & name, const std::wstring & value);
bool AddHeader(const wchar_t * name, const PT::WTextStream & value);
bool AddHeader(const std::wstring & name, const PT::WTextStream & value);
bool PrepareHeadersStaticCreateResource(PT::WTextStream & out_path);
void PrepareHeadersStatic();
void PrepareHeaderContentType();
void PrepareHeadersForbidden();
void PrepareHeadersRedirect();
void PrepareHeadersSendFile();
void PrepareHeadersCompression(int compress_encoding);
void PrepareHeadersNormal(Header header, size_t output_size);
void PrepareHeaders(bool compressing, int compress_encoding, Header header, size_t output_size);
void PrepareStandardJSONFields();
int SelectDeflateVersion();
void SelectCompression(size_t source_len, bool & compression_allowed, int & compression_encoding);
bool CanSendContent();
void ClearAfterRequest();
void IncrementRequestId();
void LogUser(const char * msg, uid_t id);
void LogGroup(const char * msg, gid_t id, bool put_logend = true);
@@ -267,6 +215,10 @@ private:
void CreateStaticTree();
bool DoDatabaseMigration();
bool TryToMakeDatabaseMigration();
// !! IMPROVE ME
// !! move to the session manager?
time_t last_sessions_save;
+16 -9
View File
@@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2010-2019, Tomasz Sowa
* Copyright (c) 2010-2022, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -42,10 +42,11 @@ namespace Winix
BaseThread::BaseThread() : thread_signal(PTHREAD_COND_INITIALIZER)
{
synchro = 0;
thread_id = 0;
work_mode = 0;
wake_up_was_called = false;
synchro = nullptr;
thread_id = 0;
work_mode = 0;
wake_up_was_called = false;
main_model_connector = nullptr;
}
@@ -54,15 +55,21 @@ BaseThread::~BaseThread()
}
void BaseThread::set_main_log_buffer(PT::WTextStream * log_buffer)
void BaseThread::set_main_log_buffer(pt::WTextStream * log_buffer)
{
main_log.SetLogBuffer(log_buffer);
main_log.set_log_buffer(log_buffer);
}
void BaseThread::set_main_file_log(PT::FileLog * file_log)
void BaseThread::set_main_file_log(pt::FileLog * file_log)
{
main_log.SetFileLog(file_log);
main_log.set_file_log(file_log);
}
void BaseThread::set_main_model_connector(morm::ModelConnector * main_model_connector)
{
this->main_model_connector = main_model_connector;
}
+16 -13
View File
@@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2010-2019, Tomasz Sowa
* Copyright (c) 2010-2022, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -37,7 +37,7 @@
#include <pthread.h>
#include "synchro.h"
#include "winixmodel.h"
#include "winixmodeldeprecated.h"
@@ -47,16 +47,17 @@ namespace Winix
class BaseThread : public WinixModel
class BaseThread : public WinixModelDeprecated
{
public:
BaseThread();
virtual ~BaseThread();
void set_main_log_buffer(PT::WTextStream * log_buffer);
void set_main_file_log(PT::FileLog * file_log);
void set_main_log_buffer(pt::WTextStream * log_buffer);
void set_main_file_log(pt::FileLog * file_log);
void set_main_model_connector(morm::ModelConnector * main_model_connector);
// work mode
// we have two modes:
@@ -105,11 +106,13 @@ protected:
// logger for the main thread
Log main_log;
// log from WinixBase is meant to be used by the second thread
// log from WinixBase is meant to be used by the other thread
// model connector for the main thread
// model_connector from the based class WinixModelDeprecated is meant to be used by the second thread
morm::ModelConnector * main_model_connector;
protected:
// signal came (work mode = 0 - default)
@@ -141,12 +144,12 @@ protected:
void SignalLoop();
static void * StartRoutine(void *);
bool BaseInit();
void BaseUninit();
bool BaseSignalReceived();
void BaseDo();
bool WaitForSignal();
bool WaitForSignalSleep(time_t second);
virtual bool BaseInit();
virtual void BaseUninit();
virtual bool BaseSignalReceived();
virtual void BaseDo();
virtual bool WaitForSignal();
virtual bool WaitForSignalSleep(time_t second);
bool Lock();
void Unlock();
-636
View File
@@ -1,636 +0,0 @@
/*
* This file is a part of Winix
* and is distributed under the 2-Clause BSD licence.
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
/*
* Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "bbcodeparser.h"
namespace Winix
{
bool BBCODEParser::Equal(const wchar_t * str1, const wchar_t * str2)
{
while( *str1 == *str2 && *str1 != 0 )
{
str1 += 1;
str2 += 1;
}
return *str1 == *str2;
}
bool BBCODEParser::IsValidCharForName(int c)
{
if( (c>='a' && c<='z') ||
(c>='A' && c<='Z') ||
c=='*' || c=='_')
return true;
return false;
}
bool BBCODEParser::IsOpeningTagMark(wchar_t c)
{
return (c == '[');
}
bool BBCODEParser::IsClosingTagMark(wchar_t c)
{
return (c == ']');
}
bool BBCODEParser::IsClosingXmlSimpleTagMark(wchar_t c)
{
return false;
}
// there are no commentaries in bbcode
bool BBCODEParser::IsOpeningCommentaryTagMark(const wchar_t *)
{
return false;
}
size_t BBCODEParser::OpeningCommentaryTagMarkSize()
{
return 0;
}
bool BBCODEParser::SkipCommentaryTagIfExists()
{
return false;
}
// one enter will generate one <br>
// two enters or more will generate only two br (<br><br>)
void BBCODEParser::PutNormalText(const wchar_t * str, const wchar_t * end)
{
int br_len;
if( *pchar == 0 )
{
// trimming last white characters at end of the user text
while( str<end && (IsWhite(*(end-1)) || *(end-1)==10) )
--end;
}
while( str < end )
{
if( *str == 10 )
{
++str;
br_len = 1;
// skipping white characters without a new line character
while( str < end && IsWhite(*str) )
++str;
if( str < end && *str == 10 )
{
br_len = 2;
// skipping white characters with new line characters
while( str < end && (IsWhite(*str) || *str==10) )
++str;
}
if( !has_open_ol_tag && !has_open_ul_tag && !has_open_li_tag )
{
for(int i=0 ; i < br_len ; ++i)
(*out_string) += L"<br>\n";
}
}
else
{
PrintEscape(*str);
++str;
}
}
}
void BBCODEParser::ReadNormalTextSkipWhite(const wchar_t * & start, const wchar_t * & last_non_white)
{
}
void BBCODEParser::CheckExceptions()
{
if( stack_len >= 2 )
{
if( pstack[stack_len-1].type == Item::opening &&
pstack[stack_len-2].type == Item::opening &&
IsNameEqual(L"*", pstack[stack_len-1].name) &&
IsNameEqual(L"*", pstack[stack_len-2].name) )
{
// removing the last [*] from the stack
// </li> was put automatically
PopStack();
}
}
}
/*
bbcode format:
[bbcodetag=value]some text[/bbcodetag]
the value can be quoted, e.g.
[bbcodetag="value"]some text[/bbcodetag], or
[bbcodetag='value']some text[/bbcodetag]
the third string below (in tags table) is 'html_argument' from Tags,
it can contain a special character % followed by a string which means:
%1 - "value" escaped as for html
%2 - "some text" escaped as for html
%u1 - "value" trimmed and escaped as for url-es
%u2 - "some text" trimmed and escaped as for url-es
%% - one %
if you are using %2 or %u2 then "some text" is not treated as bbcode, e.g.
[bbcodetag=value]some [b]text[/b][/bbcodetag] will produce:
<htmltag arg="value">some [b]text[/b]</htmltag> (the inner tags [b][/b] were not parsed)
also when using %2 or %u2 the closing bbcode tag is skipped
(if you want this tag then you can put it in 'html_argument')
and when using u (%u1 or %u2) the argument is trimmed from whitespaces and new lines
at the beginning and at the end
(because otherwise a space would be changed to %20 and this were probably not what you really wanted)
*/
const BBCODEParser::Tags * BBCODEParser::FindTag(const wchar_t * tag)
{
static Tags tags[] = {
{L"*", L"li", L">", false},
{L"b", L"em", L">", true},
{L"i", L"span", L" class=\"bbitalic\">", true},
{L"u", L"span", L" class=\"bbunderline\">", true},
{L"s", L"span", L" class=\"bbstrike\">", true},
{L"code", L"code", L" class=\"bbcode\">", false},
{L"list", L"ul", L" class=\"bblist\">", false},
{L"color", L"span", L" class=\"bbcol%1\">", true},
{L"url", L"a", L" href=\"%u1\">", true},
{L"img", L"img", L" alt=\"%1\" src=\"%u2\">", true},
{L"quote", L"div", L" class=\"bbquote\">\n<span class=\"bbquotewho\">%1</span><br>\n", false},
};
size_t i;
size_t len = sizeof(tags) / sizeof(Tags);
for(i=0 ; i<len ; ++i)
{
if( Equal(tag, tags[i].bbcode) )
return &tags[i];
}
return 0;
}
const BBCODEParser::Tags * BBCODEParser::FindTag(const std::wstring & tag)
{
return FindTag(tag.c_str());
}
void BBCODEParser::PrintArgumentCheckQuotes(const wchar_t * & start, const wchar_t * & end)
{
// skipping white characters from the argument
while( start<end && IsWhite(*start) )
++start;
// skipping first '=' character if exists
if( start<end && *start == '=' )
++start;
// skipping white characters from the argument
// at the beginning
while( start<end && IsWhite(*start) )
++start;
// and at the end
while( start<end && IsWhite(*(end-1)) )
--end;
if( start<end && (*start=='\'' || *start=='\"') )
{
++start;
if( start<end && *(start-1) == *(end-1) )
--end;
// skipping white characters after a first quote char [url = " ww...."]
while( start<end && IsWhite(*start) )
++start;
}
}
void BBCODEParser::PrintEncode(int c)
{
if( c == '&' )
{
(*out_string) += L"&amp;";
}
else
if( (c>='a' && c<='z') ||
(c>='A' && c<='Z') ||
(c>='0' && c<='9') ||
(c=='_' || c=='?' || c=='.' || c==',' || c=='/' || c=='-' ||
c=='+' || c=='*' || c=='(' || c==')' || c=='=' || c==':')
)
{
(*out_string) += c;
}
else
{
wchar_t buffer[20];
swprintf(buffer, 20, L"%02X", c);
(*out_string) += '%';
(*out_string) += buffer;
}
}
void BBCODEParser::PrintEscape(int c, bool change_quote)
{
if( c == '<' )
{
(*out_string) += L"&lt;";
}
else
if( c == '>' )
{
(*out_string) += L"&gt;";
}
else
if( c == '&' )
{
(*out_string) += L"&amp;";
}
else
if( c == '\"' && change_quote )
{
(*out_string) += L"&quot;";
}
else
{
(*out_string) += c;
}
}
void BBCODEParser::PrintArgumentEncode(const wchar_t * start, const wchar_t * end)
{
PrintArgumentCheckQuotes(start, end);
TrimWhiteWithNewLines(start, end);
for( ; start<end ; ++start )
PrintEncode(*start);
}
void BBCODEParser::PrintArgumentEscape(const wchar_t * start, const wchar_t * end)
{
PrintArgumentCheckQuotes(start, end);
for( ; start<end ; ++start )
PrintEscape(*start, true); // quotes are escaped as well here
}
void BBCODEParser::CheckOpeningTag(const Tags * tag, const wchar_t * tag_name, bool & condition)
{
if( Equal(tag->html_tag, tag_name) )
{
if( condition )
{
PutClosingTag(tag);
(*out_string) += '\n';
}
condition = true;
}
}
void BBCODEParser::CheckOpeningTag(const Tags * tag)
{
bool has_list_tag = has_open_ul_tag || has_open_ol_tag;
CheckOpeningTag(tag, L"li", has_open_li_tag);
CheckOpeningTag(tag, L"ul", has_open_ul_tag);
CheckOpeningTag(tag, L"ol", has_open_ol_tag);
if( has_open_li_tag && !has_list_tag )
{
(*out_string) += L"<ul>\n";
has_open_ul_tag = true;
}
}
void BBCODEParser::PrintEscape(const wchar_t * start, const wchar_t * end, bool change_quote)
{
for( ; start < end ; ++start)
PrintEscape(*start, change_quote);
}
void BBCODEParser::PrintEncode(const wchar_t * start, const wchar_t * end)
{
for( ; start < end ; ++start)
PrintEncode(*start);
}
void BBCODEParser::PutOpeningTagFromEzc()
{
// this can be a tag from Ezc templates system
(*out_string) += '[';
(*out_string) += LastItem().name;
const wchar_t * start = pchar;
while( *pchar && *pchar!=']' )
++pchar;
if( *pchar == ']' )
++pchar;
Put(start, pchar);
}
void BBCODEParser::PutHtmlArgument1(const wchar_t * arg_start, const wchar_t * arg_end, bool has_u)
{
if( has_u )
PrintArgumentEncode(arg_start, arg_end);
else
PrintArgumentEscape(arg_start, arg_end);
}
void BBCODEParser::TrimWhiteWithNewLines(const wchar_t * & start, const wchar_t * & end)
{
while( start < end && (IsWhite(*start) || *start==10) )
++start;
while( start < end && (IsWhite(*(end-1)) || *(end-1)==10) )
--end;
}
void BBCODEParser::PutHtmlArgument2(const Tags * tag, bool has_u)
{
const wchar_t * start = pchar;
const wchar_t * end = pchar;
bool first_tag_removed = false;
while( *pchar != 0 )
{
if( IsOpeningTagMark(*pchar) )
{
if( IsClosingTagForLastItem() )
{
// the last tag is skipped when using patterns with %2 or %u2
PopStack(); // removing opening tag from the stack
first_tag_removed = true;
break;
}
}
else
{
pchar += 1;
end = pchar;
}
}
if( !first_tag_removed )
PopStack(); // user has forgotten to close the tag
if( has_u )
{
TrimWhiteWithNewLines(start, end);
PrintEncode(start, end);
}
else
{
PrintEscape(start, end);
}
}
void BBCODEParser::PutHtmlArgument(const Tags * tag, const wchar_t * arg_start, const wchar_t * arg_end)
{
const wchar_t * pattern = tag->html_argument;
bool has_u;
while( *pattern )
{
if( *pattern == '%' )
{
++pattern;
has_u = false;
if( *pattern == 'u' )
{
++pattern;
has_u = true;
}
if( *pattern == '1' )
{
++pattern;
PutHtmlArgument1(arg_start, arg_end, has_u);
}
else
if( *pattern == '2' )
{
++pattern;
PutHtmlArgument2(tag, has_u);
}
else
if( *pattern == '%' )
{
(*out_string) += '%';
++pattern;
}
// else unrecognized, will be printed next time as a normal character
}
else
{
(*out_string) += *pattern;
++pattern;
}
}
}
void BBCODEParser::PutOpeningTagFromBBCode(const Tags * tag)
{
CheckOpeningTag(tag);
PutOpeningTagMark();
Put(tag->html_tag);
const wchar_t * start = pchar;
while( *pchar && *pchar != ']' )
++pchar;
PutHtmlArgument(tag, start, pchar);
if( *pchar == ']' )
++pchar;
if( !tag->inline_tag )
{
Put(10);
SkipWhiteLines();
}
}
bool BBCODEParser::PutOpeningTag()
{
const Tags * tag = FindTag(LastItem().name);
if( !tag )
PutOpeningTagFromEzc();
else
PutOpeningTagFromBBCode(tag);
return false;
}
void BBCODEParser::PutClosingTag(const Tags * tag)
{
if( !tag )
return; // skipping the tag
PutOpeningTagMark();
(*out_string) += '/';
(*out_string) += tag->html_tag;
PutClosingTagMark();
if( !tag->inline_tag )
{
(*out_string) += L"\n";
SkipWhiteLines();
}
if( Equal(tag->html_tag, L"li") )
has_open_li_tag = false;
if( Equal(tag->html_tag, L"ol") )
has_open_ol_tag = false;
if( Equal(tag->html_tag, L"ul") )
has_open_ul_tag = false;
}
void BBCODEParser::PutClosingTag(const wchar_t * tag_name)
{
const Tags * tag = FindTag(tag_name);
PutClosingTag(tag);
}
void BBCODEParser::Init()
{
has_open_li_tag = false;
has_open_ol_tag = false;
has_open_ul_tag = false;
SkipWhiteLines();
}
void BBCODEParser::Uninit()
{
if( has_open_li_tag )
(*out_string) += L"</li>\n";
if( has_open_ol_tag )
(*out_string) += L"</ol>\n";
if( has_open_ul_tag )
(*out_string) += L"</ul>\n";
}
} // namespace Winix
-127
View File
@@ -1,127 +0,0 @@
/*
* This file is a part of Winix
* and is distributed under the 2-Clause BSD licence.
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
/*
* Copyright (c) 2008-2018, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef headerfile_winix_core_bbcodeparser
#define headerfile_winix_core_bbcodeparser
#include "htmlfilter.h"
namespace Winix
{
class BBCODEParser : public HTMLFilter
{
struct Tags
{
const wchar_t * bbcode;
const wchar_t * html_tag;
const wchar_t * html_argument; // with closing '>'
bool inline_tag;
};
/*
virtual methods
(from HTMLFilter class)
*/
virtual void Init();
virtual void Uninit();
virtual bool IsOpeningTagMark(wchar_t c);
virtual bool IsClosingTagMark(wchar_t c);
virtual bool IsClosingXmlSimpleTagMark(wchar_t c);
virtual bool IsOpeningCommentaryTagMark(const wchar_t *);
virtual size_t OpeningCommentaryTagMarkSize();
virtual bool IsValidCharForName(int c);
virtual void CheckExceptions();
virtual bool SkipCommentaryTagIfExists();
virtual bool PutOpeningTag();
virtual void PutClosingTag(const wchar_t * tag);
virtual void PutNormalText(const wchar_t * str, const wchar_t * end);
virtual void ReadNormalTextSkipWhite(const wchar_t * & start, const wchar_t * & last_non_white);
/*
others
*/
bool Equal(const wchar_t * str1, const wchar_t * str2);
void PutHtmlArgument1(const wchar_t * arg_start, const wchar_t * arg_end, bool has_u);
void PutHtmlArgument2(const Tags * tag, bool has_u);
void PutHtmlArgument(const Tags * tag, const wchar_t * arg_start, const wchar_t * arg_end);
void PutOpeningTagFromEzc();
void PutOpeningTagFromBBCode(const Tags * tag);
const Tags * FindTag(const wchar_t * tag);
const Tags * FindTag(const std::wstring & tag);
void PrintArgumentCheckQuotes(const wchar_t * & start, const wchar_t * & end);
void PrintEscape(int c, bool change_quote = false);
void PrintEncode(int c);
void PrintEscape(const wchar_t * start, const wchar_t * end, bool change_quote = false);
void PrintEncode(const wchar_t * start, const wchar_t * end);
void PrintArgumentEncode(const wchar_t * start, const wchar_t * end);
void PrintArgumentEscape(const wchar_t * start, const wchar_t * end);
void PutClosingTag(const Tags * tag);
void CheckOpeningTag(const Tags * tag, const wchar_t * tag_name, bool & condition);
void CheckOpeningTag(const Tags * tag);
void TrimWhiteWithNewLines(const wchar_t * & start, const wchar_t * & end);
bool has_open_ol_tag; // has open html <ol> tag
bool has_open_ul_tag; // has open html <ul> tag
bool has_open_li_tag; // has open html <li> tag
};
} // namespace Winix
#endif
+2
View File
@@ -258,6 +258,8 @@ BinaryPage::const_iterator i = page.begin();
source_len -= strm.avail_in;
flush = (source_len == 0) ? Z_FINISH : Z_NO_FLUSH;
strm.next_in = (Bytef*)buffer_in;
// IMPROVE ME we can add an interface to pt::TextStreamBase<> and get all chunks of memory
CopyToInputBuffer(i, strm.avail_in);
do
+117 -102
View File
@@ -4,8 +4,8 @@
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
/*
* Copyright (c) 2008-2021, Tomasz Sowa
/*
* Copyright (c) 2008-2026, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -45,47 +45,39 @@ namespace Winix
Config::Config()
{
errors_to_stdout = true;
}
void Config::SetFileLog(FileLog * file_log)
{
log.SetFileLog(file_log);
log.set_file_log(file_log);
}
void Config::SetLogBuffer(PT::WTextStream * log_buffer)
void Config::SetLogBuffer(pt::WTextStream * log_buffer)
{
log.SetLogBuffer(log_buffer);
log.set_log_buffer(log_buffer);
}
void Config::ShowError()
void Config::ShowError(const std::wstring & config_file)
{
switch( parser.status )
{
case PT::SpaceParser::no_space:
log << log2 << "Config: space not set" << logend;
case pt::SpaceParser::ok:
break;
case PT::SpaceParser::ok:
log << log2 << "Config: syntax ok" << logend;
break;
case PT::SpaceParser::cant_open_file:
if( errors_to_stdout )
std::wcout << L"Config: I cannot open a config file: " << config_file << std::endl;
log << log1 << "Config: cant open a config file: " << config_file << logend;
case pt::SpaceParser::cant_open_file:
log << log1 << "Config: I cannot open a config file: " << config_file << logend;
break;
case PT::SpaceParser::syntax_error:
if( errors_to_stdout )
std::wcout << "Config: syntax error, line: " << parser.line << std::endl;
log << log1 << "Config: syntax error, line: " << parser.line << logend;
case pt::SpaceParser::syntax_error:
log << log1 << "Config: syntax error in file: " << config_file << ", line: "
<< parser.get_last_parsed_line() << ":" << parser.get_last_parsed_column() << logend;
break;
default:
// there are no limits sets when parsing the config file
break;
}
}
@@ -95,38 +87,38 @@ void Config::ShowError()
bool Config::ReadConfig(bool errors_to_stdout_, bool stdout_is_closed)
bool Config::ReadConfig(const std::wstring & config_file)
{
errors_to_stdout = errors_to_stdout_;
if( config_file.empty() )
{
log << log2 << "Config: name of the config file is empty" << logend;
return false;
}
log << log2 << "Config: reading a config file" << logend;
log << log2 << "Config: reading a config file: " << config_file << logend;
pt::SpaceParser::Status status = parser.parse_space_file(config_file, space, false);
parser.SetSpace(space);
PT::SpaceParser::Status status = parser.Parse(config_file);
if( status == PT::SpaceParser::ok )
if( status == pt::SpaceParser::ok )
{
AssignValues(stdout_is_closed);
SetAdditionalVariables();
return true;
}
else
{
ShowError();
ShowError(config_file);
return false;
}
}
void Config::AssignValuesFromSpace()
{
AssignValues();
SetAdditionalVariables();
}
void Config::AssignValues(bool stdout_is_closed)
void Config::AssignValues()
{
server_mode = Text(L"server_mode");
demonize = Bool(L"demonize", true);
@@ -138,10 +130,13 @@ void Config::AssignValues(bool stdout_is_closed)
log_file = Text(L"log_file");
log_delimiter = Text(L"log_delimiter", L"---------------------------------------------------------------------------------");
fcgi_socket = Text(L"fcgi_socket");
fcgi_set_socket_chmod = Bool(L"fcgi_set_socket_chmod", true);
fcgi_set_socket_owner = Bool(L"fcgi_set_socket_owner", true);
fcgi_socket_chmod = Int(L"fcgi_socket_chmod", 0770);
fcgi_socket_user = Text(L"fcgi_socket_user");
fcgi_socket_group = Text(L"fcgi_socket_group");
fcgi_socket_listen = Int(L"fcgi_socket_listen", 100);
fcgi_socket_listen = Int(L"fcgi_socket_listen", 1024);
fcgi_cannot_create_request_delay = Size(L"fcgi_cannot_create_request_delay", 3);
log_level = Int(L"log_level", 1);
log_request = Int(L"log_request", 1);
log_save_each_line = Bool(L"log_save_each_line", false);
@@ -153,9 +148,15 @@ void Config::AssignValues(bool stdout_is_closed)
log_post_value_size = Size(L"log_post_value_size", 80);
log_env_variables = Bool(L"log_env_variables", false);
log_env_http_variables = Bool(L"log_env_http_variables", false);
log_whole_http_post = Bool(L"log_whole_http_post", false);
log_http_answer_headers = Bool(L"log_http_answer_headers", false);
post_file_max = Size(L"post_file_max", 8388608); // 8 MB
post_json_max = Size(L"post_json_max", 8388608); // 8 MB
post_max_object_items = Size(L"post_max_object_items", 1024);
post_max_table_items = Size(L"post_max_table_items", 4096);
post_max_all_items = Size(L"post_max_all_items", 8192);
post_max_nested_objects = Size(L"post_max_nested_objects", 32);
upload_dir = Text(L"upload_dir");
common_dir = Text(L"common_dir");
@@ -179,22 +180,39 @@ void Config::AssignValues(bool stdout_is_closed)
image_quality = Int(L"image_quality", 92);
convert_cmd = Text(L"convert_cmd", L"/usr/local/bin/convert");
templates_dir = Text(L"templates_dir");
templates_dir_default = Text(L"templates_dir_default");
txt_templates_dir = Text(L"txt_templates_dir");
txt_templates_dir_default = Text(L"txt_templates_dir_default");
ListText(L"html_templates_dirs", html_templates_dirs);
ListText(L"txt_templates_dirs", txt_templates_dirs);
templates_fun_prefix = Text(L"templates_fun_prefix", L"fun_");
templates_fun_postfix = Text(L"templates_fun_postfix", L".html");
templates_index = Text(L"templates_index", L"index.html");
templates_index_generic = Text(L"templates_index_generic", L"index_generic.html");
templates_index_raw = Text(L"templates_index_raw", L"index_raw.html");
templates_request_status = Text(L"templates_request_status", L"request_status.html");
template_only_root_use_template_fun = Bool(L"template_only_root_use_template_fun", false);
http_session_id_name = Text(L"http_session_id_name", L"session_id");
use_internal_session_mechanism = Bool(L"use_internal_session_mechanism", true);
use_internal_loggin_mechanism = Bool(L"use_internal_loggin_mechanism", true);
session_cookie_name = Text(L"session_cookie_name", L"session_id");
session_cookie_path = Text(L"session_cookie_path", L"/");
session_cookie_domain = Text(L"session_cookie_domain", L"");
session_cookie_same_site = Int(L"session_cookie_same_site", 0);
session_cookie_http_only = Bool(L"session_cookie_http_only", false);
session_cookie_secure = Bool(L"session_cookie_secure", false);
db_conn_string = Text(L"db_conn_string");
db_host = Text(L"db_host");
db_hostaddr = Text(L"db_hostaddr");
db_port = Text(L"db_port");
db_database = Text(L"db_database");
db_user = Text(L"db_user");
db_pass = Text(L"db_pass");
db_postgresql_smaller_than_10 = Bool(L"db_postgresql_smaller_than_10", false);
db_startup_connection_max_attempts = Size(L"db_startup_connection_max_attempts", 0);
db_startup_connection_attempt_delay = Size(L"db_startup_connection_attempt_delay", 5);
db_make_migration_if_needed = Bool(L"db_make_migration_if_needed", true);
db_stop_if_migration_fails = Bool(L"db_stop_if_migration_fails", true);
item_url_empty = Text(L"item_url_empty");
@@ -240,24 +258,24 @@ void Config::AssignValues(bool stdout_is_closed)
compression_page_min_size = Size(L"compression_page_min_size", 512);
compression_encoding = Int(L"compression_encoding", 20);
html_filter = Bool(L"html_filter", true);
html_filter_trim_white = Bool(L"html_filter_trim_white", true);
html_filter_break_word = Int(L"html_filter_break_word", 60);
html_filter = Bool(L"html_filter", false);
html_filter_white_char_mode = Int(L"html_filter_white_char_mode", 2);
html_filter_wrap_line = Int(L"html_filter_wrap_line", 110);
html_filter_tabs = Size(L"html_filter_tabs", 2);
html_filter_orphans = Bool(L"html_filter_orphans", true);
html_filter_orphans_mode_str = Text(L"html_filter_orphans_mode_str", L"nbsp");
html_filter_nofilter_tag = Text(L"html_filter_nofilter_tag", L"nofilter");
locale_dir = Text(L"locale_dir");
locale_dir_default = Text(L"locale_dir_default");
ListText(L"locale_dirs", locale_dirs);
locale_max_id = Size(L"locale_max_id", 100);
locale_default_id = Size(L"locale_default_id", 0);
ListText(L"locale_files", locale_files);
title_separator = Text(L"title_separator", L" / ");
http_header_send_file = Text(L"http_header_send_file", L"X-LIGHTTPD-send-file");
send_file_mode = Int(L"send_file_mode", 0);
send_file_header = Text(L"send_file_header", L"X-SENDFILE");
send_file_relative_prefix = Text(L"send_file_relative_prefix", L"upload-files-internal");
editors_html_safe_mode = Bool(L"editors_html_safe_mode", true);
editors_html_safe_mode_skip_root = Bool(L"editors_html_safe_mode_skip_root", true);
@@ -288,8 +306,20 @@ void Config::AssignValues(bool stdout_is_closed)
ezc_max_elements = Size(L"ezc_max_elements", 50000);
ezc_max_loop_elements = Size(L"ezc_max_loop_elements", 5000);
ezc_out_streams_size = Size(L"ezc_out_streams_size", 128);
ezc_error_prefix = Text(L"ezc_error_prefix", L"<!-- ");
ezc_error_postfix = Text(L"ezc_error_postfix", L" -->");
request_frame_parameter = Text(L"request_frame_parameter", L"frame");
request_all_frames_parameter = Text(L"request_all_frames_parameter", L"all_frames");
request_main_stream_parameter = Text(L"request_main_stream_parameter", L"main_stream");
request_frame_parameter_max_length = Size(L"request_frame_parameter_max_length", 128);
request_frame_parameter_max_frames = Size(L"request_frame_parameter_max_frames", 16);
xml_root = Text(L"xml_root", L"winix");
bin_stream_field = Text(L"bin_stream_field", L"bin_stream");
main_stream_field = Text(L"main_stream_field", L"main_stream");
ezc_frames_field = Text(L"ezc_frames_field", L"ezc_frames");
request_max_accept_fields = Size(L"request_max_accept_fields", 8);
request_max_accept_language_fields = Size(L"request_max_accept_language_fields", 8);
account_need_email_verification = Bool(L"account_need_email_verification", true);
reset_password_code_expiration_time = Long(L"reset_password_code_expiration_time", 86400);
@@ -314,12 +344,22 @@ void Config::AssignValues(bool stdout_is_closed)
incorrect_login_cannot_login_delay = Size(L"incorrect_login_cannot_login_delay", 1800);
pid_file = Text(L"pid_file", L"");
allow_ezc_out_in_executable_items = Bool(L"allow_ezc_out_in_executable_items", false);
allow_ezc_frames_in_executable_items = Bool(L"allow_ezc_frames_in_executable_items", false);
check_proxy_ip_header = Bool(L"check_proxy_ip_header", false);
proxy_ip_header = Text(L"proxy_ip_header", L"X_Real_IP");
use_antispam_mechanism_for_not_logged_users = Bool(L"use_antispam_mechanism_for_not_logged_users", true);
antispam_list_max_size = Size(L"antispam_list_max_size", 10);
add_header_cache_no_store_in_htmx_request = Bool(L"add_header_cache_no_store_in_htmx_request", true);
request_queue_job_limit = Size(L"request_queue_job_limit", 1024);
ListText(L"allowed_origins", allowed_origins);
allow_all_origins = Bool(L"allow_all_origins", true);
are_cors_preflight_requests_available = Bool(L"are_cors_preflight_requests_available", false);
ListText(L"access_control_expose_headers", access_control_expose_headers);
access_control_allow_credentials = Bool(L"access_control_allow_credentials", false);
}
@@ -382,150 +422,125 @@ void Config::CheckPasswd()
std::wstring Config::Text(const wchar_t * name)
{
return space.Text(name);
return space.to_wstr(name);
}
std::wstring Config::Text(const wchar_t * name, const wchar_t * def)
{
return space.Text(name, def);
return space.to_wstr(name, def);
}
std::wstring Config::Text(const std::wstring & name, const wchar_t * def)
{
return space.Text(name, def);
}
std::wstring & Config::TextRef(const wchar_t * name)
{
return space.TextRef(name);
}
std::wstring & Config::TextRef(const wchar_t * name, const wchar_t * def)
{
return space.TextRef(name, def);
}
std::wstring & Config::TextRef(const std::wstring & name, const wchar_t * def)
{
return space.TextRef(name, def);
return space.to_wstr(name, def);
}
int Config::Int(const wchar_t * name)
{
return space.Int(name);
return space.to_int(name);
}
int Config::Int(const wchar_t * name, int def)
{
return space.Int(name, def);
return space.to_int(name, def);
}
int Config::Int(const std::wstring & name, int def)
{
return space.Int(name, def);
return space.to_int(name, def);
}
long Config::Long(const wchar_t * name)
{
return space.Long(name);
return space.to_long(name);
}
long Config::Long(const wchar_t * name, long def)
{
return space.Long(name, def);
return space.to_long(name, def);
}
long Config::Long(const std::wstring & name, long def)
{
return space.Long(name, def);
return space.to_long(name, def);
}
size_t Config::Size(const wchar_t * name)
{
return space.Size(name);
return space.to_ulong(name);
}
size_t Config::Size(const wchar_t * name, size_t def)
{
return space.Size(name, def);
return space.to_ulong(name, def);
}
size_t Config::Size(const std::wstring & name, size_t def)
{
return space.Size(name, def);
return space.to_ulong(name, def);
}
bool Config::Bool(const wchar_t * name)
{
return space.Bool(name);
return space.to_bool(name);
}
bool Config::Bool(const wchar_t * name, bool def)
{
return space.Bool(name, def);
return space.to_bool(name, def);
}
bool Config::Bool(const std::wstring & name, bool def)
{
return space.Bool(name, def);
return space.to_bool(name, def);
}
bool Config::ListText(const wchar_t * name, std::vector<std::wstring> & list)
{
return space.ListText(name, list);
return space.to_list(name, list);
}
bool Config::ListText(const std::wstring & name, std::vector<std::wstring> & list)
{
return space.ListText(name, list);
return space.to_list(name, list);
}
bool Config::HasValue(const wchar_t * name, const wchar_t * value)
{
return space.HasValue(name, value);
return space.has_value(name, value);
}
bool Config::HasValue(const wchar_t * name, const std::wstring & value)
{
return space.HasValue(name, value);
}
bool Config::HasValue(const std::wstring & name, const wchar_t * value)
{
return space.HasValue(name, value);
}
bool Config::HasValue(const std::wstring & name, const std::wstring & value)
{
return space.HasValue(name, value);
return space.has_value(name.c_str(), value.c_str());
}
void Config::Print(std::wostream & out)
{
space.Serialize(out);
}
//void Config::Print(std::wostream & out)
//{
// space.serialize_to_space_stream(out);
//}
+309 -59
View File
@@ -4,8 +4,8 @@
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
/*
* Copyright (c) 2008-2021, Tomasz Sowa
/*
* Copyright (c) 2008-2026, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -53,10 +53,6 @@ class Config
{
public:
// name of the config file
// this is the parameter passed to winix programm
std::wstring config_file;
// server mode
// you can assign any string to it such as "production" "dev"
// this value is not used by winix itself
@@ -88,7 +84,8 @@ public:
// the log level (how much info should be inserted to logs)
// 1 - minimum
// 2 - (default)
// 3 - maximum - all logs
// 3 - more logs
// 4 - maximum - all logs
int log_level;
// logging to stdout too
@@ -97,7 +94,7 @@ public:
bool log_stdout;
// how many requests should be saved in the same time
// if you have a very busy server you can incrase this value
// if you have a very busy server you can increase this value
// default: 1
int log_request;
@@ -134,11 +131,17 @@ public:
std::wstring log_delimiter;
// log environment variables (fastcgi environment)
// default: false;
bool log_env_variables;
// log environment http variables (only HTTP_* variables from fastcgi environment)
// default: false;
bool log_env_http_variables;
// log the whole http post structure (in json format) after parsing the post input
// default: false;
bool log_whole_http_post;
// log headers (+cookies) which are returned to the client
// this is what winix has generated -- the web server can change or add other headers
// default: false
@@ -147,16 +150,29 @@ public:
// fast cgi: socket (unix domain)
std::wstring fcgi_socket;
// fast cgi: whether to change chmod of the socket
// default: true
// if true then you should set fcgi_socket_chmod as well
bool fcgi_set_socket_chmod;
// fast cgi: whether to change owner/group of the socket
// default: true
// if true then you should set fcgi_socket_user and fcgi_socket_group as well
bool fcgi_set_socket_owner;
// fast cgi: socket permissions
// taken into account if fcgi_set_socket_chmod is true
// chmod and chown of the socket are set before winix drops privileges
int fcgi_socket_chmod;
// fast cgi: owner of the socket
// chmod and chown of the socket are set before winix drops privileges
// taken into account if fcgi_set_socket_owner is true
std::wstring fcgi_socket_user;
// fast cgi: group of the socket
// chmod and chown of the socket are set before winix drops privileges
// taken into account if fcgi_set_socket_owner is true
std::wstring fcgi_socket_group;
// fcgi_socket_listen is the listen queue depth used in the listen() call
@@ -164,11 +180,19 @@ public:
// default: 100
int fcgi_socket_listen;
std::wstring templates_dir;
std::wstring templates_dir_default; // html templates from winix
// in order to read a request we need to properly initialize a FastCGI structure by
// using FCGX_InitRequest function, if FCGX_InitRequest fails then we wait fcgi_cannot_create_request_delay
// seconds and trying again
// default: 3
size_t fcgi_cannot_create_request_delay;
std::wstring txt_templates_dir;
std::wstring txt_templates_dir_default; // txt (notifications) templates from winix
// html templates directories
// by default a file from the last directory is chosen
std::vector<std::wstring> html_templates_dirs;
// txt (notifications) templates directories
// by default a file from the last directory is chosen
std::vector<std::wstring> txt_templates_dirs;
// prefix and postfix for functions templates
// default:
@@ -189,22 +213,109 @@ public:
// default: index_raw.html
std::wstring templates_index_raw;
// html template used to show a http status such as Forbidden or Not Found
// default: request_status.html
std::wstring templates_request_status;
// if true then only root can use 'template' winix function
// default: false
bool template_only_root_use_template_fun;
// the database connection string
// https://www.postgresql.org/docs/14/libpq-connect.html#LIBPQ-CONNSTRING
// default: empty
// if empty then winix uses db_host and db_hostaddr
std::wstring db_conn_string;
// the database host name used if db_conn_string is empty
// default: empty
std::wstring db_host;
// the database host ip address used if db_conn_string is empty
// default: empty
// if db_host is empty and db_hostaddr is empty then winix connects to a Unix-domain socket
// meaning of db_host and db_hostaddr parameters is the same as described in
// https://www.postgresql.org/docs/14/libpq-connect.html#LIBPQ-CONNSTRING
//
// from above documentation:
// Using hostaddr allows the application to avoid a host name look-up, which might be important
// in applications with time constraints. However, a host name is required for GSSAPI or SSPI
// authentication methods, as well as for verify-full SSL certificate verification.
// The following rules are used:
//
// - If host is specified without hostaddr, a host name lookup occurs.
//
// - If hostaddr is specified without host, the value for hostaddr gives the server network address.
// The connection attempt will fail if the authentication method requires a host name.
//
// - If both host and hostaddr are specified, the value for hostaddr gives the server network address.
// The value for host is ignored unless the authentication method requires it, in which case it will
// be used as the host name.
std::wstring db_hostaddr;
// the database port number
std::wstring db_port;
// the database name, user name and a password for the PostgreSQL database
std::wstring db_database;
std::wstring db_user;
std::wstring db_pass;
// is the PostgreSQL later than 10
// default false
// if true then we are not using ROW() statements in sql query
bool db_postgresql_smaller_than_10;
// specify how many times we can try to connect to the database at startup
// default 0 (infinite)
size_t db_startup_connection_max_attempts;
// delay between each connection attempt at startup
// default 5 (seconds)
size_t db_startup_connection_attempt_delay;
// make database migration if needed
bool db_make_migration_if_needed;
// if a migration fails then stop winix
bool db_stop_if_migration_fails;
// use internal session mechanism
// default: true
// if false then we do not load/save and create internal sessions
// but there always be the temporary session object for a request
// also we do not load 'who' winix function
bool use_internal_session_mechanism;
// use internal loggin mechanism
// default: true
// if false then we do not load 'login' and 'logout' winix functions
// and the system will not allow to login through its api
bool use_internal_loggin_mechanism;
// the name of the cookie which has the session identifier
std::wstring http_session_id_name;
std::wstring session_cookie_name;
// session cookie path
// default: /
std::wstring session_cookie_path;
// session cookie domain
// if empty then the domain will be equal base_url
// default: empty
std::wstring session_cookie_domain;
// session cookie samesite attribute
// 0 - dont set the attribute
// 1 - Strict
// 2 - Lax
// 3 - None
// (values the same as values from CookieSameSite enum)
// default: 0
int session_cookie_same_site;
// whether or not set HttpOnly attribute on the session cookie
// default: false
bool session_cookie_http_only;
// whether or not set Secure attribute on the session cookie
// default: false
bool session_cookie_secure;
// string used in a place where is a user (or group) selected
// !! IMPROVE ME should be moved to locales
@@ -307,15 +418,15 @@ public:
std::vector<std::wstring> plugin_file;
// should the html code be cleaned by the html filter
// default: false
bool html_filter;
// should white characters be trimmed
bool html_filter_trim_white;
// when long words should be broken (a space will be inserted)
// default: after 60 non white characters there will be put a space
// set zero to turn off
size_t html_filter_break_word;
// how white characters between html tags are treated
// 0 - WHITE_MODE_ORIGIN - they are copied from input to output
// 1 - WHITE_MODE_SINGLE_LINE - new line characters are removed
// 2 - WHITE_MODE_TREE - try to create a tree (some kind of pretty printing)
// default: 2
int html_filter_white_char_mode;
// when long lines should be broken (a new line character will be inserted)
// default: 110
@@ -350,6 +461,35 @@ public:
// 0 - not used
size_t post_file_max;
// maximum length of the input stream when parsing it as json
// default: 8388608 - 8MB
// set zero to disable checking
size_t post_json_max;
// maximum key/value pairs in one object when parsing post json structure
// default: 1024
// set zero to disable checking
// each winix function can set its own limits
size_t post_max_object_items;
// maximum items in one table when parsing post json structure
// default: 4096
// set zero to disable checking
// each winix function can set its own limits
size_t post_max_table_items;
// maximum items (key/values pairs of objects or table items) througout the whole post input json structure
// default: 8192
// set zero to disable checking
// each winix function can set its own limits
size_t post_max_all_items;
// maximum nested objects/tables when parsing post json structure
// default: 32
// set zero to disable checking
// each winix function can set its own limits
size_t post_max_nested_objects;
// directory for static files
std::wstring upload_dir;
@@ -452,14 +592,15 @@ public:
// default: /usr/local/bin/convert
std::wstring convert_cmd;
// directory with locale files
std::wstring locale_dir;
// directory with default locale files (those from winix)
std::wstring locale_dir_default;
// directories with locale files
// we start reading locale from the first directory
// and files with the same name in each directory are concatenated
std::vector<std::wstring> locale_dirs;
// locale files (e.g. "en", "pl")
// default: only one item: en
// default: "en"
// a locale file should define winix_locale_id integer parameter
// and it should be smaller or equal to locale_max_id
std::vector<std::wstring> locale_files;
// a maximum value of a locale identifier
@@ -542,9 +683,39 @@ public:
// separator used in <title> html tag
std::wstring title_separator;
// http header recognized by www server as a file to send back
// default: X-LIGHTTPD-send-file
std::wstring http_header_send_file;
// how to send static files (uploaded by users) to the webserver
// 0 - winix will read the content of the file and send it back to the webserver
// 1 - winix will use send_file_header header with a full path to the file
// 2 - winix will use send_file_header header with a relative path to the file
// default: 0
// 0 can be be used with all webservers but it requires to copy the whole file content
// you can omit copying the content with values 1 or 2:
// for Apache set: 1
// for Lighttpd set: 1
// for Nginx set: 2
int send_file_mode;
// http header recognized by www server as a file to send back, used if send_file_mode is 1 or 2
// default: X-SENDFILE
// for Apache set: X-SENDFILE (Apache needs an external module: https://tn123.org/mod_xsendfile/)
// for Lighttpd set: X-LIGHTTPD-send-file (https://redmine.lighttpd.net/projects/1/wiki/X-LIGHTTPD-send-file)
// for Nginx set: X-Accel-Redirect (https://nginx.org/en/docs/http/ngx_http_core_module.html#internal)
std::wstring send_file_header;
// relative prefix used for sending static files if send_file_mode is 2
// default: "upload-files-internal"
// this prefix is added at the beginning of a relative file path e.g.
// /upload-files-internal/simplefs/normal/some_directories/file.jpg
//
// in Nginx config file use 'location' with the prefix, e.g:
// server {
// .....
// location /upload-files-internal/ {
// alias /path/to/winix/upload/; # trailing slash at the end
// internal;
// }
// }
std::wstring send_file_relative_prefix;
// in editors (emacs, ckeditor,...) the html will be filtered and unsafe tags
// will be dropped (script, frame, etc.)
@@ -619,6 +790,7 @@ public:
// 2 - application/xml - for XHTML 1.0 or for XHTML 1.1
// default: 0
// if utf8 is true then "; charset=UTF-8" will also be appended
// may it would be better to set just the string here instead of integers?
int content_type_header;
// global umask
@@ -636,18 +808,56 @@ public:
// how many output streams do we have in Request class
// those streams used in ajax responses
// you can use no more [ezc out] statements than this limit
// you can use no more [ezc frames] statements than this limit
// default: 128
size_t ezc_out_streams_size;
// prefix and postfix used when there is an error in Ezc patterns
// default:
// prefix: "<!-- "
// postfix: " -->"
std::wstring ezc_error_prefix;
std::wstring ezc_error_postfix;
// the name of the url parameter for returning a frame, e.g. https://domain.tld/mydir/myfunction/frame:foo
// default: frame
std::wstring request_frame_parameter;
// when true then when a user want to create a new account
// the name of the url parameter for returning all frames, e.g. https://domain.tld/mydir/myfunction/all_frames
// default: all_frames
std::wstring request_all_frames_parameter;
// the name of the url parameter for returning the main ezc stream, e.g. https://domain.tld/mydir/myfunction/main_stream
// default: main_stream
std::wstring request_main_stream_parameter;
// max lenght of the url frame parameter
// default: 128
size_t request_frame_parameter_max_length;
// max number of frames in the frame url parameter (they are separated by a comma)
// default: 16
// if you need more frames you can use all_frames url parameter to return all frames
size_t request_frame_parameter_max_frames;
// the name of the root element when serializing request answer to xml
// default: winix
std::wstring xml_root;
// the name of the field of the binary stream when serializing a request
// default: bin_stream
std::wstring bin_stream_field;
// the name of the field of the main ezc stream when serializing a request
// default: main_stream
std::wstring main_stream_field;
// the name of the field (object) of the ezc frames when serializing a request
// default: ezc_frames
std::wstring ezc_frames_field;
// max Accept header mime types to be parsed in a request
// default: 8
size_t request_max_accept_fields;
// max Accept-Language languages to be parsed in a request
// default: 8
size_t request_max_accept_language_fields;
// when true then when a user want to create a new account
// he has to provide his email and a message will be sent back to him
// with a link to activate the account
// default: true
@@ -756,10 +966,10 @@ public:
// pid file is saved after winix has dropped privileges
std::wstring pid_file;
// allow to use [ezc out] statement in executable items (used in 'run' winix function)
// allow to use [ezc frame] statements in executable items (used in 'run' winix function)
// default false
// warning: if you enable this options a user can override a different output stream when using ajax
bool allow_ezc_out_in_executable_items;
bool allow_ezc_frames_in_executable_items;
// check whether there is a 'log_proxy_ip_header' header
@@ -771,7 +981,12 @@ public:
// default: X_Real_IP
std::wstring proxy_ip_header;
// antispam mechanizm
// use an antispam mechanism for not logged users
// when they try to add a new item
// default: true
bool use_antispam_mechanism_for_not_logged_users;
// antispam mechanism
// size of an list for map: form_id to counter_id for anonymous users (each session has such an map)
// this value allowes you to open the same or different html form in the browser more than once
// and each form has its own form_id and counter_id
@@ -779,8 +994,50 @@ public:
size_t antispam_list_max_size;
// send "Cache-Control: no-store, max-age=0" http header if a request is made by htmx library (ajax)
// if a webbrowser get a page from the cache then it will render just the last request without the whole html page (css, js, etc)
// https://github.com/bigskysoftware/htmx/issues/497
bool add_header_cache_no_store_in_htmx_request;
// a limit for the queue for requests
// when a request is scheduled to a job
// default: 1024
// if the limit is reached then the http status 503 Service Unavailable is returned
size_t request_queue_job_limit;
// list of allowed origins in cors requests
// can be set per controller in a method: virtual bool FunctionBase::IsOriginAvailable(const std::wstring & origin_url)
// default: empty
std::vector<std::wstring> allowed_origins;
// whether or not all origins are allowed if allowed_origins is empty
// default: true
// this is true by default because Origin header is sent not only in cors requests
// (you can still allow it in your function/controller by overriding IsOriginAvailable(...) method)
bool allow_all_origins;
// whether or not cors preflight requests are available
// https://developer.mozilla.org/en-US/docs/Glossary/Preflight_request
// default: false
bool are_cors_preflight_requests_available;
// list of additional headers sent in Access-Control-Expose-Headers header
// can be set per controller in a method: virtual void FunctionBase::AddAccessControlExposeHeadersHeader()
// default: empty
std::vector<std::wstring> access_control_expose_headers;
// if true return Access-Control-Allow-Credentials header equal "true"
// whethert credentials (e.g. cookies, authorization headers) are available in cors requests
// can be set per controller in a method: virtual bool FunctionBase::AreCorsCredentialsAvailable()
// default: false
bool access_control_allow_credentials;
Config();
bool ReadConfig(bool errors_to_stdout_, bool stdout_is_closed = true);
bool ReadConfig(const std::wstring & config_file);
void AssignValuesFromSpace();
/*
*
@@ -793,10 +1050,6 @@ public:
std::wstring Text(const wchar_t * name, const wchar_t * def);
std::wstring Text(const std::wstring & name, const wchar_t * def);
std::wstring & TextRef(const wchar_t * name);
std::wstring & TextRef(const wchar_t * name, const wchar_t * def);
std::wstring & TextRef(const std::wstring & name, const wchar_t * def);
int Int(const wchar_t *);
int Int(const wchar_t * name, int def);
int Int(const std::wstring & name, int def);
@@ -812,30 +1065,27 @@ public:
bool ListText(const wchar_t * name, std::vector<std::wstring> & list);
bool ListText(const std::wstring & name, std::vector<std::wstring> & list);
bool HasValue(const wchar_t * name, const wchar_t * value);
bool HasValue(const wchar_t * name, const std::wstring & value);
bool HasValue(const std::wstring & name, const wchar_t * value);
bool HasValue(const wchar_t * name, const wchar_t * value);
bool HasValue(const std::wstring & name, const std::wstring & value);
// for debug
void Print(std::wostream & out);
//void Print(std::wostream & out);
// raw access to the config
PT::Space space;
pt::Space space;
void SetFileLog(FileLog * file_log);
void SetLogBuffer(PT::WTextStream * log_buffer);
void SetLogBuffer(pt::WTextStream * log_buffer);
private:
PT::SpaceParser parser;
bool errors_to_stdout;
pt::SpaceParser parser;
Log log;
void ShowError();
void AssignValues(bool stdout_is_closed);
void ShowError(const std::wstring & config_file);
void AssignValues();
void SetAdditionalVariables();
void CheckPasswd();
+32 -28
View File
@@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2011-2018, Tomasz Sowa
* Copyright (c) 2011-2021, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -78,7 +78,7 @@ bool Crypt::HashBin(int hash, const char * in, size_t inlen, std::string & out)
run.Clear();
run.set_dependency(this);
PT::WideToUTF8(config->opensll_path, command);
pt::wide_to_utf8(config->opensll_path, command);
run.Cmd(command);
run.Par("dgst");
run.Par("-binary");
@@ -119,7 +119,7 @@ bool Crypt::HashBin(int hash, const std::string & in, std::string & out)
bool Crypt::HashBin(int hash, const wchar_t * in, size_t inlen, std::string & out)
{
PT::WideToUTF8(in, inlen, bufina);
pt::wide_to_utf8(in, inlen, bufina);
int res = HashBin(hash, bufina.c_str(), bufina.size(), out);
bufina.clear();
@@ -211,7 +211,7 @@ bool Crypt::RSA(bool encrypt, const char * keypath, const char * in, size_t inle
return false;
run.Clear();
PT::WideToUTF8(config->opensll_path, command);
pt::wide_to_utf8(config->opensll_path, command);
run.Cmd(command);
run.Par("rsautl");
@@ -243,7 +243,7 @@ bool Crypt::RSA(bool encrypt, const std::string & keypath, const std::string & i
bool Crypt::RSA(bool encrypt, const wchar_t * keypath, const char * in, size_t inlen, std::string & out)
{
PT::WideToUTF8(keypath, keypatha);
pt::wide_to_utf8(keypath, keypatha);
return RSA(encrypt, keypatha.c_str(), in, inlen, out);
}
@@ -267,28 +267,28 @@ bool Crypt::RSA(bool encrypt, const std::wstring & keypath, const std::string &
bool Crypt::PassHash(const std::wstring & salt, UserPass & up)
bool Crypt::PassHash(const std::wstring & salt, User & user)
{
bool result = true;
up.pass_hash_salted = false;
user.is_pass_hash_salted = false;
if( up.pass_type != WINIX_CRYPT_HASH_NONE )
if( user.pass_type != WINIX_CRYPT_HASH_NONE )
{
pass_org = up.pass;
pass_salted = up.pass;
pass_org = user.password;
pass_salted = user.password;
pass_salted += salt;
if( HashHex(up.pass_type, pass_salted, up.pass) )
if( HashHex(user.pass_type, pass_salted, user.password) )
{
if( !salt.empty() )
up.pass_hash_salted = true;
user.is_pass_hash_salted = true;
}
else
{
log << log1 << "Crypt: problem with generating a hash, the password will not be hashed" << logend;
up.pass = pass_org;
up.pass_type = WINIX_CRYPT_HASH_NONE;
user.password = pass_org;
user.pass_type = WINIX_CRYPT_HASH_NONE;
result = false;
}
@@ -301,22 +301,23 @@ return result;
bool Crypt::PassCrypt(const std::wstring & path_to_rsa_private_key, UserPass & up)
bool Crypt::PassCrypt(const std::wstring & path_to_rsa_private_key, User & user)
{
bool result = false;
ClearString(up.pass_encrypted);
ClearString(user.pass_encrypted);
if( !path_to_rsa_private_key.empty() )
{
PT::WideToUTF8(up.pass, passa);
pt::wide_to_utf8(user.password, passa);
if( RSA(true, path_to_rsa_private_key, passa, up.pass_encrypted) )
if( RSA(true, path_to_rsa_private_key, passa, user.pass_encrypted) )
{
ClearString(user.password);
result = true;
}
else
{
ClearString(up.pass_encrypted);
ClearString(user.pass_encrypted);
log << log1 << "AddUser: problem with encrypting, the password will not be encrypted!" << logend;
}
@@ -327,27 +328,30 @@ return result;
}
void Crypt::PassHashCrypt(const std::wstring & salt, const std::wstring & path_to_rsa_private_key, UserPass & up)
void Crypt::PassHashCrypt(const std::wstring & salt, const std::wstring & path_to_rsa_private_key, User & user)
{
PassHash(salt, up);
PassCrypt(path_to_rsa_private_key, up);
PassHash(salt, user);
PassCrypt(path_to_rsa_private_key, user);
}
void Crypt::PassHashCrypt(UserPass & up)
/*
* we hashing user.password, may it would be better to get the password as a seperate argument?
*/
void Crypt::PassHashCrypt(User & user)
{
up.pass_type = config->pass_type;
user.pass_type = config->pass_type;
ClearString(user.pass_encrypted);
empty.clear();
if( config->pass_hash_use_salt && !config->pass_hash_salt.empty() )
PassHash(config->pass_hash_salt, up);
PassHash(config->pass_hash_salt, user);
else
PassHash(empty, up);
PassHash(empty, user);
if( config->pass_use_rsa && !config->pass_rsa_private_key.empty() )
PassCrypt(config->pass_rsa_private_key, up);
PassCrypt(config->pass_rsa_private_key, user);
}
+6 -6
View File
@@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2011-2014, Tomasz Sowa
* Copyright (c) 2011-2021, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -38,7 +38,7 @@
#include <string>
#include "run.h"
#include "config.h"
#include "user.h"
#include "models/user.h"
#include "winixbase.h"
@@ -177,7 +177,7 @@ public:
if there is a problem with generating a hash the method stores a plain text password
and changes up.pass_type to zero (plain text passwords are not salted)
*/
bool PassHash(const std::wstring & salt, UserPass & up);
bool PassHash(const std::wstring & salt, User & user);
/*
@@ -195,7 +195,7 @@ public:
if there is a problem (or the path to the key is empty) then up.pass_encrypted will be empty
and the method returns false
*/
bool PassCrypt(const std::wstring & path_to_rsa_private_key, UserPass & up);
bool PassCrypt(const std::wstring & path_to_rsa_private_key, User & user);
/*
@@ -217,7 +217,7 @@ public:
up.pass_encrypted - encrypted password (if not empty)
*/
void PassHashCrypt(const std::wstring & salt, const std::wstring & path_to_rsa_private_key, UserPass & up);
void PassHashCrypt(const std::wstring & salt, const std::wstring & path_to_rsa_private_key, User & user);
/*
@@ -232,7 +232,7 @@ public:
up.pass_hash_salted - true if the hash is salted (plain text are never salted)
up.pass_encrypted - encrypted password (if not empty)
*/
void PassHashCrypt(UserPass & up);
void PassHashCrypt(User & user);
/*
+9 -1
View File
@@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2010-2014, Tomasz Sowa
* Copyright (c) 2010-2022, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -56,6 +56,14 @@ struct Cur
// those pointers are never null, if there is no a session for the user
// the 'session' pointer pointers at a special temporary session
Cur()
{
request = nullptr;
session = nullptr;
mount = nullptr;
}
};
+13 -2
View File
@@ -81,13 +81,13 @@ return var_iter;
}
DirContainer::Iterator DirContainer::Begin()
DirContainer::ConstIterator DirContainer::Begin() const
{
return table.begin();
}
DirContainer::Iterator DirContainer::End()
DirContainer::ConstIterator DirContainer::End() const
{
return table.end();
}
@@ -255,6 +255,17 @@ return i->second;
}
DirContainer::ConstIterator DirContainer::FindId(long id) const
{
TableId::const_iterator i = table_id.find(id);
if( i == table_id.end() )
return table.end();
return i->second;
}
DirContainer::ParentIterator DirContainer::ParentBegin()
{
+6 -4
View File
@@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2008-2014, Tomasz Sowa
* Copyright (c) 2008-2021, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -37,8 +37,8 @@
#include <list>
#include <map>
#include "item.h"
#include "winixbase.h"
#include "models/item.h"
namespace Winix
@@ -52,6 +52,7 @@ class DirContainer : public WinixBase
public:
typedef std::list<Item> Table;
typedef Table::iterator Iterator;
typedef Table::const_iterator ConstIterator;
typedef Table::size_type SizeType;
typedef std::map<long, Iterator> TableId;
@@ -66,8 +67,8 @@ public:
Iterator GetEtc();
Iterator GetVar();
Iterator Begin();
Iterator End();
ConstIterator Begin() const;
ConstIterator End() const;
SizeType Size();
bool Empty();
Iterator PushBack(const Item & item);
@@ -75,6 +76,7 @@ public:
void Clear();
Iterator FindId(long id);
ConstIterator FindId(long id) const;
bool DelById(long id);
+52 -32
View File
@@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2008-2018, Tomasz Sowa
* Copyright (c) 2008-2024, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,7 +31,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <ctime>
#include "dirs.h"
#include "error.h"
#include "notify/notify.h"
@@ -41,13 +42,6 @@ namespace Winix
{
void Dirs::SetDb(Db * pdb)
{
db = pdb;
}
void Dirs::SetCur(Cur * pcur)
{
cur = pcur;
@@ -60,9 +54,9 @@ void Dirs::SetNotify(Notify * pnotify)
}
void Dirs::set_dependency(WinixModel * winix_model)
void Dirs::set_dependency(WinixModelDeprecated * winix_model)
{
WinixModel::set_dependency(winix_model);
WinixModelDeprecated::set_dependency(winix_model);
dir_tab.set_dependency(winix_model);
}
@@ -76,7 +70,7 @@ void Dirs::Clear()
bool Dirs::HasReadExecAccessForRoot(const Item & item)
{
// there must be at least one 'x' (for the root)
return (item.privileges & 01111) != 0;
return (item.item_content.privileges & 01111) != 0;
}
@@ -88,28 +82,32 @@ void Dirs::CheckRootDir()
{
if( !HasReadExecAccessForRoot(*i) )
{
i->privileges = 07555;
i->item_content.privileges = 07555;
log << log1 << "Dirs: there is no access for a root (admin) to the root dir, setting 07555 for the root directory" << logend;
db->EditPrivById(*i, i->id);
i->item_content.set_connector(model_connector);
i->item_content.date_modification = std::time(nullptr);
i->item_content.save(false);
}
return;
}
log << log1 << "Dirs: there is no a root directory in the database (creating one)" << logend;
Item root;
ItemModelData item_data;
item_data.prepare_unique_url = false;
Item root;
root.set_connector(model_connector);
root.type = Item::dir;
root.parent_id = -1;
root.user_id = -1;
root.group_id = -1;
root.privileges = 07555;
root.item_content.user_id = -1;
root.item_content.group_id = -1;
root.item_content.privileges = 07555;
root.item_content.date_creation = std::time(nullptr);
root.item_content.date_modification = root.item_content.date_creation;
// !! upewnic sie ze baza nie zmieni url (gdyby wczesniej juz byl w bazie pusty url)
// !! zrobic jakis wyjatek do wprowadzania roota?
if( db->AddItem(root) == WINIX_ERR_OK )
if( root.insert(item_data) )
{
dir_tab.PushBack(root);
}
@@ -122,7 +120,15 @@ void Dirs::ReadDirs()
{
Clear();
db->GetDirs(dir_tab);
//db->GetDirs(dir_tab);
morm::Finder<Item> finder(model_connector);
std::list<Item> all_dirs = finder.select().where().eq(L"type", static_cast<int>(Item::Type::dir)).get_list();
for(Item & item : all_dirs)
{
dir_tab.PushBack(item);
}
CheckRootDir();
dir_tab.FindSpecialFolders();
}
@@ -443,9 +449,20 @@ Item * Dirs::GetDir(long id)
DirContainer::Iterator i = dir_tab.FindId(id);
if( i == dir_tab.End() )
return 0;
return nullptr;
return &(*i);
return &(*i);
}
const Item * Dirs::GetDir(long id) const
{
DirContainer::ConstIterator i = dir_tab.FindId(id);
if( i == dir_tab.End() )
return nullptr;
return &(*i);
}
@@ -723,17 +740,19 @@ bool Dirs::DelDir(long dir_id)
}
Error Dirs::AddDirectory(Item & item, bool add_to_dir_tab, Item ** pdir, int notify_code)
bool Dirs::AddDirectory(Item & item, bool add_to_dir_tab, Item ** pdir, int notify_code)
{
if( pdir )
*pdir = 0;
if( item.type != Item::dir )
return WINIX_ERR_DIR_EXPECTED;
return false;
Error status = db->AddItem(item);
//Error status = db->AddItem(item);
//item.set_connector(model_connector);
bool status = item.insert();
if( status == WINIX_ERR_OK )
if( status )
{
Item * d = AddDir(item);
@@ -764,10 +783,11 @@ Item * Dirs::CreateVarDir()
if( root )
{
v.set_connector(root->get_connector());
v.parent_id = root->id;
v.user_id = root->user_id;
v.group_id = root->group_id;
v.privileges = root->privileges;
v.item_content.user_id = root->item_content.user_id;
v.item_content.group_id = root->item_content.group_id;
v.item_content.privileges = root->item_content.privileges;
v.subject = L"var";
v.url = L"var";
v.type = Item::dir;
+8 -10
View File
@@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2008-2018, Tomasz Sowa
* Copyright (c) 2008-2024, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -39,12 +39,10 @@
#include <vector>
#include <map>
#include <string>
#include "item.h"
#include "dircontainer.h"
#include "db/db.h"
#include "request.h"
#include "winixmodel.h"
#include "models/item.h"
#include "winixmodeldeprecated.h"
@@ -58,7 +56,7 @@ class Notify;
// (we will support '..' in the future)
class Dirs : public WinixModel
class Dirs : public WinixModelDeprecated
{
public:
@@ -66,10 +64,9 @@ public:
void ReadDirs();
void SetCur(Cur * pcur);
void SetDb(Db * pdb);
void SetNotify(Notify * pnotify);
void set_dependency(WinixModel * winix_model);
void set_dependency(WinixModelDeprecated * winix_model);
// these methods return false if there is no such a dir
bool IsDir(long dir_id);
@@ -110,12 +107,14 @@ public:
Item * GetDir(long id);
Item * AddDir(const Item & item);
const Item * GetDir(long id) const;
void CheckRootDir();
Item * CreateVarDir();
// !! jak juz wczesniejsze nazwy beda zmienione to tutaj damy AddDir() /AddDir() juz istnieje przeciez?/
Error AddDirectory(Item & item, bool add_to_dir_tab = false, Item ** pdir = 0, int notify_code = 0);
bool AddDirectory(Item & item, bool add_to_dir_tab = false, Item ** pdir = 0, int notify_code = 0);
// returns how many levels of directories there are
// "/" -> 0 (root dir)
@@ -129,7 +128,6 @@ public:
private:
Cur * cur;
Db * db;
Notify * notify;
DirContainer dir_tab;
+25 -14
View File
@@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2018-2019, Tomasz Sowa
* Copyright (c) 2018-2022, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -37,7 +37,7 @@
#include <string.h>
#include "utf8/utf8.h"
#include "timezones.h"
#include "plugin.h"
namespace Winix
@@ -49,6 +49,7 @@ FileLog::FileLog()
{
time_zones = nullptr;
synchro = nullptr;
plugin = nullptr;
log_time_zone_id = 0;
}
@@ -64,9 +65,15 @@ void FileLog::set_synchro(Synchro * synchro)
}
void FileLog::set_plugin(Plugin * plugin)
{
this->plugin = plugin;
}
void FileLog::init(const std::wstring & log_file, bool log_stdout, int log_level, bool save_each_line, size_t log_time_zone_id)
{
PT::FileLog::init(log_file, log_stdout, log_level, save_each_line);
pt::FileLog::init(log_file, log_stdout, log_level, save_each_line);
this->log_time_zone_id = log_time_zone_id;
}
@@ -91,7 +98,7 @@ bool FileLog::should_save_each_line()
PT::Date FileLog::get_local_date(const PT::Date & date)
pt::Date FileLog::get_local_date(const pt::Date & date)
{
if( time_zones )
{
@@ -100,7 +107,7 @@ PT::Date FileLog::get_local_date(const PT::Date & date)
if( tz )
{
PT::Date local_date = tz->ToLocal(date);
pt::Date local_date = tz->ToLocal(date);
return local_date;
}
else
@@ -116,19 +123,23 @@ PT::Date FileLog::get_local_date(const PT::Date & date)
bool FileLog::synchro_lock()
void FileLog::save_log(pt::WTextStream * buffer)
{
return synchro->Lock();
if( !buffer->empty() )
{
Lock lock(synchro);
pt::FileLog::save_log(buffer);
// at the beginning when winix starts the plugin pointer is null
// this plugin is set after the plugin object is initialized
if( plugin )
{
plugin->Call(WINIX_SAVE_FILELOG, buffer);
}
}
}
void FileLog::synchro_unlock()
{
synchro->Unlock();
}
} // namespace Winix
+10 -11
View File
@@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2018-2021, Tomasz Sowa
* Copyright (c) 2018-2022, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -47,9 +47,9 @@
namespace Winix
{
class TimeZones;
class Plugin;
class FileLog : public PT::FileLog
class FileLog : public pt::FileLog
{
public:
@@ -57,19 +57,22 @@ public:
virtual ~FileLog();
void set_synchro(Synchro * synchro);
void set_plugin(Plugin * plugin);
// using PT::FileLog::init to suppress clang warning:
// using pt::FileLog::init to suppress clang warning:
// warning: 'Winix::FileLog::init' hides overloaded virtual function [-Woverloaded-virtual]
using PT::FileLog::init;
using pt::FileLog::init;
void init(const std::wstring & log_file, bool log_stdout, int log_level, bool save_each_line, size_t log_time_zone_id);
void set_time_zones(TimeZones * time_zones);
PT::Date get_local_date(const PT::Date & date);
pt::Date get_local_date(const pt::Date & date);
int get_log_level();
bool should_save_each_line();
void save_log(pt::WTextStream * buffer);
protected:
@@ -77,12 +80,8 @@ protected:
size_t log_time_zone_id;
TimeZones * time_zones;
Synchro * synchro;
virtual bool synchro_lock();
virtual void synchro_unlock();
Plugin * plugin; // can be null (only at the beginning when winix starts)
};
+14 -5
View File
@@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2008-2018, Tomasz Sowa
* Copyright (c) 2008-2021, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -46,9 +46,9 @@ Groups::Groups()
}
void Groups::set_dependency(WinixModel * winix_model)
void Groups::set_dependency(WinixModelDeprecated * winix_model)
{
WinixModel::set_dependency(winix_model);
WinixModelDeprecated::set_dependency(winix_model);
table.set_dependency(winix_model);
}
@@ -59,11 +59,20 @@ void Groups::Clear()
}
void Groups::ReadGroups(Db * db)
void Groups::ReadGroups()
{
Clear();
db->GetGroups(table);
morm::Finder<Group> finder(model_connector);
std::vector<Group> groups_tmp = finder.
select().
get_vector();
for(Group & group : groups_tmp)
{
table.PushBack(group, group.name);
}
}
+6 -7
View File
@@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2008-2018, Tomasz Sowa
* Copyright (c) 2008-2024, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -37,10 +37,9 @@
#include <map>
#include "group.h"
#include "models/group.h"
#include "ugcontainer.h"
#include "db/db.h"
#include "winixmodel.h"
#include "winixmodeldeprecated.h"
@@ -49,7 +48,7 @@ namespace Winix
class Groups : public WinixModel
class Groups : public WinixModelDeprecated
{
typedef UGContainer<Group> Table;
@@ -57,14 +56,14 @@ Table table;
public:
void set_dependency(WinixModel * winix_model);
void set_dependency(WinixModelDeprecated * winix_model);
typedef Table::Iterator Iterator;
typedef Table::SizeType SizeType;
Groups();
void Clear();
void ReadGroups(Db * db);
void ReadGroups();
Group * GetGroup(long group_id);
Group * GetGroup(const std::wstring & name);
long GetGroupId(const std::wstring & name);
+115
View File
@@ -0,0 +1,115 @@
/*
* This file is a part of Winix
* and is distributed under the 2-Clause BSD licence.
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
/*
* Copyright (c) 2022, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "header.h"
namespace Winix
{
const wchar_t * Header::find_status_string_value(int http_status)
{
size_t table_len = sizeof(status_int_string_map) / sizeof(StatusIntStringMapHelper);
for(size_t i=0 ; i < table_len ; ++i)
{
if( status_int_string_map[i].status_int == http_status )
{
return status_int_string_map[i].status_str;
}
}
return nullptr;
}
void Header::prepare_status_value(int http_status, pt::WTextStream & value, bool clear_value)
{
if( clear_value )
value.clear();
value << http_status;
const wchar_t * value_str = find_status_string_value(http_status);
if( value_str )
{
value << ' ' << value_str;
}
}
bool Header::is_header_value_char_correct(wchar_t c)
{
/*
* make sure to not allow at least \r or \r
*/
return c > 32 && c < 127;
}
bool Header::is_header_value_correct(const wchar_t * str)
{
for( ; *str ; ++str)
{
if( !is_header_value_char_correct(*str) )
{
return false;
}
}
return true;
}
bool Header::is_header_value_correct(const std::wstring & str)
{
/*
* dont use is_header_value_correct(str.c_str()) as there can be a null character (0) inside the string
*/
for(size_t i=0 ; i < str.size() ; ++i)
{
if( !is_header_value_char_correct(str[i]) )
{
return false;
}
}
return true;
}
}
+225
View File
@@ -0,0 +1,225 @@
/*
* This file is a part of Winix
* and is distributed under the 2-Clause BSD licence.
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
/*
* Copyright (c) 2021-2024, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef headerfile_winix_core_header
#define headerfile_winix_core_header
#include "log.h"
#include <textstream/textstream.h>
namespace Winix
{
class Header
{
public:
/*
* headers' names
*/
static constexpr const wchar_t * content_type = L"Content-Type";
static constexpr const wchar_t * accept = L"Accept";
static constexpr const wchar_t * accept_language = L"Accept-Language";
static constexpr const wchar_t * authorization = L"Authorization";
static constexpr const wchar_t * allow = L"Allow";
static constexpr const wchar_t * very = L"Very";
static constexpr const wchar_t * origin = L"Origin";
static constexpr const wchar_t * access_control_allow_methods = L"Access-Control-Allow-Methods";
static constexpr const wchar_t * access_control_allow_origin = L"Access-Control-Allow-Origin";
static constexpr const wchar_t * access_control_allow_headers = L"Access-Control-Allow-Headers";
static constexpr const wchar_t * access_control_allow_credentials = L"Access-Control-Allow-Credentials";
static constexpr const wchar_t * access_control_expose_headers = L"Access-Control-Expose-Headers";
static constexpr const wchar_t * access_control_max_age = L"Access-Control-Max-Age";
static constexpr const wchar_t * hx_location = L"HX-Location";
static constexpr const wchar_t * hx_push_url = L"HX-Push-Url";
static constexpr const wchar_t * hx_redirect = L"HX-Redirect";
static constexpr const wchar_t * hx_refresh = L"HX-Refresh";
static constexpr const wchar_t * hx_replace_url = L"HX-Replace-Url";
static constexpr const wchar_t * hx_reswap = L"HX-Reswap";
static constexpr const wchar_t * hx_retarget = L"HX-Retarget";
static constexpr const wchar_t * hx_reselect = L"HX-Reselect";
static constexpr const wchar_t * hx_trigger = L"HX-Trigger";
static constexpr const wchar_t * hx_trigger_after_settle = L"HX-Trigger-After-Settle";
static constexpr const wchar_t * hx_trigger_after_swap = L"HX-Trigger-After-Swap";
/*
* headers' names lower case
*/
static constexpr const wchar_t * content_type_lc = L"content-type";
static constexpr const wchar_t * accept_lc = L"accept";
static constexpr const wchar_t * accept_language_lc = L"accept-language";
/*
* headers' values
*/
static constexpr const wchar_t * application_octet_stream = L"application/octet-stream";
static constexpr const wchar_t * text_html = L"text/html";
static constexpr const wchar_t * application_json = L"application/json";
static constexpr const wchar_t * application_xml = L"application/xml";
static constexpr const wchar_t * application_xhtml_xml = L"application/xhtml+xml";
static constexpr const wchar_t * text_csv = L"text/csv";
static constexpr const wchar_t * text_javascript = L"text/javascript";
static constexpr const wchar_t * text_xml = L"text/xml";
static constexpr const wchar_t * all_all = L"*/*";
static constexpr const wchar_t * text_all = L"text/*";
static constexpr const wchar_t * application_all = L"application/*";
static constexpr const wchar_t * text_html_utf8 = L"text/html; charset=UTF-8";
static constexpr const wchar_t * application_json_utf8 = L"application/json; charset=UTF-8";
static constexpr const wchar_t * application_xml_utf8 = L"application/xml; charset=UTF-8";
static constexpr const wchar_t * application_xhtml_xml_utf8 = L"application/xhtml+xml; charset=UTF-8";
static constexpr const wchar_t * text_csv_utf8 = L"text/csv; charset=UTF-8";
static constexpr const wchar_t * text_javascript_utf8 = L"text/javascript; charset=UTF-8";
static constexpr const wchar_t * text_xml_utf8 = L"text/xml; charset=UTF-8";
static constexpr const wchar_t * application_x_www_form_urlencoded = L"application/x-www-form-urlencoded";
static constexpr const wchar_t * multipart_form_data = L"multipart/form-data";
static constexpr const wchar_t * bearer = L"Bearer";
static constexpr const wchar_t * winix = L"Winix";
static const int status_200_ok = 200;
static const int status_201_created = 201;
static const int status_204_no_content = 204;
static const int status_300_multiple_choices = 300;
static const int status_301_moved_permanently = 301;
static const int status_302_found = 302;
static const int status_303_see_other = 303;
static const int status_307_temporary_redirect = 307;
static const int status_400_bad_request = 400;
static const int status_403_forbidden = 403;
static const int status_404_not_found = 404;
static const int status_414_uri_too_long = 414;
static const int status_422_unprocessable_entity = 422;
static const int status_500_internal_server_error = 500;
static const int status_503_service_unavailable = 503;
static constexpr const wchar_t * str_status_200 = L"OK";
static constexpr const wchar_t * str_status_201 = L"Created";
static constexpr const wchar_t * str_status_204 = L"No Content";
static constexpr const wchar_t * str_status_300 = L"Multiple Choices";
static constexpr const wchar_t * str_status_301 = L"Moved Permanently";
static constexpr const wchar_t * str_status_302 = L"Found";
static constexpr const wchar_t * str_status_303 = L"See Other";
static constexpr const wchar_t * str_status_307 = L"Temporary Redirect";
static constexpr const wchar_t * str_status_400 = L"Bad Request";
static constexpr const wchar_t * str_status_403 = L"Forbidden";
static constexpr const wchar_t * str_status_404 = L"Not Found";
static constexpr const wchar_t * str_status_414 = L"URI Too Long";
static constexpr const wchar_t * str_status_422 = L"Unprocessable Entity";
static constexpr const wchar_t * str_status_500 = L"Internal Server Error";
static constexpr const wchar_t