Commit a7b50bbe authored by Manish Singh's avatar Manish Singh

plug mem leak in message_box

* app/interface.c: plug mem leak in message_box

* plug-ins/mail/mail.c: use g_message

* plug-ins/script-fu/scripts/carve-it.scm: fix for gimp-layer-new params from
Kevin Cozens <kcozens@interlog.com>

* plug-ins/CEL/CEL.c
* plug-ins/pcx/pcx.c
* plug-ins/tiff/tiff.c: updates from author

* plug-ins/png/png.c: correct copyright

* plug-ins/print/print.h: use correct version

-Yosh
parent 619a2eb0
Sat May 30 23:42:12 PDT 1998 Manish Singh <yosh@gimp.org>
* app/interface.c: plug mem leak in message_box
* plug-ins/mail/mail.c: use g_message
* plug-ins/script-fu/scripts/carve-it.scm: fix for gimp-layer-new
params from Kevin Cozens <kcozens@interlog.com>
* plug-ins/CEL/CEL.c
* plug-ins/pcx/pcx.c
* plug-ins/tiff/tiff.c: updates from author
* plug-ins/png/png.c: correct copyright
* plug-ins/print/print.h: use correct version
Fri May 29 23:54:42 PDT 1998 Manish Singh <yosh@gimp.org>
* more changes to use g_message. All of app uses it now, plus
......
......@@ -943,6 +943,8 @@ message_box (char *message,
gtk_widget_show (label);
}
g_free (message);
msg_box->mbox = mbox;
msg_box->callback = callback;
msg_box->data = data;
......
......@@ -943,6 +943,8 @@ message_box (char *message,
gtk_widget_show (label);
}
g_free (message);
msg_box->mbox = mbox;
msg_box->callback = callback;
msg_box->data = data;
......
......@@ -943,6 +943,8 @@ message_box (char *message,
gtk_widget_show (label);
}
g_free (message);
msg_box->mbox = mbox;
msg_box->callback = callback;
msg_box->data = data;
......
/* cel.c -- KISS CEL file format plug-in for The GIMP
* (copyright) 1997,1998 Nick Lamb (njl195@ecs.soton.ac.uk)
* (copyright) 1997,1998 Nick Lamb (njl195@zepler.org.uk)
*
* Skeleton cloned from Michael Sweet's PNG plug-in. KISS format courtesy
* of the KISS/GS documentation. Problem reports to the above address
......@@ -91,7 +91,8 @@ static void query(void) {
gimp_install_procedure("file_cel_load",
"Loads files in KISS CEL file format",
"This plug-in loads individual KISS cell files.",
"Nick Lamb", "Nick Lamb", "May 1998", "<Load>/CEL", NULL, PROC_PLUG_IN,
"Nick Lamb", "Nick Lamb <njl195@zepler.org.uk>", "May 1998",
"<Load>/CEL", NULL, PROC_PLUG_IN,
nload_args, nload_return_vals, load_args, load_return_vals);
gimp_register_magic_load_handler("file_cel_load", "cel",
......@@ -100,7 +101,8 @@ static void query(void) {
gimp_install_procedure("file_cel_save",
"Saves files in KISS CEL file format",
"This plug-in saves individual KISS cell files.",
"Nick Lamb", "Nick Lamb", "May 1998", "<Save>/CEL", "INDEXEDA",
"Nick Lamb", "Nick Lamb <njl195@zepler.org.uk>", "May 1998",
"<Save>/CEL", "INDEXEDA",
PROC_PLUG_IN, nsave_args, 0, save_args, NULL);
gimp_register_save_handler("file_cel_save", "cel", "");
......@@ -226,7 +228,7 @@ static gint32 load_image(char *file, char *brief) {
image = gimp_image_new(width + offx, height + offy, INDEXED);
if (image == -1) {
g_message("Can't create a new image");
g_message("CEL Can't create a new image");
gimp_quit();
}
......@@ -286,7 +288,7 @@ static gint32 load_image(char *file, char *brief) {
}
break;
default:
g_error("Unsupported number of colours (%d)\n", colours);
g_message("Unsupported number of colours (%d)", colours);
gimp_quit();
}
......@@ -397,7 +399,7 @@ static gint save_image(char *file, char *brief, gint32 image, gint32 layer) {
fp = fopen(file, "w");
if (fp == NULL) {
g_message("Couldn't write image to\n%s", file);
g_message("CEL Couldn't write image to\n%s", file);
gimp_quit();
}
......
/* cel.c -- KISS CEL file format plug-in for The GIMP
* (copyright) 1997,1998 Nick Lamb (njl195@ecs.soton.ac.uk)
* (copyright) 1997,1998 Nick Lamb (njl195@zepler.org.uk)
*
* Skeleton cloned from Michael Sweet's PNG plug-in. KISS format courtesy
* of the KISS/GS documentation. Problem reports to the above address
......@@ -91,7 +91,8 @@ static void query(void) {
gimp_install_procedure("file_cel_load",
"Loads files in KISS CEL file format",
"This plug-in loads individual KISS cell files.",
"Nick Lamb", "Nick Lamb", "May 1998", "<Load>/CEL", NULL, PROC_PLUG_IN,
"Nick Lamb", "Nick Lamb <njl195@zepler.org.uk>", "May 1998",
"<Load>/CEL", NULL, PROC_PLUG_IN,
nload_args, nload_return_vals, load_args, load_return_vals);
gimp_register_magic_load_handler("file_cel_load", "cel",
......@@ -100,7 +101,8 @@ static void query(void) {
gimp_install_procedure("file_cel_save",
"Saves files in KISS CEL file format",
"This plug-in saves individual KISS cell files.",
"Nick Lamb", "Nick Lamb", "May 1998", "<Save>/CEL", "INDEXEDA",
"Nick Lamb", "Nick Lamb <njl195@zepler.org.uk>", "May 1998",
"<Save>/CEL", "INDEXEDA",
PROC_PLUG_IN, nsave_args, 0, save_args, NULL);
gimp_register_save_handler("file_cel_save", "cel", "");
......@@ -226,7 +228,7 @@ static gint32 load_image(char *file, char *brief) {
image = gimp_image_new(width + offx, height + offy, INDEXED);
if (image == -1) {
g_message("Can't create a new image");
g_message("CEL Can't create a new image");
gimp_quit();
}
......@@ -286,7 +288,7 @@ static gint32 load_image(char *file, char *brief) {
}
break;
default:
g_error("Unsupported number of colours (%d)\n", colours);
g_message("Unsupported number of colours (%d)", colours);
gimp_quit();
}
......@@ -397,7 +399,7 @@ static gint save_image(char *file, char *brief, gint32 image, gint32 layer) {
fp = fopen(file, "w");
if (fp == NULL) {
g_message("Couldn't write image to\n%s", file);
g_message("CEL Couldn't write image to\n%s", file);
gimp_quit();
}
......
......@@ -335,19 +335,19 @@ save_image (char *filename,
/* fork off a uuencode process */
if ((pid = fork ()) < 0)
{
g_warning ("mail: fork failed: %s\n", g_strerror (errno));
g_message ("mail: fork failed: %s\n", g_strerror (errno));
return -1;
}
else if (pid == 0)
{
if (-1 == dup2 (fileno (mailpipe), fileno (stdout)))
{
g_warning ("mail: dup2 failed: %s\n", g_strerror (errno));
g_message ("mail: dup2 failed: %s\n", g_strerror (errno));
}
execlp (UUENCODE, UUENCODE, tmpname, filename, NULL);
/* What are we doing here? exec must have failed */
g_warning ("mail: exec failed: uuencode: %s\n", g_strerror (errno));
g_message ("mail: exec failed: uuencode: %s\n", g_strerror (errno));
/* close the pipe now */
......@@ -361,7 +361,7 @@ save_image (char *filename,
if (!WIFEXITED (status) ||
WEXITSTATUS (status) != 0)
{
g_warning ("mail: mail didnt work or something on file %s\n", tmpname);
g_message ("mail: mail didnt work or something on file %s\n", tmpname);
return 0;
}
}
......@@ -656,7 +656,7 @@ find_extension (char *filename)
{
if (!ext || ext[1] == 0 || strchr (ext, '/'))
{
g_warning ("mail: some sort of error with the file extension or lack thereof \n");
g_message ("mail: some sort of error with the file extension or lack thereof \n");
return NULL;
}
......
......@@ -2,12 +2,14 @@
/* This code is based in parts on code by Francisco Bustamante, but the
largest portion of the code has been rewritten and is now maintained
occasionally by Nick Lamb njl195@ecs.soton.ac.uk */
occasionally by Nick Lamb njl195@zepler.org.uk */
/* New for 1998 -- Load 1, 4, 8 & 24 bit PCX files */
/* -- Save 8 & 24 bit PCX files */
/* 1998-01-19 - fixed some endianness problems (Raphael Quinet) */
/* 1998-02-05 - merged patch with "official" tree, some tidying up (njl) */
/* 1998-05-17 - changed email address, more tidying up (njl) */
/* 1998-05-31 - g_message (njl) */
/* Please contact me if you can't use your PCXs with this tool, I want
The GIMP to have the best file filters on the planet */
......@@ -15,7 +17,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "gtk/gtk.h"
#include "libgimp/gimp.h"
......@@ -73,7 +74,7 @@ static void query () {
"Loads files in Zsoft PCX file format",
"FIXME: write help for pcx_load",
"Francisco Bustamante & Nick Lamb",
"Nick Lamb <njl195@ecs.soton.ac.uk>",
"Nick Lamb <njl195@zepler.org.uk>",
"January 1997",
"<Load>/PCX",
NULL,
......@@ -85,7 +86,7 @@ static void query () {
"Saves files in ZSoft PCX file format",
"FIXME: write help for pcx_save",
"Francisco Bustamante & Nick Lamb",
"Nick Lamb <njl195@ecs.soton.ac.uk>",
"Nick Lamb <njl195@zepler.org.uk>",
"January 1997",
"<Save>/PCX",
"INDEXED, RGB, GRAY",
......@@ -101,10 +102,10 @@ static void query () {
/* Declare internal functions. */
static gint32 load_image (char *filename);
static void load_1(FILE *fp, int width, int height, guchar *buffer, int bytes);
static void load_4(FILE *fp, int width, int height, guchar *buffer, int bytes);
static void load_8(FILE *fp, int width, int height, guchar *buffer, int bytes);
static void load_24(FILE *fp, int width, int height, guchar *buffer, int bytes);
static void load_1(FILE *fp, int width, int height, char *buffer, int bytes);
static void load_4(FILE *fp, int width, int height, char *buffer, int bytes);
static void load_8(FILE *fp, int width, int height, char *buffer, int bytes);
static void load_24(FILE *fp, int width, int height, char *buffer, int bytes);
static void readline(FILE *fp, guchar* buffer, int bytes);
static gint save_image (char *filename, gint32 image, gint32 layer);
......@@ -128,21 +129,17 @@ static void run (char *name, int nparams, GParam *param, int *nreturn_vals,
values[0].type = PARAM_STATUS;
values[0].data.d_status = STATUS_CALLING_ERROR;
if (strcmp (name, "file_pcx_load") == 0)
{
if (strcmp (name, "file_pcx_load") == 0) {
image_ID = load_image (param[1].data.d_string);
if (image_ID != -1)
{
*nreturn_vals = 2;
values[0].data.d_status = STATUS_SUCCESS;
values[1].type = PARAM_IMAGE;
values[1].data.d_image = image_ID;
}
else
{
values[0].data.d_status = STATUS_EXECUTION_ERROR;
}
if (image_ID != -1) {
*nreturn_vals = 2;
values[0].data.d_status = STATUS_SUCCESS;
values[1].type = PARAM_IMAGE;
values[1].data.d_image = image_ID;
} else {
values[0].data.d_status = STATUS_EXECUTION_ERROR;
}
}
else if (strcmp (name, "file_pcx_save") == 0)
{
......@@ -208,17 +205,17 @@ static gint32 load_image (char *filename) {
fd = fopen (filename, "rb");
if (!fd) {
fprintf(stderr, "PCX: Can't open \"%s\"\n", filename);
g_message("PCX Can't open\n%s", filename);
return -1;
}
if (fread(&pcx_header, 128, 1, fd) == 0) {
fprintf(stderr, "PCX: Can't read header from \"%s\"\n", filename);
g_message("PCX Can't read header from\n%s", filename);
return -1;
}
if(pcx_header.manufacturer != 10) {
fprintf(stderr, "PCX: File \"%s\" is not a PCX file\n", filename);
g_message("%s\nis not a PCX file", filename);
return -1;
}
......@@ -259,7 +256,7 @@ static gint32 load_image (char *filename) {
dest = (guchar *) g_malloc (width * height * 3);
load_24(fd, width, height, dest, qtohs (pcx_header.bytesperline));
} else {
fprintf(stderr, "PCX: Unusual PCX flavour, giving up\n");
g_message("Unusual PCX flavour, giving up");
return -1;
}
......@@ -274,7 +271,7 @@ static gint32 load_image (char *filename) {
return image;
}
static void load_8(FILE *fp, int width, int height, guchar *buffer, int bytes) {
static void load_8(FILE *fp, int width, int height, char *buffer, int bytes) {
int row;
guchar *line;
line= (guchar *) g_malloc(bytes);
......@@ -288,7 +285,7 @@ static void load_8(FILE *fp, int width, int height, guchar *buffer, int bytes) {
g_free(line);
}
static void load_24(FILE *fp, int width, int height, guchar *buffer, int bytes) {
static void load_24(FILE *fp, int width, int height, char *buffer, int bytes) {
int x, y, c;
guchar *line;
line= (guchar *) g_malloc(bytes * 3);
......@@ -306,7 +303,7 @@ static void load_24(FILE *fp, int width, int height, guchar *buffer, int bytes)
g_free(line);
}
static void load_1(FILE *fp, int width, int height, guchar *buffer, int bytes) {
static void load_1(FILE *fp, int width, int height, char *buffer, int bytes) {
int x, y;
guchar *line;
line= (guchar *) g_malloc(bytes);
......@@ -325,7 +322,7 @@ static void load_1(FILE *fp, int width, int height, guchar *buffer, int bytes) {
g_free(line);
}
static void load_4(FILE *fp, int width, int height, guchar *buffer, int bytes) {
static void load_4(FILE *fp, int width, int height, char *buffer, int bytes) {
int x, y, c;
guchar *line;
line= (guchar *) g_malloc(bytes);
......@@ -367,7 +364,7 @@ static void readline(FILE *fp, guchar *buffer, int bytes) {
}
}
static gint save_image (char *filename, gint32 image, gint32 layer) {
gint save_image (char *filename, gint32 image, gint32 layer) {
FILE *fp;
GPixelRgn pixel_rgn;
GDrawable *drawable;
......@@ -417,13 +414,13 @@ static gint save_image (char *filename, gint32 image, gint32 layer) {
break;
default:
fprintf(stderr, "PCX: Can't save this image type\n");
g_message("PCX Can't save this image type\nFlatten your image");
return -1;
break;
}
if ((fp = fopen(filename, "wb")) == NULL) {
fprintf(stderr, "PCX: Can't open \"%s\"\n", filename);
g_message("PCX Can't open \n%s", filename);
return -1;
}
......@@ -461,7 +458,7 @@ static gint save_image (char *filename, gint32 image, gint32 layer) {
}
break;
default:
fprintf(stderr, "PCX: Can't save this image type\n");
g_message("Can't save this image as PCX\nFlatten your image");
return -1;
break;
}
......
......@@ -4,7 +4,7 @@
* Portable Network Graphics (PNG) plug-in for The GIMP -- an image
* manipulation program
*
* Copyright 1997 Michael Sweet (mike@easysw.com) and
* Copyright 1997-1998 Michael Sweet (mike@easysw.com) and
* Daniel Skarda (0rfelyus@atrey.karlin.mff.cuni.cz).
*
* This program is free software; you can redistribute it and/or modify
......@@ -37,6 +37,24 @@
* Revision History:
*
* $Log$
* Revision 1.7 1998/05/31 06:49:16 yosh
* * app/interface.c: plug mem leak in message_box
*
* * plug-ins/mail/mail.c: use g_message
*
* * plug-ins/script-fu/scripts/carve-it.scm: fix for gimp-layer-new params from
* Kevin Cozens <kcozens@interlog.com>
*
* * plug-ins/CEL/CEL.c
* * plug-ins/pcx/pcx.c
* * plug-ins/tiff/tiff.c: updates from author
*
* * plug-ins/png/png.c: correct copyright
*
* * plug-ins/print/print.h: use correct version
*
* -Yosh
*
* Revision 1.6 1998/04/13 05:43:08 yosh
* Have fun recompiling gimp everyone. It's the great FSF address change!
*
......
......@@ -124,7 +124,7 @@ query ()
"loads files of the tiff file format",
"FIXME: write help for tiff_load",
"Spencer Kimball, Peter Mattis & Nick Lamb",
"Nick Lamb <njl195@.ecs.soton.ac.uk>",
"Nick Lamb <njl195@zepler.org.uk>",
"1995-1996,1998",
"<Load>/Tiff",
NULL,
......@@ -248,7 +248,7 @@ static gint32 load_image (char *filename) {
unsigned short *redmap, *greenmap, *bluemap;
guchar cmap[768];
int image_type= 0, layer_type= 0;
unsigned short *extra_types, extra = 0;
unsigned short extra, *extra_types;
int col, row, start, i, j;
unsigned char sample;
......@@ -274,7 +274,7 @@ static gint32 load_image (char *filename) {
tif = TIFFOpen (filename, "r");
if (!tif) {
g_error ("TIFF Can't open \"%s\"\n", filename);
g_message("TIFF Can't open \n%s", filename);
gimp_quit ();
}
......@@ -287,7 +287,7 @@ static gint32 load_image (char *filename) {
bps = 1;
if (bps > 8) {
g_error("TIFF Can't handle samples wider than 8-bit\n");
g_message("TIFF Can't handle samples wider than 8-bit");
gimp_quit();
}
......@@ -297,17 +297,17 @@ static gint32 load_image (char *filename) {
extra = 0;
if (!TIFFGetField (tif, TIFFTAG_IMAGEWIDTH, &cols)) {
g_error ("TIFF Can't get image width\n");
g_message("TIFF Can't get image width");
gimp_quit ();
}
if (!TIFFGetField (tif, TIFFTAG_IMAGELENGTH, &rows)) {
g_error ("TIFF Can't get image length\n");
g_message("TIFF Can't get image length");
gimp_quit ();
}
if (!TIFFGetField (tif, TIFFTAG_PHOTOMETRIC, &photomet)) {
g_error ("TIFF Can't get photometric\n");
g_message("TIFF Can't get photometric");
gimp_quit ();
}
......@@ -318,9 +318,12 @@ static gint32 load_image (char *filename) {
alpha = 0;
}
/* some programs seem to think alpha etc. aren't "extra" samples (?) */
if (spp > 3) {
if (photomet == PHOTOMETRIC_RGB && spp > extra + 3) {
extra= spp - 3;
alpha= 1;
} else if (photomet != PHOTOMETRIC_RGB && spp > extra + 1) {
extra= spp - 1;
alpha= 1;
}
maxval = (1 << bps) - 1;
......@@ -343,16 +346,16 @@ static gint32 load_image (char *filename) {
break;
case PHOTOMETRIC_MASK:
g_error ("TIFF Can't handle PHOTOMETRIC_MASK\n");
g_message ("TIFF Can't handle PHOTOMETRIC_MASK");
gimp_quit ();
break;
default:
g_error ("TIFF Unknown photometric: %d\n", photomet);
g_message ("TIFF Unknown photometric\n Number %d", photomet);
gimp_quit ();
}
if ((image = gimp_image_new (cols, rows, image_type)) == -1) {
g_error ("TIFF Can't allocate new image\n");
g_message("TIFF Can't create a new image\n");
gimp_quit ();
}
gimp_image_set_filename (image, filename);
......@@ -360,7 +363,7 @@ static gint32 load_image (char *filename) {
/* Install colormap for INDEXED images only */
if (image_type == INDEXED) {
if (!TIFFGetField (tif, TIFFTAG_COLORMAP, &redmap, &greenmap, &bluemap)) {
g_error ("TIFF Can't get colormaps\n");
g_message("TIFF Can't get colormaps");
gimp_quit ();
}
......@@ -416,14 +419,14 @@ static gint32 load_image (char *filename) {
/* Special cases: Scanline is compatible with GIMP storage */
if (extra == 0 && bps == 8) {
if (TIFFReadScanline (tif, d, row, 0) < 0) {
g_error ("TIFF Bad data read on line %d\n", row);
g_message("TIFF Bad data read on line %d", row);
gimp_quit ();
}
/* Or read in and process each sample -- slower */
} else {
if (TIFFReadScanline (tif, source, row, 0) < 0) {
g_error ("TIFF Bad data read on line %d\n", row);
g_message("TIFF Bad data read on line %d\n", row);
gimp_quit ();
}
......@@ -602,11 +605,10 @@ static gint save_image (char *filename, gint32 image, gint32 layer) {
rowsperstrip = 0;
tif = TIFFOpen (filename, "w");
if (!tif)
{
g_print ("can't open \"%s\"\n", filename);
return 0;
}
if (!tif) {
g_print ("Can't write image to\n%s", filename);
return 0;
}
name = malloc (strlen (filename) + 11);
sprintf (name, "Saving %s:", filename);
......@@ -752,11 +754,10 @@ static gint save_image (char *filename, gint32 image, gint32 layer) {
break;
}
if (!success)
{
g_print ("failed a scanline write on row %d\n", row);
if (!success) {
g_message("TIFF Failed a scanline write on row %d", row);
return 0;
}
}
}
gimp_progress_update ((double) row / (double) rows);
......
......@@ -335,19 +335,19 @@ save_image (char *filename,
/* fork off a uuencode process */
if ((pid = fork ()) < 0)
{
g_warning ("mail: fork failed: %s\n", g_strerror (errno));
g_message ("mail: fork failed: %s\n", g_strerror (errno));
return -1;
}
else if (pid == 0)
{
if (-1 == dup2 (fileno (mailpipe), fileno (stdout)))
{
g_warning ("mail: dup2 failed: %s\n", g_strerror (errno));
g_message ("mail: dup2 failed: %s\n", g_strerror (errno));
}
execlp (UUENCODE, UUENCODE, tmpname, filename, NULL);
/* What are we doing here? exec must have failed */
g_warning ("mail: exec failed: uuencode: %s\n", g_strerror (errno));
g_message ("mail: exec failed: uuencode: %s\n", g_strerror (errno));
/* close the pipe now */
......@@ -361,7 +361,7 @@ save_image (char *filename,
if (!WIFEXITED (status) ||
WEXITSTATUS (status) != 0)
{
g_warning ("mail: mail didnt work or something on file %s\n", tmpname);
g_message ("mail: mail didnt work or something on file %s\n", tmpname);
return 0;
}
}
......@@ -656,7 +656,7 @@ find_extension (char *filename)
{
if (!ext || ext[1] == 0 || strchr (ext, '/'))
{
g_warning ("mail: some sort of error with the file extension or lack thereof \n");
g_message ("mail: some sort of error with the file extension or lack thereof \n");
return NULL;
}
......
......@@ -2,12 +2,14 @@
/* This code is based in parts on code by Francisco Bustamante, but the
largest portion of the code has been rewritten and is now maintained
occasionally by Nick Lamb njl195@ecs.soton.ac.uk */
occasionally by Nick Lamb njl195@zepler.org.uk */
/* New for 1998 -- Load 1, 4, 8 & 24 bit PCX files */
/* -- Save 8 & 24 bit PCX files */
/* 1998-01-19 - fixed some endianness problems (Raphael Quinet) */
/* 1998-02-05 - merged patch with "official" tree, some tidying up (njl) */
/* 1998-05-17 - changed email address, more tidying up (njl) */
/* 1998-05-31 - g_message (njl) */
/* Please contact me if you can't use your PCXs with this tool, I want
The GIMP to have the best file filters on the planet */
......@@ -15,7 +17,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "gtk/gtk.h"
#include "libgimp/gimp.h"
......@@ -73,7 +74,7 @@ static void query () {
"Loads files in Zsoft PCX file format",
"FIXME: write help for pcx_load",
"Francisco Bustamante & Nick Lamb",
"Nick Lamb <njl195@ecs.soton.ac.uk>",
"Nick Lamb <njl195@zepler.org.uk>",
"January 1997",
"<Load>/PCX",
NULL,
......@@ -85,7 +86,7 @@ static void query () {
"Saves files in ZSoft PCX file format",
"FIXME: write help for pcx_save",
"Francisco Bustamante & Nick Lamb",
"Nick Lamb <njl195@ecs.soton.ac.uk>",
"Nick Lamb <njl195@zepler.org.uk>",
"January 1997",
"<Save>/PCX",
"INDEXED, RGB, GRAY",
......@@ -101,10 +102,10 @@ static void query () {
/* Declare internal functions. */
static gint32 load_image (char *filename);
static void load_1(FILE *fp, int width, int height, guchar *buffer, int bytes);
static void load_4(FILE *fp, int width, int height, guchar *buffer, int bytes);
static void load_8(FILE *fp, int width, int height, guchar *buffer, int bytes);
static void load_24(FILE *fp, int width, int height, guchar *buffer, int bytes);
static void load_1(FILE *fp, int width, int height, char *buffer, int bytes);
static void load_4(FILE *fp, int width, int height, char *buffer, int bytes);
static void load_8(FILE *fp, int width, int height, char *buffer, int bytes);
static void load_24(FILE *fp, int width, int height, char *buffer, int bytes);
static void readline(FILE *fp, guchar* buffer, int bytes);
static gint save_image (char *filename, gint32 image, gint32 layer);
......@@ -128,21 +129,17 @@ static void run (char *name, int nparams, GParam *param, int *nreturn_vals,
values[0].type = PARAM_STATUS;
values[0].data.d_status = STATUS_CALLING_ERROR;
if (strcmp (name, "file_pcx_load") == 0)
{
if (strcmp (name, "file_pcx_load") == 0) {
image_ID = load_image (param[1].data.d_string);
if (image_ID != -1)
{
*nreturn_vals = 2;
values[0].data.d_status = STATUS_SUCCESS;
values[1].type = PARAM_IMAGE;
values[1].data.d_image = image_ID;
}
else
{
values[0].data.d_status = STATUS_EXECUTION_ERROR;
}
if (image_ID != -1) {
*nreturn_vals = 2;
values[0].data.d_status = STATUS_SUCCESS;
values[1].type = PARAM_IMAGE;
values[1].data.d_image = image_ID;
} else {
values[0].data.d_status = STATUS_EXECUTION_ERROR;
}
}
else if (strcmp (name, "file_pcx_save") == 0)
{
......@@ -208,17 +205,17 @@ static gint32 load_image (char *filename) {
fd = fopen (filename, "rb");
if (!fd) {
fprintf(stderr, "PCX: Can't open \"%s\"\n", filename);
g_message("PCX Can't open\n%s", filename);
return -1;
}
if (fread(&pcx_header, 128, 1, fd) == 0) {
fprintf(stderr, "PCX: Can't read header from \"%s\"\n", filename);
g_message("PCX Can't read header from\n%s", filename);
return -1;
}
if(pcx_header.manufacturer != 10) {
fprintf(stderr, "PCX: File \"%s\" is not a PCX file\n", filename);
g_message("%s\nis not a PCX file", filename);
return -1;
}
......@@ -259,7 +256,7 @@ static gint32 load_image (char *filename) {
dest = (guchar *) g_malloc (width * height * 3);
load_24(fd, width, height, dest, qtohs (pcx_header.bytesperline));
} else {
fprintf(stderr, "PCX: Unusual PCX flavour, giving up\n");
g_message("Unusual PCX flavour, giving up");
return -1;
}
......@@ -274,7 +271,7 @@ static gint32 load_image (char *filename) {
return image;
}
static void load_8(FILE *fp, int width, int height, guchar *buffer, int bytes) {
static void load_8(FILE *fp, int width, int height, char *buffer, int bytes) {
int row;
guchar *line;
line= (guchar *) g_malloc(bytes);
......@@ -288,7 +285,7 @@ static void load_8(FILE *fp, int width, int height, guchar *buffer, int bytes) {
g_free(line);
}
static void load_24(FILE *fp, int width, int height, guchar *buffer, int bytes) {
static void load_24(FILE *fp, int width, int height, char *buffer, int bytes) {
int x, y, c;
guchar *line;
line= (guchar *) g_malloc(bytes * 3);
......@@ -306,7 +303,7 @@ static void load_24(FILE *fp, int width, int height, guchar *buffer, int bytes)
g_free(line);
}
static void load_1(FILE *fp, int width, int height, guchar *buffer, int bytes) {
static void load_1(FILE *fp, int width, int height, char *buffer, int bytes) {
int x, y;
guchar *line;
line= (guchar *) g_malloc(bytes);
......@@ -325,7 +322,7 @@ static void load_1(FILE *fp, int width, int height, guchar *buffer, int bytes) {
g_free(line);
}
static void load_4(FILE *fp, int width, int height, guchar *buffer, int bytes) {
static void load_4(FILE *fp, int width, int height, char *buffer, int bytes) {