
2000-02-15 Tor Lillqvist <tml@iki.fi> * libgimp/gimp.def * libgimp/gimpui.def * libgimp/makefile.{cygwin,msc} * app/makefile.{cygwin,msc} * plug-ins/makefile.{cygwin,msc}: Updates. * app/datafiles.c (is_script): New Win32-only function, which tests if a file's extension matches one of the extensions in the PATHEXT environment variable (which the cmd.exe command interpreter also uses). This is to avoid starting applications associated with any random data file the user might have dropped in the plug-ins folder, while still supporting plug-ins written in scripting languages. * app/gimpparasite.c (gimp_parasiterc_save): (Win32:) Cannot rename to an existing file. * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_share.c * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c: Use G_PI. * plug-ins/common/gz.c: #ifdef G_OS_WIN32 was used before its potential definition via glib.h. * plug-ins/common/jpeg.c: Also recognize Exif files, which are typically produced by digital cameras. The usually have a .jpg file name extension, and would thus already match this plug-in, but add the magic string just in case. They are loaded just fine by libjpeg even if they don't have the JFIF signature. * plug-ins/common/tiff.c: Set TIFF warning and error handler, so we get to pass libtiff's messages through the normal channels.
172 lines
4.2 KiB
C
172 lines
4.2 KiB
C
/* gimpparasite.c: Copyright 1998 Jay Cox <jaycox@earthlink.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
|
|
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
*/
|
|
|
|
#include "config.h"
|
|
|
|
#include <glib.h>
|
|
#include <stdio.h>
|
|
#ifdef HAVE_UNISTD_H
|
|
#include <unistd.h>
|
|
#endif
|
|
|
|
#include "app_procs.h"
|
|
#include "parasitelist.h"
|
|
#include "gimpparasite.h"
|
|
#include "gimprc.h"
|
|
#include "libgimp/parasite.h"
|
|
#include "libgimp/gimpenv.h"
|
|
#include "libgimp/gimpintl.h"
|
|
|
|
static ParasiteList *parasites = NULL;
|
|
|
|
void
|
|
gimp_init_parasites()
|
|
{
|
|
g_return_if_fail (parasites == NULL);
|
|
parasites = parasite_list_new ();
|
|
gimp_parasiterc_load ();
|
|
}
|
|
|
|
void
|
|
gimp_parasite_attach (Parasite *p)
|
|
{
|
|
parasite_list_add (parasites, p);
|
|
}
|
|
|
|
void
|
|
gimp_parasite_detach (const char *name)
|
|
{
|
|
parasite_list_remove (parasites, name);
|
|
}
|
|
|
|
Parasite *
|
|
gimp_parasite_find (const char *name)
|
|
{
|
|
return parasite_list_find (parasites, name);
|
|
}
|
|
|
|
static void
|
|
list_func (char *key,
|
|
Parasite *p,
|
|
char ***cur)
|
|
{
|
|
*(*cur)++ = (char *) g_strdup (key);
|
|
}
|
|
|
|
char **
|
|
gimp_parasite_list (gint *count)
|
|
{
|
|
gchar **list, **cur;
|
|
|
|
*count = parasite_list_length (parasites);
|
|
cur = list = (char **) g_malloc (sizeof (char *) * *count);
|
|
|
|
parasite_list_foreach (parasites, (GHFunc)list_func, &cur);
|
|
|
|
return list;
|
|
}
|
|
|
|
static void
|
|
save_func (char *key,
|
|
Parasite *p,
|
|
FILE *fp)
|
|
{
|
|
if (parasite_is_persistent (p))
|
|
{
|
|
gchar *s;
|
|
guint32 l;
|
|
|
|
fprintf (fp, "(parasite \"%s\" %lu \"", parasite_name (p), parasite_flags (p));
|
|
|
|
/*
|
|
* the current methodology is: never move the parasiterc from one
|
|
* system to another. If you want to do this you should probably
|
|
* write out parasites which contain any non-alphanumeric(+some)
|
|
* characters as \xHH sequences altogether.
|
|
*/
|
|
|
|
for (s = (gchar *)parasite_data (p), l = parasite_data_size (p);
|
|
l;
|
|
l--, s++)
|
|
{
|
|
switch (*s)
|
|
{
|
|
case '\\': fputs ("\\\\", fp); break;
|
|
case '\0': fputs ("\\0", fp); break;
|
|
case '"' : fputs ("\\\"", fp); break;
|
|
/* disabled, not portable! */
|
|
/* case '\n': fputs ("\\n", fp); break;*/
|
|
/* case '\r': fputs ("\\r", fp); break;*/
|
|
case 26 : fputs ("\\z", fp); break;
|
|
default : fputc (*s, fp); break;
|
|
}
|
|
}
|
|
|
|
fputs ("\")\n\n", fp);
|
|
}
|
|
}
|
|
|
|
void
|
|
gimp_parasiterc_save (void)
|
|
{
|
|
char *filename;
|
|
FILE *fp;
|
|
|
|
filename = gimp_personal_rc_file ("#parasiterc.tmp~");
|
|
|
|
fp = fopen (filename, "w");
|
|
g_free (filename);
|
|
if (!fp)
|
|
return;
|
|
|
|
fprintf (fp, _("# GIMP parasiterc\n"
|
|
"# This file will be entirely rewritten every time you quit the gimp.\n\n"));
|
|
|
|
parasite_list_foreach (parasites, (GHFunc)save_func, fp);
|
|
|
|
fclose (fp);
|
|
|
|
#if defined(G_OS_WIN32) || defined(__EMX__)
|
|
/* First rename the old parasiterc out of the way */
|
|
unlink (gimp_personal_rc_file ("parasiterc.bak"));
|
|
rename (gimp_personal_rc_file ("parasiterc"),
|
|
gimp_personal_rc_file ("parasiterc.bak"));
|
|
#endif
|
|
|
|
if (rename(gimp_personal_rc_file ("#parasiterc.tmp~"),
|
|
gimp_personal_rc_file ("parasiterc")) != 0)
|
|
{
|
|
#if defined(G_OS_WIN32) || defined(__EMX__)
|
|
/* Rename the old parasiterc back */
|
|
rename (gimp_personal_rc_file ("parasiterc.bak"),
|
|
gimp_personal_rc_file ("parasiterc"));
|
|
#endif
|
|
unlink(gimp_personal_rc_file ("#parasiterc.tmp~"));
|
|
}
|
|
}
|
|
|
|
void
|
|
gimp_parasiterc_load (void)
|
|
{
|
|
char *filename;
|
|
|
|
filename = gimp_personal_rc_file ("parasiterc");
|
|
app_init_update_status (NULL, filename, -1);
|
|
parse_gimprc_file (filename);
|
|
g_free (filename);
|
|
}
|