mirror of
https://github.com/rkd77/elinks.git
synced 2024-09-27 02:56:18 -04:00
[terminal] terminal.cpp -> terminal.c
hash from util instead of C++ map
This commit is contained in:
parent
5b48b6be72
commit
d606aca351
@ -69,6 +69,12 @@ INIT_LIST_OF(struct file_download, downloads);
|
|||||||
|
|
||||||
std::map<std::string, std::string> uri_tempfiles;
|
std::map<std::string, std::string> uri_tempfiles;
|
||||||
|
|
||||||
|
void
|
||||||
|
clear_uri_tempfiles(void)
|
||||||
|
{
|
||||||
|
uri_tempfiles.clear();
|
||||||
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
check_url_tempfiles(const char *url)
|
check_url_tempfiles(const char *url)
|
||||||
{
|
{
|
||||||
|
@ -256,6 +256,8 @@ void tp_save(struct type_query *type_query);
|
|||||||
void tp_cancel(void *data);
|
void tp_cancel(void *data);
|
||||||
struct file_download *init_file_download(struct uri *uri, struct session *ses, char *file, int fd);
|
struct file_download *init_file_download(struct uri *uri, struct session *ses, char *file, int fd);
|
||||||
|
|
||||||
|
void clear_uri_tempfiles(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -13,7 +13,7 @@ OBJS = \
|
|||||||
kbd.o \
|
kbd.o \
|
||||||
screen.o \
|
screen.o \
|
||||||
tab.o \
|
tab.o \
|
||||||
terminal.obj \
|
terminal.o \
|
||||||
window.o
|
window.o
|
||||||
|
|
||||||
include $(top_srcdir)/Makefile.lib
|
include $(top_srcdir)/Makefile.lib
|
||||||
|
@ -7,4 +7,4 @@ endif
|
|||||||
if conf_data.get('CONFIG_TERMINFO')
|
if conf_data.get('CONFIG_TERMINFO')
|
||||||
srcs += files('terminfo.c')
|
srcs += files('terminfo.c')
|
||||||
endif
|
endif
|
||||||
srcs += files('color.c', 'draw.c', 'event.c', 'hardio.c', 'kbd.c', 'screen.c', 'tab.c', 'terminal.cpp', 'window.c')
|
srcs += files('color.c', 'draw.c', 'event.c', 'hardio.c', 'kbd.c', 'screen.c', 'tab.c', 'terminal.c', 'window.c')
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#ifdef CONFIG_SCRIPTING_SPIDERMONKEY
|
#ifdef CONFIG_SCRIPTING_SPIDERMONKEY
|
||||||
# include "scripting/smjs/smjs.h"
|
# include "scripting/smjs/smjs.h"
|
||||||
#endif
|
#endif
|
||||||
|
#include "session/download.h"
|
||||||
#include "session/session.h"
|
#include "session/session.h"
|
||||||
#include "terminal/draw.h"
|
#include "terminal/draw.h"
|
||||||
#include "terminal/event.h"
|
#include "terminal/event.h"
|
||||||
@ -44,38 +45,60 @@
|
|||||||
#endif
|
#endif
|
||||||
#include "terminal/window.h"
|
#include "terminal/window.h"
|
||||||
#include "util/error.h"
|
#include "util/error.h"
|
||||||
|
#include "util/hash.h"
|
||||||
#include "util/memory.h"
|
#include "util/memory.h"
|
||||||
#include "util/string.h"
|
#include "util/string.h"
|
||||||
#include "viewer/text/textarea.h"
|
#include "viewer/text/textarea.h"
|
||||||
|
|
||||||
#include <map>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
INIT_LIST_OF(struct terminal, terminals);
|
INIT_LIST_OF(struct terminal, terminals);
|
||||||
std::map<std::string, bool> temporary_files;
|
struct hash *temporary_files;
|
||||||
extern std::map<std::string, std::string> uri_tempfiles;
|
|
||||||
|
|
||||||
static void check_if_no_terminal(void);
|
static void check_if_no_terminal(void);
|
||||||
|
|
||||||
void
|
void
|
||||||
clean_temporary_files(void)
|
clean_temporary_files(void)
|
||||||
{
|
{
|
||||||
for (auto it : temporary_files) {
|
struct hash_item *item;
|
||||||
const char *str = (it.first).c_str();
|
int i;
|
||||||
|
|
||||||
if (str) {
|
if (!temporary_files) {
|
||||||
unlink(str);
|
return;
|
||||||
/* fprintf(stderr, "clean: %s\n", str); */
|
}
|
||||||
|
|
||||||
|
foreach_hash_item (item, *temporary_files, i) {
|
||||||
|
if (item->key) {
|
||||||
|
unlink(item->key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
temporary_files.clear();
|
free_hash(&temporary_files);
|
||||||
uri_tempfiles.clear();
|
clear_uri_tempfiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
long
|
long
|
||||||
get_number_of_temporary_files(void)
|
get_number_of_temporary_files(void)
|
||||||
{
|
{
|
||||||
return temporary_files.size();
|
struct hash_item *item;
|
||||||
|
int i;
|
||||||
|
long counter = 0;
|
||||||
|
|
||||||
|
if (temporary_files) {
|
||||||
|
foreach_hash_item (item, *temporary_files, i) {
|
||||||
|
counter++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return counter;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
save_temporary_filename(const char *filename)
|
||||||
|
{
|
||||||
|
if (!temporary_files) {
|
||||||
|
temporary_files = init_hash8();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (temporary_files) {
|
||||||
|
add_hash_item(temporary_files, filename, strlen(filename), NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -429,7 +452,7 @@ exec_on_terminal(struct terminal *term, const char *path,
|
|||||||
len = strlen(delete_);
|
len = strlen(delete_);
|
||||||
|
|
||||||
if (len && get_opt_bool("ui.sessions.postpone_unlink", NULL)) {
|
if (len && get_opt_bool("ui.sessions.postpone_unlink", NULL)) {
|
||||||
temporary_files[delete_] = true;
|
save_temporary_filename(delete_);
|
||||||
len = 0;
|
len = 0;
|
||||||
delete_ = "";
|
delete_ = "";
|
||||||
}
|
}
|
||||||
@ -441,7 +464,7 @@ exec_on_terminal(struct terminal *term, const char *path,
|
|||||||
size_t len = strlen(delete_);
|
size_t len = strlen(delete_);
|
||||||
|
|
||||||
if (len && *path && get_opt_bool("ui.sessions.postpone_unlink", NULL)) {
|
if (len && *path && get_opt_bool("ui.sessions.postpone_unlink", NULL)) {
|
||||||
temporary_files[delete_] = true;
|
save_temporary_filename(delete_);
|
||||||
len = 0;
|
len = 0;
|
||||||
delete_ = "";
|
delete_ = "";
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user