~ubuntu-branches/ubuntu/oneiric/libpng/oneiric

« back to all changes in this revision

Viewing changes to pngtest.c

  • Committer: Bazaar Package Importer
  • Author(s): Anibal Monsalve Salazar
  • Date: 2009-05-22 09:11:26 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20090522091126-ackh8fu2581nwuyg
Tags: 1.2.36-1
* New upstream release 
* Standards-Version is 3.8.1
* debhelper compat is 7
* Run dh_prep instead of dh_clean -k

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
 
2
2
/* pngtest.c - a simple test program to test libpng
3
3
 *
4
 
 * Last changed in libpng 1.2.32 [September 18, 2008]
 
4
 * Last changed in libpng 1.2.36 [May 7, 2009]
5
5
 * For conditions of distribution and use, see copyright notice in png.h
6
 
 * Copyright (c) 1998-2008 Glenn Randers-Pehrson
 
6
 * Copyright (c) 1998-2009 Glenn Randers-Pehrson
7
7
 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
8
8
 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
9
9
 *
362
362
static void
363
363
pngtest_flush(png_structp png_ptr)
364
364
{
365
 
#if !defined(_WIN32_WCE)
366
 
   png_FILE_p io_ptr;
367
 
   io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr));
368
 
   if (io_ptr != NULL)
369
 
      fflush(io_ptr);
370
 
#endif
 
365
   /* Do nothing; fflush() is said to be just a waste of energy. */
 
366
   png_ptr = png_ptr;  /* stifle compiler warning */
371
367
}
372
368
#endif
373
369
 
611
607
   png_unknown_chunkp chunk)
612
608
{
613
609
  png_uint_32
614
 
    *user_chunk_data;
 
610
    *my_user_chunk_data;
615
611
 
616
612
  /* Return one of the following: */
617
613
     /* return (-n);  chunk had an error */
634
630
         return (-1); /* Error return */
635
631
       if (chunk->data[0] != 0 && chunk->data[0] != 1)
636
632
          return (-1);  /* Invalid mode */
637
 
       user_chunk_data=(png_uint_32 *) png_get_user_chunk_ptr(png_ptr);
638
 
       user_chunk_data[0]=chunk->data[0]+1;
 
633
       my_user_chunk_data=(png_uint_32 *) png_get_user_chunk_ptr(png_ptr);
 
634
       my_user_chunk_data[0]=chunk->data[0]+1;
639
635
       return (1);
640
636
     }
641
637
  if (chunk->name[0] != 118 || chunk->name[1] != 112 ||    /* v  p */
647
643
  if (chunk->size != 9)
648
644
    return (-1); /* Error return */
649
645
 
650
 
  user_chunk_data=(png_uint_32 *) png_get_user_chunk_ptr(png_ptr);
 
646
  my_user_chunk_data=(png_uint_32 *) png_get_user_chunk_ptr(png_ptr);
651
647
 
652
 
  user_chunk_data[1]=png_get_uint_31(png_ptr, chunk->data);
653
 
  user_chunk_data[2]=png_get_uint_31(png_ptr, chunk->data + 4);
654
 
  user_chunk_data[3]=(png_uint_32)chunk->data[8];
 
648
  my_user_chunk_data[1]=png_get_uint_31(png_ptr, chunk->data);
 
649
  my_user_chunk_data[2]=png_get_uint_31(png_ptr, chunk->data + 4);
 
650
  my_user_chunk_data[3]=(png_uint_32)chunk->data[8];
655
651
 
656
652
  return (1);
657
653
 
1161
1157
       ster_chunk_data[1];
1162
1158
 
1163
1159
     if (verbose)
1164
 
        fprintf(STDERR, "stereo mode = %lu\n",
 
1160
        fprintf(STDERR, "\n stereo mode = %lu\n",
1165
1161
          (unsigned long)(user_chunk_data[0] - 1));
1166
1162
     ster_chunk_data[0]=(unsigned char)(user_chunk_data[0] - 1);
1167
1163
     png_write_chunk(write_ptr, png_sTER, ster_chunk_data, 1);
1174
1170
       vpag_chunk_data[9];
1175
1171
 
1176
1172
     if (verbose)
1177
 
        fprintf(STDERR, "vpAg = %lu x %lu, units=%lu\n",
 
1173
        fprintf(STDERR, " vpAg = %lu x %lu, units = %lu\n",
1178
1174
          (unsigned long)user_chunk_data[1],
1179
1175
          (unsigned long)user_chunk_data[2],
1180
1176
          (unsigned long)user_chunk_data[3]);
1318
1314
      png_uint_32 iwidth, iheight;
1319
1315
      iwidth = png_get_image_width(write_ptr, write_info_ptr);
1320
1316
      iheight = png_get_image_height(write_ptr, write_info_ptr);
1321
 
      fprintf(STDERR, "Image width = %lu, height = %lu\n",
 
1317
      fprintf(STDERR, "\n Image width = %lu, height = %lu\n",
1322
1318
         (unsigned long)iwidth, (unsigned long)iheight);
1323
1319
   }
1324
1320
#endif
1439
1435
   int multiple = 0;
1440
1436
   int ierror = 0;
1441
1437
 
1442
 
   fprintf(STDERR, "Testing libpng version %s\n", PNG_LIBPNG_VER_STRING);
 
1438
   fprintf(STDERR, "\n Testing libpng version %s\n", PNG_LIBPNG_VER_STRING);
1443
1439
   fprintf(STDERR, "   with zlib   version %s\n", ZLIB_VERSION);
1444
1440
   fprintf(STDERR, "%s", png_get_copyright(NULL));
1445
1441
   /* Show the version of libpng used in building the library */
1527
1523
         int k;
1528
1524
#endif
1529
1525
         int kerror;
1530
 
         fprintf(STDERR, "Testing %s:", argv[i]);
 
1526
         fprintf(STDERR, "\n Testing %s:", argv[i]);
1531
1527
         kerror = test_one_file(argv[i], outname);
1532
1528
         if (kerror == 0)
1533
1529
         {
1597
1593
         if (i == 1) status_dots_requested = 1;
1598
1594
         else if (verbose == 0)status_dots_requested = 0;
1599
1595
         if (i == 0 || verbose == 1 || ierror != 0)
1600
 
            fprintf(STDERR, "Testing %s:", inname);
 
1596
            fprintf(STDERR, "\n Testing %s:", inname);
1601
1597
         kerror = test_one_file(inname, outname);
1602
1598
         if (kerror == 0)
1603
1599
         {
1628
1624
         else
1629
1625
         {
1630
1626
            if (verbose == 0 && i != 2)
1631
 
               fprintf(STDERR, "Testing %s:", inname);
 
1627
               fprintf(STDERR, "\n Testing %s:", inname);
1632
1628
            fprintf(STDERR, " FAIL\n");
1633
1629
            ierror += kerror;
1634
1630
         }
1678
1674
#endif
1679
1675
 
1680
1676
   if (ierror == 0)
1681
 
      fprintf(STDERR, "libpng passes test\n");
 
1677
      fprintf(STDERR, " libpng passes test\n");
1682
1678
   else
1683
 
      fprintf(STDERR, "libpng FAILS test\n");
 
1679
      fprintf(STDERR, " libpng FAILS test\n");
1684
1680
   return (int)(ierror != 0);
1685
1681
}
1686
1682
 
1687
1683
/* Generate a compiler error if there is an old png.h in the search path. */
1688
 
typedef version_1_2_35 your_png_h_is_not_version_1_2_35;
 
1684
typedef version_1_2_36 your_png_h_is_not_version_1_2_36;