mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-16 04:13:02 +01:00
Remove legacy code and fix a couple format specifiers
This code was added over 5 years ago and no longer serves a purpose
This commit is contained in:
parent
3f02e119f4
commit
a86884c40e
@ -103,7 +103,7 @@ void cmd_groupinvite(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*a
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Invited contact to Group %lu.", groupnum);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Invited contact to Group %ld.", groupnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_join_group(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
void cmd_join_group(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
||||||
@ -189,7 +189,7 @@ void cmd_savefile(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv
|
|||||||
goto on_recv_error;
|
goto on_recv_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Saving file [%zu] as: '%s'", idx, ft->file_path);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Saving file [%ld] as: '%s'", idx, ft->file_path);
|
||||||
|
|
||||||
/* prep progress bar line */
|
/* prep progress bar line */
|
||||||
char progline[MAX_STR_SIZE];
|
char progline[MAX_STR_SIZE];
|
||||||
|
@ -411,7 +411,7 @@ void line_info_print(ToxWindow *self)
|
|||||||
|
|
||||||
if (type == OUT_ACTION && timed_out(line->timestamp, NOREAD_FLAG_TIMEOUT)) {
|
if (type == OUT_ACTION && timed_out(line->timestamp, NOREAD_FLAG_TIMEOUT)) {
|
||||||
wattron(win, COLOR_PAIR(RED));
|
wattron(win, COLOR_PAIR(RED));
|
||||||
wprintw(win, " x", line->msg);
|
wprintw(win, " x");
|
||||||
wattroff(win, COLOR_PAIR(RED));
|
wattroff(win, COLOR_PAIR(RED));
|
||||||
|
|
||||||
if (line->noread_flag == false) {
|
if (line->noread_flag == false) {
|
||||||
|
105
src/toxic.c
105
src/toxic.c
@ -1093,6 +1093,11 @@ static void parse_args(int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'c':
|
case 'c':
|
||||||
|
if (optarg == NULL) {
|
||||||
|
queue_init_message("Invalid argument for option: %d", opt);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
snprintf(arg_opts.config_path, sizeof(arg_opts.config_path), "%s", optarg);
|
snprintf(arg_opts.config_path, sizeof(arg_opts.config_path), "%s", optarg);
|
||||||
|
|
||||||
if (!file_exists(arg_opts.config_path)) {
|
if (!file_exists(arg_opts.config_path)) {
|
||||||
@ -1176,6 +1181,11 @@ static void parse_args(int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'n':
|
case 'n':
|
||||||
|
if (optarg == NULL) {
|
||||||
|
queue_init_message("Invalid argument for option: %d", opt);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
snprintf(arg_opts.nodes_path, sizeof(arg_opts.nodes_path), "%s", optarg);
|
snprintf(arg_opts.nodes_path, sizeof(arg_opts.nodes_path), "%s", optarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1185,6 +1195,11 @@ static void parse_args(int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'p':
|
case 'p':
|
||||||
|
if (optarg == NULL) {
|
||||||
|
queue_init_message("Invalid argument for option: %d", opt);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
arg_opts.proxy_type = TOX_PROXY_TYPE_SOCKS5;
|
arg_opts.proxy_type = TOX_PROXY_TYPE_SOCKS5;
|
||||||
snprintf(arg_opts.proxy_address, sizeof(arg_opts.proxy_address), "%s", optarg);
|
snprintf(arg_opts.proxy_address, sizeof(arg_opts.proxy_address), "%s", optarg);
|
||||||
|
|
||||||
@ -1202,6 +1217,11 @@ static void parse_args(int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'P':
|
case 'P':
|
||||||
|
if (optarg == NULL) {
|
||||||
|
queue_init_message("Invalid argument for option: %d", opt);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
arg_opts.proxy_type = TOX_PROXY_TYPE_HTTP;
|
arg_opts.proxy_type = TOX_PROXY_TYPE_HTTP;
|
||||||
snprintf(arg_opts.proxy_address, sizeof(arg_opts.proxy_address), "%s", optarg);
|
snprintf(arg_opts.proxy_address, sizeof(arg_opts.proxy_address), "%s", optarg);
|
||||||
|
|
||||||
@ -1219,6 +1239,11 @@ static void parse_args(int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'r':
|
case 'r':
|
||||||
|
if (optarg == NULL) {
|
||||||
|
queue_init_message("Invalid argument for option: %d", opt);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
snprintf(arg_opts.nameserver_path, sizeof(arg_opts.nameserver_path), "%s", optarg);
|
snprintf(arg_opts.nameserver_path, sizeof(arg_opts.nameserver_path), "%s", optarg);
|
||||||
|
|
||||||
if (!file_exists(arg_opts.nameserver_path)) {
|
if (!file_exists(arg_opts.nameserver_path)) {
|
||||||
@ -1232,10 +1257,15 @@ static void parse_args(int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'T':
|
case 'T':
|
||||||
|
if (optarg == NULL) {
|
||||||
|
queue_init_message("Invalid argument for option: %d", opt);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
port = strtol(optarg, NULL, 10);
|
port = strtol(optarg, NULL, 10);
|
||||||
|
|
||||||
if (port <= 0 || port > MAX_PORT_RANGE) {
|
if (port <= 0 || port > MAX_PORT_RANGE) {
|
||||||
port = 14191;
|
port = MAX_PORT_RANGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
arg_opts.tcp_port = port;
|
arg_opts.tcp_port = port;
|
||||||
@ -1250,6 +1280,8 @@ static void parse_args(int argc, char *argv[])
|
|||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
|
|
||||||
case 'h':
|
case 'h':
|
||||||
|
|
||||||
|
// Intentional fallthrough
|
||||||
default:
|
default:
|
||||||
print_usage();
|
print_usage();
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
@ -1257,72 +1289,6 @@ static void parse_args(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Looks for an old default profile data file and blocklist, and renames them to the new default names.
|
|
||||||
*
|
|
||||||
* Returns 0 on success.
|
|
||||||
* Returns -1 on failure.
|
|
||||||
*/
|
|
||||||
#define OLD_DATA_NAME "data"
|
|
||||||
#define OLD_DATA_BLOCKLIST_NAME "data-blocklist"
|
|
||||||
static int rename_old_profile(const char *user_config_dir)
|
|
||||||
{
|
|
||||||
size_t old_buf_size = strlen(user_config_dir) + strlen(CONFIGDIR) + strlen(OLD_DATA_NAME) + 1;
|
|
||||||
char *old_data_file = malloc(old_buf_size);
|
|
||||||
|
|
||||||
if (old_data_file == NULL) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
snprintf(old_data_file, old_buf_size, "%s%s%s", user_config_dir, CONFIGDIR, OLD_DATA_NAME);
|
|
||||||
|
|
||||||
if (!file_exists(old_data_file)) {
|
|
||||||
free(old_data_file);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (file_exists(DATA_FILE)) {
|
|
||||||
free(old_data_file);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rename(old_data_file, DATA_FILE) != 0) {
|
|
||||||
free(old_data_file);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
free(old_data_file);
|
|
||||||
|
|
||||||
queue_init_message("Data file has been moved to %s", DATA_FILE);
|
|
||||||
|
|
||||||
size_t old_block_buf_size = strlen(user_config_dir) + strlen(CONFIGDIR) + strlen(OLD_DATA_BLOCKLIST_NAME) + 1;
|
|
||||||
char *old_data_blocklist = malloc(old_block_buf_size);
|
|
||||||
|
|
||||||
if (old_data_blocklist == NULL) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
snprintf(old_data_blocklist, old_block_buf_size, "%s%s%s", user_config_dir, CONFIGDIR, OLD_DATA_BLOCKLIST_NAME);
|
|
||||||
|
|
||||||
if (!file_exists(old_data_blocklist)) {
|
|
||||||
free(old_data_blocklist);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (file_exists(BLOCK_FILE)) {
|
|
||||||
free(old_data_blocklist);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rename(old_data_blocklist, BLOCK_FILE) != 0) {
|
|
||||||
free(old_data_blocklist);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
free(old_data_blocklist);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Initializes the default config directory and data files used by toxic.
|
/* Initializes the default config directory and data files used by toxic.
|
||||||
*
|
*
|
||||||
* Exits the process with an error on failure.
|
* Exits the process with an error on failure.
|
||||||
@ -1365,11 +1331,6 @@ static void init_default_data_files(void)
|
|||||||
strcat(BLOCK_FILE, BLOCKNAME);
|
strcat(BLOCK_FILE, BLOCKNAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* For backwards compatibility with old toxic profile names. TODO: remove this some day */
|
|
||||||
if (rename_old_profile(user_config_dir) == -1) {
|
|
||||||
queue_init_message("Warning: Profile backwards compatibility failed.");
|
|
||||||
}
|
|
||||||
|
|
||||||
free(user_config_dir);
|
free(user_config_dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user