From 0726c604fede6d6ea73ef6157a6fcc053e33d581 Mon Sep 17 00:00:00 2001
From: Sergey Fedorov <barracuda@macos-powerpc.org>
Date: Wed, 20 Aug 2025 07:36:46 +0800
Subject: [PATCH] Fix conflict with POSIX unistd.h

Fixes: https://github.com/IMprojtech/NotaMy/issues/1
---
 src/Module_Protect/Protect.c |  4 ++--
 src/Module_Protect/Protect.h |  4 ++--
 src/display_utils.c          | 10 +++++-----
 src/task_manager.c           |  6 +++---
 4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/Module_Protect/Protect.c b/src/Module_Protect/Protect.c
index 6d914e1..7daef70 100644
--- a/src/Module_Protect/Protect.c
+++ b/src/Module_Protect/Protect.c
@@ -174,7 +174,7 @@ static void decrypt_data( char *str, size_t len, const char *key ) {
 
 // --------------------------------------
 /***** Encrypts fields in the context *****/
-void encrypt( const char *passwd, Protect *ctx, char *key ) {
+void protect_encrypt( const char *passwd, Protect *ctx, char *key ) {
     *( ctx->protection ) = true;
     generate_random_iv( ctx->iv, IV_SIZE );
     generate_key( passwd, ctx->iv, key );
@@ -187,7 +187,7 @@ void encrypt( const char *passwd, Protect *ctx, char *key ) {
 
 // --------------------------------------
 /***** Decrypts fields in the context *****/
-void decrypt( const char *passwd, Protect *ctx, char *key ) {
+void protect_decrypt( const char *passwd, Protect *ctx, char *key ) {
     generate_key( passwd, ctx->iv, key );
 
     decrypt_data( ctx->comment, strlen( ctx->comment ), key );
diff --git a/src/Module_Protect/Protect.h b/src/Module_Protect/Protect.h
index 10a3536..2abd817 100644
--- a/src/Module_Protect/Protect.h
+++ b/src/Module_Protect/Protect.h
@@ -47,10 +47,10 @@ void write_key( char *password, size_t max_size );
 void generate_SHA512( const char *input, char *output );
 
 // Encrypts fields in the context
-void encrypt( const char *passwd, Protect *ctx, char *key );
+void protect_encrypt( const char *passwd, Protect *ctx, char *key );
 
 // Decrypts fields in the context
-void decrypt( const char *passwd, Protect *ctx, char *key );
+void protect_decrypt( const char *passwd, Protect *ctx, char *key );
 
 // Masks sensitive fields in the context with asterisks
 void mask( Protect *ctx );
diff --git a/src/display_utils.c b/src/display_utils.c
index d89dcee..696440c 100644
--- a/src/display_utils.c
+++ b/src/display_utils.c
@@ -173,7 +173,7 @@ void print_all( TreeNode *root, int depth, AppGlobal *app, char *Passwd, char *K
     if ( app->NDat.Protection ) {
         init_ctx_from_ndat( &app->ctx, &app->NDat );
         if ( app->opts.with_protection )
-            decrypt( Passwd, &app->ctx, Key );
+            protect_decrypt( Passwd, &app->ctx, Key );
         else
             mask( &app->ctx );
     }
@@ -189,7 +189,7 @@ void print_list( TreeNode *root, int depth, AppGlobal *app, char *Passwd, char *
     if ( app->NDat.Protection ) {
         init_ctx_from_ndat( &app->ctx, &app->NDat );
         if ( app->opts.with_protection )
-            decrypt( Passwd, &app->ctx, Key );
+            protect_decrypt( Passwd, &app->ctx, Key );
         else
             mask( &app->ctx );
     }
@@ -208,7 +208,7 @@ void print_find( TreeNode *root, char *key, find_function fn, AppGlobal *app, ch
         if ( app->NDat.Protection ) {
             init_ctx_from_ndat( &app->ctx, &app->NDat );
             if ( app->opts.with_protection )
-                decrypt( Passwd, &app->ctx, Key );
+                protect_decrypt( Passwd, &app->ctx, Key );
             else
                 mask( &app->ctx );
         }
@@ -227,7 +227,7 @@ void print_children( TreeNode *parent, AppGlobal *app, char *Passwd, char *Key )
     if ( app->NDat.Protection ) {
         init_ctx_from_ndat( &app->ctx, &app->NDat );
         if ( app->opts.with_protection )
-            decrypt( Passwd, &app->ctx, Key );
+            protect_decrypt( Passwd, &app->ctx, Key );
         else
             mask( &app->ctx );
     }
@@ -244,7 +244,7 @@ void print_sibling( TreeNode *parent, AppGlobal *app, char *Passwd, char *Key )
     if ( app->NDat.Protection ) {
         init_ctx_from_ndat( &app->ctx, &app->NDat );
         if ( app->opts.with_protection )
-            decrypt( Passwd, &app->ctx, Key );
+            protect_decrypt( Passwd, &app->ctx, Key );
         else
             mask( &app->ctx );
     }
diff --git a/src/task_manager.c b/src/task_manager.c
index d943a4c..e56e7ad 100644
--- a/src/task_manager.c
+++ b/src/task_manager.c
@@ -59,7 +59,7 @@ void controller( char *SetFile, char *Passwd, char *Key, AppGlobal *app ) {
 
         if ( app->opts.with_protection == true ) {
             init_ctx_from_ndat( &app->ctx, &app->NDat );
-            encrypt( Passwd, &app->ctx, Key );
+            protect_encrypt( Passwd, &app->ctx, Key );
         }
 
         copy_ndat( &tmpNDat, &app->NDat );
@@ -255,7 +255,7 @@ void controller( char *SetFile, char *Passwd, char *Key, AppGlobal *app ) {
         if ( app->NDat.Protection ) {
             init_ctx_from_ndat( &app->ctx, &app->NDat );
             if ( app->opts.with_protection )
-                decrypt( Passwd, &app->ctx, Key );
+                protect_decrypt( Passwd, &app->ctx, Key );
             else {
                 fprintf( stderr, "[ERROR] protected \n" );
                 exit( EXIT_FAILURE );
@@ -284,7 +284,7 @@ void controller( char *SetFile, char *Passwd, char *Key, AppGlobal *app ) {
 
         if ( app->opts.with_protection == true ) {
             init_ctx_from_ndat( &app->ctx, &app->NDat );
-            encrypt( Passwd, &app->ctx, Key );
+            protect_encrypt( Passwd, &app->ctx, Key );
         }
 
         copy_ndat( &tmpNDat, &app->NDat );
