Commit f48efa96 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

plug-ins/FractalExplorer plug-ins/Lighting plug-ins/bmp plug-ins/dbbrowser

2005-03-04  Sven Neumann  <sven@gimp.org>

	* plug-ins/FractalExplorer
	* plug-ins/Lighting
	* plug-ins/bmp
	* plug-ins/dbbrowser
	* plug-ins/faxg3
	* plug-ins/fits
	* plug-ins/flame
	* plug-ins/gfig
	* plug-ins/gflare
	* plug-ins/gfli
	* plug-ins/gimpressionist
	* plug-ins/ifscompose
	* plug-ins/jpeg
	* plug-ins/maze
	* plug-ins/pagecurl
	* plug-ins/print
	* plug-ins/rcm
	* plug-ins/script-fu
	* plug-ins/sel2path
	* plug-ins/sgi
	* plug-ins/twain
	* plug-ins/winicon
	* plug-ins/xjt: ported to gstdio, removed unnecessary includes,
	minor fixes to filename handling here and there.
parent a303b44c
/**********************************************************************
The GIMP -- an image manipulation program
Copyright (C) 1995 Spencer Kimball and Peter Mattis
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 2 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, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*********************************************************************/
#include "config.h"
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gstdio.h>
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
......@@ -1790,12 +1810,10 @@ save_options (FILE * fp)
static void
save_callback (void)
{
FILE *fp;
gchar *savename;
savename = filename;
FILE *fp;
const gchar *savename = filename;
fp = fopen (savename, "wt+");
fp = g_fopen (savename, "wt+");
if (!fp)
{
......@@ -2093,7 +2111,8 @@ explorer_load (void)
gchar load_buf[MAX_LOAD_LINE];
g_assert (filename != NULL);
fp = fopen (filename, "rt");
fp = g_fopen (filename, "rt");
if (!fp)
{
......
......@@ -51,13 +51,16 @@
#include "config.h"
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <glib/gstdio.h>
#ifdef __GNUC__
#warning GTK_DISABLE_DEPRECATED
#endif
......@@ -1132,9 +1135,8 @@ fractalexplorer_free_everything (fractalexplorerOBJ *fractalexplorer)
g_assert (fractalexplorer != NULL);
if (fractalexplorer->filename)
{
remove (fractalexplorer->filename);
}
g_remove (fractalexplorer->filename);
fractalexplorer_free (fractalexplorer);
}
......@@ -1155,10 +1157,12 @@ fractalexplorer_load (const gchar *filename,
gchar load_buf[MAX_LOAD_LINE];
g_assert (filename != NULL);
fp = fopen (filename, "rt");
fp = g_fopen (filename, "rt");
if (!fp)
{
g_warning ("Error opening: %s", filename);
g_message (_("Could not open '%s' for reading: %s"),
gimp_filename_to_utf8 (filename), g_strerror (errno));
return NULL;
}
......@@ -1212,7 +1216,7 @@ fractalexplorer_list_load_one (const GimpDatafileData *file_data,
if (fractalexplorer)
{
/* Read only ?*/
/* Read only ?*/ /* FIXME: filename handling for Win32 */
if (access (filename, W_OK))
fractalexplorer->obj_status |= fractalexplorer_READONLY;
......
......@@ -19,10 +19,11 @@
#include "config.h"
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <glib/gstdio.h>
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
......@@ -72,14 +73,14 @@ static void envmap_combo_callback (GtkWidget *widget,
gpointer data);
static void save_lighting_preset (GtkWidget *widget,
gpointer data);
static void file_chooser_response (GtkFileChooser *chooser,
static void save_preset_response (GtkFileChooser *chooser,
gint response_id,
gpointer data);
static void load_lighting_preset (GtkWidget *widget,
gpointer data);
static void load_file_chooser_response (GtkFileChooser *chooser,
gint response_id,
gpointer data);
static void load_preset_response (GtkFileChooser *chooser,
gint response_id,
gpointer data);
static void lightselect_callback (GimpIntComboBox *combo,
gpointer data);
static void apply_settings (GtkWidget *widget,
......@@ -1088,7 +1089,7 @@ save_lighting_preset (GtkWidget *widget,
G_CALLBACK (gtk_widget_destroyed),
&window);
g_signal_connect (window, "response",
G_CALLBACK (file_chooser_response),
G_CALLBACK (save_preset_response),
NULL);
}
......@@ -1119,9 +1120,9 @@ save_lighting_preset (GtkWidget *widget,
static void
file_chooser_response (GtkFileChooser *chooser,
gint response_id,
gpointer data)
save_preset_response (GtkFileChooser *chooser,
gint response_id,
gpointer data)
{
FILE *fp;
gint num_lights = 0;
......@@ -1136,7 +1137,7 @@ file_chooser_response (GtkFileChooser *chooser,
{
gchar *filename = gtk_file_chooser_get_filename (chooser);
fp = fopen (filename, "w");
fp = g_fopen (filename, "w");
if (!fp)
{
......@@ -1194,6 +1195,8 @@ file_chooser_response (GtkFileChooser *chooser,
fclose (fp);
}
g_free (filename);
}
gtk_widget_destroy (GTK_WIDGET (chooser));
......@@ -1223,7 +1226,7 @@ load_lighting_preset (GtkWidget *widget,
G_CALLBACK (gtk_widget_destroyed),
&window);
g_signal_connect (window, "response",
G_CALLBACK (load_file_chooser_response),
G_CALLBACK (load_preset_response),
NULL);
}
......@@ -1255,9 +1258,9 @@ load_lighting_preset (GtkWidget *widget,
static void
load_file_chooser_response (GtkFileChooser *chooser,
gint response_id,
gpointer data)
load_preset_response (GtkFileChooser *chooser,
gint response_id,
gpointer data)
{
FILE *fp;
gint num_lights;
......@@ -1269,12 +1272,11 @@ load_file_chooser_response (GtkFileChooser *chooser,
gchar type_label[20];
gchar *endptr;
if (response_id == GTK_RESPONSE_OK)
{
gchar *filename = gtk_file_chooser_get_filename (chooser);
fp = fopen (filename, "r");
fp = g_fopen (filename, "r");
if (!fp)
{
......@@ -1332,6 +1334,8 @@ load_file_chooser_response (GtkFileChooser *chooser,
fclose (fp);
}
g_free (filename);
lightselect_callback (GIMP_INT_COMBO_BOX (lightselect_combo), NULL);
}
......
......@@ -50,7 +50,6 @@
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
......@@ -63,6 +62,7 @@
#include "libgimp/stdplugins-intl.h"
const gchar *filename = NULL;
gboolean interactive_bmp;
......
......@@ -24,10 +24,10 @@
#include "config.h"
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gstdio.h>
#include <gtk/gtk.h>
#include <libgimp/gimp.h>
......@@ -126,7 +126,8 @@ ReadChannelMasks (FILE *fd, Bitmap_Channel *masks, guint channels)
masks[i].shiftin = offset;
masks[i].shiftout = 8 - nbits;
#ifdef DEBUG
g_print ("Channel %d mask %08x in %d out %d\n", i, masks[i].mask, masks[i].shiftin, masks[i].shiftout);
g_print ("Channel %d mask %08x in %d out %d\n",
i, masks[i].mask, masks[i].shiftin, masks[i].shiftout);
#endif
}
return TRUE;
......@@ -145,7 +146,7 @@ ReadBMP (const gchar *name)
Bitmap_Channel *masks;
filename = name;
fd = fopen (filename, "rb");
fd = g_fopen (filename, "rb");
if (!fd)
{
......@@ -160,17 +161,17 @@ ReadBMP (const gchar *name)
/* It is a File. Now is it a Bitmap? Read the shortest possible header */
if (!ReadOK (fd, magick, 2) || !(!strncmp (magick,"BA",2) ||
!strncmp (magick,"BM",2) || !strncmp (magick,"IC",2) ||
!strncmp (magick,"PI",2) || !strncmp (magick,"CI",2) ||
!strncmp (magick,"CP",2)))
if (!ReadOK (fd, magick, 2) || !(!strncmp (magick, "BA", 2) ||
!strncmp (magick, "BM", 2) || !strncmp (magick, "IC", 2) ||
!strncmp (magick, "PI", 2) || !strncmp (magick, "CI", 2) ||
!strncmp (magick, "CP", 2)))
{
g_message (_("'%s' is not a valid BMP file"),
gimp_filename_to_utf8 (filename));
return -1;
}
while (!strncmp(magick,"BA",2))
while (!strncmp (magick, "BA", 2))
{
if (!ReadOK (fd, buffer, 12))
{
......
......@@ -30,12 +30,9 @@
#include "config.h"
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <glib/gstdio.h>
#include <gtk/gtk.h>
......@@ -192,7 +189,7 @@ WriteBMP (const gchar *filename,
}
/* Let's take some file */
outfile = fopen (filename, "wb");
outfile = g_fopen (filename, "wb");
if (!outfile)
{
g_message (_("Could not open '%s' for writing: %s"),
......
......@@ -23,8 +23,6 @@
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
......
......@@ -41,9 +41,6 @@
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <gtk/gtk.h>
#include <libgimp/gimp.h>
......
......@@ -23,8 +23,6 @@
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
......
......@@ -41,9 +41,6 @@
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <gtk/gtk.h>
#include <libgimp/gimp.h>
......
......@@ -20,18 +20,19 @@
*/
#include "config.h"
#include <glib.h> /* For G_OS_WIN32 */
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <sys/types.h>
#include <string.h>
#include <fcntl.h>
#include <glib.h> /* For G_OS_WIN32 */
#include <glib/gstdio.h>
#ifdef G_OS_WIN32
#include <io.h>
#endif
......@@ -211,7 +212,7 @@ load_image (const gchar *filename)
init_byte_tab( 0, byte_tab );
fd = open (filename, O_RDONLY | _O_BINARY);
fd = g_open (filename, O_RDONLY | _O_BINARY);
if (fd < 0)
{
......@@ -232,7 +233,7 @@ load_image (const gchar *filename)
lseek(fd, 0L, 0);
rs = read( fd, rbuf, sizeof(rbuf) );
if ( rs < 0 ) { perror( "read" ); close( rs ); exit(8); }
if ( rs < 0 ) { perror( "read" ); close( rs ); gimp_quit (); }
rr += rs;
gimp_progress_update ((float)rr/rsize/2.0);
......@@ -250,7 +251,7 @@ load_image (const gchar *filename)
while ( rs > 0 && cons_eol < 4 ) /* i.e., while (!EOF) */
{
#ifdef DEBUG
fprintf( stderr, "hibit=%2d, data=", hibit );
g_printerr ("hibit=%2d, data=", hibit );
putbin( data );
#endif
while ( hibit < 20 )
......@@ -268,7 +269,7 @@ load_image (const gchar *filename)
if ( rs == 0 ) { goto do_write; }
}
#ifdef DEBUG
fprintf( stderr, "hibit=%2d, data=", hibit );
g_printerr ("hibit=%2d, data=", hibit );
putbin( data );
#endif
}
......@@ -287,7 +288,7 @@ load_image (const gchar *filename)
if ( p == NULL ) /* invalid code */
{
fprintf( stderr, "invalid code, row=%d, col=%d, file offset=%lx, skip to eol\n",
g_printerr ("invalid code, row=%d, col=%d, file offset=%lx, skip to eol\n",
row, col, (unsigned long) lseek( fd, 0, 1 ) - rs + rp );
while ( ( data & 0x03f ) != 0 )
{
......@@ -316,7 +317,7 @@ load_image (const gchar *filename)
nr_pels = ( (struct g3_leaf *) p ) ->nr_pels;
#ifdef DEBUG
fprintf( stderr, "PELs: %d (%c)\n", nr_pels, '0'+color );
g_printerr ("PELs: %d (%c)\n", nr_pels, '0'+color );
#endif
}
......@@ -324,7 +325,7 @@ load_image (const gchar *filename)
if ( nr_pels == -1 )
{
#ifdef DEBUG
fprintf( stderr, "hibit=%2d, data=", hibit );
g_printerr ("hibit=%2d, data=", hibit );
putbin( data );
#endif
/* skip filler 0bits -> seek for "1"-bit */
......@@ -354,7 +355,7 @@ load_image (const gchar *filename)
}
}
#ifdef DEBUG
fprintf( stderr, "hibit=%2d, data=", hibit );
g_printerr ("hibit=%2d, data=", hibit );
putbin( data );
#endif
} /* end skip 0bits */
......@@ -371,21 +372,21 @@ load_image (const gchar *filename)
/* bitmap memory full? make it larger! */
if ( row >= max_rows )
{
char * p = (char *) realloc( bitmap,
( max_rows += 500 ) * MAX_COLS/8 );
{
gchar *p = g_try_realloc( bitmap,
( max_rows += 500 ) * MAX_COLS/8 );
if ( p == NULL )
{
{
perror( "realloc() failed, page truncated" );
rs = 0;
}
}
else
{
{
bitmap = p;
memset( &bitmap[ row * MAX_COLS/8 ], 0,
( max_rows - row ) * MAX_COLS/8 );
}
}
}
}
col=0; bp = &bitmap[ row * MAX_COLS/8 ];
cons_eol = 0;
......@@ -418,7 +419,7 @@ do_write: /* write pbm (or whatever) file */
if( fd != 0 ) close(fd); /* close input file */
#ifdef DEBUG
fprintf( stderr, "consecutive EOLs: %d, max columns: %d\n", cons_eol, hcol );
g_printerr ("consecutive EOLs: %d, max columns: %d\n", cons_eol, hcol );
#endif
image_id = emitgimp (hcol, row, bitmap, bperrow, filename);
......@@ -454,7 +455,7 @@ emitgimp (gint hcol,
tmp = 0;
#ifdef DEBUG
fprintf( stderr, "emit gimp: %d x %d\n", hcol, row);
g_printerr ("emit gimp: %d x %d\n", hcol, row);
#endif
image_ID = gimp_image_new (hcol, row, GIMP_GRAY);
......@@ -471,7 +472,7 @@ emitgimp (gint hcol,
0, 0, drawable->width, drawable->height, TRUE, FALSE);
tile_height = gimp_tile_height ();
#ifdef DEBUG
fprintf( stderr, "tile height: %d\n", tile_height);
g_printerr ("tile height: %d\n", tile_height);
#endif
buf = g_new (guchar, hcol*tile_height);
......@@ -484,7 +485,7 @@ emitgimp (gint hcol,
}
if ((y-yy) == tile_height-1) {
#ifdef DEBUG
fprintf( stderr, "update tile height: %d\n", tile_height);
g_printerr ("update tile height: %d\n", tile_height);
#endif
gimp_pixel_rgn_set_rect (&pixel_rgn, buf, 0, yy, hcol, tile_height);
gimp_progress_update (0.5+(float)y/row/2.0);
......@@ -494,7 +495,7 @@ emitgimp (gint hcol,
}
if (row-yy) {
#ifdef DEBUG
fprintf( stderr, "update rest: %d\n", row-yy);
g_printerr ("update rest: %d\n", row-yy);
#endif
gimp_pixel_rgn_set_rect (&pixel_rgn, buf, 0, yy, hcol, row-yy);
}
......
......@@ -2,13 +2,10 @@
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <sys/types.h>
#include <string.h>
#include <stdio.h>
#include <glib.h>
#include "g3.h"
......@@ -244,7 +241,7 @@ int i;
}
if ( p2->nr_bits != 0 )
{
fprintf( stderr, "internal table setup error\n" ); exit(6);
g_printerr ("internal table setup error\n" ); exit(6);
}
tree_add_node( p2, g3c, bit_code >> FBITS, bit_length - FBITS );
}
......
......@@ -32,16 +32,12 @@
* (moved it from load to save)
*/
static char ident[] = "@(#) GIMP FITS file-plugin v1.06 21-Nov-99";
#include "config.h"
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <gtk/gtk.h>
#include <glib/gstdio.h>
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
......@@ -331,7 +327,7 @@ load_image (const gchar *filename)
FITS_FILE *ifp;
FITS_HDU_LIST *hdu;
fp = fopen (filename, "rb");
fp = g_fopen (filename, "rb");
if (!fp)
{
g_message (_("Could not open '%s' for reading: %s"),
......@@ -420,7 +416,6 @@ save_image (const gchar *filename,
FITS_FILE* ofp;
GimpImageType drawable_type;
gint retval;
char *temp = ident; /* Just to satisfy lint/gcc */
drawable_type = gimp_drawable_type (drawable_ID);
......@@ -452,10 +447,9 @@ save_image (const gchar *filename,
return (FALSE);
}
temp = g_strdup_printf (_("Saving '%s'..."),
gimp_progress_init (NULL);
gimp_progress_set_text (_("Saving '%s'..."),
gimp_filename_to_utf8 (filename));
gimp_progress_init (temp);
g_free (temp);
if ((drawable_type == GIMP_INDEXED_IMAGE) ||
(drawable_type == GIMP_INDEXEDA_IMAGE))
......@@ -986,7 +980,7 @@ load_dialog (void)
TRUE, TRUE, 0);
gtk_widget_show (vbox);
frame = gimp_int_radio_group_new (TRUE, _("BLANK/NaN Pixel Replacement"),
frame = gimp_int_radio_group_new (TRUE, _("Replacement for undefined pixels"),
G_CALLBACK (gimp_radio_button_update),
&plvals.replace, plvals.replace,
......
......@@ -56,8 +56,6 @@
/******************************************************************************/
#define VERSIO 0.11
/* Identifikation: "@(#) <product> <ver> <dd-mmm-yy>" */
static char ident[] = "@(#) libfits.c 0.11 20-Dec-97 (%I%)";
/******************************************************************************/
/* FITS reading/writing library */
......@@ -86,12 +84,10 @@ static char ident[] = "@(#) libfits.c 0.11 20-Dec-97 (%I%)";
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <glib/gstdio.h>
#include "fitsrw.h"
......@@ -350,7 +346,7 @@ static int fits_nan_32 (unsigned char *v)
return ( ((k >= 0x7f7fffff) && (k <= 0x7fffffff))
|| ((k >= 0x00000001) && (k <= 0x00800000)));
}
/*****************************************************************************/
/* #BEG-PAR */
......@@ -519,7 +515,7 @@ FITS_FILE *fits_open (const char *filename, const char *openmode)
if ((!reading) && (!writing))
FITS_RETURN ("fits_open: Invalid openmode", NULL);
fp = fopen (filename, reading ? "rb" : "wb");
fp = g_fopen (filename, reading ? "rb" : "wb");
if (fp == NULL) FITS_RETURN ("fits_open: fopen() failed", NULL);
ff = fits_new_filestruct ();
......@@ -560,7 +556,7 @@ FITS_FILE *fits_open (const char *filename, const char *openmode)
if (hdulist->used.blank_value) ff->blank_used = 1;
if (hdulist->used.nan_value) ff->nan_used = 1;
if (n_hdr == 0)
if (n_hdr == 0)
ff->hdu_list = hdulist;
else
last_hdulist->next_hdu = hdulist;
......@@ -572,7 +568,7 @@ FITS_FILE *fits_open (const char *filename, const char *openmode)
if (fseek (fp, hdulist->data_offset+hdulist->data_size, SEEK_SET) < 0)
break;
}
return (ff);
}
......@@ -956,7 +952,7 @@ int fits_write_header (FITS_FILE *ff, FITS_HDU_LIST *hdulist)
/* */
/* #END-PAR */
/*****************************************************************************/
static FITS_HDU_LIST *fits_decode_header (FITS_RECORD_LIST *hdr,
long hdr_offset, long dat_offset)
......@@ -1101,7 +1097,7 @@ static FITS_HDU_LIST *fits_decode_header (FITS_RECORD_LIST *hdr,
|| ( (hdulist->bitpix == -32)
&& ( fits_ieee32_intel || fits_ieee32_motorola
|| fits_ieee64_intel || fits_ieee64_motorola));
if (bitpix_supported)
{
if (hdulist->used.simple)
......@@ -1165,11 +1161,11 @@ err_return:
static int fits_eval_pixrange (FILE *fp, FITS_HDU_LIST *hdu)
{register int maxelem;
#define FITSNPIX 4096
#define FITSNPIX 4096
unsigned char pixdat[FITSNPIX];
int nelem, bpp;
int blank_found = 0, nan_found = 0;
if (fseek (fp, hdu->data_offset, SEEK_SET) < 0)
FITS_RETURN ("fits_eval_pixrange: cant position file", -1);
......@@ -1191,7 +1187,7 @@ static int fits_eval_pixrange (FILE *fp, FITS_HDU_LIST *hdu)
nelem -= maxelem;
if (fread ((char *)pixdat, bpp, maxelem, fp) != maxelem)
FITS_RETURN ("fits_eval_pixrange: error on read bitpix 8 data", -1);
ptr = pixdat;
if (hdu->used.blank)
{
......@@ -1233,7 +1229,7 @@ static int fits_eval_pixrange (FILE *fp, FITS_HDU_LIST *hdu)
nelem -= maxelem;
if (fread ((char *)pixdat, bpp, maxelem, fp) != maxelem)
FITS_RETURN ("fits_eval_pixrange: error on read bitpix 16 data", -1);
ptr = pixdat;
if (hdu->used.blank)
{FITS_BITPIX16 blankval = (FITS_BITPIX16)hdu->blank;
......@@ -1278,7 +1274,7 @@ static int fits_eval_pixrange (FILE *fp, FITS_HDU_LIST *hdu)
nelem -= maxelem;
if (fread ((char *)pixdat, bpp, maxelem, fp) != maxelem)
FITS_RETURN ("fits_eval_pixrange: error on read bitpix 32 data", -1);
ptr = pixdat;
if (hdu->used.blank)
{FITS_BITPIX32 blankval = (FITS_BITPIX32)hdu->blank;
......@@ -1329,7 +1325,7 @@ static int fits_eval_pixrange (FILE *fp, FITS_HDU_LIST *hdu)
nelem -= maxelem;
if (fread ((char *)pixdat, bpp, maxelem, fp) != maxelem)
FITS_RETURN ("fits_eval_pixrange: error on read bitpix -32 data", -1);