FW: X 4.3.99.902 Compile error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



After a few more attempts to get 4.4 to compile completely I have again come
back to the group. I am not a programmer. I just want a screen that has
better size then 800x600 ->SaX2 will not set it beyond that. If I us the
correct manufacturer driver (instead of the VESA) then the screen gets split
3/4 of the way down and 'wraps' back onto the bottom. I was told that this
was a known bug that 4.4 fixes which is why I am trying to get it compiled
and running. 

The only other thought I had was that if there is someone out their who can
successfully compile their install of 4.4 and compile it into an RPM that
would solve my problems also. (Just a thought)

To those who have assisted as much as they can; my apologies for the
plethora of emails on this issue.

Jeremey Wise

-----Original Message-----
From: xfree86-admin@xxxxxxxxxxx [mailto:xfree86-admin@xxxxxxxxxxx] On Behalf
Of Wise, Jeremey
Sent: Wednesday, January 07, 2004 11:38 AM
To: xfree86@xxxxxxxxxxx
Subject: RE:  X 4.3.99.902 Compile error

The saga continues. As I received no help back I tried to (remember I am
not a programer:>) remark out the 'if-fi' section containing the errors
listed below, thinking it may skip this section and go on it's mary way.
It got a little farther then failed with another set of referances. I am
attaching both the ...../xc/programs/xcursorgen/xcursorgen.c file and
the error output I could get from the shell session. 

Help please -> failing to understand why SuSE has these problems but
Fedora and Knoppix do not. Issue is I have to use SuSE as our companies
technical contact for SuSE.

THanks,


On Tue, 2004-01-06 at 15:24, Wise, Jeremey wrote:
> Thanks for the update. That was the fix for that error. Now a new one.
> 
> 
> ****SnIP)***
> ....
> xcursorgen.c:262: warning: redundant redeclaration of
> 'png_destroy_read_structure' in the same scope
> xcursorgen.c:181: warning: previous declaration of
'png_destory_read_struct'
> make[4] *** [xcursorgen.o] Error 1
> make[4] Leaving directory '/home/wisej/XFreeUpdate/xc/programs/xcursorgen'
> make[3]: *** [all] Error 2
> make[3]: Leaving directory '/home/wisej/XFreeUpdate/xc/programs'
> ...
> 
> Suggestions?
> 
> Thanks,
> 
> -----Original Message-----
> From: xfree86-admin@xxxxxxxxxxx [mailto:xfree86-admin@xxxxxxxxxxx] On
Behalf
> Of JD Ross
> Sent: Tuesday, January 06, 2004 12:38 PM
> To: xfree86@xxxxxxxxxxx
> Subject: Re:  X 4.3.99.902 Compile error
> 
> You need libncurses-dev.
> 
> Jay R. Ashworth wrote:
> 
> >On Tue, Jan 06, 2004 at 07:06:37AM -0500, Wise, Jeremey wrote:
> >  
> >
> >>gcc -m32 -o resize -O2 -fno-strength-reduce -fno-strict-aliasing -ansi
> >>-pedantic -Wall -Wpointer-arith
> >>-Wstrict-prototypes                        -Wmissing-prototypes
> >>-Wmissing-declarations                     -Wredundant-decls
> >>-Wnested-externs -Wundef     -L../../exports/lib   resize.o
> >>xstrings.o      -lncurses -Wl,-rpath-link,../../exports/lib
>
>>/usr/lib/gcc-lib/i586-suse-linux/3.3.1/../../../../i586-suse-linux/bin/ld:
> >>cannot find -lncurses
> >>    
> >>
> >
> >Normal ordinary C compilation eror -- I'm not an X Guy, and I can tell
> >you how to fix it.
> >
> >The compile is trying to build resize, and wants the ncurses
> >library... which I can't imagine *isn't* on your machine *somewhere*...
> >but clearly, it's not on the search path that GCC is looking in.
> >
> >Locate (or install) it, and then either symlink it into a useful place,
> >or modify the makefile.  (Actually, that might be the *imake*file; this
> >is where you got into "needs to be an Xguy" territory.
> >
> >I think you're gonna find out you don't have it installed, as difficult
> >as that is to fathom -- so *much* stuff uses curses.
> >
> >On second look, that error from ld seems wrong, too; it shouldn't be
> >looking for "-lncurses", it should be looking for "libncurses".  I'm
> >wondering if that's a thinko in the makefile -- perhaps the .o files
> >should be at the end; there isn't anything else after xstrings.o, which
> >may be confusing getargs in gcc.
> >
> >Noting that you're in the beta, I'm leaning towards this; I suspect
> >someone hosed the makefile.
> >
> >Cheers,
> >-- jra
> >  
> >
> 
> _______________________________________________
> XFree86 mailing list
> XFree86@xxxxxxxxxxx
> http://XFree86.Org/mailman/listinfo/xfree86
> 
> _______________________________________________
> XFree86 mailing list
> XFree86@xxxxxxxxxxx
> http://XFree86.Org/mailman/listinfo/xfree86


xcursorgen.c:252: error: `height' undeclared here (not in a function)
xcursorgen.c:252: warning: initialization makes integer from pointer without a cast
xcursorgen.c:252: error: initializer element is not constant
xcursorgen.c:252: error: ISO C forbids data definition with no type or storage class
xcursorgen.c:254: error: parse error before "for"
xcursorgen.c:257: warning: type defaults to `int' in declaration of `png_read_image'
xcursorgen.c:257: warning: parameter names (without types) in function declaration
xcursorgen.c:257: error: ISO C forbids data definition with no type or storage class
xcursorgen.c:258: warning: type defaults to `int' in declaration of `png_read_end'
xcursorgen.c:258: warning: parameter names (without types) in function declaration
xcursorgen.c:258: error: ISO C forbids data definition with no type or storage class
xcursorgen.c:260: warning: type defaults to `int' in declaration of `free'
xcursorgen.c:260: warning: parameter names (without types) in function declaration
xcursorgen.c:260: error: conflicting types for `free'
/usr/include/stdlib.h:569: error: previous declaration of `free'
xcursorgen.c:260: warning: redundant redeclaration of `free' in same scope
/usr/include/stdlib.h:569: warning: previous declaration of `free'
xcursorgen.c:260: error: ISO C forbids data definition with no type or storage class
xcursorgen.c:261: warning: type defaults to `int' in declaration of `fclose'
xcursorgen.c:261: warning: parameter names (without types) in function declaration
xcursorgen.c:261: error: conflicting types for `fclose'
/usr/include/stdio.h:208: error: previous declaration of `fclose'
xcursorgen.c:261: warning: redundant redeclaration of `fclose' in same scope
/usr/include/stdio.h:208: warning: previous declaration of `fclose'
xcursorgen.c:261: error: ISO C forbids data definition with no type or storage class
xcursorgen.c:262: error: parse error before '&' token
xcursorgen.c:141: warning: `premultiply_data' defined but not used
make[4]: *** [xcursorgen.o] Error 1
make[4]: Leaving directory `/home/wisej/XFreeUpdate/xc/programs/xcursorgen'
make[3]: *** [all] Error 2
make[3]: Leaving directory `/home/wisej/XFreeUpdate/xc/programs'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/home/wisej/XFreeUpdate/xc'
make[1]: *** [World] Error 2
make[1]: Leaving directory `/home/wisej/XFreeUpdate/xc'
make: *** [World] Error 2
wizej:/home/wisej/XFreeUpdate/xc #

/* $XFree86: xc/programs/xcursorgen/xcursorgen.c,v 1.9 2003/04/21 14:15:35 herrb Exp $ */
/*
 * xcursorgen.c
 *
 * Copyright (C) 2002 Manish Singh
 *
 * Permission to use, copy, modify, distribute, and sell this software and its
 * documentation for any purpose is hereby granted without fee, provided that
 * the above copyright notice appear in all copies and that both that
 * copyright notice and this permission notice appear in supporting
 * documentation, and that the name of Manish Singh not be used in
 * advertising or publicity pertaining to distribution of the software without
 * specific, written prior permission.  Manish Singh makes no
 * representations about the suitability of this software for any purpose.  It
 * is provided "as is" without express or implied warranty.
 *
 * MANISH SINGH DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
 * EVENT SHALL MANISH SINGH BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 * PERFORMANCE OF THIS SOFTWARE.
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xcursor/Xcursor.h>

#include <png.h>

#define VERSION_STR "0.1"

struct flist
{
  int size;
  int xhot, yhot;
  char *pngfile;
  int delay;
  struct flist *next;
};

static void
usage (char *name)
{
  fprintf (stderr, "usage: %s [-Vh] [--version] [--help] [-p <dir>] [--prefix <dir>] [CONFIG [OUT]]\n",
	   name);

  fprintf (stderr, "Generate an Xcursor file from a series of PNG images\n");
  fprintf (stderr, "\n");
  fprintf (stderr, "  -V, --version      display the version number and exit\n");
  fprintf (stderr, "  -?, --help         display this message and exit\n");
  fprintf (stderr, "  -p, --prefix <dir> find cursor images in <dir>\n");
  fprintf (stderr, "\n");
  fprintf (stderr, "With no CONFIG, or when CONFIG is -, read standard input. "
		   "Same with OUT and\n");
  fprintf (stderr, "standard output.\n");
}

static int
read_config_file (char *config, struct flist **list)
{
  FILE *fp;
  char line[4096], pngfile[4000];
  int size, xhot, yhot, delay;
  struct flist *start = NULL, *end = NULL, *curr;
  int count = 0;

  if (strcmp (config, "-") != 0)
    {
      fp = fopen (config, "r");
      if (!fp)
	{
	  *list = NULL;
          return 0;
	}
    }
  else
    fp = stdin;

  while (fgets (line, sizeof (line), fp) != NULL)
    {
      if (line[0] == '#')
	continue;

      switch (sscanf (line, "%d %d %d %3999s %d", &size, &xhot, &yhot, pngfile, &delay))
      {
      case 4:
	delay = 50;
	break;
      case 5:
	break;
      default:
	{
	  fprintf (stderr, "Bad config file data!\n");
	  fclose (fp);
	  return 0;
	}
      }

      curr = malloc (sizeof (struct flist));

      curr->size = size;
      curr->xhot = xhot;
      curr->yhot = yhot;

      curr->delay = delay;

      curr->pngfile = malloc (strlen (pngfile) + 1);
      strcpy (curr->pngfile, pngfile);

      curr->next = NULL;

      if (start)
	{
	  end->next = curr;
          end = curr;
	}
      else
	{
	  start = curr; 
          end = curr;
        }

      count++;
    }

  fclose (fp);

  *list = start;
  return count;
}

static void
premultiply_data (png_structp png, png_row_infop row_info, png_bytep data)
{
  int i;

  for (i = 0; i < row_info->rowbytes; i += 4)
    {
	unsigned char  *base = &data[i];
	unsigned char  blue = base[0];
	unsigned char  green = base[1];
	unsigned char  red = base[2];
	unsigned char  alpha = base[3];
	XcursorPixel   p;

	red = (unsigned) red * (unsigned) alpha / 255;
	green = (unsigned) green * (unsigned) alpha / 255;
	blue = (unsigned) blue * (unsigned) alpha / 255;
	p = (alpha << 24) | (red << 16) | (green << 8) | (blue << 0);
	memcpy (base, &p, sizeof (XcursorPixel));
    }
}

static XcursorImage *
load_image (struct flist *list, char *prefix)
{
  XcursorImage *image;
  png_structp png;
  png_infop info;
  png_bytepp rows;
  FILE *fp;
  int i;
  png_uint_32 width, height;
  int depth, color, interlace;
  char *file;

  png = png_create_read_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
  if (png == NULL)
    return NULL;

  info = png_create_info_struct (png);
  *if (info == NULL)
  *  {
  *    png_destroy_read_struct (&png, NULL, NULL);
  *    return NULL;
  *  }

  if (setjmp (png->jmpbuf))
    {
      png_destroy_read_struct (&png, &info, NULL);
      return NULL;
    }

  if (prefix)
    {
      file = malloc (strlen (prefix) + 1 + strlen (list->pngfile) + 1);
      strcpy (file, prefix);
      strcat (file, "/");
      strcat (file, list->pngfile);
    }
  else
    file = list->pngfile;
  fp = fopen (file, "rb");
  if (prefix)
    free (file);

  if (fp == NULL)
    {
      png_destroy_read_struct (&png, &info, NULL);
      return NULL;
    }

  png_init_io (png, fp);
  png_read_info (png, info);
  png_get_IHDR (png, info, &width, &height, &depth, &color, &interlace,
		NULL, NULL);

  /* TODO: More needs to be done here maybe */

  if (color == PNG_COLOR_TYPE_PALETTE && depth <= 8)
    png_set_expand (png);

  if (color == PNG_COLOR_TYPE_GRAY && depth < 8)
    png_set_expand (png);

  if (png_get_valid (png, info, PNG_INFO_tRNS))
    png_set_expand (png);

  if (depth == 16)
    png_set_strip_16 (png);

  if (depth < 8)
    png_set_packing (png);

  if (color == PNG_COLOR_TYPE_GRAY || color == PNG_COLOR_TYPE_GRAY_ALPHA)
    png_set_gray_to_rgb (png);

  if (interlace != PNG_INTERLACE_NONE)
    png_set_interlace_handling (png);

  png_set_bgr (png);
  png_set_filler (png, 255, PNG_FILLER_AFTER);

  png_set_read_user_transform_fn (png, premultiply_data);

  png_read_update_info (png, info);

  image = XcursorImageCreate (width, height);

  image->size = list->size;
  image->xhot = list->xhot;
  image->yhot = list->yhot;
  image->delay = list->delay;

  rows = malloc (sizeof (png_bytep) * height);
  
  for (i = 0; i < height; i++)
    rows[i] = (png_bytep) (image->pixels + i * width);

  png_read_image (png, rows);
  png_read_end (png, info);

  free (rows);
*  fclose (fp);
*  png_destroy_read_struct (&png, &info, NULL);

  return image;
}

static int
write_cursors (int count, struct flist *list, char *filename, char *prefix)
{
  XcursorImages *cimages;
  XcursorImage *image;
  int i;
  FILE *fp;
  int ret;

  if (strcmp (filename, "-") != 0)
    {
      fp = fopen (filename, "wb");
      if (!fp)
        return 1;
    }
  else
    fp = stdout;

  cimages = XcursorImagesCreate (count);

  cimages->nimage = count;

  for (i = 0; i < count; i++, list = list->next)
    {
      image = load_image (list, prefix);
      if (image == NULL)
	{
	  fprintf (stderr, "PNG error while reading %s!\n", list->pngfile);
	  return 1;
	}

      cimages->images[i] = image;
    }

  ret = XcursorFileSaveImages (fp, cimages);

  fclose (fp);

  return ret ? 0 : 1;
}

static int
check_image (char *image)
{
  unsigned int width, height;
  unsigned char *data;
  int x_hot, y_hot;
  XImage ximage;
  unsigned char hash[XCURSOR_BITMAP_HASH_SIZE];
  int i;

  if (XReadBitmapFileData (image, &width, &height, &data, &x_hot, &y_hot) != BitmapSuccess)
  {
    fprintf (stderr, "Can't open bitmap file \"%s\"\n", image);
    return 1;
  }
  ximage.height = height;
  ximage.width = width;
  ximage.depth = 1;
  ximage.bits_per_pixel = 1;
  ximage.xoffset = 0;
  ximage.format = XYPixmap;
  ximage.data = (char *)data;
  ximage.byte_order = LSBFirst;
  ximage.bitmap_unit = 8;
  ximage.bitmap_bit_order = LSBFirst;
  ximage.bitmap_pad = 8;
  ximage.bytes_per_line = (width+7)/8;
  XcursorImageHash (&ximage, hash);
  printf ("%s: ", image);
  for (i = 0; i < XCURSOR_BITMAP_HASH_SIZE; i++)
    printf ("%02x", hash[i]);
  printf ("\n");
  return 0;
}

int
main (int argc, char *argv[])
{
  struct flist *list;
  int count;
  char *in = 0, *out = 0;
  char *prefix = 0;
  int i;

  for (i = 1; i < argc; i++)
    {
      if (strcmp (argv[i], "-V") == 0 || strcmp (argv[i], "--version") == 0)
        {
          printf ("xcursorgen version %s\n", VERSION_STR);
          return 0;
        }

      if (strcmp (argv[i], "-?") == 0 || strcmp (argv[i], "--help") == 0)
        {
          usage (argv[0]);
          return 0;
        }
      if (strcmp (argv[i], "-image") == 0)
        {
	  int i = 2;
	  int ret = 0;
	  while (argv[i])
	  {
	    if (check_image (argv[i]))
	      ret = i;
	    i++;
	  }
	  return ret;
	}
      if (strcmp (argv[i], "-p") == 0 || strcmp (argv[i], "--prefix") == 0)
        {
	  i++;
	  if (argv[i] == 0)
	    {
	      usage (argv[0]);
	      return 1;
	    }
	  prefix = argv[i];
	  continue;
        }

      if (!in)
	in = argv[i];
      else if (!out)
	out = argv[i];
      else
      {
	usage (argv[0]);
	return 1;
      }
    }

  if (!in)
    in = "-";
  if (!out)
    out = "-";

  count = read_config_file (in, &list);
  if (count == 0)
    {
      fprintf (stderr, "Error reading config file!\n");
      return 1;
    }

  return write_cursors (count, list, out, prefix);
}
/* $XFree86: xc/programs/xcursorgen/xcursorgen.c,v 1.9 2003/04/21 14:15:35 herrb Exp $ */
/*
 * xcursorgen.c
 *
 * Copyright (C) 2002 Manish Singh
 *
 * Permission to use, copy, modify, distribute, and sell this software and its
 * documentation for any purpose is hereby granted without fee, provided that
 * the above copyright notice appear in all copies and that both that
 * copyright notice and this permission notice appear in supporting
 * documentation, and that the name of Manish Singh not be used in
 * advertising or publicity pertaining to distribution of the software without
 * specific, written prior permission.  Manish Singh makes no
 * representations about the suitability of this software for any purpose.  It
 * is provided "as is" without express or implied warranty.
 *
 * MANISH SINGH DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
 * EVENT SHALL MANISH SINGH BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 * PERFORMANCE OF THIS SOFTWARE.
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xcursor/Xcursor.h>

#include <png.h>

#define VERSION_STR "0.1"

struct flist
{
  int size;
  int xhot, yhot;
  char *pngfile;
  int delay;
  struct flist *next;
};

static void
usage (char *name)
{
  fprintf (stderr, "usage: %s [-Vh] [--version] [--help] [-p <dir>] [--prefix <dir>] [CONFIG [OUT]]\n",
	   name);

  fprintf (stderr, "Generate an Xcursor file from a series of PNG images\n");
  fprintf (stderr, "\n");
  fprintf (stderr, "  -V, --version      display the version number and exit\n");
  fprintf (stderr, "  -?, --help         display this message and exit\n");
  fprintf (stderr, "  -p, --prefix <dir> find cursor images in <dir>\n");
  fprintf (stderr, "\n");
  fprintf (stderr, "With no CONFIG, or when CONFIG is -, read standard input. "
		   "Same with OUT and\n");
  fprintf (stderr, "standard output.\n");
}

static int
read_config_file (char *config, struct flist **list)
{
  FILE *fp;
  char line[4096], pngfile[4000];
  int size, xhot, yhot, delay;
  struct flist *start = NULL, *end = NULL, *curr;
  int count = 0;

  if (strcmp (config, "-") != 0)
    {
      fp = fopen (config, "r");
      if (!fp)
	{
	  *list = NULL;
          return 0;
	}
    }
  else
    fp = stdin;

  while (fgets (line, sizeof (line), fp) != NULL)
    {
      if (line[0] == '#')
	continue;

      switch (sscanf (line, "%d %d %d %3999s %d", &size, &xhot, &yhot, pngfile, &delay))
      {
      case 4:
	delay = 50;
	break;
      case 5:
	break;
      default:
	{
	  fprintf (stderr, "Bad config file data!\n");
	  fclose (fp);
	  return 0;
	}
      }

      curr = malloc (sizeof (struct flist));

      curr->size = size;
      curr->xhot = xhot;
      curr->yhot = yhot;

      curr->delay = delay;

      curr->pngfile = malloc (strlen (pngfile) + 1);
      strcpy (curr->pngfile, pngfile);

      curr->next = NULL;

      if (start)
	{
	  end->next = curr;
          end = curr;
	}
      else
	{
	  start = curr; 
          end = curr;
        }

      count++;
    }

  fclose (fp);

  *list = start;
  return count;
}

static void
premultiply_data (png_structp png, png_row_infop row_info, png_bytep data)
{
  int i;

  for (i = 0; i < row_info->rowbytes; i += 4)
    {
	unsigned char  *base = &data[i];
	unsigned char  blue = base[0];
	unsigned char  green = base[1];
	unsigned char  red = base[2];
	unsigned char  alpha = base[3];
	XcursorPixel   p;

	red = (unsigned) red * (unsigned) alpha / 255;
	green = (unsigned) green * (unsigned) alpha / 255;
	blue = (unsigned) blue * (unsigned) alpha / 255;
	p = (alpha << 24) | (red << 16) | (green << 8) | (blue << 0);
	memcpy (base, &p, sizeof (XcursorPixel));
    }
}

static XcursorImage *
load_image (struct flist *list, char *prefix)
{
  XcursorImage *image;
  png_structp png;
  png_infop info;
  png_bytepp rows;
  FILE *fp;
  int i;
  png_uint_32 width, height;
  int depth, color, interlace;
  char *file;

  png = png_create_read_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
  if (png == NULL)
    return NULL;

  info = png_create_info_struct (png);
  if (info == NULL)
    {
      png_destroy_read_struct (&png, NULL, NULL);
      return NULL;
    }

  if (setjmp (png->jmpbuf))
    {
      png_destroy_read_struct (&png, &info, NULL);
      return NULL;
    }

  if (prefix)
    {
      file = malloc (strlen (prefix) + 1 + strlen (list->pngfile) + 1);
      strcpy (file, prefix);
      strcat (file, "/");
      strcat (file, list->pngfile);
    }
  else
    file = list->pngfile;
  fp = fopen (file, "rb");
  if (prefix)
    free (file);

  if (fp == NULL)
    {
      png_destroy_read_struct (&png, &info, NULL);
      return NULL;
    }

  png_init_io (png, fp);
  png_read_info (png, info);
  png_get_IHDR (png, info, &width, &height, &depth, &color, &interlace,
		NULL, NULL);

  /* TODO: More needs to be done here maybe */

  if (color == PNG_COLOR_TYPE_PALETTE && depth <= 8)
    png_set_expand (png);

  if (color == PNG_COLOR_TYPE_GRAY && depth < 8)
    png_set_expand (png);

  if (png_get_valid (png, info, PNG_INFO_tRNS))
    png_set_expand (png);

  if (depth == 16)
    png_set_strip_16 (png);

  if (depth < 8)
    png_set_packing (png);

  if (color == PNG_COLOR_TYPE_GRAY || color == PNG_COLOR_TYPE_GRAY_ALPHA)
    png_set_gray_to_rgb (png);

  if (interlace != PNG_INTERLACE_NONE)
    png_set_interlace_handling (png);

  png_set_bgr (png);
  png_set_filler (png, 255, PNG_FILLER_AFTER);

  png_set_read_user_transform_fn (png, premultiply_data);

  png_read_update_info (png, info);

  image = XcursorImageCreate (width, height);

  image->size = list->size;
  image->xhot = list->xhot;
  image->yhot = list->yhot;
  image->delay = list->delay;

  rows = malloc (sizeof (png_bytep) * height);
  
  for (i = 0; i < height; i++)
    rows[i] = (png_bytep) (image->pixels + i * width);

  png_read_image (png, rows);
  png_read_end (png, info);

  free (rows);
  fclose (fp);
  png_destroy_read_struct (&png, &info, NULL);

  return image;
}

static int
write_cursors (int count, struct flist *list, char *filename, char *prefix)
{
  XcursorImages *cimages;
  XcursorImage *image;
  int i;
  FILE *fp;
  int ret;

  if (strcmp (filename, "-") != 0)
    {
      fp = fopen (filename, "wb");
      if (!fp)
        return 1;
    }
  else
    fp = stdout;

  cimages = XcursorImagesCreate (count);

  cimages->nimage = count;

  for (i = 0; i < count; i++, list = list->next)
    {
      image = load_image (list, prefix);
      if (image == NULL)
	{
	  fprintf (stderr, "PNG error while reading %s!\n", list->pngfile);
	  return 1;
	}

      cimages->images[i] = image;
    }

  ret = XcursorFileSaveImages (fp, cimages);

  fclose (fp);

  return ret ? 0 : 1;
}

static int
check_image (char *image)
{
  unsigned int width, height;
  unsigned char *data;
  int x_hot, y_hot;
  XImage ximage;
  unsigned char hash[XCURSOR_BITMAP_HASH_SIZE];
  int i;

  if (XReadBitmapFileData (image, &width, &height, &data, &x_hot, &y_hot) != BitmapSuccess)
  {
    fprintf (stderr, "Can't open bitmap file \"%s\"\n", image);
    return 1;
  }
  ximage.height = height;
  ximage.width = width;
  ximage.depth = 1;
  ximage.bits_per_pixel = 1;
  ximage.xoffset = 0;
  ximage.format = XYPixmap;
  ximage.data = (char *)data;
  ximage.byte_order = LSBFirst;
  ximage.bitmap_unit = 8;
  ximage.bitmap_bit_order = LSBFirst;
  ximage.bitmap_pad = 8;
  ximage.bytes_per_line = (width+7)/8;
  XcursorImageHash (&ximage, hash);
  printf ("%s: ", image);
  for (i = 0; i < XCURSOR_BITMAP_HASH_SIZE; i++)
    printf ("%02x", hash[i]);
  printf ("\n");
  return 0;
}

int
main (int argc, char *argv[])
{
  struct flist *list;
  int count;
  char *in = 0, *out = 0;
  char *prefix = 0;
  int i;

  for (i = 1; i < argc; i++)
    {
      if (strcmp (argv[i], "-V") == 0 || strcmp (argv[i], "--version") == 0)
        {
          printf ("xcursorgen version %s\n", VERSION_STR);
          return 0;
        }

      if (strcmp (argv[i], "-?") == 0 || strcmp (argv[i], "--help") == 0)
        {
          usage (argv[0]);
          return 0;
        }
      if (strcmp (argv[i], "-image") == 0)
        {
	  int i = 2;
	  int ret = 0;
	  while (argv[i])
	  {
	    if (check_image (argv[i]))
	      ret = i;
	    i++;
	  }
	  return ret;
	}
      if (strcmp (argv[i], "-p") == 0 || strcmp (argv[i], "--prefix") == 0)
        {
	  i++;
	  if (argv[i] == 0)
	    {
	      usage (argv[0]);
	      return 1;
	    }
	  prefix = argv[i];
	  continue;
        }

      if (!in)
	in = argv[i];
      else if (!out)
	out = argv[i];
      else
      {
	usage (argv[0]);
	return 1;
      }
    }

  if (!in)
    in = "-";
  if (!out)
    out = "-";

  count = read_config_file (in, &list);
  if (count == 0)
    {
      fprintf (stderr, "Error reading config file!\n");
      return 1;
    }

  return write_cursors (count, list, out, prefix);
}

[Index of Archives]     [X Forum]     [Xorg]     [XFree86 Newbie]     [IETF Announce]     [Security]     [Font Config]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux Kernel]

  Powered by Linux