22
22
#include <string.h>
23
23
#include <signal.h>
24
24
25
- #include "../common/info .h"
25
+ #include "../common/defs .h"
26
26
#include "../includes/common/inc.h"
27
27
#include "../headers/time_handler.h"
28
28
#include "../headers/mutexed.h"
33
33
typedef pthread_t Thread ;
34
34
35
35
36
- Void clocker_update_checking () {
37
- Updater checker = update_checker_new ();
38
- soft_assert_wrn (
39
- checker != 0 ,
40
- "Creating new update object failed!"
41
- );
36
+ Void clocker_update_checking (Updater checker ) {
42
37
43
38
UpdateStatus update_check_res = update_checker_check (checker );
44
39
soft_assert_wrn (
@@ -54,8 +49,8 @@ Void clocker_update_checking() {
54
49
55
50
Char result = fgetc (stdin );
56
51
if (result == '\n' || result == 'Y' || result == 'y' ) {
57
- Str arg [2 ] = {"/root/.clocker /clocker-updater" , INVALID_HNDL };
58
- execvp ("/root/.clocker /clocker-updater" , arg );
52
+ Str arg [3 ] = {"/usr/bin /clocker-updater" , "--from-clocker " , INVALID_HNDL };
53
+ execvp ("/usr/bin /clocker-updater" , arg );
59
54
perror ("" );
60
55
}
61
56
else {
@@ -74,26 +69,40 @@ Int32 main(
74
69
) {
75
70
76
71
// signal handling
77
- signal (SIGINT , sig_handler );
78
- signal (SIGSEGV , sig_handler );
72
+ signal (SIGINT , signal_handler );
73
+ signal (SIGSEGV , signal_handler );
74
+
75
+
76
+ Updater checker = update_checker_new ();
77
+ soft_assert_wrn (
78
+ checker != 0 ,
79
+ "Creating new update object failed!"
80
+ );
79
81
80
82
if (argv [1 ] && strcmp (argv [1 ], "--update" ) == 0 ) {
81
- clocker_update_checking ();
83
+ clocker_update_checking (checker );
82
84
}
83
85
84
- printf ("%s\n\n" , clocker_banner );
85
- printf ("Type " COLOR_ITALIC "`help`" COLOR_RESET " to list supported commands\n" );
86
86
87
- Mutexed * state = mutexed_new (gen_type (0 ));
88
- soft_assert_ret_int (state != INVALID_HNDL , "Failed to create new mutexed!" );
87
+ printf ("%s\n\n" , CLOCKER_BANNER );
88
+ printf ("Type " ITALIC_TXT ("`help`" )" to list supported commands\n" );
89
+
90
+ TreadArg thread_arg = (TreadArg ) {
91
+ .command = mutexed_new (gen_type (TC_None )),
92
+ .mode = mutexed_new (gen_type (TM_Default )),
93
+ .version = update_checker_get_version (checker )
94
+ };
95
+ soft_assert_ret_int (thread_arg .command != INVALID_HNDL , "Failed to create new mutexed!" );
96
+ soft_assert_ret_int (thread_arg .mode != INVALID_HNDL , "Failed to create new mutexed!" );
97
+
89
98
90
99
// creating time handling thread
91
100
Thread timer_thread = 0 ;
92
101
pthread_create (
93
102
& timer_thread ,
94
103
INVALID_HNDL ,
95
104
time_handle ,
96
- (Hndl ) state
105
+ (Hndl ) & thread_arg
97
106
);
98
107
99
108
// creating cmd handling thread
@@ -102,7 +111,7 @@ Int32 main(
102
111
& cmd_thread ,
103
112
INVALID_HNDL ,
104
113
cmd_run ,
105
- (Hndl ) state
114
+ (Hndl ) & thread_arg
106
115
);
107
116
108
117
// waiting for time thread
0 commit comments