1997-11-25 06:05:25 +08:00
|
|
|
/* 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
|
1998-04-13 13:44:11 +08:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
|
|
|
#include "config.h"
|
1998-03-15 01:54:08 +08:00
|
|
|
#include <locale.h>
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/wait.h>
|
|
|
|
#include <unistd.h>
|
1998-11-08 07:02:14 +08:00
|
|
|
#include "libgimp/gserialize.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
#ifndef WAIT_ANY
|
|
|
|
#define WAIT_ANY -1
|
|
|
|
#endif /* WAIT_ANY */
|
|
|
|
|
1998-07-15 10:28:31 +08:00
|
|
|
#include "libgimp/gimpfeatures.h"
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#include "appenv.h"
|
|
|
|
#include "app_procs.h"
|
|
|
|
#include "errors.h"
|
|
|
|
#include "install.h"
|
|
|
|
|
1998-08-06 07:46:04 +08:00
|
|
|
#include "libgimp/gimpintl.h"
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
static RETSIGTYPE on_signal (int);
|
|
|
|
static RETSIGTYPE on_sig_child (int);
|
|
|
|
static void init (void);
|
1998-11-08 07:02:14 +08:00
|
|
|
static void test_gserialize();
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* GLOBAL data */
|
|
|
|
int no_interface;
|
|
|
|
int no_data;
|
1998-02-18 04:14:29 +08:00
|
|
|
int no_splash;
|
|
|
|
int no_splash_image;
|
1998-01-26 06:13:00 +08:00
|
|
|
int be_verbose;
|
1997-11-25 06:05:25 +08:00
|
|
|
int use_shm;
|
1998-04-21 09:19:30 +08:00
|
|
|
int use_debug_handler;
|
1998-05-30 15:32:37 +08:00
|
|
|
int console_messages;
|
1998-07-12 06:23:23 +08:00
|
|
|
int restore_session;
|
1998-07-02 07:06:49 +08:00
|
|
|
GimpSet* image_context;
|
1998-06-20 07:45:54 +08:00
|
|
|
|
|
|
|
MessageHandlerType message_handler;
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
char *prog_name; /* The path name we are invoked with */
|
1998-07-11 10:00:19 +08:00
|
|
|
char *alternate_gimprc;
|
1998-07-11 15:06:39 +08:00
|
|
|
char *alternate_system_gimprc;
|
1997-11-25 06:05:25 +08:00
|
|
|
char **batch_cmds;
|
|
|
|
|
|
|
|
/* LOCAL data */
|
|
|
|
static int gimp_argc;
|
|
|
|
static char **gimp_argv;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* argv processing:
|
|
|
|
* Arguments are either switches, their associated
|
|
|
|
* values, or image files. As switches and their
|
|
|
|
* associated values are processed, those slots in
|
1998-09-11 03:03:20 +08:00
|
|
|
* the argv[] array are NULLed. We do this because
|
|
|
|
* unparsed args are treated as images to load on
|
|
|
|
* startup.
|
|
|
|
*
|
1997-11-25 06:05:25 +08:00
|
|
|
*
|
|
|
|
* The GTK switches are processed first (X switches are
|
|
|
|
* processed here, not by any X routines). Then the
|
|
|
|
* general GIMP switches are processed. Any args
|
|
|
|
* left are assumed to be image files the GIMP should
|
|
|
|
* display.
|
|
|
|
*
|
|
|
|
* The exception is the batch switch. When this is
|
|
|
|
* encountered, all remaining args are treated as batch
|
|
|
|
* commands.
|
|
|
|
*/
|
|
|
|
|
1998-02-05 13:41:05 +08:00
|
|
|
int
|
1997-11-25 06:05:25 +08:00
|
|
|
main (int argc, char **argv)
|
|
|
|
{
|
|
|
|
int show_version;
|
|
|
|
int show_help;
|
|
|
|
int i, j;
|
1998-08-29 07:01:46 +08:00
|
|
|
#ifdef HAVE_PUTENV
|
1997-12-18 07:28:44 +08:00
|
|
|
gchar *display_name, *display_env;
|
1998-08-29 07:01:46 +08:00
|
|
|
#endif
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-09-08 13:31:51 +08:00
|
|
|
g_atexit (g_mem_profile);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Initialize variables */
|
|
|
|
prog_name = argv[0];
|
|
|
|
|
|
|
|
/* Initialize Gtk toolkit */
|
1998-03-15 01:54:08 +08:00
|
|
|
gtk_set_locale ();
|
|
|
|
setlocale(LC_NUMERIC, "C"); /* must use dot, not comma, as decimal separator */
|
1998-08-06 07:46:04 +08:00
|
|
|
/* Initialize i18n support */
|
|
|
|
|
|
|
|
#ifdef HAVE_LC_MESSAGES
|
|
|
|
setlocale(LC_MESSAGES, "");
|
|
|
|
#endif
|
|
|
|
bindtextdomain("gimp", LOCALEDIR);
|
|
|
|
textdomain("gimp");
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_init (&argc, &argv);
|
1998-06-07 21:55:36 +08:00
|
|
|
|
|
|
|
#ifdef HAVE_LIBGLE
|
|
|
|
gle_init (&argc, &argv);
|
|
|
|
#endif /* !HAVE_LIBGLE */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-08-29 07:01:46 +08:00
|
|
|
#ifdef HAVE_PUTENV
|
1997-12-18 07:28:44 +08:00
|
|
|
display_name = gdk_get_display ();
|
|
|
|
display_env = g_new (gchar, strlen (display_name) + 9);
|
|
|
|
*display_env = 0;
|
|
|
|
strcat (display_env, "DISPLAY=");
|
|
|
|
strcat (display_env, display_name);
|
|
|
|
putenv (display_env);
|
1998-08-29 07:01:46 +08:00
|
|
|
#endif
|
1997-12-18 07:28:44 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
no_interface = FALSE;
|
|
|
|
no_data = FALSE;
|
1998-02-18 04:14:29 +08:00
|
|
|
no_splash = FALSE;
|
|
|
|
no_splash_image = FALSE;
|
1998-08-29 07:01:46 +08:00
|
|
|
#ifdef HAVE_SHM_H
|
1997-11-25 06:05:25 +08:00
|
|
|
use_shm = TRUE;
|
1998-08-29 07:01:46 +08:00
|
|
|
#else
|
|
|
|
use_shm = FALSE;
|
|
|
|
#endif
|
1998-04-21 09:19:30 +08:00
|
|
|
use_debug_handler = FALSE;
|
1998-07-12 06:23:23 +08:00
|
|
|
restore_session = FALSE;
|
1998-05-30 15:32:37 +08:00
|
|
|
console_messages = FALSE;
|
1998-06-20 07:45:54 +08:00
|
|
|
|
|
|
|
message_handler = CONSOLE;
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
batch_cmds = g_new (char*, argc);
|
|
|
|
batch_cmds[0] = NULL;
|
1998-07-11 10:00:19 +08:00
|
|
|
|
|
|
|
alternate_gimprc = NULL;
|
1998-07-11 15:06:39 +08:00
|
|
|
alternate_system_gimprc = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
show_version = FALSE;
|
|
|
|
show_help = FALSE;
|
|
|
|
|
1998-11-08 07:02:14 +08:00
|
|
|
test_gserialize();
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
for (i = 1; i < argc; i++)
|
|
|
|
{
|
|
|
|
if ((strcmp (argv[i], "--no-interface") == 0) ||
|
|
|
|
(strcmp (argv[i], "-n") == 0))
|
|
|
|
{
|
|
|
|
no_interface = TRUE;
|
1998-09-11 03:03:20 +08:00
|
|
|
argv[i] = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
else if ((strcmp (argv[i], "--batch") == 0) ||
|
|
|
|
(strcmp (argv[i], "-b") == 0))
|
|
|
|
{
|
1998-09-11 03:03:20 +08:00
|
|
|
argv[i] = NULL;
|
|
|
|
for (j = 0, i++ ; i < argc; j++, i++)
|
|
|
|
{
|
1997-11-25 06:05:25 +08:00
|
|
|
batch_cmds[j] = argv[i];
|
1998-09-11 03:03:20 +08:00
|
|
|
argv[i] = NULL;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
batch_cmds[j] = NULL;
|
1998-09-11 03:03:20 +08:00
|
|
|
|
|
|
|
if (batch_cmds[0] == NULL) /* We need at least one batch command */
|
|
|
|
show_help = TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
1998-07-11 15:06:39 +08:00
|
|
|
else if (strcmp (argv[i], "--system-gimprc") == 0)
|
|
|
|
{
|
1998-09-11 03:03:20 +08:00
|
|
|
argv[i] = NULL;
|
1998-07-11 15:06:39 +08:00
|
|
|
if (argc <= ++i)
|
|
|
|
{
|
|
|
|
show_help = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
alternate_system_gimprc = argv[i];
|
1998-09-11 03:03:20 +08:00
|
|
|
argv[i] = NULL;
|
1998-07-11 15:06:39 +08:00
|
|
|
}
|
|
|
|
}
|
1998-07-11 10:00:19 +08:00
|
|
|
else if ((strcmp (argv[i], "--gimprc") == 0) ||
|
|
|
|
(strcmp (argv[i], "-g") == 0))
|
|
|
|
{
|
|
|
|
if (argc <= ++i)
|
|
|
|
{
|
|
|
|
show_help = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
alternate_gimprc = argv[i];
|
1998-09-11 03:03:20 +08:00
|
|
|
argv[i] = NULL;
|
1998-07-11 10:00:19 +08:00
|
|
|
}
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
else if ((strcmp (argv[i], "--help") == 0) ||
|
|
|
|
(strcmp (argv[i], "-h") == 0))
|
|
|
|
{
|
|
|
|
show_help = TRUE;
|
1998-09-11 03:03:20 +08:00
|
|
|
argv[i] = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
else if (strcmp (argv[i], "--version") == 0 ||
|
|
|
|
strcmp (argv[i], "-v") == 0)
|
|
|
|
{
|
|
|
|
show_version = TRUE;
|
1998-09-11 03:03:20 +08:00
|
|
|
argv[i] = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
else if (strcmp (argv[i], "--no-data") == 0)
|
|
|
|
{
|
|
|
|
no_data = TRUE;
|
1998-09-11 03:03:20 +08:00
|
|
|
argv[i] = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
1998-02-18 04:14:29 +08:00
|
|
|
else if (strcmp (argv[i], "--no-splash") == 0)
|
|
|
|
{
|
|
|
|
no_splash = TRUE;
|
1998-09-11 03:03:20 +08:00
|
|
|
argv[i] = NULL;
|
1998-02-18 04:14:29 +08:00
|
|
|
}
|
|
|
|
else if (strcmp (argv[i], "--no-splash-image") == 0)
|
|
|
|
{
|
|
|
|
no_splash_image = TRUE;
|
1998-09-11 03:03:20 +08:00
|
|
|
argv[i] = NULL;
|
1998-02-18 04:14:29 +08:00
|
|
|
}
|
1998-01-26 06:13:00 +08:00
|
|
|
else if (strcmp (argv[i], "--verbose") == 0)
|
|
|
|
{
|
|
|
|
be_verbose = TRUE;
|
1998-09-11 03:03:20 +08:00
|
|
|
argv[i] = NULL;
|
1998-01-26 06:13:00 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
else if (strcmp (argv[i], "--no-shm") == 0)
|
|
|
|
{
|
|
|
|
use_shm = FALSE;
|
1998-09-11 03:03:20 +08:00
|
|
|
argv[i] = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
1998-04-21 09:19:30 +08:00
|
|
|
else if (strcmp (argv[i], "--debug-handlers") == 0)
|
|
|
|
{
|
|
|
|
use_debug_handler = TRUE;
|
1998-09-11 03:03:20 +08:00
|
|
|
argv[i] = NULL;
|
1998-04-21 09:19:30 +08:00
|
|
|
}
|
1998-05-30 15:32:37 +08:00
|
|
|
else if (strcmp (argv[i], "--console-messages") == 0)
|
|
|
|
{
|
|
|
|
console_messages = TRUE;
|
1998-09-11 03:03:20 +08:00
|
|
|
argv[i] = NULL;
|
1998-05-30 15:32:37 +08:00
|
|
|
}
|
1998-07-12 06:23:23 +08:00
|
|
|
else if ((strcmp (argv[i], "--restore-session") == 0) ||
|
|
|
|
(strcmp (argv[i], "-r") == 0))
|
|
|
|
{
|
|
|
|
restore_session = TRUE;
|
1998-09-11 03:03:20 +08:00
|
|
|
argv[i] = NULL;
|
1998-07-12 06:23:23 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
/*
|
|
|
|
* ANYTHING ELSE starting with a '-' is an error.
|
|
|
|
*/
|
|
|
|
else if (argv[i][0] == '-')
|
|
|
|
{
|
|
|
|
show_help = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (show_version)
|
1998-08-06 07:46:04 +08:00
|
|
|
g_print ( "%s %s\n", _("GIMP version"), GIMP_VERSION);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (show_help)
|
|
|
|
{
|
1998-08-06 07:46:04 +08:00
|
|
|
g_print (_("\007Usage: %s [option ...] [files ...]\n"), argv[0]);
|
|
|
|
g_print (_("Valid options are:\n"));
|
|
|
|
g_print (_(" -h --help Output this help.\n"));
|
|
|
|
g_print (_(" -v --version Output version info.\n"));
|
|
|
|
g_print (_(" -b --batch <commands> Run in batch mode.\n"));
|
|
|
|
g_print (_(" -g --gimprc <gimprc> Use an alternate gimprc file.\n"));
|
|
|
|
g_print (_(" -n --no-interface Run without a user interface.\n"));
|
|
|
|
g_print (_(" -r --restore-session Try to restore saved session.\n"));
|
|
|
|
g_print (_(" --no-data Do not load patterns, gradients, palettes, brushes.\n"));
|
|
|
|
g_print (_(" --verbose Show startup messages.\n"));
|
|
|
|
g_print (_(" --no-splash Do not show the startup window.\n"));
|
|
|
|
g_print (_(" --no-splash-image Do not add an image to the startup window.\n"));
|
|
|
|
g_print (_(" --no-shm Do not use shared memory between GIMP and its plugins.\n"));
|
|
|
|
g_print (_(" --no-xshm Do not use the X Shared Memory extension.\n"));
|
|
|
|
g_print (_(" --console-messages Display warnings to console instead of a dialog box.\n"));
|
|
|
|
g_print (_(" --debug-handlers Enable debugging signal handlers.\n"));
|
|
|
|
g_print (_(" --display <display> Use the designated X display.\n\n"));
|
|
|
|
g_print (_(" --system-gimprc <gimprc> Use an alternate system gimprc file.\n"));
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (show_version || show_help)
|
|
|
|
exit (0);
|
|
|
|
|
1998-08-30 06:33:57 +08:00
|
|
|
g_set_message_handler ((GPrintFunc) message_func);
|
1998-05-28 17:03:57 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* Handle some signals */
|
|
|
|
signal (SIGHUP, on_signal);
|
|
|
|
signal (SIGINT, on_signal);
|
|
|
|
signal (SIGQUIT, on_signal);
|
|
|
|
signal (SIGABRT, on_signal);
|
|
|
|
signal (SIGBUS, on_signal);
|
|
|
|
signal (SIGSEGV, on_signal);
|
|
|
|
signal (SIGPIPE, on_signal);
|
|
|
|
signal (SIGTERM, on_signal);
|
|
|
|
signal (SIGFPE, on_signal);
|
|
|
|
|
|
|
|
/* Handle child exits */
|
|
|
|
signal (SIGCHLD, on_sig_child);
|
|
|
|
|
|
|
|
/* Keep the command line arguments--for use in gimp_init */
|
|
|
|
gimp_argc = argc - 1;
|
|
|
|
gimp_argv = argv + 1;
|
|
|
|
|
|
|
|
/* Check the installation */
|
|
|
|
install_verify (init);
|
|
|
|
|
|
|
|
/* Main application loop */
|
1998-02-05 13:41:05 +08:00
|
|
|
if (!app_exit_finish_done ())
|
|
|
|
gtk_main ();
|
|
|
|
|
|
|
|
return 0;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
init ()
|
|
|
|
{
|
|
|
|
/* Continue initializing */
|
|
|
|
gimp_init (gimp_argc, gimp_argv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int caught_fatal_sig = 0;
|
|
|
|
|
|
|
|
static RETSIGTYPE
|
|
|
|
on_signal (int sig_num)
|
|
|
|
{
|
|
|
|
if (caught_fatal_sig)
|
|
|
|
/* raise (sig_num);*/
|
|
|
|
kill (getpid (), sig_num);
|
|
|
|
caught_fatal_sig = 1;
|
|
|
|
|
|
|
|
switch (sig_num)
|
|
|
|
{
|
|
|
|
case SIGHUP:
|
1998-08-06 07:46:04 +08:00
|
|
|
terminate (_("sighup caught"));
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
case SIGINT:
|
1998-08-06 07:46:04 +08:00
|
|
|
terminate (_("sigint caught"));
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
case SIGQUIT:
|
1998-08-06 07:46:04 +08:00
|
|
|
terminate (_("sigquit caught"));
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
case SIGABRT:
|
1998-08-06 07:46:04 +08:00
|
|
|
terminate (_("sigabrt caught"));
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
case SIGBUS:
|
1998-08-06 07:46:04 +08:00
|
|
|
fatal_error (_("sigbus caught"));
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
case SIGSEGV:
|
1998-08-06 07:46:04 +08:00
|
|
|
fatal_error (_("sigsegv caught"));
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
case SIGPIPE:
|
1998-08-06 07:46:04 +08:00
|
|
|
terminate (_("sigpipe caught"));
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
case SIGTERM:
|
1998-08-06 07:46:04 +08:00
|
|
|
terminate (_("sigterm caught"));
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
case SIGFPE:
|
1998-08-06 07:46:04 +08:00
|
|
|
fatal_error (_("sigfpe caught"));
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
default:
|
1998-08-06 07:46:04 +08:00
|
|
|
fatal_error (_("unknown signal"));
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static RETSIGTYPE
|
|
|
|
on_sig_child (int sig_num)
|
|
|
|
{
|
|
|
|
int pid;
|
|
|
|
int status;
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
pid = waitpid (WAIT_ANY, &status, WNOHANG);
|
|
|
|
if (pid <= 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1998-11-08 07:02:14 +08:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
gint32 test_gint32;
|
|
|
|
float test_float;
|
|
|
|
char *test_string;
|
|
|
|
guint32 test_length;
|
|
|
|
guint16 *test_array;
|
|
|
|
} test_struct;
|
|
|
|
|
|
|
|
static void test_gserialize()
|
|
|
|
{
|
|
|
|
GSerialDescription *test_struct_descript;
|
|
|
|
test_struct *ts, *to;
|
1998-12-16 19:23:30 +08:00
|
|
|
char ser_1[] = {3, 1, 2, 3, 4, 4, 64, 83, 51, 51, 101, 0, 0, 0, 4, 102, 111, 111, 0, 103, 0, 0, 0, 2, 5, 6, 7, 8 };
|
1998-11-08 07:02:14 +08:00
|
|
|
ts = g_malloc(sizeof(test_struct));
|
|
|
|
to = g_malloc(sizeof(test_struct));
|
|
|
|
test_struct_descript
|
|
|
|
= g_new_serial_description("test_struct",
|
|
|
|
g_serial_item(GSERIAL_INT32,
|
|
|
|
test_struct,
|
|
|
|
test_gint32),
|
|
|
|
g_serial_item(GSERIAL_FLOAT,
|
|
|
|
test_struct,
|
|
|
|
test_float),
|
|
|
|
g_serial_item(GSERIAL_STRING,
|
|
|
|
test_struct,
|
|
|
|
test_string),
|
|
|
|
g_serial_vlen_array(GSERIAL_INT16ARRAY,
|
|
|
|
test_struct,
|
|
|
|
test_array,
|
|
|
|
test_length),
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
|
|
|
ts->test_gint32 = 0x01020304;
|
|
|
|
ts->test_float = 3.3f;
|
|
|
|
ts->test_string = "foo";
|
|
|
|
ts->test_length = 2;
|
|
|
|
ts->test_array = g_malloc(sizeof(short) *2);
|
|
|
|
ts->test_array[0] = 0x0506;
|
|
|
|
ts->test_array[1] = 0x0708;
|
|
|
|
|
|
|
|
g_deserialize(test_struct_descript, (char *)(void*)to, ser_1);
|
|
|
|
|
1998-11-08 08:38:16 +08:00
|
|
|
if (to->test_gint32 != ts->test_gint32)
|
1998-11-13 12:00:54 +08:00
|
|
|
g_message("gint32 test failed (please email your system configuration to jaycox@earthlink.net): %d\n", to->test_gint32);
|
1998-11-08 08:38:16 +08:00
|
|
|
if (to->test_float != ts->test_float)
|
1998-11-13 12:00:54 +08:00
|
|
|
g_message("float test failed (please email your system configuration to jaycox@earthlink.net): %f\n", to->test_float);
|
1998-11-08 08:38:16 +08:00
|
|
|
if (strcmp(to->test_string, ts->test_string) != 0)
|
1998-11-13 12:00:54 +08:00
|
|
|
g_message("string test failed (please email your system configuration to jaycox@earthlink.net): %s\n", to->test_string);
|
1998-11-08 08:38:16 +08:00
|
|
|
if (to->test_length != ts->test_length)
|
1998-11-13 12:00:54 +08:00
|
|
|
g_message("array length test failed(please email your system configuration to jaycox@earthlink.net): %d\n", to->test_length);
|
1998-11-08 08:38:16 +08:00
|
|
|
if (to->test_array[0] != ts->test_array[0])
|
1998-11-13 12:00:54 +08:00
|
|
|
g_message("int16array value 0 test failed(please email your system configuration to jaycox@earthlink.net): %d\n", to->test_array[0]);
|
1998-11-08 07:02:14 +08:00
|
|
|
g_return_if_fail (to->test_array[1] == ts->test_array[1]);
|
1998-11-08 08:38:16 +08:00
|
|
|
if (to->test_array[1] != ts->test_array[1])
|
1998-11-13 12:00:54 +08:00
|
|
|
g_message("int16array value 1 test failed(please email your system configuration to jaycox@earthlink.net): %d\n", to->test_array[1]);
|
1998-11-08 07:02:14 +08:00
|
|
|
/* really should free the memory... */
|
|
|
|
g_message("Passed serialization test\n");
|
1998-11-08 08:38:16 +08:00
|
|
|
}/*
|
|
|
|
67108864 */
|