Compare commits
20
Commits
cebacc7017
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
267518fe3a | ||
|
|
89c3f88a34 | ||
|
|
6d1c9c95ac | ||
|
|
06c00a0924 | ||
|
|
b30229b770 | ||
|
|
f7589dbe2b | ||
|
|
25c912069a | ||
|
|
24fe4a4aa4 | ||
|
|
56d2f9d5d0 | ||
|
|
a55c38abfa | ||
|
|
a5fcd1985e | ||
|
|
c68b872d1e | ||
|
|
c6ec8c1199 | ||
|
|
230bac4d75 | ||
|
|
e898ec3ba5 | ||
|
|
e65a2ecdb6 | ||
|
|
94ca039248 | ||
|
|
441e02e289 | ||
|
|
fd2bb01b96 | ||
|
|
18705b01c4 |
@@ -81,26 +81,24 @@ char* smartstrcasestr(const char *haystack, const char *needle){
|
||||
}
|
||||
|
||||
|
||||
char* parse_cmd(const char *cmd, file *f){
|
||||
char* parse_cmd(const char *cmd, char *file_name){
|
||||
char *out;
|
||||
if (f == NULL) {
|
||||
out = malloc(strlen(cmd)+1);
|
||||
memcpy(out, cmd, strlen(cmd)+1);
|
||||
return out;
|
||||
if (file_name == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
const char *offset = strstr(cmd, SETTINGS_COMMAND_REPLACE_STR);
|
||||
|
||||
int count = 0;
|
||||
char *pos;
|
||||
unsigned long i = 0;
|
||||
while(f->file_name[i]) {
|
||||
if (f->file_name[i] == '\'') {
|
||||
while(file_name[i]) {
|
||||
if (file_name[i] == '\'') {
|
||||
count++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
out = malloc(strlen(cmd) + 1 + (strlen(f->file_name)+(count*3)) + 3);
|
||||
out = malloc(strlen(cmd) + 1 + (strlen(file_name)+(count*3)) + 3);
|
||||
|
||||
pos = out;
|
||||
if (offset) {
|
||||
@@ -115,13 +113,13 @@ char* parse_cmd(const char *cmd, file *f){
|
||||
pos++;
|
||||
|
||||
i = 0;
|
||||
while(f->file_name[i]) {
|
||||
if (f->file_name[i] == '\'') {
|
||||
while(file_name[i]) {
|
||||
if (file_name[i] == '\'') {
|
||||
*pos++ = '\'';
|
||||
*pos++ = '\\';
|
||||
*pos++ = '\'';
|
||||
}
|
||||
*pos = f->file_name[i];
|
||||
*pos = file_name[i];
|
||||
pos++;
|
||||
i++;
|
||||
}
|
||||
|
||||
@@ -7,5 +7,5 @@
|
||||
|
||||
/*char* concat(const char *s1, const char *s2);*/
|
||||
char* smartstrcasestr(const char *haystack, const char *needle);
|
||||
char* parse_cmd(const char *cmd, file *f);
|
||||
char* parse_cmd(const char *cmd, char *file_name);
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ static const binding key_binding[] = {
|
||||
{ "G", jump_bottom, NULL, "jump to last file in dir" },
|
||||
{ "gg", jump_top, NULL, "jump to first file in dir" },
|
||||
{ "gh", jump_to_dir, "$HOME", "jump to $HOME" },
|
||||
{ "gs", jump_to_dir, "$START_PATH", "jump to $START_PATH" }, /* the path you started th in */
|
||||
{ "gs", jump_to_dir, "$TH_START_PATH", "jump to $TH_START_PATH" }, /* the path you started th in */
|
||||
{ "gD", jump_to_dir, "$HOME/Downloads", "jump to $HOME/Downloads" },
|
||||
{ "gC", jump_to_dir, "$HOME/Documents", "jump to $HOME/Documents" },
|
||||
{ "gP", jump_to_dir, "$HOME/Pictures", "jump to $HOME/Pictures" },
|
||||
@@ -129,6 +129,7 @@ static const char ui_rename_text[] = "rename "SETTINGS_COMMAND_REPLACE_STR" to:"
|
||||
static const char ui_makefile_text[] = "makedir:";
|
||||
static const char ui_makedir_text[] = "makefile:";
|
||||
static const char ui_delete_text[] = "delete:";
|
||||
static const char ui_search_text[] = "/"; /*unlike the other ui, this one doesnt automatically add a space*/
|
||||
|
||||
/* {{{ */
|
||||
static const unsigned long binding_count = sizeof(key_binding) / sizeof(binding);
|
||||
@@ -156,6 +157,7 @@ static const char ui_delete_text[];
|
||||
static const char copy_cmd[];
|
||||
static const char cut_cmd[];
|
||||
static const char del_cmd[];
|
||||
static const char ui_search_text[];
|
||||
|
||||
#endif
|
||||
/* }}} */
|
||||
|
||||
@@ -63,6 +63,10 @@
|
||||
#define BTM_WINDOW_HEIGHT_ON_STR_INTERACTION 5
|
||||
#define INPUT_BUFFER_SIZE 255
|
||||
|
||||
#define ignore_return(in) if (in) { };
|
||||
#define unused(in) (void)(in);
|
||||
|
||||
|
||||
#ifndef STRUCT_GUARD
|
||||
#define STRUCT_GUARD
|
||||
/* complex types are good actually */
|
||||
|
||||
@@ -317,7 +317,14 @@ void dir_changed(){
|
||||
}
|
||||
|
||||
}
|
||||
void deselect_all_files() {
|
||||
unsigned long i;
|
||||
for (i = 0; i < mid_dir.file_count; i++) {
|
||||
mid_dir.file_list[i].status &= ~FILE_STATUS_SELECTED;
|
||||
}
|
||||
}
|
||||
void change_dir(char *new_path){
|
||||
deselect_all_files();
|
||||
|
||||
current_linked_dir = list_beginning;
|
||||
while (current_linked_dir->next != NULL) {
|
||||
|
||||
@@ -9,4 +9,5 @@ void print_dir(WINDOW *win, char print_info, dir *dir);
|
||||
char update_selected_file();
|
||||
void dir_set_selected_file_current(unsigned long selected_file_current);
|
||||
unsigned long dir_get_selected_file_current();
|
||||
void deselect_all_files();
|
||||
void dir_init();
|
||||
|
||||
+9
-10
@@ -12,6 +12,7 @@ static FILE *ueberzug = NULL;
|
||||
#endif
|
||||
extern unsigned int terminal_height;
|
||||
extern unsigned int terminal_width;
|
||||
extern char *global_path;
|
||||
char previewd;
|
||||
magic_t cookie_type;
|
||||
magic_t cookie_description;
|
||||
@@ -22,7 +23,7 @@ void images_clear();
|
||||
char* generic(file *f);
|
||||
|
||||
char* get_mimetype(file *f){
|
||||
char *mime = (char*)magic_file(cookie_type, f->file_name);
|
||||
char *mime = (char*)magic_file(cookie_type, f->file_name); /*freeing this causes th to crash*/
|
||||
|
||||
return mime;
|
||||
}
|
||||
@@ -52,7 +53,6 @@ char* preview_file(file *f){
|
||||
file_buffer = generic(f);
|
||||
}
|
||||
|
||||
/*free(mime); seems like magic_file handles the free too*/
|
||||
return file_buffer;
|
||||
|
||||
}
|
||||
@@ -90,17 +90,16 @@ void images_clear(){
|
||||
}
|
||||
}
|
||||
void images_print(char *file_name){
|
||||
char *path=getcwd(NULL, 0);
|
||||
|
||||
fprintf(ueberzug, "{\"action\":\"add\", \
|
||||
\"identifier\":\"preview\", \
|
||||
\"scaler\":\"fit_contain\", \
|
||||
\"max_height\":%d, \
|
||||
\"max_width\":%d, \
|
||||
\"y\":0, \
|
||||
\"x\":%d, \
|
||||
\"path\":\"%s/%s\"}\n", terminal_height, terminal_width/2, terminal_width/2, path, file_name);
|
||||
\"path\":\"%s/%s\"}\n", terminal_height, terminal_width/2, terminal_width/2, global_path, file_name);
|
||||
fflush(ueberzug);
|
||||
free(path);
|
||||
}
|
||||
void ueberzug_init(){
|
||||
#if SETTINGS_UEBERZUG_IMAGE_PREVIEW == 2
|
||||
@@ -109,14 +108,14 @@ void ueberzug_init(){
|
||||
ueberzug = popen("ueberzug layer -s --no-cache ", "w");
|
||||
#endif
|
||||
}
|
||||
void ueberzug_close(){
|
||||
images_clear();
|
||||
pclose(ueberzug);
|
||||
}
|
||||
#endif
|
||||
void file_preview_init(){
|
||||
cookie_type = magic_open(MAGIC_MIME_TYPE);
|
||||
cookie_description = magic_open(MAGIC_NONE);
|
||||
magic_load(cookie_type, NULL);
|
||||
magic_load(cookie_description, NULL);
|
||||
}
|
||||
void ueberzug_close(){
|
||||
images_clear();
|
||||
pclose(ueberzug);
|
||||
}
|
||||
#endif
|
||||
|
||||
+153
-124
@@ -53,13 +53,16 @@ void user_interactions() {
|
||||
|
||||
|
||||
ch = getch();
|
||||
if(ch != ERR) {
|
||||
if(ch != (char)ERR) {
|
||||
input[input_pass] = ch;
|
||||
input_pass++;
|
||||
if (ch == 27) { /* esc key */
|
||||
memset(input, 0, INPUT_BUFFER_SIZE);
|
||||
input_pass = 0;
|
||||
}
|
||||
if (input_pass >= INPUT_BUFFER_SIZE) {
|
||||
input_pass = INPUT_BUFFER_SIZE - 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -93,6 +96,12 @@ void user_interactions() {
|
||||
pthread_mutex_unlock(&mutex_mid);
|
||||
|
||||
timeout(SETTINGS_CURSES_TIMEOUT); /* blocking timeout of getch() */
|
||||
|
||||
#if SETTINGS_RELOAD_DIR_DELTA != 0
|
||||
/* workaround for file previews not working on changing file while this is true
|
||||
* disabling this here does not influence the reload/rerun of the logic */
|
||||
status &= ~STATUS_DELTA_TIME;
|
||||
#endif
|
||||
} else {
|
||||
binding_matches++;
|
||||
mvwprintw(stdscr, terminal_height-binding_matches-1, 0, "\t\t\t");
|
||||
@@ -113,43 +122,50 @@ void user_interactions() {
|
||||
binding_matches = 0;
|
||||
}
|
||||
}
|
||||
int read_string(WINDOW *win, int y, int x, char *str){
|
||||
curs_set(1);
|
||||
char read_string_loop(WINDOW *win, char *buffer, char *nullable_return_char, unsigned long *pass, unsigned long y, unsigned long x) {
|
||||
char ch = wgetch(win_b);
|
||||
|
||||
timeout(-1); /* negative numbers block until enter is pressed */
|
||||
|
||||
unsigned int pass = 0;
|
||||
char ch;
|
||||
char err = 0;
|
||||
|
||||
wmove(win, y, x);
|
||||
while(1) {
|
||||
ch = wgetch(win);
|
||||
if (ch == '\n') {
|
||||
break;
|
||||
} else if (ch == 27) { /* esc key */
|
||||
err = 1;
|
||||
break;
|
||||
} else if (ch == '\t') { /* tab */
|
||||
memcpy(str + pass, mid_dir.current_file->file_name, strlen(mid_dir.current_file->file_name));
|
||||
mvwaddstr(win, y, x + pass, mid_dir.current_file->file_name);
|
||||
pass += strlen(mid_dir.current_file->file_name);
|
||||
} else if (ch == 127) { /* backspace */
|
||||
if (pass > 0) {
|
||||
pass--;
|
||||
mvwdelch(win, y, x + pass);
|
||||
}
|
||||
} else {
|
||||
mvwaddch(win, y, x + pass, ch);
|
||||
str[pass] = ch;
|
||||
pass++;
|
||||
}
|
||||
if (nullable_return_char != NULL) {
|
||||
*nullable_return_char = 0;
|
||||
}
|
||||
str[pass] = '\0';
|
||||
if (ch == '\n' ) {
|
||||
buffer[*pass] = 0;
|
||||
return 1;
|
||||
} else if ( ch == 27 /* esc key */) {
|
||||
buffer[*pass] = 0;
|
||||
return 2;
|
||||
} else if (ch == '\t') { /* tab */
|
||||
memcpy(buffer + *pass, mid_dir.current_file->file_name, strlen(mid_dir.current_file->file_name));
|
||||
mvwaddstr(win_b, 0, x+ *pass, mid_dir.current_file->file_name);
|
||||
*pass += strlen(mid_dir.current_file->file_name);
|
||||
} else if (ch == 127) { /* backspace */
|
||||
if (*pass > 0) {
|
||||
unsigned long i = x;
|
||||
while (i < terminal_width) {
|
||||
mvwaddch(win, y, i, ' ');
|
||||
i++;
|
||||
}
|
||||
*pass -= 1;
|
||||
buffer[*pass] = 0;
|
||||
mvwaddstr(win, y, x, buffer);
|
||||
|
||||
curs_set(0);
|
||||
}
|
||||
} else if (ch) {
|
||||
if (nullable_return_char != NULL) {
|
||||
*nullable_return_char = ch;
|
||||
}
|
||||
|
||||
return err;
|
||||
mvwaddch(win_b, 0, x + *pass, ch);
|
||||
buffer[*pass] = ch;
|
||||
*pass += 1;
|
||||
|
||||
|
||||
}
|
||||
if (*pass >= INPUT_BUFFER_SIZE) {
|
||||
*pass = INPUT_BUFFER_SIZE - 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
void quit_program(){
|
||||
status = STATUS_QUIT_PROGRAM;
|
||||
@@ -198,12 +214,35 @@ void move_right(){
|
||||
|
||||
skip_if_empty_dir
|
||||
|
||||
char *cmd = NULL;
|
||||
|
||||
|
||||
if (mid_dir.current_file->file_type & FILE_TYPE_DIR) {
|
||||
change_dir(mid_dir.current_file->file_name);
|
||||
} else if (mid_dir.current_file->file_type & FILE_TYPE_EXEC) {
|
||||
char *cmd = parse_cmd("./"SETTINGS_COMMAND_REPLACE_STR,mid_dir.current_file);
|
||||
if (system(cmd)) {
|
||||
|
||||
/* if an .exe is executable, this branch will trigger as expected,
|
||||
* however since executing an .exe without wine causes a exec format error, we should check if the program you tried to access is that
|
||||
* if an .exe is not executable, it will get to the top else branch, then hit the comparison in the file extension area, and succeed also.
|
||||
* that is unless the user removed wine out of the file_extension_default_cmd,
|
||||
* in which case im going to assume wine isnt installed anyways as that would require:
|
||||
* a. thought on my end in how to catch wine being removed in the config
|
||||
* b. the user having deliberately changed the default config (good, thats why they are easily configurable)
|
||||
* c. if wine is not installed on the system, executing an .exe would fail regardless of via direct execution or through wine */
|
||||
char *extension = mid_dir.current_file->file_name;
|
||||
while (extension <= mid_dir.current_file->file_name + strlen(mid_dir.current_file->file_name)) {
|
||||
if (*extension == '.') {
|
||||
break;
|
||||
}
|
||||
extension++;
|
||||
}
|
||||
|
||||
if (strcmp(extension, ".exe") == 0) {
|
||||
cmd = parse_cmd("wine ./"SETTINGS_COMMAND_REPLACE_STR, mid_dir.current_file->file_name);
|
||||
} else {
|
||||
cmd = parse_cmd("./"SETTINGS_COMMAND_REPLACE_STR, mid_dir.current_file->file_name);
|
||||
}
|
||||
ignore_return(system(cmd));
|
||||
} else {
|
||||
char *mime = get_mimetype(mid_dir.current_file);
|
||||
char *extension = mid_dir.current_file->file_name;
|
||||
@@ -220,17 +259,16 @@ void move_right(){
|
||||
for (i = 0; i < file_extension_default_count; i++) {
|
||||
if (strcmp(extension, file_extension_default_cmd[i].file_extension) == 0) {
|
||||
if (file_extension_default_cmd[i].command[0] == SETTINGS_COMMAND_FORK) {
|
||||
cmd = parse_cmd(file_extension_default_cmd[i].command + 1, mid_dir.current_file);
|
||||
cmd = parse_cmd(file_extension_default_cmd[i].command + 1, mid_dir.current_file->file_name);
|
||||
pid_t pid = fork();
|
||||
if (pid == 0 && setsid()) {
|
||||
system(cmd);
|
||||
ignore_return(system(cmd));
|
||||
status = STATUS_QUIT_PROGRAM;
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
cmd = parse_cmd(file_extension_default_cmd[i].command, mid_dir.current_file);
|
||||
if (system(cmd)) {
|
||||
}
|
||||
cmd = parse_cmd(file_extension_default_cmd[i].command, mid_dir.current_file->file_name);
|
||||
ignore_return(system(cmd));
|
||||
}
|
||||
status |= STATUS_MOVE_RIGHT_MATCH;
|
||||
update();
|
||||
@@ -242,17 +280,16 @@ void move_right(){
|
||||
for (i = 0; i < mimetype_default_count; i++) {
|
||||
if (strstr(mime, mimetype_default_cmd[i].mimetype)) {
|
||||
if (mimetype_default_cmd[i].command[0] == SETTINGS_COMMAND_FORK) {
|
||||
cmd = parse_cmd(mimetype_default_cmd[i].command + 1, mid_dir.current_file);
|
||||
cmd = parse_cmd(mimetype_default_cmd[i].command + 1, mid_dir.current_file->file_name);
|
||||
pid_t pid = fork();
|
||||
if (pid == 0 && setsid()) {
|
||||
system(cmd);
|
||||
ignore_return(system(cmd));
|
||||
status = STATUS_QUIT_PROGRAM;
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
cmd = parse_cmd(mimetype_default_cmd[i].command, mid_dir.current_file);
|
||||
if (system(cmd)) {
|
||||
}
|
||||
cmd = parse_cmd(mimetype_default_cmd[i].command, mid_dir.current_file->file_name);
|
||||
ignore_return(system(cmd));
|
||||
}
|
||||
status |= STATUS_MOVE_RIGHT_MATCH;
|
||||
update();
|
||||
@@ -261,9 +298,8 @@ void move_right(){
|
||||
}
|
||||
}
|
||||
status &= ~STATUS_MOVE_RIGHT_MATCH;
|
||||
free(cmd);
|
||||
free(mime);
|
||||
}
|
||||
free(cmd);
|
||||
|
||||
status |= (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY);
|
||||
}
|
||||
@@ -292,25 +328,30 @@ void open_with(){
|
||||
wclear(win_b);
|
||||
char *cmd;
|
||||
char *str = malloc(INPUT_BUFFER_SIZE);
|
||||
char *parsed_ui_text = parse_cmd(ui_open_with_text, mid_dir.current_file);
|
||||
char *parsed_ui_text = parse_cmd(ui_open_with_text, mid_dir.current_file->file_name);
|
||||
mvwprintw(win_b, 0, 0, parsed_ui_text);
|
||||
unsigned long pass = 0;
|
||||
char ret;
|
||||
|
||||
if (read_string(win_b, 0, strlen(parsed_ui_text)+1, str) == 0) {
|
||||
while ((ret = read_string_loop(win_b, str, NULL, &pass, 0, strlen(parsed_ui_text)+1)) == 0) {
|
||||
}
|
||||
|
||||
if (ret == 1) {
|
||||
if (str[0] == SETTINGS_COMMAND_FORK) {
|
||||
cmd = parse_cmd(str+1, mid_dir.current_file);
|
||||
cmd = parse_cmd(str+1, mid_dir.current_file->file_name);
|
||||
pid_t pid = fork();
|
||||
if (pid == 0 && setsid()) {
|
||||
system(cmd);
|
||||
ignore_return(system(cmd));
|
||||
status = STATUS_QUIT_PROGRAM;
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
cmd = parse_cmd(str, mid_dir.current_file);
|
||||
if (system(cmd)) {
|
||||
}
|
||||
cmd = parse_cmd(str, mid_dir.current_file->file_name);
|
||||
ignore_return(system(cmd));
|
||||
}
|
||||
free(cmd);
|
||||
}
|
||||
|
||||
free(parsed_ui_text);
|
||||
free(str);
|
||||
|
||||
@@ -318,20 +359,23 @@ void open_with(){
|
||||
}
|
||||
void rename_hovered(){
|
||||
wclear(win_b);
|
||||
file tmp;
|
||||
tmp.file_name = malloc(INPUT_BUFFER_SIZE);
|
||||
char *parsed_ui_text = parse_cmd(ui_rename_text, mid_dir.current_file);
|
||||
char *new_file_name = malloc(INPUT_BUFFER_SIZE);
|
||||
char *parsed_ui_text = parse_cmd(ui_rename_text, mid_dir.current_file->file_name);
|
||||
mvwprintw(win_b, 0, 0, parsed_ui_text);
|
||||
unsigned long pass = 0;
|
||||
char ret;
|
||||
|
||||
if (read_string(win_b, 0, strlen(parsed_ui_text)+1, tmp.file_name) == 0) {
|
||||
char *cmd0 = parse_cmd(rename_cmd, mid_dir.current_file);
|
||||
char *cmd1 = parse_cmd(cmd0, &tmp);
|
||||
system(cmd1);
|
||||
while ((ret = read_string_loop(win_b, new_file_name, NULL, &pass, 0, strlen(parsed_ui_text)+1)) == 0) {
|
||||
}
|
||||
if (ret == 1) {
|
||||
char *cmd0 = parse_cmd(rename_cmd, mid_dir.current_file->file_name);
|
||||
char *cmd1 = parse_cmd(cmd0, new_file_name);
|
||||
ignore_return(system(cmd1));
|
||||
free(cmd0);
|
||||
free(cmd1);
|
||||
}
|
||||
free(parsed_ui_text);
|
||||
free(tmp.file_name);
|
||||
free(new_file_name);
|
||||
|
||||
status |= (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY);
|
||||
}
|
||||
@@ -343,8 +387,8 @@ void delete(unsigned long passes){
|
||||
|
||||
for (i = 0; i < mid_dir.file_count; i++) {
|
||||
if (mid_dir.file_list[i].status & FILE_STATUS_SELECTED) {
|
||||
cmd = parse_cmd(del_cmd, &mid_dir.file_list[i]);
|
||||
system(cmd);
|
||||
cmd = parse_cmd(del_cmd, mid_dir.file_list[i].file_name);
|
||||
ignore_return(system(cmd));
|
||||
free(cmd);
|
||||
del_count++;
|
||||
}
|
||||
@@ -355,50 +399,57 @@ void delete(unsigned long passes){
|
||||
if (&mid_dir.current_file[i] > mid_dir.file_list + mid_dir.file_count) {
|
||||
break;
|
||||
}
|
||||
cmd = parse_cmd(del_cmd, &mid_dir.current_file[i]);
|
||||
system(cmd);
|
||||
cmd = parse_cmd(del_cmd, mid_dir.current_file[i].file_name);
|
||||
ignore_return(system(cmd));
|
||||
free(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
deselect_all_files();
|
||||
|
||||
status |= (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY);
|
||||
}
|
||||
void makedir(){
|
||||
wclear(win_b);
|
||||
file tmp;
|
||||
tmp.file_name = malloc(INPUT_BUFFER_SIZE);
|
||||
char *file_name = malloc(INPUT_BUFFER_SIZE);
|
||||
mvwprintw(win_b, 0, 0, ui_makedir_text);
|
||||
if (read_string(win_b, 0, strlen(ui_makedir_text)+1, tmp.file_name) == 0) {
|
||||
char *cmd = parse_cmd(makedir_cmd, &tmp);
|
||||
system(cmd);
|
||||
unsigned long pass = 0;
|
||||
char ret;
|
||||
while ((ret = read_string_loop(win_b, file_name, NULL, &pass, 0, strlen(ui_makedir_text)+1)) == 0) {
|
||||
}
|
||||
if (ret == 1) {
|
||||
char *cmd = parse_cmd(makedir_cmd, file_name);
|
||||
ignore_return(system(cmd));
|
||||
free(cmd);
|
||||
}
|
||||
free(tmp.file_name);
|
||||
free(file_name);
|
||||
|
||||
status |= (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY);
|
||||
}
|
||||
void makefile(){
|
||||
wclear(win_b);
|
||||
file tmp;
|
||||
tmp.file_name = malloc(INPUT_BUFFER_SIZE);
|
||||
char *file_name = malloc(INPUT_BUFFER_SIZE);
|
||||
mvwprintw(win_b, 0, 0, ui_makefile_text);
|
||||
if (read_string(win_b, 0, strlen(ui_makefile_text)+1, tmp.file_name) == 0) {
|
||||
char *cmd = parse_cmd(makefile_cmd, &tmp);
|
||||
system(cmd);
|
||||
unsigned long pass = 0;
|
||||
char ret;
|
||||
while ((ret = read_string_loop(win_b, file_name, NULL, &pass, 0, strlen(ui_makefile_text)+1)) == 0) {
|
||||
}
|
||||
if (ret == 1) {
|
||||
char *cmd = parse_cmd(makefile_cmd, file_name);
|
||||
ignore_return(system(cmd));
|
||||
free(cmd);
|
||||
}
|
||||
free(tmp.file_name);
|
||||
free(file_name);
|
||||
|
||||
status |= (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY);
|
||||
}
|
||||
void enter_shell(unsigned long passes, int index){
|
||||
(void)passes; /*remove compiler warning*/
|
||||
unused(passes);
|
||||
|
||||
endwin();\
|
||||
echo();\
|
||||
curs_set(1);\
|
||||
if (system(key_binding[index].black_magic)) {
|
||||
}
|
||||
ignore_return(system(key_binding[index].black_magic));
|
||||
initscr(); /* start ncurses */
|
||||
noecho(); /* hide keyboard input */
|
||||
curs_set(0);
|
||||
@@ -406,7 +457,7 @@ void enter_shell(unsigned long passes, int index){
|
||||
status |= (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY);
|
||||
}
|
||||
void jump_to_dir(unsigned long passes, int index){
|
||||
(void)passes;
|
||||
unused(passes);
|
||||
|
||||
unsigned long len;
|
||||
char *c = strchr(key_binding[index].black_magic, '/');
|
||||
@@ -435,7 +486,7 @@ void jump_to_dir(unsigned long passes, int index){
|
||||
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_CLEAR | STATUS_RELOAD_DIRECTORY );
|
||||
}
|
||||
void order_by(unsigned long passes, int index){
|
||||
(void)passes;
|
||||
unused(passes);
|
||||
|
||||
seed = time(NULL);
|
||||
order_func = key_binding[index].black_magic;
|
||||
@@ -443,17 +494,17 @@ void order_by(unsigned long passes, int index){
|
||||
status |= (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY);
|
||||
}
|
||||
void cmd_on_selected(unsigned long passes, int index){
|
||||
(void)passes;
|
||||
unused(passes);
|
||||
|
||||
char *cmd = parse_cmd(key_binding[index].black_magic, mid_dir.current_file);
|
||||
system(cmd);
|
||||
char *cmd = parse_cmd(key_binding[index].black_magic, mid_dir.current_file->file_name);
|
||||
ignore_return(system(cmd));
|
||||
free(cmd);
|
||||
|
||||
status |= (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY | STATUS_UPDATE_SCREEN_CLEAR);
|
||||
}
|
||||
void yank_file_name(){
|
||||
char *cmd = parse_cmd(clipboard_cmd, mid_dir.current_file);
|
||||
system(cmd);
|
||||
char *cmd = parse_cmd(clipboard_cmd, mid_dir.current_file->file_name);
|
||||
ignore_return(system(cmd));
|
||||
free(cmd);
|
||||
|
||||
status |= (STATUS_RUN_BACKEND);
|
||||
@@ -464,8 +515,8 @@ void yank_file_path(){
|
||||
memcpy(tmp->file_name, global_path, strlen(global_path));
|
||||
memcpy(tmp->file_name+strlen(global_path)+1, mid_dir.current_file->file_name, strlen(mid_dir.current_file->file_name)+1);
|
||||
tmp->file_name[strlen(global_path)] = '/'; /*no +1 is needed*/
|
||||
char *cmd = parse_cmd(clipboard_cmd, tmp);
|
||||
system(cmd);
|
||||
char *cmd = parse_cmd(clipboard_cmd, tmp->file_name);
|
||||
ignore_return(system(cmd));
|
||||
free(cmd);
|
||||
free(tmp->file_name);
|
||||
free(tmp);
|
||||
@@ -473,7 +524,7 @@ void yank_file_path(){
|
||||
status |= (STATUS_RUN_BACKEND);
|
||||
}
|
||||
void copy_file(unsigned long passes, int index){
|
||||
(void)passes;
|
||||
unused(passes);
|
||||
|
||||
yank_files.status = key_binding[index].black_magic;
|
||||
|
||||
@@ -550,16 +601,16 @@ void paste(unsigned long passes){
|
||||
|
||||
}
|
||||
if (yank_files.status == COPY_FILE) {
|
||||
cmd = parse_cmd(copy_cmd, &tmp);
|
||||
cmd = parse_cmd(copy_cmd, tmp.file_name);
|
||||
} else if (yank_files.status == CUT_FILE) {
|
||||
cmd = parse_cmd(cut_cmd, &tmp);
|
||||
cmd = parse_cmd(cut_cmd, tmp.file_name);
|
||||
} else {
|
||||
free(dest_file_name);
|
||||
continue;
|
||||
}
|
||||
tmp.file_name = dest_file_name;
|
||||
cmd = parse_cmd(cmd, &tmp);
|
||||
system(cmd);
|
||||
cmd = parse_cmd(cmd, tmp.file_name);
|
||||
ignore_return(system(cmd));
|
||||
free(cmd);
|
||||
free(tmp.file_name);
|
||||
}
|
||||
@@ -573,7 +624,7 @@ void search(){
|
||||
for (i = 0; i < terminal_width -1; i++) {
|
||||
mvwaddch(win_b, 0, i, ' ');
|
||||
}
|
||||
mvwaddch(win_b, 0, 0, '/');
|
||||
mvwaddstr(win_b, 0, 0, ui_search_text);
|
||||
memset(search_buffer, 0, INPUT_BUFFER_SIZE);
|
||||
|
||||
curs_set(1);
|
||||
@@ -581,33 +632,12 @@ void search(){
|
||||
|
||||
timeout(-1); /* negative numbers block until enter is pressed */
|
||||
|
||||
unsigned int pass = 0;
|
||||
unsigned long pass = 0;
|
||||
char ch;
|
||||
|
||||
wmove(win_b, 0, 1);
|
||||
while(1) {
|
||||
ch = wgetch(win_b);
|
||||
if (ch == '\n' || ch == 27 /* esc key */) {
|
||||
/* unlike the other uses of a read string reimplementation,
|
||||
* here we do not differentiate between accepting and cancle.
|
||||
* this is intentional */
|
||||
break;
|
||||
} else if (ch == '\t') { /* tab */
|
||||
memcpy(search_buffer + pass, mid_dir.current_file->file_name, strlen(mid_dir.current_file->file_name));
|
||||
mvwaddstr(win_b, 0, pass+1, mid_dir.current_file->file_name);
|
||||
pass += strlen(mid_dir.current_file->file_name);
|
||||
} else if (ch == 127) { /* backspace */
|
||||
if (pass > 0) {
|
||||
pass--;
|
||||
mvwdelch(win_b, 0, pass+1);
|
||||
}
|
||||
}
|
||||
while (read_string_loop(win_b, search_buffer, &ch, &pass, 0, strlen(ui_search_text)) == 0) {
|
||||
if (ch) {
|
||||
mvwaddch(win_b, 0, pass+1, ch);
|
||||
search_buffer[pass] = ch;
|
||||
pass++;
|
||||
|
||||
unsigned long index = (mid_dir.current_file - mid_dir.file_list);
|
||||
unsigned long index = 0;
|
||||
for (; &mid_dir.file_list[index] < mid_dir.file_list + mid_dir.file_count; index++) {
|
||||
if (smartstrcasestr(mid_dir.file_list[index].file_name, search_buffer)) {
|
||||
mid_dir.current_file = &mid_dir.file_list[index];
|
||||
@@ -618,15 +648,14 @@ void search(){
|
||||
werase(win_m);
|
||||
print_dir(win_m, 1, &mid_dir);
|
||||
|
||||
wnoutrefresh(win_m);
|
||||
wrefresh(win_m);
|
||||
|
||||
pthread_mutex_unlock(&mutex_render);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
search_buffer[pass] = '\0';
|
||||
|
||||
noecho();
|
||||
curs_set(0);
|
||||
|
||||
@@ -133,10 +133,6 @@ int main(){
|
||||
|
||||
void render_pass(){
|
||||
|
||||
if (status & STATUS_UPDATE_SCREEN_CLEAR) {
|
||||
clear();
|
||||
status &= ~STATUS_UPDATE_SCREEN_CLEAR;
|
||||
}
|
||||
if (status & STATUS_UPDATE_SCREEN_RESIZE) {
|
||||
|
||||
wresize(win_t, 1, terminal_width);
|
||||
@@ -151,12 +147,23 @@ void render_pass(){
|
||||
mvwin(win_m, 1, (terminal_width/8));
|
||||
mvwin(win_r, 1, ((terminal_width/2)));
|
||||
mvwin(win_b, terminal_height-1, 0);
|
||||
status |= STATUS_UPDATE_SCREEN_CLEAR;
|
||||
status &= ~STATUS_UPDATE_SCREEN_RESIZE;
|
||||
|
||||
}
|
||||
if (pthread_mutex_lock(&mutex_render) == 0) {
|
||||
if (status & STATUS_UPDATE_SCREEN_CLEAR) {
|
||||
clear();
|
||||
pthread_mutex_lock(&mutex_render);
|
||||
refresh();
|
||||
status &= ~STATUS_UPDATE_SCREEN_CLEAR;
|
||||
pthread_mutex_unlock(&mutex_render);
|
||||
}
|
||||
/*
|
||||
if (pthread_mutex_trylock(&mutex_render) == 0) {
|
||||
doupdate();
|
||||
pthread_mutex_unlock(&mutex_render);
|
||||
}
|
||||
*/
|
||||
}
|
||||
/*this function exists for things done at startup (initialization, reading config, etc)*/
|
||||
void init() {
|
||||
@@ -188,7 +195,7 @@ void init() {
|
||||
ESCDELAY = 10;
|
||||
global_path = getcwd(NULL, 0);
|
||||
char *start_path = getcwd(NULL, 0);
|
||||
setenv("START_PATH", start_path, 0);
|
||||
setenv("TH_START_PATH", start_path, 0);
|
||||
free(start_path);
|
||||
|
||||
seed = time(NULL);
|
||||
|
||||
@@ -38,7 +38,7 @@ int sort_natural(const void *file0, const void *file1){
|
||||
long parsed_number0 = 0;
|
||||
long parsed_number1 = 0;
|
||||
char is_num = 0;
|
||||
char result = 0;
|
||||
signed char result = 0;
|
||||
|
||||
do {
|
||||
|
||||
|
||||
+79
-68
@@ -31,7 +31,6 @@ dir mid_dir;
|
||||
dir lft_dir;
|
||||
char *rgt_buffer; /* used for file previews, unlike rgt_content, which is used for directory previews */
|
||||
char *btm_buffer;
|
||||
char *top_buffer; /* current path */
|
||||
|
||||
extern WINDOW *win_t;
|
||||
extern WINDOW *win_b;
|
||||
@@ -52,10 +51,7 @@ unsigned int btm_status;
|
||||
|
||||
|
||||
void *thread_mid(){
|
||||
dir tmp;
|
||||
tmp.current_file = NULL;
|
||||
tmp.file_list = NULL;
|
||||
tmp.file_count = 0;
|
||||
dir previous_dir_state = { 0 };
|
||||
|
||||
while(!(status & STATUS_QUIT_PROGRAM)){
|
||||
|
||||
@@ -75,7 +71,7 @@ void *thread_mid(){
|
||||
if (status & STATUS_RELOAD_DIRECTORY) {
|
||||
long index = mid_dir.current_file - mid_dir.file_list;
|
||||
|
||||
tmp = mid_dir;
|
||||
previous_dir_state = mid_dir;
|
||||
|
||||
mid_dir.file_count = get_dir_size(path);
|
||||
mid_dir.file_list = malloc(mid_dir.file_count * sizeof(file));
|
||||
@@ -89,8 +85,21 @@ void *thread_mid(){
|
||||
}
|
||||
|
||||
unsigned long i;
|
||||
for(i = 0; i < mid_dir.file_count && i < tmp.file_count; i++) {
|
||||
mid_dir.file_list[i].status = tmp.file_list[i].status;
|
||||
for(i = 0; i < mid_dir.file_count && i < previous_dir_state.file_count; i++) {
|
||||
mid_dir.file_list[i].status = previous_dir_state.file_list[i].status;
|
||||
}
|
||||
/* youd think that after the above previous_dir_state = mid_dir previous_dir_state.current_file is always within the bounds of the file_list,
|
||||
* but no, it fucking is not for some reason
|
||||
* however for some mysterious reason this condition doesnt fail. well it probably does,
|
||||
* but that doesnt matter as it does what its supposed to do:
|
||||
* keep the current file selected after a reload even if the dir contents change like a new file being added */
|
||||
if (previous_dir_state.current_file != NULL && previous_dir_state.current_file < previous_dir_state.file_list + previous_dir_state.file_count) {
|
||||
for (i = 0; i < mid_dir.file_count; i++) {
|
||||
if (strcmp(mid_dir.file_list[i].file_name, previous_dir_state.file_list[index].file_name) == 0) {
|
||||
mid_dir.current_file = &mid_dir.file_list[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -120,21 +129,20 @@ void *thread_mid(){
|
||||
} else {
|
||||
print_dir(win_m, 1, &mid_dir);
|
||||
}
|
||||
wnoutrefresh(win_m);
|
||||
/*wnoutrefresh(win_m);*/
|
||||
wrefresh(win_m);
|
||||
pthread_mutex_unlock(&mutex_render);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
unsigned long i;
|
||||
for (i = 0; i < tmp.file_count; i++) {
|
||||
free(tmp.file_list[i].file_name);
|
||||
for (i = 0; i < previous_dir_state.file_count; i++) {
|
||||
free(previous_dir_state.file_list[i].file_name);
|
||||
}
|
||||
free(tmp.file_list);
|
||||
tmp.current_file = NULL;
|
||||
tmp.file_list = NULL;
|
||||
tmp.file_count = 0;
|
||||
free(previous_dir_state.file_list);
|
||||
previous_dir_state.current_file = NULL;
|
||||
previous_dir_state.file_list = NULL;
|
||||
previous_dir_state.file_count = 0;
|
||||
free(path);
|
||||
}
|
||||
pthread_exit(0);
|
||||
}
|
||||
@@ -182,7 +190,8 @@ void *thread_lft(){
|
||||
pthread_mutex_lock(&mutex_render);
|
||||
werase(win_l);
|
||||
print_dir(win_l, 0, &lft_dir);
|
||||
wnoutrefresh(win_l);
|
||||
/*wnoutrefresh(win_l);*/
|
||||
wrefresh(win_l);
|
||||
pthread_mutex_unlock(&mutex_render);
|
||||
|
||||
pthread_mutex_unlock(&mutex_lft);
|
||||
@@ -244,7 +253,8 @@ void *thread_rgt(){
|
||||
pthread_mutex_lock(&mutex_render);
|
||||
werase(win_r);
|
||||
print_dir(win_r, 0, &rgt_dir);
|
||||
wnoutrefresh(win_r);
|
||||
/*wnoutrefresh(win_r);*/
|
||||
wrefresh(win_r);
|
||||
pthread_mutex_unlock(&mutex_render);
|
||||
|
||||
} else if ((status & STATUS_DELTA_TIME) != STATUS_DELTA_TIME && rgt_dir.file_count > 0) {
|
||||
@@ -259,7 +269,8 @@ void *thread_rgt(){
|
||||
} else if ((rgt_dir.current_file->permissions & S_IRUSR) == 0) {
|
||||
mvwaddstr(win_r, 0, 0, "not accessible");
|
||||
}
|
||||
wnoutrefresh(win_r);
|
||||
/*wnoutrefresh(win_r);*/
|
||||
wrefresh(win_r);
|
||||
pthread_mutex_unlock(&mutex_render);
|
||||
}
|
||||
}
|
||||
@@ -285,43 +296,42 @@ void *thread_top(){
|
||||
pthread_cond_wait(&cond_top, &mutex_top);
|
||||
|
||||
|
||||
free(top_buffer);
|
||||
|
||||
if(global_path == NULL) {
|
||||
top_buffer = malloc(sizeof("cannot open directory"));
|
||||
top_width = sizeof("cannot open directory");
|
||||
top_buffer = "cannot open directory";
|
||||
pthread_mutex_unlock(&mutex_top);
|
||||
continue;
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&mutex_mid);
|
||||
|
||||
if (mid_dir.current_file != NULL) {
|
||||
top_buffer = malloc(strlen(global_path)+1 + strlen(mid_dir.current_file->file_name)+1);
|
||||
memcpy(top_buffer, global_path, strlen(global_path));
|
||||
memcpy(top_buffer + strlen(global_path) + 1, mid_dir.current_file->file_name, strlen(mid_dir.current_file->file_name)+1);
|
||||
|
||||
top_buffer[strlen(global_path)] = '/';
|
||||
top_width = strlen(top_buffer);
|
||||
} else {
|
||||
top_buffer = malloc(strlen(global_path)+1);
|
||||
memcpy(top_buffer, global_path, strlen(global_path)+1);
|
||||
if(global_path == NULL) {
|
||||
mvwaddstr(win_t, 0, 0, "cannot open directory");
|
||||
pthread_mutex_unlock(&mutex_top);
|
||||
pthread_mutex_unlock(&mutex_mid);
|
||||
continue;
|
||||
} else if (mid_dir.current_file == NULL) {
|
||||
mvwaddstr(win_t, 0, 0, "cannot open file");
|
||||
pthread_mutex_unlock(&mutex_top);
|
||||
pthread_mutex_unlock(&mutex_mid);
|
||||
continue;
|
||||
}
|
||||
pthread_mutex_unlock(&mutex_mid);
|
||||
|
||||
|
||||
|
||||
|
||||
/* rendering */
|
||||
pthread_mutex_lock(&mutex_render);
|
||||
werase(win_t);
|
||||
wattron(win_t, COLOR_PAIR(COLOR_PATH));
|
||||
mvwaddnstr(win_t, 0, 0, top_buffer, strlen(global_path)+1);
|
||||
wattroff(win_t, COLOR_PAIR(COLOR_PATH));
|
||||
mvwaddstr(win_t, 0, strlen(global_path)+1, top_buffer+strlen(global_path)+1);
|
||||
wnoutrefresh(win_t);
|
||||
if (strlen(global_path) != 1) {
|
||||
wattron(win_t, COLOR_PAIR(COLOR_PATH));
|
||||
mvwaddnstr(win_t, 0, 0, global_path, strlen(global_path)+1);
|
||||
mvwaddch(win_t, 0, strlen(global_path), '/');
|
||||
wattroff(win_t, COLOR_PAIR(COLOR_PATH));
|
||||
mvwaddstr(win_t, 0, strlen(global_path)+1, mid_dir.current_file->file_name);
|
||||
} else { /* dir '/' */
|
||||
wattron(win_t, COLOR_PAIR(COLOR_PATH));
|
||||
mvwaddnstr(win_t, 0, 0, global_path, 1);
|
||||
wattroff(win_t, COLOR_PAIR(COLOR_PATH));
|
||||
mvwaddstr(win_t, 0, 1, mid_dir.current_file->file_name);
|
||||
}
|
||||
/*wnoutrefresh(win_t);*/
|
||||
wrefresh(win_t);
|
||||
pthread_mutex_unlock(&mutex_render);
|
||||
|
||||
|
||||
pthread_mutex_unlock(&mutex_mid);
|
||||
pthread_mutex_unlock(&mutex_top);
|
||||
}
|
||||
pthread_exit(0);
|
||||
@@ -332,10 +342,19 @@ void *thread_btm(){
|
||||
unsigned int ui_btm_right_block_size = 0;
|
||||
unsigned int buffer_width = 0;
|
||||
|
||||
|
||||
while(!(status & STATUS_QUIT_PROGRAM)){
|
||||
pthread_mutex_lock(&mutex_btm);
|
||||
pthread_cond_wait(&cond_btm, &mutex_btm);
|
||||
|
||||
if (buffer_width != terminal_width) {
|
||||
buffer_width = (terminal_width > 10) ? terminal_width : 11;
|
||||
|
||||
free(btm_buffer);
|
||||
btm_buffer = malloc(buffer_width+1);
|
||||
/*in this case STATUS_RUN_BACKEND should be true as defined in the main loop resize check*/
|
||||
}
|
||||
|
||||
|
||||
if (status & (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY)) {
|
||||
/*{{{ parse storage info; the fold of shame*/
|
||||
@@ -408,15 +427,11 @@ void *thread_btm(){
|
||||
/*}}}*/
|
||||
}
|
||||
|
||||
if (buffer_width != terminal_width) {
|
||||
buffer_width = terminal_width;
|
||||
free(btm_buffer);
|
||||
btm_buffer = malloc(buffer_width+1);
|
||||
}
|
||||
memset(btm_buffer, ' ', buffer_width);
|
||||
btm_buffer[buffer_width] = '\0';
|
||||
|
||||
memcpy(btm_buffer + buffer_width - ui_btm_right_block_size, ui_btm_right_block, ui_btm_right_block_size);
|
||||
if (ui_btm_right_block_size + 9 < buffer_width) {
|
||||
memcpy(btm_buffer + buffer_width - ui_btm_right_block_size, ui_btm_right_block, ui_btm_right_block_size);
|
||||
}
|
||||
|
||||
if (mid_dir.current_file != NULL) {
|
||||
btm_buffer[0] = (S_ISLNK(mid_dir.current_file->permissions)) ? 'l':
|
||||
@@ -432,15 +447,17 @@ void *thread_btm(){
|
||||
btm_buffer[9] = (mid_dir.current_file->permissions & S_IXOTH) ? 'x' : '-';
|
||||
}
|
||||
|
||||
btm_buffer[buffer_width] = '\0';
|
||||
|
||||
|
||||
/* rendering */
|
||||
pthread_mutex_lock(&mutex_render);
|
||||
werase(win_b);
|
||||
if (*top_buffer != ' ') { /*printing ' ' (standard initialized value, see threading_init) makes valgrind throw a fuss*/
|
||||
mvwprintw(win_b, 0, 0, "%s", btm_buffer);
|
||||
}
|
||||
wnoutrefresh(win_b);
|
||||
|
||||
mvwprintw(win_b, 0, 0, "%s", btm_buffer);
|
||||
|
||||
/*wnoutrefresh(win_b);*/
|
||||
wrefresh(win_b);
|
||||
pthread_mutex_unlock(&mutex_render);
|
||||
pthread_mutex_unlock(&mutex_btm);
|
||||
/*the printing of all possible inputs are done in user_interactions */
|
||||
@@ -453,13 +470,8 @@ void *thread_btm(){
|
||||
|
||||
void threading_init(){
|
||||
|
||||
top_buffer = malloc(sizeof(char));
|
||||
rgt_buffer = malloc(sizeof(char));
|
||||
btm_buffer = malloc(sizeof(char));
|
||||
memset(top_buffer, '\0', sizeof(char));
|
||||
memset(rgt_buffer, '\0', sizeof(char));
|
||||
memset(btm_buffer, '\0', sizeof(char));
|
||||
|
||||
rgt_buffer = NULL;
|
||||
btm_buffer = NULL;
|
||||
|
||||
pthread_mutex_init(&mutex_top, NULL);
|
||||
pthread_mutex_init(&mutex_mid, NULL);
|
||||
@@ -475,7 +487,6 @@ void threading_init(){
|
||||
|
||||
}
|
||||
void threading_free(){
|
||||
free(top_buffer);
|
||||
|
||||
pthread_mutex_destroy(&mutex_top);
|
||||
pthread_mutex_destroy(&mutex_mid);
|
||||
|
||||
Reference in New Issue
Block a user