(CC:ed to authors) I went through the file plugins and added magic patterns to those who didn't register any, and corrected those already exisiting. The only case where I'm not 100% certain is the MPEG magic number; the ones chosen are from my /etc/magic file, and all mpegs I've looked at had either of them. This patch, together with the earlier TGA-and-magicless-load patch, have been uploaded to ftp.gimp.org as gimp-mattias-000227-0.patch. --- gimp-1.1.17/plug-ins/common/CEL.c.orig Sat Feb 26 22:43:27 2000 +++ gimp-1.1.17/plug-ins/common/CEL.c Sat Feb 26 22:43:53 2000 @@ -132,7 +132,7 @@ gimp_register_magic_load_handler ("file_cel_load", "cel", "", - "0,string,KiSS\040"); + "0,string,KiSS\\040"); gimp_register_save_handler ("file_cel_save", "cel", ""); --- gimp-1.1.17/plug-ins/common/bz2.c.orig Sat Feb 26 21:15:06 2000 +++ gimp-1.1.17/plug-ins/common/bz2.c Sat Feb 26 21:17:20 2000 @@ -132,9 +132,10 @@ nsave_args, 0, save_args, NULL); - gimp_register_load_handler ("file_bz2_load", - "xcf.bz2,bz2,xcfbz2", - ""); + gimp_register_magic_load_handler ("file_bz2_load", + "xcf.bz2,bz2,xcfbz2", + "", + "0,string,BZh"); gimp_register_save_handler ("file_bz2_save", "xcf.bz2,bz2,xcfbz2", ""); --- gimp-1.1.17/plug-ins/common/gicon.c.orig Sat Feb 26 22:28:50 2000 +++ gimp-1.1.17/plug-ins/common/gicon.c Sat Feb 26 22:46:23 2000 @@ -146,9 +146,11 @@ nsave_args, 0, save_args, NULL); - gimp_register_load_handler ("file_gicon_load", - "ico", - ""); + gimp_register_magic_load_handler ("file_gicon_load", + "ico", + "", + "0,string," + "/*\\040\\040GIMP\\040icon\\040image"); gimp_register_save_handler ("file_gicon_save", "ico", ""); --- gimp-1.1.17/plug-ins/common/mpeg.c.orig Sat Feb 26 21:07:10 2000 +++ gimp-1.1.17/plug-ins/common/mpeg.c Sat Feb 26 21:14:44 2000 @@ -133,9 +133,10 @@ nload_args, nload_return_vals, load_args, load_return_vals); - gimp_register_load_handler ("file_mpeg_load", - "mpg,mpeg", - ""); + gimp_register_magic_load_handler ("file_mpeg_load", + "mpg,mpeg", + "" + "0,long,0x000001b3,0,long,0x000001ba"); } static void --- gimp-1.1.17/plug-ins/common/psd.c.orig Sat Feb 26 21:29:26 2000 +++ gimp-1.1.17/plug-ins/common/psd.c Sat Feb 26 21:37:51 2000 @@ -402,7 +402,8 @@ nload_args, nload_return_vals, load_args, load_return_vals); - gimp_register_load_handler ("file_psd_load", "psd", ""); + gimp_register_magic_load_handler ("file_psd_load", "psd", "", + "0,string,8BPS"); } --- gimp-1.1.17/plug-ins/common/psp.c.orig Sat Feb 26 22:50:38 2000 +++ gimp-1.1.17/plug-ins/common/psp.c Sat Feb 26 22:51:06 2000 @@ -398,7 +398,7 @@ gimp_register_magic_load_handler ("file_psp_load", "psp,tub", "", - "0,string,Paint Shop Pro Image File\n\032"); + "0,string,Paint\\040Shop\\040Pro\\040Image\\040File\n\032"); /* Removed until Saving is implemented -- njl195@xxxxxxxxxx gimp_register_save_handler ("file_psp_save", "psp,tub", --- gimp-1.1.17/plug-ins/common/xpm.c.orig Sat Feb 26 22:51:25 2000 +++ gimp-1.1.17/plug-ins/common/xpm.c Sat Feb 26 22:51:32 2000 @@ -180,7 +180,7 @@ gimp_register_magic_load_handler ("file_xpm_load", "xpm", "<Load>/Xpm", - "0, string, /* XPM */"); + "0, string,/*\\040XPM\\040*/"); gimp_register_save_handler ("file_xpm_save", "xpm", "<Save>/Xpm"); --- gimp-1.1.17/plug-ins/common/xwd.c.orig Sun Feb 27 17:32:13 2000 +++ gimp-1.1.17/plug-ins/common/xwd.c Sun Feb 27 18:36:29 2000 @@ -1,7 +1,7 @@ /* The GIMP -- an image manipulation program * Copyright (C) 1995 Spencer Kimball and Peter Mattis * XWD reading and writing code Copyright (C) 1996 Peter Kirchgessner - * (email: pkirchg@xxxxxxx, WWW: http://members.aol.com/pkirchg) + * (email: peter@xxxxxxxxxxxxxxxx, WWW: http://www.kirchgessner.net) * * 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 @@ -35,6 +35,7 @@ * 2 | 1,...,24 | 32 */ /* Event history: + * PK = Peter Kirchgessner, ME = Mattias Engdegård * V 1.00, PK, xx-Aug-96: First try * V 1.01, PK, 03-Sep-96: Check for bitmap_bit_order * V 1.90, PK, 17-Mar-97: Upgrade to work with GIMP V0.99 @@ -43,8 +44,10 @@ * V 1.91, PK, 05-Apr-97: Return all arguments, even in case of an error * V 1.92, PK, 12-Oct-97: No progress bars for non-interactive mode * V 1.93, PK, 11-Apr-98: Fix problem with overwriting memory + * V 1.94, ME, 27-Feb-00: Remove superfluous little-endian support (format is + specified as big-endian). Trim magic header */ -static char ident[] = "@(#) GIMP XWD file-plugin v1.93 11-Apr-98"; +static char ident[] = "@(#) GIMP XWD file-plugin v1.94 27-Feb-2000"; #include "config.h" @@ -183,8 +186,6 @@ static gint save_rgb (FILE *, gint32, gint32); -static int read_msb_first = 1; - GPlugInInfo PLUG_IN_INFO = { @@ -260,7 +261,7 @@ gimp_register_magic_load_handler ("file_xwd_load", "xwd", "", - "4,long,0x00000007,4,long,0x07000000"); + "4,long,0x00000007"); gimp_register_save_handler ("file_xwd_save", "xwd", ""); @@ -399,22 +400,12 @@ return (-1); } - read_msb_first = 1; /* Start reading with most significant byte first */ - read_xwd_header (ifp, &xwdhdr); if (xwdhdr.l_file_version != 7) { - read_msb_first = 0; /* Try reading with least significant byte first */ - - fseek (ifp, 0, SEEK_SET); - - read_xwd_header (ifp, &xwdhdr); - if (xwdhdr.l_file_version != 7) - { - g_message(_("can't open file as XWD file")); - fclose (ifp); - return (-1); - } + g_message(_("can't open file as XWD file")); + fclose (ifp); + return (-1); } /* Position to start of XWDColor structures */ @@ -585,20 +576,10 @@ { L_CARD32 c; - if (read_msb_first) - { - c = (((L_CARD32)(getc (ifp))) << 24); - c |= (((L_CARD32)(getc (ifp))) << 16); - c |= (((L_CARD32)(getc (ifp))) << 8); - c |= ((L_CARD32)(*err = getc (ifp))); - } - else - { - c = ((L_CARD32)(getc (ifp))); - c |= (((L_CARD32)(getc (ifp))) << 8); - c |= (((L_CARD32)(getc (ifp))) << 16); - c |= (((L_CARD32)(*err = getc (ifp))) << 24); - } + c = (((L_CARD32)(getc (ifp))) << 24); + c |= (((L_CARD32)(getc (ifp))) << 16); + c |= (((L_CARD32)(getc (ifp))) << 8); + c |= ((L_CARD32)(*err = getc (ifp))); *err = (*err < 0); return (c); @@ -612,16 +593,8 @@ { L_CARD16 c; - if (read_msb_first) - { - c = (((L_CARD16)(getc (ifp))) << 8); - c |= ((L_CARD16)(*err = getc (ifp))); - } - else - { - c = ((L_CARD16)(getc (ifp))); - c |= (((L_CARD16)(*err = getc (ifp))) << 8); - } + c = (((L_CARD16)(getc (ifp))) << 8); + c |= ((L_CARD16)(*err = getc (ifp))); *err = (*err < 0); return (c);