testsocket_child.c 1.46 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/* testsocket_child.c
 * Copyright (C) 2001 Red Hat, Inc
 * Author: Owen Taylor
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library 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
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
Javier Jardón's avatar
Javier Jardón committed
16
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
17 18
 */

19
#include "config.h"
20 21 22 23 24
#include <stdio.h>
#include <stdlib.h>

#include <gtk/gtk.h>

25 26
extern guint32 create_child_plug (guint32  xid,
				  gboolean local);
27 28 29 30 31

int
main (int argc, char *argv[])
{
  guint32 xid;
32
  guint32 plug_xid;
33 34 35

  gtk_init (&argc, &argv);

36
  if (argc != 1 && argc != 2)
37
    {
38
      fprintf (stderr, "Usage: testsocket_child [WINDOW_ID]\n");
39 40 41
      exit (1);
    }

42
  if (argc == 2)
43
    {
44 45 46 47 48 49 50 51 52 53 54 55 56 57
      xid = strtol (argv[1], NULL, 0);
      if (xid == 0)
	{
	  fprintf (stderr, "Invalid window id '%s'\n", argv[1]);
	  exit (1);
	}
      
      create_child_plug (xid, FALSE);
    }
  else
    {
      plug_xid = create_child_plug (0, FALSE);
      printf ("%d\n", plug_xid);
      fflush (stdout);
58 59 60 61 62 63 64 65
    }

  gtk_main ();

  return 0;
}