diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..bdd62fa --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 Oleksandr Zhylin + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/TODO.md b/TODO.md index 6acf75c..0a6f4dc 100644 --- a/TODO.md +++ b/TODO.md @@ -3,7 +3,7 @@ ## Current: - [ ] PageUp/PageDown key functionality in lists - [ ] File upload multiline description (window) -- [ ] Permission checkboxes for file upload/edit +- [x] Permission checkboxes for file upload/edit - [ ] Check file upload - [ ] More intuitive navigation between nested groups (by pressing left and right buttons) diff --git a/src/common.h b/src/common.h index 76b7bcf..c06bded 100644 --- a/src/common.h +++ b/src/common.h @@ -1,3 +1,6 @@ +/* SPDX-License-Identifier: MIT */ +/* Copyright (c) 2026 Oleksandr Zhylin */ + #ifndef COMMON_H #define COMMON_H #include diff --git a/src/connection.c b/src/connection.c index 65d6b85..2d72ae2 100644 --- a/src/connection.c +++ b/src/connection.c @@ -1,3 +1,6 @@ +/* SPDX-License-Identifier: MIT */ +/* Copyright (c) 2026 Oleksandr Zhylin */ + #include "main.h" #include #include diff --git a/src/connection.h b/src/connection.h index 0628a79..26da6f2 100644 --- a/src/connection.h +++ b/src/connection.h @@ -1,3 +1,6 @@ +/* SPDX-License-Identifier: MIT */ +/* Copyright (c) 2026 Oleksandr Zhylin */ + #ifndef CONNECTION_H #define CONNECTION_H #include "main.h" diff --git a/src/draw_modal.c b/src/draw_modal.c index 72bc1bb..1ae154c 100644 --- a/src/draw_modal.c +++ b/src/draw_modal.c @@ -1,3 +1,6 @@ +/* SPDX-License-Identifier: MIT */ +/* Copyright (c) 2026 Oleksandr Zhylin */ + #include #include #include "main.h" diff --git a/src/draw_modal.h b/src/draw_modal.h index 52ee04c..5fb8576 100644 --- a/src/draw_modal.h +++ b/src/draw_modal.h @@ -1,3 +1,6 @@ +/* SPDX-License-Identifier: MIT */ +/* Copyright (c) 2026 Oleksandr Zhylin */ + #ifndef DRAW_MODAL_H #define DRAW_MODAL_H #include diff --git a/src/file_processor.c b/src/file_processor.c index 83dae32..3f4fd0b 100644 --- a/src/file_processor.c +++ b/src/file_processor.c @@ -1,3 +1,6 @@ +/* SPDX-License-Identifier: MIT */ +/* Copyright (c) 2026 Oleksandr Zhylin */ + #include #include #include diff --git a/src/file_processor.h b/src/file_processor.h index 8892ebf..9a58a14 100644 --- a/src/file_processor.h +++ b/src/file_processor.h @@ -1,3 +1,6 @@ +/* SPDX-License-Identifier: MIT */ +/* Copyright (c) 2026 Oleksandr Zhylin */ + #ifndef FILE_PROCESSOR_H #define FILE_PROCESSOR_H #include "main.h" diff --git a/src/fs.c b/src/fs.c index 74a36ec..32f5268 100644 --- a/src/fs.c +++ b/src/fs.c @@ -1,3 +1,6 @@ +/* SPDX-License-Identifier: MIT */ +/* Copyright (c) 2026 Oleksandr Zhylin */ + #include #include #include diff --git a/src/fs.h b/src/fs.h index 58b0b19..7d67c27 100644 --- a/src/fs.h +++ b/src/fs.h @@ -1,3 +1,6 @@ +/* SPDX-License-Identifier: MIT */ +/* Copyright (c) 2026 Oleksandr Zhylin */ + #ifndef LOC_FS_H #define LOC_FS_H diff --git a/src/main.c b/src/main.c index baed886..655472c 100644 --- a/src/main.c +++ b/src/main.c @@ -1,3 +1,6 @@ +/* SPDX-License-Identifier: MIT */ +/* Copyright (c) 2026 Oleksandr Zhylin */ + #include #include #include @@ -9,12 +12,12 @@ #include #include #include +#include #include "connection.h" #include "file_list.h" #include "main.h" #include "query.h" -#include uint32_t m_id = 0; diff --git a/src/main.h b/src/main.h index 679cf68..05f9560 100644 --- a/src/main.h +++ b/src/main.h @@ -1,3 +1,6 @@ +/* SPDX-License-Identifier: MIT */ +/* Copyright (c) 2026 Oleksandr Zhylin */ + #ifndef MAIN_H #define MAIN_H diff --git a/src/modals/upload_props_dialogue.c b/src/modals/upload_props_dialogue.c index 6939324..abbd836 100644 --- a/src/modals/upload_props_dialogue.c +++ b/src/modals/upload_props_dialogue.c @@ -8,6 +8,7 @@ #include #include #include +#include void upload_props_dialogue_modal_cb(callback_args_t *args) { callback_args_t d_args; @@ -23,10 +24,12 @@ void upload_props_dialogue_modal_cb(callback_args_t *args) { checkbox_t *reg_cbx = (checkbox_t *)d->g_content->elements[0].element; checkbox_t *anon_cbx = (checkbox_t *)d->g_content->elements[1].element; checkbox_t *comp_cbx = (checkbox_t *)d->g_content->elements[2].element; + int32_t privileges = 0; if (anon_cbx->value == true) privileges |= 1; if (reg_cbx->value == true) privileges |= 2; if (comp_cbx->value == true) privileges |= 4; + switch (d_args.resp_data.val.val.num) { case 1: query_len = @@ -41,12 +44,9 @@ void upload_props_dialogue_modal_cb(callback_args_t *args) { write(app->query_args->sd, query, query_len); break; case 2: - if (app->query_args->file->name != NULL) - free(app->query_args->file->name); - if (app->query_args->file->path != NULL) - free(app->query_args->file->path); - free(app->query_args->file); - app->query_args->file = NULL; + FREE_MLC(app->query_args->file->name); + FREE_MLC(app->query_args->file->path) + FREE_MLC(app->query_args->file); app->query_args->state = S_WAIT_SERVER; break; } diff --git a/src/query.c b/src/query.c index 2807d5c..04e6bfd 100644 --- a/src/query.c +++ b/src/query.c @@ -1,3 +1,6 @@ +/* SPDX-License-Identifier: MIT */ +/* Copyright (c) 2026 Oleksandr Zhylin */ + #include #include #include diff --git a/src/query.h b/src/query.h index 7517c0b..30cf1b1 100644 --- a/src/query.h +++ b/src/query.h @@ -1,3 +1,6 @@ +/* SPDX-License-Identifier: MIT */ +/* Copyright (c) 2026 Oleksandr Zhylin */ + #ifndef QUERY_H #define QUERY_H diff --git a/src/server.c b/src/server.c index a6fd9a9..0b775b7 100644 --- a/src/server.c +++ b/src/server.c @@ -1,3 +1,6 @@ +/* SPDX-License-Identifier: MIT */ +/* Copyright (c) 2026 Oleksandr Zhylin */ + #include "dialogue.h" #include "main.h" #include diff --git a/src/server.h b/src/server.h index b78f644..4e0bfde 100644 --- a/src/server.h +++ b/src/server.h @@ -1,3 +1,6 @@ +/* SPDX-License-Identifier: MIT */ +/* Copyright (c) 2026 Oleksandr Zhylin */ + #ifndef SERVER_H #define SERVER_H diff --git a/src/types.h b/src/types.h index 61eb662..40bbabd 100644 --- a/src/types.h +++ b/src/types.h @@ -1,3 +1,6 @@ +/* SPDX-License-Identifier: MIT */ +/* Copyright (c) 2026 Oleksandr Zhylin */ + #ifndef D_TYPES_H #define D_TYPES_H diff --git a/src/utils/utils.h b/src/utils/utils.h index 2b49d74..6971a76 100644 --- a/src/utils/utils.h +++ b/src/utils/utils.h @@ -2,4 +2,11 @@ #define D_UTILS_H #include "d_array.h" #include "utf8.h" + +/* Free if not null and assign NULL */ +#define FREE_MLC(arg) \ + if (arg != NULL) { \ + free(arg); \ + arg = NULL; \ + } #endif \ No newline at end of file diff --git a/src/widget/app.c b/src/widget/app.c index c25ebf9..e98c34c 100644 --- a/src/widget/app.c +++ b/src/widget/app.c @@ -1,3 +1,6 @@ +/* SPDX-License-Identifier: MIT */ +/* Copyright (c) 2026 Oleksandr Zhylin */ + #include "app.h" #include #include diff --git a/src/widget/app.h b/src/widget/app.h index 4dfa2db..d0dfbf6 100644 --- a/src/widget/app.h +++ b/src/widget/app.h @@ -1,3 +1,6 @@ +/* SPDX-License-Identifier: MIT */ +/* Copyright (c) 2026 Oleksandr Zhylin */ + #ifndef N_APP_H #define N_APP_H diff --git a/src/widget/button.c b/src/widget/button.c index 3f92639..05f8e6e 100644 --- a/src/widget/button.c +++ b/src/widget/button.c @@ -1,3 +1,6 @@ +/* SPDX-License-Identifier: MIT */ +/* Copyright (c) 2026 Oleksandr Zhylin */ + #include #include #include diff --git a/src/widget/button.h b/src/widget/button.h index 57d49d2..74784e3 100644 --- a/src/widget/button.h +++ b/src/widget/button.h @@ -1,3 +1,6 @@ +/* SPDX-License-Identifier: MIT */ +/* Copyright (c) 2026 Oleksandr Zhylin */ + #ifndef BUTTON_H #define BUTTON_H diff --git a/src/widget/checkbox.c b/src/widget/checkbox.c index 1890642..3e934e4 100644 --- a/src/widget/checkbox.c +++ b/src/widget/checkbox.c @@ -1,3 +1,6 @@ +/* SPDX-License-Identifier: MIT */ +/* Copyright (c) 2026 Oleksandr Zhylin */ + #include #include #include diff --git a/src/widget/checkbox.h b/src/widget/checkbox.h index 60db01d..aa299b0 100644 --- a/src/widget/checkbox.h +++ b/src/widget/checkbox.h @@ -1,3 +1,6 @@ +/* SPDX-License-Identifier: MIT */ +/* Copyright (c) 2026 Oleksandr Zhylin */ + #ifndef CHECKBOX_H #define CHECKBOX_H diff --git a/src/widget/dialogue.c b/src/widget/dialogue.c index cb09025..26cf7c3 100644 --- a/src/widget/dialogue.c +++ b/src/widget/dialogue.c @@ -1,3 +1,6 @@ +/* SPDX-License-Identifier: MIT */ +/* Copyright (c) 2026 Oleksandr Zhylin */ + #include #include #include diff --git a/src/widget/dialogue.h b/src/widget/dialogue.h index 5041f69..2d201db 100644 --- a/src/widget/dialogue.h +++ b/src/widget/dialogue.h @@ -1,3 +1,6 @@ +/* SPDX-License-Identifier: MIT */ +/* Copyright (c) 2026 Oleksandr Zhylin */ + #ifndef DIALOGUE_H #define DIALOGUE_H diff --git a/src/widget/file_list.c b/src/widget/file_list.c index 4892794..7f9b593 100644 --- a/src/widget/file_list.c +++ b/src/widget/file_list.c @@ -1,3 +1,6 @@ +/* SPDX-License-Identifier: MIT */ +/* Copyright (c) 2026 Oleksandr Zhylin */ + #include "file_list.h" #include "../file_processor.h" #include "../fs.h" diff --git a/src/widget/file_list.h b/src/widget/file_list.h index a0141a9..394ec25 100644 --- a/src/widget/file_list.h +++ b/src/widget/file_list.h @@ -1,3 +1,6 @@ +/* SPDX-License-Identifier: MIT */ +/* Copyright (c) 2026 Oleksandr Zhylin */ + #ifndef FILE_LIST_H #define FILE_LIST_H #include diff --git a/src/widget/fs_file_list.c b/src/widget/fs_file_list.c index 075b92b..270ff1e 100644 --- a/src/widget/fs_file_list.c +++ b/src/widget/fs_file_list.c @@ -1,3 +1,6 @@ +/* SPDX-License-Identifier: MIT */ +/* Copyright (c) 2026 Oleksandr Zhylin */ + #include #include #include diff --git a/src/widget/fs_file_list.h b/src/widget/fs_file_list.h index 418b31a..27717e9 100644 --- a/src/widget/fs_file_list.h +++ b/src/widget/fs_file_list.h @@ -1,3 +1,6 @@ +/* SPDX-License-Identifier: MIT */ +/* Copyright (c) 2026 Oleksandr Zhylin */ + #ifndef FS_FILE_LIST_H #define FS_FILE_LIST_H #include diff --git a/src/widget/group.c b/src/widget/group.c index b092027..213fef8 100644 --- a/src/widget/group.c +++ b/src/widget/group.c @@ -1,3 +1,6 @@ +/* SPDX-License-Identifier: MIT */ +/* Copyright (c) 2026 Oleksandr Zhylin */ + #include "group.h" #include "button.h" #include "checkbox.h" diff --git a/src/widget/group.h b/src/widget/group.h index fb7cc40..2c54fc4 100644 --- a/src/widget/group.h +++ b/src/widget/group.h @@ -1,3 +1,6 @@ +/* SPDX-License-Identifier: MIT */ +/* Copyright (c) 2026 Oleksandr Zhylin */ + #ifndef GROUP_H #define GROUP_H diff --git a/src/widget/input.c b/src/widget/input.c index 589aaca..1c5e197 100644 --- a/src/widget/input.c +++ b/src/widget/input.c @@ -1,3 +1,6 @@ +/* SPDX-License-Identifier: MIT */ +/* Copyright (c) 2026 Oleksandr Zhylin */ + #include #include #include diff --git a/src/widget/input.h b/src/widget/input.h index 4fcfe2a..86b8065 100644 --- a/src/widget/input.h +++ b/src/widget/input.h @@ -1,3 +1,6 @@ +/* SPDX-License-Identifier: MIT */ +/* Copyright (c) 2026 Oleksandr Zhylin */ + #ifndef INPUT_H #define INPUT_H diff --git a/src/widget/progress_bar.c b/src/widget/progress_bar.c index 9784bec..54f80c3 100644 --- a/src/widget/progress_bar.c +++ b/src/widget/progress_bar.c @@ -1,3 +1,6 @@ +/* SPDX-License-Identifier: MIT */ +/* Copyright (c) 2026 Oleksandr Zhylin */ + #include "progress_bar.h" #include "app.h" #include diff --git a/src/widget/progress_bar.h b/src/widget/progress_bar.h index 99a985e..3ed1997 100644 --- a/src/widget/progress_bar.h +++ b/src/widget/progress_bar.h @@ -1,3 +1,6 @@ +/* SPDX-License-Identifier: MIT */ +/* Copyright (c) 2026 Oleksandr Zhylin */ + #ifndef PROGRESS_BAR_H #define PROGRESS_BAR_H #include diff --git a/src/widget/widget.h b/src/widget/widget.h index 68ff5a8..0b3b2fd 100644 --- a/src/widget/widget.h +++ b/src/widget/widget.h @@ -1,3 +1,6 @@ +/* SPDX-License-Identifier: MIT */ +/* Copyright (c) 2026 Oleksandr Zhylin */ + #ifndef WIDGET_H #define WIDGET_H #include "app.h" diff --git a/src/widget_core/widget_core.c b/src/widget_core/widget_core.c index b303368..cc874d5 100644 --- a/src/widget_core/widget_core.c +++ b/src/widget_core/widget_core.c @@ -1,3 +1,6 @@ +/* SPDX-License-Identifier: MIT */ +/* Copyright (c) 2026 Oleksandr Zhylin */ + #include "widget_core.h" #include "../main.h" #include diff --git a/src/widget_core/widget_core.h b/src/widget_core/widget_core.h index c172c97..825c583 100644 --- a/src/widget_core/widget_core.h +++ b/src/widget_core/widget_core.h @@ -1,3 +1,6 @@ +/* SPDX-License-Identifier: MIT */ +/* Copyright (c) 2026 Oleksandr Zhylin */ + #ifndef WIDGET_CORE_H #define WIDGET_CORE_H