void plugin_load(void) { debug_print("autoenc plug-in loaded!\n"); syl_init_gettext(GETTEXT_PACKAGE, LOCALEDIR); syl_plugin_add_menuitem("/Configuration", NULL, NULL, NULL); syl_plugin_add_menuitem("/Configuration", _("Configure automatic attachment encryption"), autoenc_setting, NULL); g_signal_connect_after(syl_app_get(), "init-done", G_CALLBACK(init_done_cb), NULL); autoenc_app_exit_handler_id = g_signal_connect(syl_app_get(), "app-exit", G_CALLBACK(app_exit_cb), NULL); syl_plugin_signal_connect("compose-created", G_CALLBACK(compose_created_cb), NULL); syl_plugin_signal_connect("compose-destroy", G_CALLBACK(compose_destroy_cb), NULL); syl_plugin_signal_connect("compose-send", G_CALLBACK(compose_send_cb), NULL); syl_plugin_signal_connect("compose-toolbar-changed", G_CALLBACK(compose_toolbar_changed_cb), NULL); syl_plugin_signal_connect("compose-attach-changed", G_CALLBACK(compose_attach_changed_cb), NULL); /* load config */ read_config(); if (is_dir_exist(get_autoenc_tmp_dir())) { remove_all_files(get_autoenc_tmp_dir()); } debug_print("autoenc plug-in loading done\n"); }
static void app_exit_cb(GObject *obj, gpointer data) { debug_print("autoenc: app_exit_cb: removing all temporary files\n"); if (is_dir_exist(get_autoenc_tmp_dir())) { remove_all_files(get_autoenc_tmp_dir()); } }
void syl_cleanup(void) { /* remove temporary files */ remove_all_files(get_tmp_dir()); remove_all_files(get_mime_tmp_dir()); #if GLIB_CHECK_VERSION(2, 6, 0) g_log_set_default_handler(g_log_default_handler, NULL); #endif close_log_file(); sock_cleanup(); if (app) { g_object_unref(app); app = NULL; } }
void template_write_config(GSList *tmpl_list) { const gchar *path; GSList *cur; Template *tmpl; FILE *fp; 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\n"), path); return; } if (make_dir(path) < 0) return; } remove_all_files(path); for (cur = tmpl_list; cur != NULL; cur = cur->next) { gchar *filename; tmpl = cur->data; filename = g_strconcat(path, G_DIR_SEPARATOR_S, itos(tmpl->tmplid), NULL); if ((fp = g_fopen(filename, "wb")) == NULL) { FILE_OP_ERROR(filename, "fopen"); g_free(filename); return; } fprintf(fp, "Name: %s\n", tmpl->name); if (tmpl->to && *tmpl->to != '\0') fprintf(fp, "To: %s\n", tmpl->to); if (tmpl->cc && *tmpl->cc != '\0') fprintf(fp, "Cc: %s\n", tmpl->cc); if (tmpl->bcc && *tmpl->bcc != '\0') fprintf(fp, "Bcc: %s\n", tmpl->bcc); if (tmpl->replyto && *tmpl->replyto != '\0') fprintf(fp, "Reply-To: %s\n", tmpl->replyto); if (tmpl->subject && *tmpl->subject != '\0') fprintf(fp, "Subject: %s\n", tmpl->subject); fputs("\n", fp); fwrite(tmpl->value, sizeof(gchar) * strlen(tmpl->value), 1, fp); fclose(fp); g_free(filename); } }
gint syl_setup_rc_dir(void) { if (!is_dir_exist(get_rc_dir())) { if (make_dir_hier(get_rc_dir()) < 0) return -1; } MAKE_DIR_IF_NOT_EXIST(get_mail_base_dir()); CHDIR_RETURN_VAL_IF_FAIL(get_rc_dir(), -1); MAKE_DIR_IF_NOT_EXIST(get_imap_cache_dir()); MAKE_DIR_IF_NOT_EXIST(get_news_cache_dir()); MAKE_DIR_IF_NOT_EXIST(get_mime_tmp_dir()); MAKE_DIR_IF_NOT_EXIST(get_tmp_dir()); MAKE_DIR_IF_NOT_EXIST(UIDL_DIR); MAKE_DIR_IF_NOT_EXIST(PLUGIN_DIR); /* remove temporary files */ remove_all_files(get_tmp_dir()); remove_all_files(get_mime_tmp_dir()); return 0; }
/** * Parses the file and populates the structures used by this FUSE driver. * * \param filename The filename to parse * \param r The result structure to populate (or NULL if not needed) * \returns 0 if successful, -1 if not. */ static int process_file(const char *filename, result_t new_result) { img_info = tsk_img_open_sing(filename, TSK_IMG_TYPE_DETECT, 0); if (img_info == NULL) { info_log("Failed to open image: %s", filename); return -1; } fs_info = tsk_fs_open_img(img_info, 0, TSK_FS_TYPE_DETECT); if (fs_info == NULL) { info_log("Failed to open filesystem: %s", filename); return -1; } const char *fsname = tsk_fs_type_toname(fs_info->ftype); result_set_brief_data_description(new_result, fsname); mountpoint = g_strdup_printf("%s:mnt-%s", filename, fsname); char *description = g_strdup_printf("%" PRIdDADDR " bytes (%" PRIdDADDR " %ss of %u size)", fs_info->block_count * fs_info->block_size, fs_info->block_count, fs_info->duname, fs_info->block_size); result_set_data_description(new_result, description); g_free(description); result_set_confidence(new_result, 100); block_start(absolute_offset); TSK_FS_DIR_WALK_FLAG_ENUM name_flags = (TSK_FS_DIR_WALK_FLAG_ENUM) (TSK_FS_DIR_WALK_FLAG_ALLOC | TSK_FS_DIR_WALK_FLAG_UNALLOC | TSK_FS_DIR_WALK_FLAG_RECURSE); if (tsk_fs_dir_walk(fs_info, fs_info->root_inum, name_flags, examine_dirent, new_result) != 0) { // Why does this occur? Is it because it's an invalid filesystem structure, or the // structure is damaged? I'm going to assume the structure is damaged, but partially available. warning_log("Warning, unable to fully walk fs! Probably truncated or not a real FS header."); } unsigned int size; block_range_t *ranges = block_end(&size); if (ranges != NULL) { result_set_block_ranges(new_result, ranges, size); for (int i = 0; i < size; i++) { block_range_close(ranges[i]); } g_free(ranges); } if (inode_lookup != NULL) { g_tree_destroy(inode_lookup); inode_lookup = NULL; } unsigned int num_contracts; result_get_new_contracts(new_result, &num_contracts); if (num_contracts > 0) { // Ready to mount! int ret = do_mount(mountpoint); if (ret != 0) { error_log("Failed to mount filesystem!"); } } remove_all_files(); return 0; }