commit cab59c0fbb25e07921a546b510782a3496c84ced from: Oliver Lowe date: Sat Sep 6 07:02:02 2025 UTC Delete more dead code commit - 796e6d93de00cbe420af4ece0a56a2003e8f6704 commit + cab59c0fbb25e07921a546b510782a3496c84ced blob - 561ec7ad23f9c59cdba8c65fb9173c2c0c4b7928 (mode 644) blob + /dev/null --- src/common/template.c +++ /dev/null @@ -1,327 +0,0 @@ -/* - * Claws Mail templates subsystem - * Copyright (C) 2001 Alexander Barinov - * Copyright (C) 2001-2021 The Claws Mail team - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -#include "defs.h" - -#include -#include -#include -#include -#include - -#include "utils.h" -#include "template.h" -#include "codeconv.h" -#include "file-utils.h" - -static GSList *template_list; - -static Template *template_load(gchar *filename) -{ - Template *tmpl; - FILE *fp; - gchar buf[BUFFSIZE]; - gint bytes_read; - - if ((fp = g_fopen(filename, "rb")) == NULL) { - FILE_OP_ERROR(filename, "g_fopen"); - return NULL; - } - - tmpl = g_new(Template, 1); - tmpl->load_filename = g_strdup(filename); - tmpl->name = NULL; - tmpl->subject = NULL; - tmpl->from = NULL; - tmpl->to = NULL; - tmpl->cc = NULL; - tmpl->bcc = NULL; - tmpl->replyto = NULL; - tmpl->value = NULL; - - while (fgets(buf, sizeof(buf), fp) != NULL) { - if (buf[0] == '\n') - break; - else if (!g_ascii_strncasecmp(buf, "Name:", 5)) - tmpl->name = g_strdup(g_strstrip(buf + 5)); - else if (!g_ascii_strncasecmp(buf, "From:", 5)) - tmpl->from = g_strdup(g_strstrip(buf + 5)); - else if (!g_ascii_strncasecmp(buf, "To:", 3)) - tmpl->to = g_strdup(g_strstrip(buf + 3)); - else if (!g_ascii_strncasecmp(buf, "Cc:", 3)) - tmpl->cc = g_strdup(g_strstrip(buf + 3)); - else if (!g_ascii_strncasecmp(buf, "Bcc:", 4)) - tmpl->bcc = g_strdup(g_strstrip(buf + 4)); - else if (!g_ascii_strncasecmp(buf, "Reply-To:", 9)) - tmpl->replyto = g_strdup(g_strstrip(buf + 9)); - else if (!g_ascii_strncasecmp(buf, "Subject:", 8)) - tmpl->subject = g_strdup(g_strstrip(buf + 8)); - } - - if (!tmpl->name) { - g_warning("wrong template format"); - template_free(tmpl); - fclose(fp); - return NULL; - } - - if ((bytes_read = fread(buf, 1, sizeof(buf), fp)) == 0) { - if (ferror(fp)) { - FILE_OP_ERROR(filename, "fread"); - template_free(tmpl); - fclose(fp); - return NULL; - } - } - fclose(fp); - tmpl->value = g_strndup(buf, bytes_read); - - return tmpl; -} - -void template_free(Template *tmpl) -{ - g_free(tmpl->load_filename); - g_free(tmpl->name); - g_free(tmpl->subject); - g_free(tmpl->from); - g_free(tmpl->to); - g_free(tmpl->cc); - g_free(tmpl->bcc); - g_free(tmpl->replyto); - g_free(tmpl->value); - g_free(tmpl); -} - -static void template_clear_config(GSList *tmpl_list) -{ - GSList *cur; - Template *tmpl; - - for (cur = tmpl_list; cur != NULL; cur = cur->next) { - tmpl = (Template *)cur->data; - template_free(tmpl); - } - g_slist_free(tmpl_list); -} - -static gint tmpl_compare(gconstpointer tmpl1, gconstpointer tmpl2) -{ - gchar *basename1, *basename2; - long filenum1, filenum2; - gint ret = 0; - - if ((Template *)tmpl1 == NULL || (Template *)tmpl2 == NULL) - return 0; - - if (((Template *)tmpl1)->load_filename == NULL || ((Template *)tmpl2)->load_filename == NULL) - return 0; - - basename1 = g_path_get_basename(((Template *)tmpl1)->load_filename); - basename2 = g_path_get_basename(((Template *)tmpl2)->load_filename); - filenum1 = atol(basename1); - filenum2 = atol(basename2); - g_free(basename1); - g_free(basename2); - - if (filenum1 == 0 || filenum2 == 0) - return 0; - - if (filenum1 < filenum2) - ret = -1; - else - if (filenum1 > filenum2) - ret = 1; - - return ret; -} - -GSList *template_read_config(void) -{ - const gchar *path; - GDir *dir; - const gchar *dir_name; - GSList *tmpl_list = NULL; - - path = get_template_dir(); - debug_print("%s:%d reading templates dir %s\n", - __FILE__, __LINE__, path); - - if (!is_dir_exist(path)) { - if (make_dir(path) < 0) - return NULL; - } - - if ((dir = g_dir_open(path, 0, NULL)) == NULL) { - g_warning("failed to open directory: '%s'", path); - return NULL; - } - - while ((dir_name = g_dir_read_name(dir)) != NULL) { - Template *tmpl; - GStatBuf s; - gchar *filename = g_strconcat(path, G_DIR_SEPARATOR_S, - dir_name, NULL); - - if (g_stat(filename, &s) != 0 || !S_ISREG(s.st_mode) ) { - debug_print("%s:%d %s is not an ordinary file\n", - __FILE__, __LINE__, filename); - g_free(filename); - continue; - } - - tmpl = template_load(filename); - if (tmpl) - tmpl_list = g_slist_insert_sorted(tmpl_list, tmpl, tmpl_compare); - - g_free(filename); - } - - g_dir_close(dir); - - return tmpl_list; -} - -#define TRY(func) { \ -if (!(func)) \ -{ \ - g_warning("failed to write template to file"); \ - if (fp) fclose(fp); \ - if (new) unlink(new); \ - g_free(new); \ - g_free(filename); \ - return; \ -} \ -} - -#define TRY_NO_CLOSE(func) { \ -if (!(func)) \ -{ \ - g_warning("failed to write template to file"); \ - if (new) unlink(new); \ - g_free(new); \ - g_free(filename); \ - return; \ -} \ -} - -static void template_write_config(GSList *tmpl_list) -{ - const gchar *path; - GSList *cur; - Template *tmpl; - FILE *fp; - gint tmpl_num; - - debug_print("%s:%d writing templates\n", __FILE__, __LINE__); - - path = get_template_dir(); - - if (!is_dir_exist(path)) { - if (is_file_exist(path)) { - g_warning("file '%s' already exists", path); - return; - } - if (make_dir(path) < 0) - return; - } - - for (cur = tmpl_list, tmpl_num = 1; cur != NULL; - cur = cur->next, tmpl_num++) { - gchar *filename, *new = NULL; - - tmpl = cur->data; - - filename = g_strconcat(path, G_DIR_SEPARATOR_S, - itos(tmpl_num), NULL); - - if (is_file_exist(filename)) { - new = g_strconcat(filename, ".new", NULL); - } - - if ((fp = g_fopen(new?new:filename, "wb")) == NULL) { - FILE_OP_ERROR(new?new:filename, "g_fopen"); - g_free(new); - g_free(filename); - return; - } - - TRY(fprintf(fp, "Name: %s\n", tmpl->name) > 0); - if (tmpl->subject && *tmpl->subject != '\0') - TRY(fprintf(fp, "Subject: %s\n", tmpl->subject) > 0); - if (tmpl->from && *tmpl->from != '\0') - TRY(fprintf(fp, "From: %s\n", tmpl->from) > 0); - if (tmpl->to && *tmpl->to != '\0') - TRY(fprintf(fp, "To: %s\n", tmpl->to) > 0); - if (tmpl->cc && *tmpl->cc != '\0') - TRY(fprintf(fp, "Cc: %s\n", tmpl->cc) > 0); - if (tmpl->bcc && *tmpl->bcc != '\0') - TRY(fprintf(fp, "Bcc: %s\n", tmpl->bcc) > 0); - if (tmpl->replyto && *tmpl->replyto != '\0') - TRY(fprintf(fp, "Reply-To: %s\n", tmpl->replyto) > 0); - - TRY(fputs("\n", fp) != EOF); - - if (tmpl->value && *tmpl->value != '\0') { - TRY(fwrite(tmpl->value, sizeof(gchar), strlen(tmpl->value), fp) == strlen(tmpl->value)); - } else { - TRY(fwrite("", sizeof(gchar), 1, fp) == 1); - } - TRY_NO_CLOSE(safe_fclose(fp) != EOF); - - if (new) { - if (rename_force(new, filename) < 0) { - FILE_OP_ERROR(new, "rename"); - } - } - g_free(new); - g_free(filename); - } - - /* remove other templates */ - while (TRUE) { - gchar *filename = g_strconcat(path, G_DIR_SEPARATOR_S, - itos(tmpl_num), NULL); - if (is_file_exist(filename)) { - debug_print("removing old template %d\n", tmpl_num); - unlink(filename); - g_free(filename); - } else { - g_free(filename); - break; - } - tmpl_num++; - } -} - -GSList *template_get_config(void) -{ - if (!template_list) - template_list = template_read_config(); - - return template_list; -} - -void template_set_config(GSList *tmpl_list) -{ - template_clear_config(template_list); - template_write_config(tmpl_list); - template_list = tmpl_list; -} blob - d7cf4227ad590e5e840e89acb629f9ffadae8036 (mode 644) blob + /dev/null --- src/common/template.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Claws Mail templates subsystem - * Copyright (C) 2001 Alexander Barinov - * Copyright (C) 2001-2018 The Claws Mail team - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -#ifndef __TEMPLATE_H__ -#define __TEMPLATE_H__ - -#include - -typedef struct _Template Template; - -struct _Template { - gchar *load_filename; - gchar *name; - gchar *subject; - gchar *from; - gchar *to; - gchar *cc; - gchar *bcc; - gchar *replyto; - gchar *value; -}; - -void template_free (Template *tmpl); - -GSList *template_read_config (void); - -GSList *template_get_config (void); -void template_set_config (GSList *tmpl_list); - -#endif /* __TEMPLATE_H__ */ blob - 12472e9b4e51bb68d782c7cb31bb31403b9cbe87 (mode 644) blob + /dev/null --- src/common/uuencode.c +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Claws Mail -- a GTK based, lightweight, and fast e-mail client - * Copyright (C) 1999-2024 Hiroyuki Yamamoto and the Claws Mail Team - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include - -#define UUDECODE(c) (c=='`' ? 0 : c - ' ') -#define N64(i) (i & ~63) - -const char uudigit[64] = -{ - '`', '!', '"', '#', '$', '%', '&', '\'', - '(', ')', '*', '+', ',', '-', '.', '/', - '0', '1', '2', '3', '4', '5', '6', '7', - '8', '9', ':', ';', '<', '=', '>', '?', - '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', - 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', - 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', - 'X', 'Y', 'Z', '[', '\\', ']', '^', '_' -}; - -int fromuutobits(char *out, const char *in) -{ - int len, outlen, inlen; - register unsigned char digit1, digit2; - - outlen = UUDECODE(in[0]); - in += 1; - if(outlen < 0 || outlen > 45) - return -2; - if(outlen == 0) - return 0; - inlen = (outlen * 4 + 2) / 3; - len = 0; - - for( ; inlen>0; inlen-=4) { - digit1 = UUDECODE(in[0]); - if (N64(digit1)) return -1; - digit2 = UUDECODE(in[1]); - if (N64(digit2)) return -1; - out[len++] = (digit1 << 2) | (digit2 >> 4); - if (inlen > 2) { - digit1 = UUDECODE(in[2]); - if (N64(digit1)) return -1; - out[len++] = (digit2 << 4) | (digit1 >> 2); - if (inlen > 3) { - digit2 = UUDECODE(in[3]); - if (N64(digit2)) return -1; - out[len++] = (digit1 << 6) | digit2; - } - } - in += 4; - } - - return len == outlen ? len : -3; -} blob - 670196c536f29b7172220cd1dc13d25acf0b1523 (mode 644) blob + /dev/null --- src/common/uuencode.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Claws Mail -- a GTK based, lightweight, and fast e-mail client - * Copyright (C) 1999-2024 Hiroyuki Yamamoto and the Claws Mail Team - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef __UUENCODE_H__ -#define __UUENCODE_H__ - -int fromuutobits(char *, const char *); - -#endif /* __UUENCODE_H__ */ blob - 826e0c7f12354d7b7f7c0e92cb517652de83c803 blob + 1848373d50d8955767d43358a4eb1199d971e91e --- src/compose.h +++ src/compose.h @@ -32,7 +32,6 @@ typedef struct _AttachInfo AttachInfo; #include "undo.h" #include "toolbar.h" #include "codeconv.h" -#include "template.h" #include "viewtypes.h" #include "folder.h"