2006.08.11 19:49 "RE: [Tiff] Newbie RICHTIFFIPTC query -- code snippet (sample usage of TIFFTAG_RICHTIFFIPTC)", by

2006.08.11 10:29 "[Tiff] Newbie RICHTIFFIPTC query", by Beginner

Hi,

First off, I am very in-experienced with C.

I would like to be able to retieve the IPTC data from a TIFF file. I have managed to get fairly close to my goal thanx to reading the archives but I need a bit of help and hopefully some explanations of what is wrong.

The program below compiles (GCC 3.4.2) with the error: warning: dereferencing `void *' pointer

The IPTC was addded to the TIFF file via PhotoShop 7, so it pre-XMP. When it runs I do get all the text I put into the file but it seg faults. I think the fault is because I strcat data that doesn't exist

in my loop. What I'd like is some way to 1) to know where to start reading the data from 2) who to check the data is text that come from data, 3) any other suggested sanity checks anyone can think of.

Is that a tall order? If so sorry but the books I have are not really

helping me understand how to deal with a void pointers.

TIA.

=============

include <stdio.h>
include <tiffio.h>

main()

 int i;

  uint16 count;                /* unit32 gives me no text at all */

 void *data;
 char iptc_data[600];

  TIFF* tif = TIFFOpen("test.tif", "r");
  if (tif == NULL) {
        printf("Failed to open file\n");
        exit(8);
  }
  if (TIFFGetField(tif, TIFFTAG_RICHTIFFIPTC, &count, &data) == 0) {
          printf("No IPTC Tag found\n");
          exit(8);
  }
  printf("Size of IPTC Tag is %d bytes. %s.\n", count, &data);

  for ( i = 0; i < count; ++i) {
        strcat(iptc_data, &data[i]);
  }

  printf("%s\n", iptc_data);

TIFFClose(tif);

  return 0;
}

=================