summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMattia Rizzolo <mattia@mapreri.org>2014-10-03 14:05:23 +0000
committerMattia Rizzolo <mattia@mapreri.org>2014-10-03 14:05:23 +0000
commit96b92dfa3cb0a3ae876a3e650984a404327cdf93 (patch)
tree991a1ea3b056ca5804e2bca75fc4e134152fb3cd /src
parent7fad909266d49203537a28e6acc5d96b14bf4e7f (diff)
Imported Upstream version 0.99+0.991upstream/0.99+0.991
Diffstat (limited to 'src')
-rw-r--r--src/xsane-back-gtk.c14
-rw-r--r--src/xsane-batch-scan.c14
-rw-r--r--src/xsane-device-preferences.c10
-rw-r--r--src/xsane-email-project.c38
-rw-r--r--src/xsane-fax-project.c32
-rw-r--r--src/xsane-front-gtk.c30
-rw-r--r--src/xsane-gamma.c4
-rw-r--r--src/xsane-multipage-project.c74
-rw-r--r--src/xsane-preview.c24
-rw-r--r--src/xsane-save.c90
-rw-r--r--src/xsane-scan.c38
-rw-r--r--src/xsane-setup.c6
-rw-r--r--src/xsane-viewer.c48
-rw-r--r--src/xsane.c237
-rw-r--r--src/xsane.h10
15 files changed, 337 insertions, 332 deletions
diff --git a/src/xsane-back-gtk.c b/src/xsane-back-gtk.c
index 6599c98..10ac0b3 100644
--- a/src/xsane-back-gtk.c
+++ b/src/xsane-back-gtk.c
@@ -406,7 +406,7 @@ int xsane_back_gtk_make_path(size_t buf_size, char *buf, const char *prog_name,
if (location == XSANE_PATH_TMP) /* tmp dir, add uid */
{
- char tmpbuf[256];
+ char tmpbuf[TEXTBUFSIZE];
uid_t uid;
int fd;
@@ -469,7 +469,7 @@ void xsane_back_gtk_set_option(int opt_num, void *val, SANE_Action action)
{
SANE_Status status;
SANE_Int info;
- char buf[256];
+ char buf[TEXTBUFSIZE];
int old_colors = xsane.xsane_colors;
int update_gamma = FALSE;
@@ -789,12 +789,12 @@ gint xsane_back_gtk_decision(gchar *title, gchar **xpm_d, gchar *message, gchar
void xsane_back_gtk_ipc_dialog_callback(gpointer data, gint source, GdkInputCondition cond)
{
- char message[256];
+ char message[TEXTBUFSIZE];
size_t bytes;
DBG(DBG_proc, "xsane_back_gtk_message\n");
- bytes = read(xsane.ipc_pipefd[0], message, 255);
+ bytes = read(xsane.ipc_pipefd[0], message, sizeof(message)-1);
message[bytes] = 0;
xsane_back_gtk_decision(ERR_HEADER_CHILD_PROCESS_ERROR, (gchar **) error_xpm, message, BUTTON_CLOSE, 0 /* no reject text */, FALSE);
@@ -877,7 +877,7 @@ char *fileselection_filetype = NULL;
static void xsane_back_gtk_filetype_callback(GtkWidget *widget, gpointer data)
{
char *extension, *filename;
- char buffer[256];
+ char buffer[PATH_MAX];
char *new_filetype = (char *) data;
DBG(DBG_proc, "xsane_filetype_callback\n");
@@ -1302,7 +1302,7 @@ static gint xsane_back_gtk_autobutton_update(GtkWidget *widget, DialogElement *e
const SANE_Option_Descriptor *opt;
SANE_Status status;
SANE_Word val;
- char buf[256];
+ char buf[TEXTBUFSIZE];
DBG(DBG_proc, "xsane_back_gtk_autobutton_update\n");
@@ -1466,7 +1466,7 @@ static void xsane_back_gtk_value_update(GtkAdjustment *adj_data, DialogElement *
static void xsane_back_gtk_range_display_value_right_callback(GtkAdjustment *adjust, gpointer data)
{
- gchar buf[256];
+ gchar buf[TEXTBUFSIZE];
int digits = (int) data;
GtkLabel *label;
diff --git a/src/xsane-batch-scan.c b/src/xsane-batch-scan.c
index a356612..604e052 100644
--- a/src/xsane-batch-scan.c
+++ b/src/xsane-batch-scan.c
@@ -81,7 +81,7 @@ desc[] =
static void xsane_batch_scan_get_parameters(Batch_Scan_Parameters *parameters)
{
- char buf[255];
+ char buf[TEXTBUFSIZE];
SANE_Int unit;
DBG(DBG_proc, "xsane_batch_scan_get_parameters\n");
@@ -336,7 +336,7 @@ int xsane_batch_scan_load_list_from_file(char *filename)
static void xsane_batch_scan_load_list(void)
{
char filename[PATH_MAX];
- char windowname[256];
+ char windowname[TEXTBUFSIZE];
DBG(DBG_proc, "xsane_batch_scan_load_list\n");
@@ -349,7 +349,7 @@ static void xsane_batch_scan_load_list(void)
{
if (xsane_batch_scan_load_list_from_file(filename)) /* error while loading file ? */
{
- char buf[256];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s `%s': %s", ERR_OPEN_FAILED, filename, strerror(errno));
xsane_back_gtk_error(buf, TRUE);
@@ -387,7 +387,7 @@ static void xsane_batch_scan_save_list(void)
int fd;
Wire w;
char filename[PATH_MAX];
- char windowname[256];
+ char windowname[TEXTBUFSIZE];
DBG(DBG_proc, "xsane_batch_scan_save_list\n");
@@ -429,7 +429,7 @@ static void xsane_batch_scan_save_list(void)
}
else
{
- char buf[256];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s `%s': %s", ERR_OPEN_FAILED, filename, strerror(errno));
xsane_back_gtk_error(buf, TRUE);
@@ -599,7 +599,7 @@ static void xsane_batch_scan_delete(void)
static void xsane_batch_scan_update_label(Batch_Scan_Parameters *parameters)
{
- char buf[256];
+ char buf[TEXTBUFSIZE];
const char *unit_str;
double tl_x = parameters->tl_x;
double tl_y = parameters->tl_y;
@@ -847,7 +847,7 @@ static void xsane_batch_scan_rename_callback(GtkWidget *widget, gpointer data)
GtkWidget *text;
GtkWidget *button;
GtkWidget *vbox, *hbox;
- char buf[256];
+ char buf[TEXTBUFSIZE];
DBG(DBG_proc, "xsane_batch_scan_rename\n");
diff --git a/src/xsane-device-preferences.c b/src/xsane-device-preferences.c
index 57c5ae8..003cb77 100644
--- a/src/xsane-device-preferences.c
+++ b/src/xsane-device-preferences.c
@@ -366,7 +366,7 @@ static int xsane_device_preferences_save_values(Wire *w, SANE_Handle device)
void xsane_device_preferences_load_file(char *filename)
{
int fd;
- char buf[256];
+ char buf[TEXTBUFSIZE];
#if 0
char *version = 0;
#endif
@@ -461,7 +461,7 @@ void xsane_device_preferences_load_file(char *filename)
if (w.status)
{
- char buf[256];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s\n%s %s", ERR_LOAD_DEVICE_SETTINGS, filename, ERR_NO_DRC_FILE);
xsane_back_gtk_error(buf, TRUE);
@@ -612,7 +612,7 @@ void xsane_device_preferences_restore(void)
void xsane_device_preferences_load(void)
{
char filename[PATH_MAX];
- char windowname[256];
+ char windowname[TEXTBUFSIZE];
DBG(DBG_proc, "xsane_device_preferences_load\n");
@@ -649,7 +649,7 @@ void xsane_device_preferences_save_file(char *filename)
fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0666);
if (fd < 0)
{
- char buf[256];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s %s.", ERR_FAILED_CREATE_FILE, strerror(errno));
xsane_back_gtk_error(buf, TRUE);
@@ -763,7 +763,7 @@ void xsane_device_preferences_store(void)
void xsane_device_preferences_save(void)
{
char filename[PATH_MAX];
- char windowname[256];
+ char windowname[TEXTBUFSIZE];
DBG(DBG_proc, "xsane_device_preferences_save\n");
diff --git a/src/xsane-email-project.c b/src/xsane-email-project.c
index 67713ec..79df15b 100644
--- a/src/xsane-email-project.c
+++ b/src/xsane-email-project.c
@@ -489,7 +489,7 @@ static void xsane_email_project_set_sensitive(int sensitive)
static void xsane_email_project_display_status()
{
FILE *lockfile;
- char buf[256];
+ char buf[TEXTBUFSIZE];
char filename[PATH_MAX];
int val;
int i, c;
@@ -606,10 +606,10 @@ static gint xsane_email_send_timer_callback(gpointer data)
static void xsane_email_project_load()
{
FILE *projectfile;
- char page[256];
+ char page[TEXTBUFSIZE];
char *type;
char *extension;
- char buf[256];
+ char buf[TEXTBUFSIZE];
char filename[PATH_MAX];
GtkWidget *list_item;
int i;
@@ -858,7 +858,7 @@ static void xsane_email_project_delete()
{
char *page;
char *type;
- char file[256];
+ char file[PATH_MAX];
GList *list = (GList *) GTK_LIST(xsane.project_list)->children;
GtkObject *list_item;
@@ -890,7 +890,7 @@ static void xsane_email_project_update_project_status()
{
FILE *projectfile;
char filename[PATH_MAX];
- char buf[256];
+ char buf[TEXTBUFSIZE];
snprintf(filename, sizeof(filename), "%s/xsane-mail-list", preferences.email_project);
projectfile = fopen(filename, "r+b"); /* r+ = read and write, position = start of file */
@@ -911,7 +911,7 @@ void xsane_email_project_save()
char *page;
char *type;
gchar *email_text;
- char filename[256];
+ char filename[PATH_MAX];
DBG(DBG_proc, "xsane_email_project_save\n");
@@ -922,7 +922,7 @@ void xsane_email_project_save()
if (xsane_create_secure_file(filename)) /* remove possibly existing symbolic links for security */
{
- char buf[256];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s %s %s\n", ERR_DURING_SAVE, ERR_CREATE_SECURE_FILE, filename);
xsane_back_gtk_error(buf, TRUE);
@@ -933,7 +933,7 @@ void xsane_email_project_save()
if (xsane.email_status)
{
- char buf[256];
+ char buf[TEXTBUFSIZE];
snprintf(buf, 32, "%s@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@", xsane.email_status); /* fill 32 characters status line */
fprintf(projectfile, "%s\n", buf); /* first line is status of email */
@@ -1224,8 +1224,8 @@ static void xsane_email_entry_rename_callback(GtkWidget *widget, gpointer list)
char *oldpage;
char *newpage;
char *type;
- char oldfile[256];
- char newfile[256];
+ char oldfile[PATH_MAX];
+ char newfile[PATH_MAX];
DBG(DBG_proc, "xsane_email_entry_rename_callback\n");
@@ -1344,7 +1344,7 @@ static void xsane_email_entry_delete_callback(GtkWidget *widget, gpointer list)
GList *select;
char *page;
char *type;
- char file[256];
+ char file[PATH_MAX];
DBG(DBG_proc, "xsane_email_entry_delete_callback\n");
@@ -1378,7 +1378,7 @@ static void xsane_email_show_callback(GtkWidget *widget, gpointer list)
GList *select;
char *page;
char *type;
- char filename[256];
+ char filename[PATH_MAX];
DBG(DBG_proc, "xsane_email_entry_show_callback\n");
@@ -1406,8 +1406,8 @@ static void xsane_email_edit_callback(GtkWidget *widget, gpointer list)
GList *select;
char *page;
char *type;
- char filename[256];
- char outfilename[256];
+ char filename[PATH_MAX];
+ char outfilename[PATH_MAX];
Image_info image_info;
int cancel_save = 0;
@@ -1447,10 +1447,10 @@ static void xsane_create_email(int fd)
char *email_text_pos = NULL;
char **attachment_filename = NULL;
char *mime_type = NULL;
- char buf[256];
- char filename[256];
- char content_id[256];
- char image[256];
+ char buf[TEXTBUFSIZE];
+ char filename[PATH_MAX];
+ char content_id[TEXTBUFSIZE];
+ char image[TEXTBUFSIZE];
int i, j;
int c;
int attachments = 0;
@@ -1536,7 +1536,7 @@ static void xsane_create_email(int fd)
if (strcmp("mailtext:", image) && (c > 1))
{
- char imagename[256];
+ char imagename[PATH_MAX];
char *filename;
char *extension;
diff --git a/src/xsane-fax-project.c b/src/xsane-fax-project.c
index 0d0e4dc..8f23bf2 100644
--- a/src/xsane-fax-project.c
+++ b/src/xsane-fax-project.c
@@ -277,7 +277,7 @@ void xsane_fax_dialog()
static void xsane_fax_project_load()
{
FILE *projectfile;
- char page[256];
+ char page[TEXTBUFSIZE];
char filename[PATH_MAX];
GtkWidget *list_item;
int i;
@@ -417,7 +417,7 @@ static void xsane_fax_project_load()
static void xsane_fax_project_delete()
{
char *page;
- char file[256];
+ char file[PATH_MAX];
GList *list = (GList *) GTK_LIST(xsane.project_list)->children;
GtkObject *list_item;
@@ -447,7 +447,7 @@ static void xsane_fax_project_update_project_status()
{
FILE *projectfile;
char filename[PATH_MAX];
- char buf[256];
+ char buf[TEXTBUFSIZE];
snprintf(filename, sizeof(filename), "%s/xsane-fax-list", preferences.fax_project);
projectfile = fopen(filename, "r+b"); /* r+ = read and write, position = start of file */
@@ -465,7 +465,7 @@ void xsane_fax_project_save()
FILE *projectfile;
char *page;
char *type;
- char filename[256];
+ char filename[PATH_MAX];
GList *list = (GList *) GTK_LIST(xsane.project_list)->children;
GtkObject *list_item;
@@ -479,7 +479,7 @@ void xsane_fax_project_save()
if (xsane_create_secure_file(filename)) /* remove possibly existing symbolic links for security
*/
{
- char buf[256];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s %s %s\n", ERR_DURING_SAVE, ERR_CREATE_SECURE_FILE, filename);
xsane_back_gtk_error(buf, TRUE);
@@ -496,7 +496,7 @@ void xsane_fax_project_save()
if (xsane.fax_status)
{
- char buf[256];
+ char buf[TEXTBUFSIZE];
snprintf(buf, 32, "%s@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@", xsane.fax_status); /* fill 32 characters status line */
fprintf(projectfile, "%s\n", buf); /* first line is status of mail */
@@ -708,8 +708,8 @@ static void xsane_fax_entry_rename_callback(GtkWidget *widget, gpointer list)
char *oldpage;
char *newpage;
char *type;
- char oldfile[256];
- char newfile[256];
+ char oldfile[PATH_MAX];
+ char newfile[PATH_MAX];
DBG(DBG_proc, "xsane_fax_entry_rename_callback\n");
@@ -822,7 +822,7 @@ static void xsane_fax_entry_insert_callback(GtkWidget *widget, gpointer list)
{
GtkWidget *list_item;
char filename[PATH_MAX];
- char windowname[255];
+ char windowname[TEXTBUFSIZE];
DBG(DBG_proc, "xsane_fax_entry_insert_callback\n");
@@ -917,7 +917,7 @@ static void xsane_fax_entry_insert_callback(GtkWidget *widget, gpointer list)
}
else
{
- char buf[256];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), ERR_FILE_NOT_EXISTS, filename);
xsane_back_gtk_decision(ERR_HEADER_ERROR, (gchar **) error_xpm, buf, BUTTON_OK, NULL, TRUE /* wait */);
}
@@ -964,7 +964,7 @@ static void xsane_fax_show_callback(GtkWidget *widget, gpointer list)
GList *select;
char *page;
char *type;
- char filename[256];
+ char filename[PATH_MAX];
DBG(DBG_proc, "xsane_fax_entry_show_callback\n");
@@ -1042,7 +1042,7 @@ static int xsane_fax_convert_pnm_to_ps(char *source_filename, char *fax_filename
FILE *outfile;
FILE *infile;
Image_info image_info;
- char buf[256];
+ char buf[TEXTBUFSIZE];
int cancel_save;
/* open progressbar */
@@ -1089,7 +1089,7 @@ static int xsane_fax_convert_pnm_to_ps(char *source_filename, char *fax_filename
}
else
{
- char buf[256];
+ char buf[TEXTBUFSIZE];
DBG(DBG_info, "open of faxfile `%s'failed : %s\n", fax_filename, strerror(errno));
@@ -1101,7 +1101,7 @@ static int xsane_fax_convert_pnm_to_ps(char *source_filename, char *fax_filename
}
else
{
- char buf[256];
+ char buf[TEXTBUFSIZE];
DBG(DBG_info, "open of faxfile `%s'failed : %s\n", source_filename, strerror(errno));
@@ -1132,7 +1132,7 @@ static void xsane_fax_send()
GtkObject *list_item;
pid_t pid;
char *arg[1000];
- char buf[256];
+ char buf[TEXTBUFSIZE];
char source_filename[PATH_MAX];
char fax_filename[PATH_MAX];
int argnr = 0;
@@ -1190,7 +1190,7 @@ static void xsane_fax_send()
snprintf(fax_filename, sizeof(fax_filename), "%s/%s-fax%s", preferences.fax_project, page, fax_type);
if (xsane_create_secure_file(fax_filename)) /* remove possibly existing symbolic links for security */
{
- char buf[256];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s %s %s\n", ERR_DURING_SAVE, ERR_CREATE_SECURE_FILE, fax_filename);
xsane_back_gtk_error(buf, TRUE);
diff --git a/src/xsane-front-gtk.c b/src/xsane-front-gtk.c
index 4eb4add..a11779e 100644
--- a/src/xsane-front-gtk.c
+++ b/src/xsane-front-gtk.c
@@ -93,7 +93,7 @@ int xsane_parse_options(char *options, char *argv[])
int optpos = 0;
int bufpos = 0;
int arg = 0;
- char buf[256];
+ char buf[TEXTBUFSIZE];
DBG(DBG_proc, "xsane_parse_options\n");
@@ -171,11 +171,11 @@ void xsane_get_bounds(const SANE_Option_Descriptor *opt, double *minp, double *m
{
if (min > -INF && min < INF)
{
- min = SANE_UNFIX (min);
+ min = SANE_UNFIX(min);
}
if (max > -INF && max < INF)
{
- max = SANE_UNFIX (max);
+ max = SANE_UNFIX(max);
}
}
*minp = min;
@@ -397,10 +397,6 @@ void xsane_set_all_resolutions(void)
printer_resolution = preferences.printer[preferences.printernr]->color_resolution;
break;
}
-
- xsane.zoom = xsane.resolution / printer_resolution;
- xsane.zoom_x = xsane.resolution_x / printer_resolution;
- xsane.zoom_y = xsane.resolution_y / printer_resolution;
}
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -433,15 +429,15 @@ void xsane_define_maximum_output_size()
if (preferences.paper_orientation >= 8) /* rotate: landscape */
{
preview_set_maximum_output_size(xsane.preview,
- preferences.printer[preferences.printernr]->height / xsane.zoom_y,
- preferences.printer[preferences.printernr]->width / xsane.zoom_x,
+ preferences.printer[preferences.printernr]->height / xsane.zoom,
+ preferences.printer[preferences.printernr]->width / xsane.zoom,
preferences.paper_orientation);
}
else /* do not rotate: portrait */
{
preview_set_maximum_output_size(xsane.preview,
- preferences.printer[preferences.printernr]->width / xsane.zoom_x,
- preferences.printer[preferences.printernr]->height / xsane.zoom_y,
+ preferences.printer[preferences.printernr]->width / xsane.zoom,
+ preferences.printer[preferences.printernr]->height / xsane.zoom,
preferences.paper_orientation);
}
break;
@@ -1062,7 +1058,7 @@ void xsane_option_menu_new_with_pixmap(GdkWindow *window, GtkBox *parent, const
static void xsane_range_display_value_right_callback(GtkAdjustment *adjust, gpointer data)
{
- gchar buf[256];
+ gchar buf[TEXTBUFSIZE];
int digits = (int) data;
GtkLabel *label;
@@ -1264,8 +1260,8 @@ void xsane_range_new_with_pixmap(GdkWindow *window, GtkBox *parent, const char *
static void xsane_browse_filename_callback(GtkWidget *widget, gpointer data)
{
- char filename[1024];
- char windowname[256];
+ char filename[PATH_MAX];
+ char windowname[TEXTBUFSIZE];
DBG(DBG_proc, "xsane_browse_filename_callback\n");
@@ -1792,7 +1788,7 @@ int xsane_identify_output_format(char *filename, char *filetype, char **ext)
void xsane_change_working_directory(void)
{
char filename[PATH_MAX];
- char windowname[256];
+ char windowname[TEXTBUFSIZE];
DBG(DBG_proc, "xsane_change_working_directory\n");
@@ -1804,7 +1800,7 @@ void xsane_change_working_directory(void)
xsane_back_gtk_get_filename(windowname, filename, sizeof(filename), filename, NULL, TRUE, FALSE, TRUE, FALSE);
if (chdir(filename))
{
- char buf[256];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s %s (%s).", ERR_CHANGE_WORKING_DIR, filename, strerror(errno));
xsane_back_gtk_error(buf, TRUE);
@@ -2362,7 +2358,7 @@ int xsane_front_gtk_getname_dialog(const char *dialog_title, const char *desc_te
GtkWidget *button;
GtkWidget *vbox, *hbox;
GtkAccelGroup *accelerator_group;
- char buf[256];
+ char buf[TEXTBUFSIZE];
DBG(DBG_proc, "xsane_getname_dialog, oldname = %s\n", oldname);
diff --git a/src/xsane-gamma.c b/src/xsane-gamma.c
index fdae222..40fe835 100644
--- a/src/xsane-gamma.c
+++ b/src/xsane-gamma.c
@@ -2173,7 +2173,7 @@ static gint xsane_histogram_win_delete(GtkWidget *widget, gpointer data)
void xsane_create_histogram_dialog(const char *devicetext)
{
- char windowname[255];
+ char windowname[TEXTBUFSIZE];
GtkWidget *xsane_color_hbox;
GtkWidget *xsane_histogram_vbox;
GtkWidget *button;
@@ -2498,7 +2498,7 @@ GtkWidget* xsane_gamma_curve_notebook_page_new(GtkWidget *notebook, char *title)
void xsane_create_gamma_dialog(const char *devicetext)
{
- char windowname[255];
+ char windowname[TEXTBUFSIZE];
GtkWidget *xsane_vbox_gamma, *notebook;
DBG(DBG_proc, "xsane_create_free_gamma_dialog\n");
diff --git a/src/xsane-multipage-project.c b/src/xsane-multipage-project.c
index 5a6f1ab..20a1cc3 100644
--- a/src/xsane-multipage-project.c
+++ b/src/xsane-multipage-project.c
@@ -324,7 +324,7 @@ static void xsane_multipage_project_set_sensitive(int sensitive)
static void xsane_multipage_project_load()
{
FILE *projectfile;
- char page[256];
+ char page[TEXTBUFSIZE];
char filename[PATH_MAX];
GtkWidget *list_item;
int i;
@@ -467,7 +467,7 @@ static void xsane_multipage_project_delete()
{
char *page;
char *type;
- char file[256];
+ char file[PATH_MAX];
GList *list = (GList *) GTK_LIST(xsane.project_list)->children;
GtkObject *list_item;
@@ -502,7 +502,7 @@ void xsane_multipage_project_save()
GtkObject *list_item;
char *page;
char *type;
- char filename[256];
+ char filename[PATH_MAX];
DBG(DBG_proc, "xsane_multipage_project_save\n");
@@ -513,7 +513,7 @@ void xsane_multipage_project_save()
if (xsane_create_secure_file(filename)) /* remove possibly existing symbolic links for security */
{
- char buf[256];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s %s %s\n", ERR_DURING_SAVE, ERR_CREATE_SECURE_FILE, filename);
xsane_back_gtk_error(buf, TRUE);
@@ -524,7 +524,7 @@ void xsane_multipage_project_save()
if (xsane.multipage_status)
{
- char buf[256];
+ char buf[TEXTBUFSIZE];
snprintf(buf, 32, "%s@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@", xsane.multipage_status); /* fill 32 characters status line */
fprintf(projectfile, "%s\n", buf); /* first line is status of multipage */
@@ -694,7 +694,7 @@ static void xsane_multipage_entry_delete_callback(GtkWidget *widget, gpointer li
GList *select;
char *page;
char *type;
- char file[256];
+ char file[PATH_MAX];
DBG(DBG_proc, "xsane_multipage_entry_delete_callback\n");
@@ -728,7 +728,7 @@ static void xsane_multipage_show_callback(GtkWidget *widget, gpointer list)
GList *select;
char *page;
char *type;
- char filename[256];
+ char filename[PATH_MAX];
DBG(DBG_proc, "xsane_multipage_entry_show_callback\n");
@@ -805,8 +805,9 @@ static void xsane_multipage_save_file()
Image_info image_info;
long int source_size = 0;
float imagewidth, imageheight;
- char buf[255];
+ char buf[TEXTBUFSIZE];
struct pdf_xref xref;
+ int remove_lineart_file = FALSE;
DBG(DBG_proc, "xsane_multipage_save_file\n");
@@ -854,7 +855,7 @@ static void xsane_multipage_save_file()
testfile = fopen(multipage_filename, "rb"); /* read binary (b for win32) */
if (testfile) /* filename used: skip */
{
- char buf[256];
+ char buf[TEXTBUFSIZE];
fclose(testfile);
@@ -972,9 +973,6 @@ static void xsane_multipage_save_file()
xsane_convert_text_to_filename(&image);
snprintf(source_filename, sizeof(source_filename), "%s/%s%s", preferences.multipage_project, image, type);
- snprintf(buf, sizeof(buf), "%s %s %d/%d", _(xsane.multipage_status), PROGRESS_PAGE, page, pages);
- gtk_progress_set_format_string(GTK_PROGRESS(xsane.project_progress_bar), buf);
-
imagefile = fopen(source_filename, "rb"); /* read binary (b for win32) */
if (!imagefile)
{
@@ -984,6 +982,48 @@ static void xsane_multipage_save_file()
xsane_read_pnm_header(imagefile, &image_info);
+ /* reduce lineart images to lineart before conversion */
+ if (image_info.reduce_to_lineart)
+ {
+ char lineart_filename[PATH_MAX];
+
+ DBG(DBG_info, "original image is a lineart => reduce to lineart\n");
+ fclose(imagefile);
+ xsane_back_gtk_make_path(sizeof(lineart_filename), lineart_filename, 0, 0, "xsane-conversion-", xsane.dev_name, ".pbm", XSANE_PATH_TMP);
+
+ snprintf(buf, sizeof(buf), "%s", PROGRESS_PACKING_DATA);
+
+ gtk_progress_set_format_string(GTK_PROGRESS(xsane.project_progress_bar), buf);
+ gtk_progress_bar_update(GTK_PROGRESS_BAR(xsane.project_progress_bar), 0.0);
+
+ while (gtk_events_pending())
+ {
+ gtk_main_iteration();
+ }
+
+ xsane_save_image_as_lineart(lineart_filename, source_filename, xsane.project_progress_bar, &cancel_save);
+
+ strncpy(source_filename, lineart_filename, sizeof(source_filename));
+ remove_lineart_file = TRUE;
+
+ imagefile = fopen(source_filename, "rb"); /* read binary (b for win32) */
+ if (imagefile == 0)
+ {
+ char buf[TEXTBUFSIZE];
+ snprintf(buf, sizeof(buf), "%s `%s': %s", ERR_OPEN_FAILED, source_filename, strerror(errno));
+ xsane_back_gtk_error(buf, TRUE);
+
+ return;
+ }
+
+ xsane_read_pnm_header(imagefile, &image_info);
+ }
+
+
+ snprintf(buf, sizeof(buf), "%s %s %d/%d", _(xsane.multipage_status), PROGRESS_PAGE, page, pages);
+ gtk_progress_set_format_string(GTK_PROGRESS(xsane.project_progress_bar), buf);
+
+
if (output_format == XSANE_PS)
{
imagewidth = 72.0 * image_info.image_width/image_info.resolution_x; /* width in 1/72 inch */
@@ -1014,6 +1054,11 @@ static void xsane_multipage_save_file()
}
#endif
+ if (remove_lineart_file)
+ {
+ remove(source_filename); /* remove lineart pbm file */
+ }
+
free(image);
free(type);
list = list->next;
@@ -1027,7 +1072,7 @@ static void xsane_multipage_save_file()
if (ferror(outfile))
{
- char buf[255];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s %s", ERR_DURING_SAVE, strerror(errno));
DBG(DBG_error, "%s\n", buf);
@@ -1043,7 +1088,7 @@ static void xsane_multipage_save_file()
if (ferror(outfile))
{
- char buf[255];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s %s", ERR_DURING_SAVE, strerror(errno));
DBG(DBG_error, "%s\n", buf);
@@ -1076,7 +1121,6 @@ static void xsane_multipage_save_file()
}
xsane_multipage_project_save();
-
gtk_progress_set_format_string(GTK_PROGRESS(xsane.project_progress_bar), _(xsane.multipage_status));
gtk_progress_bar_update(GTK_PROGRESS_BAR(xsane.project_progress_bar), 0.0);
diff --git a/src/xsane-preview.c b/src/xsane-preview.c
index b59ef1b..46d8611 100644
--- a/src/xsane-preview.c
+++ b/src/xsane-preview.c
@@ -1317,7 +1317,7 @@ static void preview_restore_option(Preview *p, int option, void *saved_value, in
if (status != SANE_STATUS_GOOD)
{
- char buf[256];
+ char buf[TEXTBUFSIZE];
opt = xsane_get_option_descriptor(dev, option);
if (opt && opt->name)
{
@@ -1400,7 +1400,7 @@ static int preview_test_image_y(Preview *p)
{
if (p->image_y >= p->image_height) /* make sure backend does not send more data then expected */
{
- char buf[256];
+ char buf[TEXTBUFSIZE];
--p->image_y;
preview_scan_done(p, 1);
@@ -1417,7 +1417,7 @@ static int preview_test_image_y(Preview *p)
static int preview_increment_image_y(Preview *p)
{
size_t extra_size, offset;
- char buf[256];
+ char buf[TEXTBUFSIZE];
DBG(DBG_proc, "preview_increment_image_y\n");
@@ -1894,7 +1894,7 @@ static void preview_scan_done(Preview *p, int save_image)
static int preview_get_memory(Preview *p)
{
- char buf[256];
+ char buf[TEXTBUFSIZE];
DBG(DBG_proc, "preview_get_memory\n");
@@ -1960,7 +1960,7 @@ static void preview_scan_start(Preview *p)
{
SANE_Handle dev = xsane.dev;
SANE_Status status;
- char buf[256];
+ char buf[TEXTBUFSIZE];
int fd, y;
DBG(DBG_proc, "preview_scan_start\n");
@@ -2065,7 +2065,7 @@ static void preview_scan_start(Preview *p)
static int preview_make_image_path(Preview *p, size_t filename_size, char *filename, int level)
{
- char buf[256];
+ char buf[TEXTBUFSIZE];
DBG(DBG_proc, "preview_make_image_path\n");
@@ -2085,7 +2085,7 @@ int preview_create_batch_icon_from_file(Preview *p, FILE *in, Batch_Scan_Paramet
int time;
float psurface[4];
float dsurface[4];
- char buf[255];
+ char buf[TEXTBUFSIZE];
float scale;
int header = 0;
int rotate16 = 16 - preview_gamma_input_bits;
@@ -2456,7 +2456,7 @@ static int preview_restore_image_from_file(Preview *p, FILE *in, int min_quality
size_t nread;
guint16 *imagep;
guint16 *imagepx;
- char buf[255];
+ char buf[TEXTBUFSIZE];
DBG(DBG_proc, "preview_restore_image_from_file\n");
@@ -2959,7 +2959,7 @@ static void preview_display_zoom(Preview *p, int x, int y, int zoom)
static void preview_display_color_components(Preview *p, int x, int y)
{
- char buffer[256];
+ char buffer[TEXTBUFSIZE];
int raw_red, raw_green, raw_blue, enh_red, enh_green, enh_blue;
if (! preview_get_pixel_color(p, x, y, &raw_red, &raw_green, &raw_blue, &enh_red, &enh_green, &enh_blue))
@@ -4189,7 +4189,7 @@ Preview *preview_new(void)
GtkWidget *pixmapwidget;
Preview *p;
int i;
- char buf[256];
+ char buf[TEXTBUFSIZE];
int ratio_nr = 0;
DBG(DBG_proc, "preview_new\n");
@@ -5730,7 +5730,7 @@ static gint preview_preset_area_add_callback(GtkWidget *widget, GtkWidget *prese
int selection, i, old_selection = 0;
Preview *p;
float coord[4];
- char suggested_name[256];
+ char suggested_name[PATH_MAX];
char *newname;
GtkWidget *old_preset_area_menu;
@@ -5925,7 +5925,7 @@ static gint preview_preset_area_context_menu_callback(GtkWidget *widget, GdkEven
GtkWidget *menu_item;
GdkEventButton *event_button;
int selection;
- char buf[256];
+ char buf[TEXTBUFSIZE];
DBG(DBG_proc, "preview_preset_area_context_menu_callback\n");
diff --git a/src/xsane-save.c b/src/xsane-save.c
index 9c3784b..a56e2ce 100644
--- a/src/xsane-save.c
+++ b/src/xsane-save.c
@@ -163,7 +163,7 @@ void xsane_convert_text_to_filename(char **text)
if (text)
{
char *filename = *text;
- char buf[256];
+ char buf[TEXTBUFSIZE];
int buflen=0;
int txtlen=0;
@@ -418,7 +418,7 @@ void xsane_update_counter_in_filename(char **filename, int skip, int step, int m
void xsane_read_pnm_header(FILE *file, Image_info *image_info)
{
int max_val, filetype_nr;
- char buf[256];
+ char buf[TEXTBUFSIZE];
fgets(buf, sizeof(buf)-1, file);
DBG(DBG_info, "filetype header :%s", buf);
@@ -703,7 +703,7 @@ int xsane_copy_file(FILE *outfile, FILE *infile, GtkProgressBar *progress_bar, i
if (ferror(infile))
{
- char buf[255];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s %s", ERR_DURING_READ, strerror(errno));
DBG(DBG_error, "%s\n", buf);
@@ -714,7 +714,7 @@ int xsane_copy_file(FILE *outfile, FILE *infile, GtkProgressBar *progress_bar, i
if (ferror(outfile))
{
- char buf[255];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s %s", ERR_DURING_SAVE, strerror(errno));
DBG(DBG_error, "%s\n", buf);
@@ -756,7 +756,7 @@ int xsane_copy_file_by_name(char *output_filename, char *input_filename, GtkProg
if (outfile == 0)
{
- char buf[255];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s `%s': %s", ERR_OPEN_FAILED, output_filename, strerror(errno));
xsane_back_gtk_error(buf, TRUE);
@@ -766,7 +766,7 @@ int xsane_copy_file_by_name(char *output_filename, char *input_filename, GtkProg
infile = fopen(input_filename, "rb"); /* read binary (b for win32) */
if (infile == 0)
{
- char buf[256];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s `%s': %s", ERR_OPEN_FAILED, input_filename, strerror(errno));
xsane_back_gtk_error(buf, TRUE);
@@ -839,7 +839,7 @@ int xsane_save_grayscale_image_as_lineart(FILE *outfile, FILE *imagefile, Image_
if (ferror(outfile))
{
- char buf[255];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s %s", ERR_DURING_SAVE, strerror(errno));
DBG(DBG_error, "%s\n", buf);
@@ -1042,7 +1042,7 @@ int xsane_save_scaled_image(FILE *outfile, FILE *imagefile, Image_info *image_in
if (ferror(outfile))
{
- char buf[255];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s %s", ERR_DURING_SAVE, strerror(errno));
DBG(DBG_error, "%s\n", buf);
@@ -1352,7 +1352,7 @@ int xsane_save_despeckle_image(FILE *outfile, FILE *imagefile, Image_info *image
if (ferror(outfile))
{
- char buf[255];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s %s", ERR_DURING_SAVE, strerror(errno));
DBG(DBG_error, "%s\n", buf);
@@ -1568,7 +1568,7 @@ int xsane_save_blur_image(FILE *outfile, FILE *imagefile, Image_info *image_info
if (ferror(outfile))
{
- char buf[255];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s %s", ERR_DURING_SAVE, strerror(errno));
DBG(DBG_error, "%s\n", buf);
@@ -1799,7 +1799,7 @@ int xsane_save_rotate_image(FILE *outfile, FILE *imagefile, Image_info *image_in
if (ferror(outfile))
{
- char buf[255];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s %s", ERR_DURING_SAVE, strerror(errno));
DBG(DBG_error, "%s\n", buf);
@@ -1858,7 +1858,7 @@ int xsane_save_rotate_image(FILE *outfile, FILE *imagefile, Image_info *image_in
if (ferror(outfile))
{
- char buf[255];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s %s", ERR_DURING_SAVE, strerror(errno));
DBG(DBG_error, "%s\n", buf);
@@ -1912,7 +1912,7 @@ int xsane_save_rotate_image(FILE *outfile, FILE *imagefile, Image_info *image_in
if (ferror(outfile))
{
- char buf[255];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s %s", ERR_DURING_SAVE, strerror(errno));
DBG(DBG_error, "%s\n", buf);
@@ -1971,7 +1971,7 @@ int xsane_save_rotate_image(FILE *outfile, FILE *imagefile, Image_info *image_in
if (ferror(outfile))
{
- char buf[255];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s %s", ERR_DURING_SAVE, strerror(errno));
DBG(DBG_error, "%s\n", buf);
@@ -2024,7 +2024,7 @@ int xsane_save_rotate_image(FILE *outfile, FILE *imagefile, Image_info *image_in
if (ferror(outfile))
{
- char buf[255];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s %s", ERR_DURING_SAVE, strerror(errno));
DBG(DBG_error, "%s\n", buf);
@@ -2083,7 +2083,7 @@ int xsane_save_rotate_image(FILE *outfile, FILE *imagefile, Image_info *image_in
if (ferror(outfile))
{
- char buf[255];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s %s", ERR_DURING_SAVE, strerror(errno));
DBG(DBG_error, "%s\n", buf);
@@ -2137,7 +2137,7 @@ int xsane_save_rotate_image(FILE *outfile, FILE *imagefile, Image_info *image_in
if (ferror(outfile))
{
- char buf[255];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s %s", ERR_DURING_SAVE, strerror(errno));
DBG(DBG_error, "%s\n", buf);
@@ -2196,7 +2196,7 @@ int xsane_save_rotate_image(FILE *outfile, FILE *imagefile, Image_info *image_in
if (ferror(outfile))
{
- char buf[255];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s %s", ERR_DURING_SAVE, strerror(errno));
DBG(DBG_error, "%s\n", buf);
@@ -2756,7 +2756,7 @@ static int xsane_save_ps_pdf_bw(FILE *outfile, FILE *imagefile, Image_info *imag
if (line == NULL)
{
- char buf[255];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s malloc failed", ERR_DURING_SAVE);
DBG(DBG_error, "%s\n", buf);
@@ -2791,7 +2791,7 @@ static int xsane_save_ps_pdf_bw(FILE *outfile, FILE *imagefile, Image_info *imag
if ((ret != 0) || (ferror(outfile)))
{
- char buf[255];
+ char buf[TEXTBUFSIZE];
if (ret == 0)
{
@@ -2836,7 +2836,7 @@ static int xsane_save_ps_pdf_gray(FILE *outfile, FILE *imagefile, Image_info *im
if (line == NULL)
{
- char buf[255];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s malloc failed", ERR_DURING_SAVE);
DBG(DBG_error, "%s\n", buf);
@@ -2878,7 +2878,7 @@ static int xsane_save_ps_pdf_gray(FILE *outfile, FILE *imagefile, Image_info *im
if ((ret != 0) || (ferror(outfile)))
{
- char buf[255];
+ char buf[TEXTBUFSIZE];
if (ret == 0)
{
@@ -2929,7 +2929,7 @@ static int xsane_save_ps_pdf_color(FILE *outfile, FILE *imagefile, Image_info *i
if (line == NULL)
{
- char buf[255];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s malloc failed", ERR_DURING_SAVE);
DBG(DBG_error, "%s\n", buf);
@@ -2985,7 +2985,7 @@ static int xsane_save_ps_pdf_color(FILE *outfile, FILE *imagefile, Image_info *i
if ((ret != 0) || (ferror(outfile)))
{
- char buf[255];
+ char buf[TEXTBUFSIZE];
if (ret == 0)
{
@@ -3050,7 +3050,7 @@ int xsane_save_ps_page(FILE *outfile, int page,
if (ferror(outfile))
{
- char buf[255];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s %s", ERR_DURING_SAVE, strerror(errno));
DBG(DBG_error, "%s\n", buf);
@@ -3084,7 +3084,7 @@ int xsane_save_ps(FILE *outfile, FILE *imagefile, Image_info *image_info, float
if (ferror(outfile))
{
- char buf[255];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s %s", ERR_DURING_SAVE, strerror(errno));
DBG(DBG_error, "%s\n", buf);
@@ -3417,7 +3417,7 @@ int xsane_save_pdf_page(FILE *outfile, struct pdf_xref *xref, int page,
if (ferror(outfile))
{
- char buf[255];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s %s", ERR_DURING_SAVE, strerror(errno));
DBG(DBG_error, "%s\n", buf);
@@ -3453,7 +3453,7 @@ int xsane_save_pdf(FILE *outfile, FILE *imagefile, Image_info *image_info, float
if (ferror(outfile))
{
- char buf[255];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s %s", ERR_DURING_SAVE, strerror(errno));
DBG(DBG_error, "%s\n", buf);
@@ -3477,7 +3477,7 @@ typedef xsane_jpeg_error_mgr *xsane_jpeg_error_mgr_ptr;
static void xsane_jpeg_error_exit(j_common_ptr cinfo)
{
- char buf[256];
+ char buf[TEXTBUFSIZE];
/* cinfo->err points to a xsane_jpeg_error_mgr struct */
xsane_jpeg_error_mgr_ptr xsane_jpeg_error_mgr_data = (xsane_jpeg_error_mgr_ptr) cinfo->err;
@@ -3497,7 +3497,7 @@ static void xsane_jpeg_error_exit(j_common_ptr cinfo)
int xsane_save_jpeg(FILE *outfile, FILE *imagefile, Image_info *image_info, int quality, GtkProgressBar *progress_bar, int *cancel_save)
{
unsigned char *data;
- char buf[256];
+ char buf[TEXTBUFSIZE];
int components = 1;
int x,y;
int bytespp = 1;
@@ -3634,7 +3634,7 @@ int xsane_save_tiff_page(TIFF *tiffile, int page, int pages, FILE *imagefile, Im
GtkProgressBar *progress_bar, int *cancel_save)
{
char *data;
- char buf[256];
+ char buf[TEXTBUFSIZE];
int y, w;
int components;
int compression;
@@ -3764,7 +3764,7 @@ int xsane_save_tiff_page(TIFF *tiffile, int page, int pages, FILE *imagefile, Im
if (TIFFWriteScanline(tiffile, data, y, 0) != 1)
{
- char buf[255];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s", ERR_DURING_SAVE);
DBG(DBG_error, "%s\n", buf);
@@ -3800,7 +3800,7 @@ int xsane_save_png(FILE *outfile, FILE *imagefile, Image_info *image_info, int c
png_bytep row_ptr;
png_color_8 sig_bit;
unsigned char *data;
- char buf[256];
+ char buf[TEXTBUFSIZE];
int colortype, components, byte_width;
int y;
@@ -3936,7 +3936,7 @@ int xsane_save_png_16(FILE *outfile, FILE *imagefile, Image_info *image_info, in
png_bytep row_ptr;
png_color_8 sig_bit; /* should be 16, but then I get a warning about wrong type */
unsigned char *data;
- char buf[256];
+ char buf[TEXTBUFSIZE];
int colortype, components;
int x,y;
guint16 val;
@@ -4072,7 +4072,7 @@ static int xsane_save_pnm_16_ascii_gray(FILE *outfile, FILE *imagefile, Image_in
if (ferror(outfile))
{
- char buf[255];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s %s", ERR_DURING_SAVE, strerror(errno));
DBG(DBG_error, "%s\n", buf);
@@ -4132,7 +4132,7 @@ static int xsane_save_pnm_16_ascii_color(FILE *outfile, FILE *imagefile, Image_i
if (ferror(outfile))
{
- char buf[255];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s %s", ERR_DURING_SAVE, strerror(errno));
DBG(DBG_error, "%s\n", buf);
@@ -4186,7 +4186,7 @@ static int xsane_save_pnm_16_binary_gray(FILE *outfile, FILE *imagefile, Image_i
if (ferror(outfile))
{
- char buf[255];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s %s", ERR_DURING_SAVE, strerror(errno));
DBG(DBG_error, "%s\n", buf);
@@ -4244,7 +4244,7 @@ static int xsane_save_pnm_16_binary_color(FILE *outfile, FILE *imagefile, Image_
if (ferror(outfile))
{
- char buf[255];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s %s", ERR_DURING_SAVE, strerror(errno));
DBG(DBG_error, "%s\n", buf);
@@ -4306,7 +4306,7 @@ int xsane_save_image_as_lineart(char *output_filename, char *input_filename, Gtk
{
FILE *outfile;
FILE *infile;
- char buf[256];
+ char buf[TEXTBUFSIZE];
Image_info image_info;
*cancel_save = 0;
@@ -4323,7 +4323,7 @@ int xsane_save_image_as_lineart(char *output_filename, char *input_filename, Gtk
infile = fopen(input_filename, "rb"); /* read binary (b for win32) */
if (infile == 0)
{
- char buf[256];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s `%s': %s", ERR_OPEN_FAILED, input_filename, strerror(errno));
xsane_back_gtk_error(buf, TRUE);
@@ -4352,7 +4352,7 @@ int xsane_save_image_as_lineart(char *output_filename, char *input_filename, Gtk
int xsane_save_image_as_text(char *output_filename, char *input_filename, GtkProgressBar *progress_bar, int *cancel_save)
{
char *arg[1000];
- char buf[256];
+ char buf[TEXTBUFSIZE];
int argnr;
pid_t pid;
int i;
@@ -4528,7 +4528,7 @@ int xsane_save_image_as(char *output_filename, char *input_filename, int output_
{
FILE *outfile;
FILE *infile;
- char buf[256];
+ char buf[TEXTBUFSIZE];
Image_info image_info;
char lineart_filename[PATH_MAX];
int remove_input_file = FALSE;
@@ -4540,7 +4540,7 @@ int xsane_save_image_as(char *output_filename, char *input_filename, int output_
infile = fopen(input_filename, "rb"); /* read binary (b for win32) */
if (infile == 0)
{
- char buf[256];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s `%s': %s", ERR_OPEN_FAILED, input_filename, strerror(errno));
xsane_back_gtk_error(buf, TRUE);
@@ -4573,7 +4573,7 @@ int xsane_save_image_as(char *output_filename, char *input_filename, int output_
infile = fopen(input_filename, "rb"); /* read binary (b for win32) */
if (infile == 0)
{
- char buf[256];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s `%s': %s", ERR_OPEN_FAILED, input_filename, strerror(errno));
xsane_back_gtk_error(buf, TRUE);
@@ -5122,7 +5122,7 @@ int xsane_transfer_to_gimp(char *input_filename, GtkProgressBar *progress_bar, i
imagefile = fopen(input_filename, "rb"); /* read binary (b for win32) */
if (imagefile == 0)
{
- char buf[256];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s `%s': %s", ERR_OPEN_FAILED, input_filename, strerror(errno));
xsane_back_gtk_error(buf, TRUE);
diff --git a/src/xsane-scan.c b/src/xsane-scan.c
index bf054dc..578cc57 100644
--- a/src/xsane-scan.c
+++ b/src/xsane-scan.c
@@ -140,7 +140,7 @@ static void xsane_read_image_data(gpointer data, gint source, GdkInputCondition
SANE_Status status;
SANE_Int len;
int i, j;
- char buf[255];
+ char buf[TEXTBUFSIZE];
DBG(DBG_proc, "xsane_read_image_data\n");
@@ -480,7 +480,7 @@ static void xsane_read_image_data(gpointer data, gint source, GdkInputCondition
guint16 *buf16ptr;
unsigned char *buf8 = (unsigned char *) buf16;
unsigned char *buf8ptr;
- char buf[255];
+ char buf[TEXTBUFSIZE];
DBG(DBG_info, "depth = 16 bit\n");
@@ -963,7 +963,7 @@ static int xsane_reduce_to_lineart()
/* no temporary file */
if (xsane_create_secure_file(xsane.dummy_filename)) /* remove possibly existing symbolic links for security */
{
- char buf[256];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s %s %s\n", ERR_DURING_SAVE, ERR_CREATE_SECURE_FILE, xsane.dummy_filename);
xsane_back_gtk_error(buf, TRUE);
@@ -1127,7 +1127,7 @@ void xsane_scan_done(SANE_Status status)
/* no temporary file */
if (xsane_create_secure_file(xsane.dummy_filename)) /* remove possibly existing symbolic links for security */
{
- char buf[256];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s %s %s\n", ERR_DURING_SAVE, ERR_CREATE_SECURE_FILE, xsane.dummy_filename);
xsane_back_gtk_error(buf, TRUE);
@@ -1149,7 +1149,7 @@ void xsane_scan_done(SANE_Status status)
}
else
{
- char buf[256];
+ char buf[TEXTBUFSIZE];
DBG(DBG_info, "open of file `%s'failed : %s\n", xsane.dummy_filename, strerror(errno));
snprintf(buf, sizeof(buf), "%s `%s': %s", ERR_OPEN_FAILED, xsane.dummy_filename, strerror(errno));
xsane_back_gtk_error(buf, TRUE);
@@ -1167,7 +1167,7 @@ void xsane_scan_done(SANE_Status status)
}
else
{
- char buf[256];
+ char buf[TEXTBUFSIZE];
DBG(DBG_info, "open of file `%s'failed : %s\n", xsane.dummy_filename, strerror(errno));
snprintf(buf, sizeof(buf), "%s `%s': %s", ERR_OPEN_FAILED, xsane.dummy_filename, strerror(errno));
xsane_back_gtk_error(buf, TRUE);
@@ -1271,7 +1271,7 @@ void xsane_scan_done(SANE_Status status)
{
FILE *outfile;
FILE *infile;
- char buf[256];
+ char buf[TEXTBUFSIZE];
DBG(DBG_info, "XSANE_COPY\n");
@@ -1326,15 +1326,16 @@ void xsane_scan_done(SANE_Status status)
xsane_read_pnm_header(infile, &image_info);
- imagewidth = 72.0 * image_info.image_width/(float)printer_resolution; /* width in 1/72 inch */
- imageheight = 72.0 * image_info.image_height/(float)printer_resolution; /* height in 1/72 inch */
+ imagewidth = 72.0 * image_info.image_width /image_info.resolution_x * xsane.zoom; /* desired width in 1/72 inch */
+ imageheight = 72.0 * image_info.image_height/image_info.resolution_y * xsane.zoom; /* desired height in 1/72 inch */
memset (&act, 0, sizeof (act)); /* define broken pipe handler */
act.sa_handler = xsane_sigpipe_handler;
sigaction (SIGPIPE, &act, 0);
- DBG(DBG_info, "imagewidth = %f\n 1/72 inch", imagewidth);
- DBG(DBG_info, "imageheight = %f\n 1/72 inch", imageheight);
+ DBG(DBG_info, "imagewidth = %f 1/72 inch\n", imagewidth);
+ DBG(DBG_info, "imageheight = %f 1/72 inch\n", imageheight);
+ DBG(DBG_info, "zoom = %f\n", xsane.zoom);
xsane_save_ps(outfile, infile,
&image_info,
@@ -1350,7 +1351,7 @@ void xsane_scan_done(SANE_Status status)
}
else
{
- char buf[256];
+ char buf[TEXTBUFSIZE];
if (!infile)
{
@@ -1616,7 +1617,7 @@ static void xsane_start_scan(void)
SANE_Status status;
SANE_Handle dev = xsane.dev;
const char *frame_type = 0;
- char buf[256];
+ char buf[TEXTBUFSIZE];
int fd;
Image_info image_info;
@@ -1680,6 +1681,7 @@ static void xsane_start_scan(void)
if ((xsane.param.depth == 1) && ((xsane.scan_rotation) ||
(xsane.xsane_mode == XSANE_VIEWER) ||
+ (xsane.xsane_mode == XSANE_MULTIPAGE) ||
(xsane.xsane_mode == XSANE_FAX) ||
(xsane.xsane_mode == XSANE_EMAIL))
) /* We want to do a transformation with a lineart scan */
@@ -1769,14 +1771,14 @@ static void xsane_start_scan(void)
if (preferences.adf_pages_max > 1)
{
- char buf2[255];
+ char buf2[TEXTBUFSIZE];
if (preferences.adf_pages_max > 1)
{
- snprintf(buf2, sizeof(buf), "%s (%d/%d)", PROGRESS_SCANNING, xsane.adf_page_counter+1, preferences.adf_pages_max);
+ snprintf(buf2, sizeof(buf2), "%s (%d/%d)", PROGRESS_SCANNING, xsane.adf_page_counter+1, preferences.adf_pages_max);
}
else
{
- snprintf(buf2, sizeof(buf), "%s (%d)", PROGRESS_SCANNING, xsane.adf_page_counter+1);
+ snprintf(buf2, sizeof(buf2), "%s (%d)", PROGRESS_SCANNING, xsane.adf_page_counter+1);
}
xsane_progress_new(buf, buf2, (GtkSignalFunc) xsane_cancel, NULL);
}
@@ -1814,7 +1816,7 @@ static void xsane_start_scan(void)
/* and return value 0 is used to tell the timeout handler to stop timer */
gint xsane_scan_dialog(gpointer *data)
{
- char buf[256];
+ char buf[TEXTBUFSIZE];
const SANE_Option_Descriptor *opt;
DBG(DBG_proc, "xsane_scan_dialog\n");
@@ -1854,7 +1856,7 @@ gint xsane_scan_dialog(gpointer *data)
testfile = fopen(xsane.output_filename, "rb"); /* read binary (b for win32) */
if (testfile) /* filename used: skip */
{
- char buf[256];
+ char buf[TEXTBUFSIZE];
fclose(testfile);
diff --git a/src/xsane-setup.c b/src/xsane-setup.c
index f97e7ef..c0c9000 100644
--- a/src/xsane-setup.c
+++ b/src/xsane-setup.c
@@ -242,7 +242,7 @@ static int xsane_update_double(GtkWidget *widget, double *val)
static void xsane_setup_printer_update()
{
- char buf[256];
+ char buf[TEXTBUFSIZE];
DBG(DBG_proc, "xsane_setup_printer_update\n");
@@ -1327,8 +1327,8 @@ static void xsane_printer_notebook(GtkWidget *notebook)
static void xsane_setup_browse_tmp_path_callback(GtkWidget *widget, gpointer data)
{
const gchar *old_tmp_path;
- char tmp_path[256];
- char windowname[256];
+ char tmp_path[PATH_MAX];
+ char windowname[TEXTBUFSIZE];
DBG(DBG_proc, "xsane_setup_browse_tmp_path_callback\n");
diff --git a/src/xsane-viewer.c b/src/xsane-viewer.c
index 718ab6d..d1d8e5e 100644
--- a/src/xsane-viewer.c
+++ b/src/xsane-viewer.c
@@ -163,7 +163,7 @@ static gint xsane_viewer_close_callback(GtkWidget *widget, gpointer data)
if (!v->image_saved)
{
- char buf[256];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), WARN_VIEWER_IMAGE_NOT_SAVED);
xsane_viewer_set_sensitivity(v, FALSE);
@@ -252,10 +252,10 @@ static void xsane_viewer_save_callback(GtkWidget *window, gpointer data)
Viewer *v = (Viewer *) data;
char outputfilename[1024];
char *inputfilename;
- char windowname[256];
+ char windowname[TEXTBUFSIZE];
int output_format;
int abort = 0;
- char buf[256];
+ char buf[TEXTBUFSIZE];
if (v->block_actions) /* actions blocked: return */
{
@@ -312,7 +312,7 @@ static void xsane_viewer_save_callback(GtkWidget *window, gpointer data)
testfile = fopen(v->output_filename, "rb"); /* read binary (b for win32) */
if (testfile) /* filename used: skip */
{
- char buf[256];
+ char buf[TEXTBUFSIZE];
fclose(testfile);
snprintf(buf, sizeof(buf), WARN_FILE_EXISTS, v->output_filename);
@@ -333,7 +333,7 @@ static void xsane_viewer_save_callback(GtkWidget *window, gpointer data)
{
if (xsane_create_secure_file(v->output_filename)) /* remove possibly existing symbolic links for security */
{
- char buf[256];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s %s %s\n", ERR_DURING_SAVE, ERR_CREATE_SECURE_FILE, v->output_filename);
xsane_back_gtk_error(buf, TRUE);
@@ -385,7 +385,7 @@ static void xsane_viewer_ocr_callback(GtkWidget *window, gpointer data)
Viewer *v = (Viewer *) data;
char outputfilename[1024];
char *extensionptr;
- char windowname[256];
+ char windowname[TEXTBUFSIZE];
int abort = 0;
if (v->block_actions) /* actions blocked: return */
@@ -435,7 +435,7 @@ static void xsane_viewer_ocr_callback(GtkWidget *window, gpointer data)
static void xsane_viewer_clone_callback(GtkWidget *window, gpointer data)
{
Viewer *v = (Viewer *) data;
- char outfilename[256];
+ char outfilename[PATH_MAX];
if (v->block_actions) /* actions blocked: return */
{
@@ -456,7 +456,7 @@ static void xsane_viewer_clone_callback(GtkWidget *window, gpointer data)
if (v->last_saved_filename)
{
- char buf[256];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s%s", FILENAME_PREFIX_CLONE_OF, v->last_saved_filename);
xsane_viewer_new(outfilename, v->selection_filetype, v->allow_reduction_to_lineart, buf, v->allow_modification, IMAGE_NOT_SAVED);
}
@@ -576,7 +576,7 @@ static void xsane_viewer_scale_callback(GtkWidget *window, gpointer data)
GdkPixmap *pixmap;
GdkBitmap *mask;
GtkWidget *pixmapwidget;
- char buf[256];
+ char buf[TEXTBUFSIZE];
FILE *infile;
Image_info image_info;
@@ -831,7 +831,7 @@ static void xsane_viewer_despeckle_callback(GtkWidget *window, gpointer data)
GtkWidget *hbox, *vbox;
GtkWidget *label, *spinbutton, *button;
GtkAdjustment *adjustment;
- char buf[256];
+ char buf[TEXTBUFSIZE];
if (v->block_actions) /* actions blocked: return */
{
@@ -925,7 +925,7 @@ static void xsane_viewer_blur_callback(GtkWidget *window, gpointer data)
GtkWidget *hbox, *vbox;
GtkWidget *label, *spinbutton, *button;
GtkAdjustment *adjustment;
- char buf[256];
+ char buf[TEXTBUFSIZE];
if (v->block_actions) /* actions blocked: return */
{
@@ -1036,7 +1036,7 @@ static void xsane_viewer_undo_callback(GtkWidget *window, gpointer data)
if (v->last_saved_filename)
{
- char buf[256];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s (%s) - %s", WINDOW_VIEWER, v->last_saved_filename, xsane.device_text);
gtk_window_set_title(GTK_WINDOW(v->top), buf);
}
@@ -1051,7 +1051,7 @@ static void xsane_viewer_scale_image(GtkWidget *window, gpointer data)
{
FILE *outfile;
FILE *infile;
- char outfilename[256];
+ char outfilename[PATH_MAX];
Viewer *v = (Viewer *) data;
Image_info image_info;
@@ -1119,7 +1119,7 @@ static void xsane_viewer_scale_image(GtkWidget *window, gpointer data)
if (v->last_saved_filename)
{
- char buf[256];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s (%s) - %s", WINDOW_VIEWER, v->last_saved_filename, xsane.device_text);
gtk_window_set_title(GTK_WINDOW(v->top), buf);
}
@@ -1133,7 +1133,7 @@ static void xsane_viewer_despeckle_image(GtkWidget *window, gpointer data)
{
FILE *outfile;
FILE *infile;
- char outfilename[256];
+ char outfilename[PATH_MAX];
Viewer *v = (Viewer *) data;
Image_info image_info;
@@ -1196,7 +1196,7 @@ static void xsane_viewer_despeckle_image(GtkWidget *window, gpointer data)
if (v->last_saved_filename)
{
- char buf[256];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s (%s) - %s", WINDOW_VIEWER, v->last_saved_filename, xsane.device_text);
gtk_window_set_title(GTK_WINDOW(v->top), buf);
}
@@ -1210,7 +1210,7 @@ static void xsane_viewer_blur_image(GtkWidget *window, gpointer data)
{
FILE *outfile;
FILE *infile;
- char outfilename[256];
+ char outfilename[PATH_MAX];
Viewer *v = (Viewer *) data;
Image_info image_info;
@@ -1273,7 +1273,7 @@ static void xsane_viewer_blur_image(GtkWidget *window, gpointer data)
if (v->last_saved_filename)
{
- char buf[256];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s (%s) - %s", WINDOW_VIEWER, v->last_saved_filename, xsane.device_text);
gtk_window_set_title(GTK_WINDOW(v->top), buf);
}
@@ -1287,7 +1287,7 @@ static void xsane_viewer_rotate(Viewer *v, int rotation)
{
FILE *outfile;
FILE *infile;
- char outfilename[256];
+ char outfilename[PATH_MAX];
Image_info image_info;
if (v->block_actions) /* actions blocked: return */
@@ -1363,7 +1363,7 @@ static void xsane_viewer_rotate(Viewer *v, int rotation)
if (v->last_saved_filename)
{
- char buf[256];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s (%s) - %s", WINDOW_VIEWER, v->last_saved_filename, xsane.device_text);
gtk_window_set_title(GTK_WINDOW(v->top), buf);
}
@@ -1663,7 +1663,7 @@ static int xsane_viewer_read_image(Viewer *v)
int pos0;
FILE *infile;
Image_info image_info;
- char buf[256];
+ char buf[TEXTBUFSIZE];
float size;
char *size_unit;
int width, height;
@@ -1804,7 +1804,7 @@ static int xsane_viewer_read_image(Viewer *v)
size *= 2.0;
}
- if ((v->allow_reduction_to_lineart) && (image_info.reduce_to_lineart))
+ if (image_info.reduce_to_lineart)
{
size /= 8.0;
}
@@ -1822,7 +1822,7 @@ static int xsane_viewer_read_image(Viewer *v)
size_unit = "KB";
}
- if ((v->allow_reduction_to_lineart) && (image_info.reduce_to_lineart))
+ if (image_info.reduce_to_lineart)
{
snprintf(buf, sizeof(buf), TEXT_VIEWER_IMAGE_INFO, image_info.image_width, image_info.image_height, 1, image_info.colors,
image_info.resolution_x, image_info.resolution_y, size, size_unit);
@@ -1870,7 +1870,7 @@ static int xsane_viewer_read_image(Viewer *v)
Viewer *xsane_viewer_new(char *filename, char *selection_filetype, int allow_reduction_to_lineart,
char *output_filename, viewer_modification allow_modification, int image_saved)
{
- char buf[256];
+ char buf[TEXTBUFSIZE];
Viewer *v;
GtkWidget *vbox, *hbox;
GtkWidget *menubar, *menubar_item;
diff --git a/src/xsane.c b/src/xsane.c
index 279df23..9254ea7 100644
--- a/src/xsane.c
+++ b/src/xsane.c
@@ -133,10 +133,6 @@ int xsane_scanmode_number[] = { XSANE_VIEWER, XSANE_SAVE, XSANE_COPY, XSANE_MULT
#define XSANE_GTK_NAME_X_RESOLUTION "GtkMenuXResolution"
#define XSANE_GTK_NAME_Y_RESOLUTION "GtkMenuYResolution"
-#define XSANE_GTK_NAME_ZOOM "GtkMenuZoom"
-#define XSANE_GTK_NAME_X_ZOOM "GtkMenuXZoom"
-#define XSANE_GTK_NAME_Y_ZOOM "GtkMenuYZoom"
-
/* ---------------------------------------------------------------------------------------------------------------------- */
/* forward declarations: */
@@ -307,12 +303,10 @@ static void xsane_set_modus_defaults(void)
break;
}
xsane.zoom = 1.0;
- xsane.zoom_x = 1.0;
- xsane.zoom_y = 1.0;
- xsane.resolution = xsane.zoom * printer_resolution;
- xsane.resolution_x = xsane.zoom_x * printer_resolution;
- xsane.resolution_y = xsane.zoom_y * printer_resolution;
+ xsane.resolution = xsane.zoom * printer_resolution;
+ xsane.resolution_x = xsane.zoom * printer_resolution;
+ xsane.resolution_y = xsane.zoom * printer_resolution;
xsane_set_all_resolutions();
xsane_define_maximum_output_size(); /* must come before select_full_preview_area */
@@ -623,9 +617,9 @@ static void xsane_printer_callback(GtkWidget *widget, gpointer data)
break;
}
- xsane.resolution = xsane.zoom * printer_resolution;
- xsane.resolution_x = xsane.zoom_x * printer_resolution;
- xsane.resolution_y = xsane.zoom_y * printer_resolution;
+ xsane.resolution = xsane.zoom * printer_resolution;
+ xsane.resolution_x = xsane.zoom * printer_resolution;
+ xsane.resolution_y = xsane.zoom * printer_resolution;
xsane_set_all_resolutions();
xsane_define_maximum_output_size();
@@ -654,8 +648,6 @@ static gint xsane_resolution_timer_callback(GtkAdjustment *adj)
static void xsane_resolution_scale_update(GtkAdjustment *adj, double *val)
{
- int printer_resolution;
-
/* gtk does not make sure that the value is quantisized correct */
float diff, old, new, quant;
@@ -687,34 +679,8 @@ static void xsane_resolution_scale_update(GtkAdjustment *adj, double *val)
*val = adj->value;
}
- switch (xsane.param.format)
- {
- case SANE_FRAME_GRAY:
- if (xsane.param.depth == 1)
- {
- printer_resolution = preferences.printer[preferences.printernr]->lineart_resolution;
- }
- else
- {
- printer_resolution = preferences.printer[preferences.printernr]->grayscale_resolution;
- }
- break;
-
- case SANE_FRAME_RGB:
- case SANE_FRAME_RED:
- case SANE_FRAME_GREEN:
- case SANE_FRAME_BLUE:
- default:
- printer_resolution = preferences.printer[preferences.printernr]->color_resolution;
- break;
- }
-
xsane_set_all_resolutions();
-
xsane_update_param(0);
- xsane.zoom = xsane.resolution / printer_resolution;
- xsane.zoom_x = xsane.resolution_x / printer_resolution;
- xsane.zoom_y = xsane.resolution_y / printer_resolution;
}
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -763,8 +729,6 @@ static void xsane_resolution_list_callback(GtkWidget *widget, gpointer data)
xsane_set_resolution(xsane.well_known.dpi_y, xsane.resolution_y);
xsane.zoom = xsane.resolution / printer_resolution;
- xsane.zoom_x = xsane.resolution_x / printer_resolution;
- xsane.zoom_y = xsane.resolution_y / printer_resolution;
}
else if (!strcmp(name, XSANE_GTK_NAME_X_RESOLUTION))
{
@@ -1018,9 +982,9 @@ static void xsane_zoom_update(GtkAdjustment *adj, double *val)
}
/* update all resolutions */
- xsane.resolution = xsane.zoom * printer_resolution;
- xsane.resolution_x = xsane.zoom_x * printer_resolution;
- xsane.resolution_y = xsane.zoom_y * printer_resolution;
+ xsane.resolution = xsane.zoom * printer_resolution;
+ xsane.resolution_x = xsane.zoom * printer_resolution;
+ xsane.resolution_y = xsane.zoom * printer_resolution;
xsane_set_all_resolutions();
@@ -1031,11 +995,42 @@ static void xsane_zoom_update(GtkAdjustment *adj, double *val)
/* ---------------------------------------------------------------------------------------------------------------------- */
-static int xsane_zoom_widget_new(GtkWidget *parent, int well_known_option, double *zoom, double resolution,
- const char *image_xpm[], const gchar *desc)
+static int xsane_get_zoom_range(int printer_resolution, int well_known_option, double *min, double *max)
+{
+ const SANE_Option_Descriptor *opt;
+
+ DBG(DBG_proc, "xsane_get_zoom_range\n");
+
+ opt = xsane_get_option_descriptor(xsane.dev, well_known_option);
+ if (!opt)
+ {
+ return -1; /* option not available */
+ }
+ else
+ {
+ if (SANE_OPTION_IS_ACTIVE(opt->cap))
+ {
+ xsane_get_bounds(opt, min, max);
+ *min = *min / printer_resolution;
+ *max = *max / printer_resolution;
+
+ return 0; /* everything is ok */
+ }
+ return 1; /* option not active */
+ }
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+static int xsane_zoom_widget_new(GtkWidget *parent)
{
const SANE_Option_Descriptor *opt;
int printer_resolution;
+ double min = 0.0;
+ double max = 0.0;
+ double min2 = 0.0;
+ double max2 = 0.0;
+ int well_known_option = 0;
DBG(DBG_proc, "xsane_zoom_widget_new\n");
@@ -1061,68 +1056,53 @@ static int xsane_zoom_widget_new(GtkWidget *parent, int well_known_option, doubl
break;
}
- opt = xsane_get_option_descriptor(xsane.dev, well_known_option);
- if (!opt)
+ if (!xsane_get_zoom_range(printer_resolution, xsane.well_known.dpi, &min, &max)) /* we have well_known.dpi: */
{
- return -1; /* option not available */
+ well_known_option = xsane.well_known.dpi;
}
else
{
- if (SANE_OPTION_IS_ACTIVE(opt->cap))
+ if (!xsane_get_zoom_range(printer_resolution, xsane.well_known.dpi_x, &min, &max)) /* we have well.known.dpi_x */
{
- double min = 0.0;
- double max = 0.0;
- SANE_Word val = 0.0;
-
- xsane_control_option(xsane.dev, well_known_option, SANE_ACTION_GET_VALUE, &val, 0);
-
- switch (opt->constraint_type)
+ well_known_option = xsane.well_known.dpi_x;
+ if (!xsane_get_zoom_range(printer_resolution, xsane.well_known.dpi_y, &min2, &max2)) /* we have well.known.dpi_y */
{
- case SANE_CONSTRAINT_RANGE:
- switch (opt->type)
- {
- case SANE_TYPE_INT:
- min = ((double) opt->constraint.range->min) / printer_resolution;
- max = ((double) opt->constraint.range->max) / printer_resolution;
- break;
-
- case SANE_TYPE_FIXED:
- min = SANE_UNFIX(opt->constraint.range->min) / printer_resolution;
- max = SANE_UNFIX(opt->constraint.range->max) / printer_resolution;
- val = SANE_UNFIX(val);
- break;
-
- default:
- DBG(DBG_error, "zoom_scale_update: %s %d\n", ERR_UNKNOWN_TYPE, opt->type);
- }
- break;
-
- case SANE_CONSTRAINT_WORD_LIST:
- xsane_get_bounds(opt, &min, &max);
- min = min / printer_resolution;
- max = max / printer_resolution;
- break;
+ if (min < min2)
+ {
+ min = min2;
+ }
- default:
- DBG(DBG_error, "zoom_scale_update: %s %d\n", ERR_UNKNOWN_CONSTRAINT_TYPE, opt->constraint_type);
+ if (max > max2)
+ {
+ max = max2;
+ }
}
+ }
+ else
+ {
+ return -1; /* no zoom widget created */
+ }
+ }
- if (resolution == 0) /* no prefered value */
- {
- resolution = val; /* set backend predefined value */
- }
+ if (min < 0.01)
+ {
+ min = 0.01;
+ }
- *zoom = resolution / printer_resolution;
+ opt = xsane_get_option_descriptor(xsane.dev, well_known_option);
+ xsane_range_new_with_pixmap(xsane.xsane_window->window, GTK_BOX(parent), zoom_xpm, DESC_ZOOM, min, max, 0.01, 0.1, 2,
+ &xsane.zoom, &xsane.zoom_widget, well_known_option, xsane_zoom_update,
+ SANE_OPTION_IS_SETTABLE(opt->cap));
- xsane_range_new_with_pixmap(xsane.xsane_window->window, GTK_BOX(parent), image_xpm, desc, min, max, 0.01, 0.1, 2,
- zoom, &xsane.zoom_widget, well_known_option, xsane_zoom_update,
- SANE_OPTION_IS_SETTABLE(opt->cap));
+ xsane.resolution = xsane.zoom * printer_resolution;
+ xsane.resolution_x = xsane.zoom * printer_resolution;
+ xsane.resolution_y = xsane.zoom * printer_resolution;
- return 0; /* everything is ok */
- }
- return 1; /* option not active */
- }
+ xsane_set_all_resolutions();
+
+ return 0; /* everything ok */
}
+
/* ---------------------------------------------------------------------------------------------------------------------- */
static void xsane_scanmode_menu_callback(GtkWidget *widget, gpointer data)
@@ -1132,14 +1112,9 @@ static void xsane_scanmode_menu_callback(GtkWidget *widget, gpointer data)
const SANE_Option_Descriptor *opt;
int opt_num;
int printer_resolution;
- double zoom, zoom_x, zoom_y;
DBG(DBG_proc, "xsane_scanmode_menu_callback\n");
- zoom = xsane.zoom;
- zoom_x = xsane.zoom_x;
- zoom_y = xsane.zoom_y;
-
opt_num = elem - xsane.element;
opt = xsane_get_option_descriptor(xsane.dev, opt_num);
xsane_back_gtk_set_option(opt_num, menu_item->label, SANE_ACTION_SET_VALUE);
@@ -1168,9 +1143,9 @@ static void xsane_scanmode_menu_callback(GtkWidget *widget, gpointer data)
break;
}
- xsane.resolution = xsane_find_best_resolution(xsane.well_known.dpi, zoom * printer_resolution);
- xsane.resolution_x = xsane_find_best_resolution(xsane.well_known.dpi_x, zoom_x * printer_resolution);
- xsane.resolution_y = xsane_find_best_resolution(xsane.well_known.dpi_y, zoom_y * printer_resolution);
+ xsane.resolution = xsane_find_best_resolution(xsane.well_known.dpi, xsane.zoom * printer_resolution);
+ xsane.resolution_x = xsane_find_best_resolution(xsane.well_known.dpi_x, xsane.zoom * printer_resolution);
+ xsane.resolution_y = xsane_find_best_resolution(xsane.well_known.dpi_y, xsane.zoom * printer_resolution);
xsane_set_all_resolutions(); /* make sure resolution, resolution_x and resolution_y are up to date */
xsane_back_gtk_refresh_dialog(); /* update resolution - a bit overkill, any better idea? */
@@ -1319,11 +1294,7 @@ GtkWidget *xsane_update_xsane_callback() /* creates the XSane option window */
}
-#if 0
- if (xsane.xsane_mode == XSANE_SAVE)
-#else
if ( (xsane.xsane_mode == XSANE_SAVE) || (xsane.xsane_mode == XSANE_VIEWER) )
-#endif
{
xsane.copy_number_entry = NULL;
@@ -1633,18 +1604,7 @@ GtkWidget *xsane_update_xsane_callback() /* creates the XSane option window */
}
else if (xsane.xsane_mode == XSANE_COPY)
{
- /* zoom selection */
- if (!xsane_zoom_widget_new(xsane_vbox_xsane_modus, xsane.well_known.dpi_x, &xsane.zoom_x,
- xsane.resolution_x, zoom_x_xpm, DESC_ZOOM_X))
- {
- xsane_zoom_widget_new(xsane_vbox_xsane_modus, xsane.well_known.dpi_y, &xsane.zoom_y,
- xsane.resolution_y, zoom_y_xpm, DESC_ZOOM_Y);
- }
- else
- {
- xsane_zoom_widget_new(xsane_vbox_xsane_modus, xsane.well_known.dpi, &xsane.zoom,
- xsane.resolution, zoom_xpm, DESC_ZOOM);
- }
+ xsane_zoom_widget_new(xsane_vbox_xsane_modus);
}
else if (xsane.xsane_mode == XSANE_MULTIPAGE)
{
@@ -1880,7 +1840,7 @@ void xsane_pref_save(void)
if (fd < 0)
{
- char buf[256];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s %s.", ERR_FAILED_CREATE_FILE, strerror(errno));
xsane_back_gtk_error(buf, TRUE);
@@ -2082,6 +2042,11 @@ static int xsane_pref_restore(void)
preferences.multipage_project = strdup(MULTIPAGEPROJECT);
}
+ if (!preferences.multipage_filetype)
+ {
+ preferences.multipage_filetype = strdup(MULTIPAGEFILETYPE);
+ }
+
if (!preferences.ocr_command)
{
preferences.ocr_command = strdup(OCRCOMMAND);
@@ -2148,7 +2113,7 @@ void xsane_pref_save_media(void)
if (fd < 0)
{
- char buf[256];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s %s.", ERR_FAILED_CREATE_FILE, strerror(errno));
xsane_back_gtk_error(buf, TRUE);
@@ -2411,7 +2376,7 @@ static gint xsane_scan_win_delete(GtkWidget *w, gpointer data)
if (unsaved_images)
{
- char buf[256];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), WARN_UNSAVED_IMAGES, unsaved_images);
if (!xsane_back_gtk_decision(ERR_HEADER_WARNING, (gchar **) warning_xpm, buf, BUTTON_DO_NOT_CLOSE, BUTTON_DISCARD_ALL_IMAGES, TRUE /* wait */) == FALSE)
@@ -2762,7 +2727,7 @@ static gint xsane_medium_context_menu_callback(GtkWidget *widget, GdkEvent *even
if (event_button->button == 3)
{
- char buf[256];
+ char buf[TEXTBUFSIZE];
menu = gtk_menu_new();
@@ -3017,7 +2982,7 @@ static gint xsane_close_info_callback(GtkWidget *widget, gpointer data)
static void xsane_info_dialog(GtkWidget *widget, gpointer data)
{
GtkWidget *info_dialog, *vbox, *button, *label, *frame, *framebox, *hbox, *table;
- char buf[256];
+ char buf[TEXTBUFSIZE];
char *bufptr;
GtkAccelGroup *accelerator_group;
@@ -3549,7 +3514,7 @@ static void xsane_show_gpl(GtkWidget *widget, gpointer data)
static void xsane_show_doc_via_nsr(GtkWidget *widget, gpointer data) /* show via netscape remote */
{
char *name = (char *) data;
- char buf[256];
+ char buf[TEXTBUFSIZE];
pid_t pid;
char *arg[5];
struct stat st;
@@ -3722,7 +3687,7 @@ static char **xsane_parse_command(char *command_line, char *url)
static void xsane_show_doc(GtkWidget *widget, gpointer data)
{
char *name = (char *) data;
- char path[256];
+ char path[PATH_MAX];
pid_t pid;
char *arg[3];
struct stat st;
@@ -4213,7 +4178,7 @@ void xsane_panel_build()
const SANE_Option_Descriptor *opt;
SANE_Handle dev = xsane.dev;
double dval, dmin, dmax, dquant;
- char *buf, str[16], title[256];
+ char *buf, str[16], title[TEXTBUFSIZE];
DialogElement *elem;
SANE_Word quant, val;
SANE_Status status;
@@ -4682,7 +4647,7 @@ void xsane_panel_build()
get_value_failed:
{
- char msg[256];
+ char msg[TEXTBUFSIZE];
sprintf(msg, "%s %s: %s.", ERR_GET_OPTION, opt->name, XSANE_STRSTATUS(status));
xsane_back_gtk_error(msg, TRUE);
@@ -4730,9 +4695,9 @@ static void xsane_device_dialog(void)
GtkWidget *menubar, *menubar_item;
GtkStyle *current_style;
const gchar *devname;
- char buf[256];
- char windowname[255];
- char devicetext[255];
+ char buf[TEXTBUFSIZE];
+ char windowname[TEXTBUFSIZE];
+ char devicetext[TEXTBUFSIZE];
char *textptr;
GtkWidget *xsane_window;
GtkWidget *xsane_vbox_main;
@@ -5261,7 +5226,7 @@ static void xsane_choose_device(void)
GtkAccelGroup *device_selection_accelerator_group;
gint i;
const SANE_Device *adev;
- char buf[256];
+ char buf[TEXTBUFSIZE];
char vendor[12];
char model[17];
char type[20];
@@ -5471,7 +5436,7 @@ static int xsane_init(int argc, char **argv)
GtkWidget *frame;
struct stat st;
char filename[PATH_MAX];
- char buf[256];
+ char buf[TEXTBUFSIZE];
DBG(DBG_proc, "xsane_init\n");
@@ -5828,7 +5793,7 @@ void xsane_interface(int argc, char **argv)
}
else /* xsane.num_of_devs == 0, no devices available */
{
- char buf[256];
+ char buf[TEXTBUFSIZE];
snprintf(buf, sizeof(buf), "%s\n", ERR_NO_DEVICES);
@@ -5886,8 +5851,6 @@ int main(int argc, char **argv)
xsane.histogram_lines = 1;
xsane.zoom = 1.0;
- xsane.zoom_x = 1.0;
- xsane.zoom_y = 1.0;
xsane.resolution = 72.0;
xsane.resolution_x = 72.0;
xsane.resolution_y = 72.0;
diff --git a/src/xsane.h b/src/xsane.h
index abf8447..154bb52 100644
--- a/src/xsane.h
+++ b/src/xsane.h
@@ -85,10 +85,10 @@
/* ---------------------------------------------------------------------------------------------------------------------- */
-#define XSANE_VERSION "0.99"
+#define XSANE_VERSION "0.991"
#define XSANE_AUTHOR "Oliver Rauch"
#define XSANE_COPYRIGHT "Oliver Rauch"
-#define XSANE_DATE "1998-2005"
+#define XSANE_DATE "1998-2006"
#define XSANE_EMAIL_ADR "Oliver.Rauch@xsane.org"
#define XSANE_HOMEPAGE "http://www.xsane.org"
#define XSANE_COPYRIGHT_TXT XSANE_DATE " " XSANE_COPYRIGHT
@@ -102,9 +102,10 @@
#define XSANE_CONTINUOUS_HOLD_TIME 10
#define XSANE_DEFAULT_DEVICE "SANE_DEFAULT_DEVICE"
#define XSANE_3PASS_BUFFER_RGB_SIZE 1024
+#define TEXTBUFSIZE 255
#ifndef M_PI_2
-# define M_PI_2 1.57079632679489661923  /* pi/2 */
+# define M_PI_2 1.57079632679489661923 /* pi/2 */
#endif
#ifdef HAVE_WINDOWS_H
@@ -501,6 +502,7 @@ extern void xsane_batch_scan_add(void);
#define EMAILPROJECT "emailproject"
#define EMAILCOMMAND "sendmail"
#define MULTIPAGEPROJECT "multipageproject"
+#define MULTIPAGEFILETYPE XSANE_FILETYPE_PDF
#define OCRCOMMAND "gocr"
#define OCRINPUTFILEOPT "-i"
#define OCROUTPUTFILEOPT "-o"
@@ -796,8 +798,6 @@ typedef struct Xsane
int copy_number;
double zoom;
- double zoom_x;
- double zoom_y;
double resolution;
double resolution_x;
double resolution_y;