AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2005.05.18 18:17 "[Tiff] Looking for the definitions of (MS Specific?) tags", by Kevin Grover
2005.05.19 02:14 "Re: [Tiff] Looking for the definitions of (MS Specific?) tags", by Joris Van Damme
2005.05.19 13:53 "Re: [Tiff] Looking for the definitions of (MS Specific?) tags [part 1]", by Ulf Zibis
2005.05.19 15:23 "Re: [Tiff] Looking for the definitions of (MS Specific?) tags [part 1]", by Joris Van Damme
2005.05.19 21:16 "Re: [Tiff] Looking for the definitions of (MS Specific?)", by Ulf Zibis
2005.05.19 21:35 "Re: [Tiff] Looking for the definitions of (MS Specific?) tags", by Ulf Zibis
2005.05.19 13:54 "Re: [Tiff] Looking for the definitions of (MS Specific?) tags [part 2]", by Ulf Zibis
2005.05.23 11:33 "Re: [Tiff] (MS Specific?) tags, Hi Kevin", by Ulf Zibis
2005.05.24 09:08 "Re: [Tiff] (MS Specific?) tags, Hi Kevin", by Joris Van Damme

2005.05.19 13:54 "Re: [Tiff] Looking for the definitions of (MS Specific?) tags [part 2]", by Ulf Zibis

Hi Joris, Kevin and all,

the requested MS-tags are not listed in awaresystems directory.

I have explored some new tags, which are used by Microsoft for the faxconsole, which is included in Windows XP. I dissassembled and iterpreted the TIFF-files myself, so I can't guerantee that the values are all right. I added these tags as described in http://www.remotesensing.org/libtiff/addingtags.html. Please refer to the files in the attachment.

I have written these files to extend sfftobmp capabilities. See: http://sfftools.sourceforge.net.

I had some problems because via xtiffiop.h there are only 33 additional tags possible. So I propose to add theese tags to the normal library.

Because the 3 files exceed the limit of 40 kBytes I post them in to parts for the mailing list.

bye

Ulf Zibis

/*
 * xtif_dir.c
 *
 * Extended TIFF Directory Tag Support.
 *
 *  You may use this file as a template to add your own
 *  extended tags to the library. Only the parts of the code
 *  marked with "XXX" require modification. Three example tags
 *  are shown; you should replace them with your own.
 *
 *  Author: Niles D. Ritter
 *  Author: Ulf Zibis <Ulf.Zibis@gmx.de>: new tags for Microsoft faxconsole
 */

#include "xtiffiop.h"
#include <stdio.h>

/*  Tiff info structure.
 *
 *     Entry format:
 *        { TAGNUMBER, ReadCount, WriteCount, DataType, FIELDNUM,
 *          OkToChange, PassDirCountOnSet, AsciiName }
 *
 *     For ReadCount, WriteCount, -1 = unknown; used for mult-valued
 *         tags and ASCII.
 */

// Note: For the following tags :
//
// PARENTJOBID, SUBMISSIONTIME, SCHEDULED, STARTTIME, ENDTIME
// Microsoft faxconsole uses DataType 10, which is incorrect according to
// TIFF specification. So we use DataType 7 =UNDEFINED. We can do this,
// because the actual Microsoft faxconsole (delivered with Windows XP)
// seems to ignore this.

static const TIFFFieldInfo xtiffFieldInfo[] = {

  /* XXX Replace these example tags with your own extended tags */
    { TIFFTAG_MSFAX_CSID, -1,-1, TIFF_ASCII, FIELD_MSFAX_CSID,
      TRUE, FALSE, "MyCalledStationIdTag" },
    { TIFFTAG_MSFAX_TSID, -1,-1, TIFF_ASCII, FIELD_MSFAX_TSID,
      TRUE, FALSE, "MyTransmitStationIdTag" },
    { TIFFTAG_MSFAX_DEVICE, -1,-1, TIFF_ASCII, FIELD_MSFAX_DEVICE,
      TRUE, FALSE, "MyDeviceTag" },
    { TIFFTAG_MSFAX_ROUTINGINFO, -1,-1, TIFF_ASCII, FIELD_MSFAX_ROUTINGINFO,
      TRUE, FALSE, "MyRoutingInfoTag" },
    { TIFFTAG_MSFAX_CALLERID, -1,-1, TIFF_ASCII, FIELD_MSFAX_CALLERID,
      TRUE, FALSE, "MyCallerIdTag" },
    { TIFFTAG_MSFAX_RECIPIENTNAME, -1,-1, TIFF_ASCII, FIELD_MSFAX_RECIPIENTNAME,
      TRUE, FALSE, "MyRecipientNameTag" },
    { TIFFTAG_MSFAX_RECIPIENTFAXNUMBER, -1,-1, TIFF_ASCII, FIELD_MSFAX_RECIPIENTFAXNUMBER,
      TRUE, FALSE, "MyRecipientFaxNumberTag" },
/*
    { TIFFTAG_MSFAX_40008, -1,-1, TIFF_ASCII, FIELD_MSFAX_40008,
      TRUE, FALSE, "My40008Tag" },
    { TIFFTAG_MSFAX_40009, -1,-1, TIFF_ASCII, FIELD_MSFAX_40009,
      TRUE, FALSE, "My40009Tag" },
    { TIFFTAG_MSFAX_40010, -1,-1, TIFF_ASCII, FIELD_MSFAX_40010,
      TRUE, FALSE, "My40010Tag" },
    { TIFFTAG_MSFAX_40011, -1,-1, TIFF_ASCII, FIELD_MSFAX_40011,
      TRUE, FALSE, "My40011Tag" },
    { TIFFTAG_MSFAX_40012, -1,-1, TIFF_ASCII, FIELD_MSFAX_40012,
      TRUE, FALSE, "My40012Tag" },
    { TIFFTAG_MSFAX_40013, -1,-1, TIFF_ASCII, FIELD_MSFAX_40013,
      TRUE, FALSE, "My40013Tag" },
    { TIFFTAG_MSFAX_40014, -1,-1, TIFF_ASCII, FIELD_MSFAX_40014,
      TRUE, FALSE, "My40014Tag" },
    { TIFFTAG_MSFAX_40015, -1,-1, TIFF_ASCII, FIELD_MSFAX_40015,
      TRUE, FALSE, "My40015Tag" },
    { TIFFTAG_MSFAX_40016, -1,-1, TIFF_ASCII, FIELD_MSFAX_40016,
      TRUE, FALSE, "My40016Tag" },
    { TIFFTAG_MSFAX_40017, -1,-1, TIFF_ASCII, FIELD_MSFAX_40017,
      TRUE, FALSE, "My40017Tag" },
    { TIFFTAG_MSFAX_40018, -1,-1, TIFF_ASCII, FIELD_MSFAX_40018,
      TRUE, FALSE, "My40018Tag" },
    { TIFFTAG_MSFAX_40019, -1,-1, TIFF_ASCII, FIELD_MSFAX_40019,
      TRUE, FALSE, "My40019Tag" },
    { TIFFTAG_MSFAX_40020, -1,-1, TIFF_ASCII, FIELD_MSFAX_40020,
      TRUE, FALSE, "My40020Tag" },
*/
    { TIFFTAG_MSFAX_SENDERNAME, -1,-1, TIFF_ASCII, FIELD_MSFAX_SENDERNAME,
      TRUE, FALSE, "MySenderNameTag" },
    { TIFFTAG_MSFAX_SENDERFAXNUMBER, -1,-1, TIFF_ASCII, FIELD_MSFAX_SENDERFAXNUMBER,
      TRUE, FALSE, "MySenderFaxNumberTag" },
/*
    { TIFFTAG_MSFAX_SENDERCOMPANY, -1,-1, TIFF_ASCII, FIELD_MSFAX_SENDERCOMPANY,
      TRUE, FALSE, "MySenderCompanyTag" },
    { TIFFTAG_MSFAX_40024, -1,-1, TIFF_ASCII, FIELD_MSFAX_40024,
      TRUE, FALSE, "My40024Tag" },
    { TIFFTAG_MSFAX_40025, -1,-1, TIFF_ASCII, FIELD_MSFAX_40025,
      TRUE, FALSE, "My40025Tag" },
    { TIFFTAG_MSFAX_40026, -1,-1, TIFF_ASCII, FIELD_MSFAX_40026,
      TRUE, FALSE, "My40026Tag" },
    { TIFFTAG_MSFAX_40027, -1,-1, TIFF_ASCII, FIELD_MSFAX_40027,
      TRUE, FALSE, "My40027Tag" },
    { TIFFTAG_MSFAX_40028, -1,-1, TIFF_ASCII, FIELD_MSFAX_40028,
      TRUE, FALSE, "My40028Tag" },
    { TIFFTAG_MSFAX_40029, -1,-1, TIFF_ASCII, FIELD_MSFAX_40029,
      TRUE, FALSE, "My40029Tag" },
    { TIFFTAG_MSFAX_40030, -1,-1, TIFF_ASCII, FIELD_MSFAX_40030,
      TRUE, FALSE, "My40030Tag" },
    { TIFFTAG_MSFAX_40031, -1,-1, TIFF_ASCII, FIELD_MSFAX_40031,
      TRUE, FALSE, "My40031Tag" },
    { TIFFTAG_MSFAX_40032, -1,-1, TIFF_ASCII, FIELD_MSFAX_40032,
      TRUE, FALSE, "My40032Tag" },
    { TIFFTAG_MSFAX_40033, -1,-1, TIFF_ASCII, FIELD_MSFAX_40033,
      TRUE, FALSE, "My40033Tag" },
    { TIFFTAG_MSFAX_40034, -1,-1, TIFF_ASCII, FIELD_MSFAX_40034,
      TRUE, FALSE, "My40034Tag" },
    { TIFFTAG_MSFAX_40035, -1,-1, TIFF_ASCII, FIELD_MSFAX_40035,
      TRUE, FALSE, "My40035Tag" },
*/
    { TIFFTAG_MSFAX_BILLINGCODE, -1,-1, TIFF_ASCII, FIELD_MSFAX_BILLINGCODE,
      TRUE, FALSE, "MyBillingCcodeTag" },
    { TIFFTAG_MSFAX_USERNAME, -1,-1, TIFF_ASCII, FIELD_MSFAX_USERNAME,
      TRUE, FALSE, "MyUserNameTag" },
    { TIFFTAG_MSFAX_40038, -1,-1, TIFF_ASCII, FIELD_MSFAX_40038,
      TRUE, FALSE, "My40038Tag" },
    { TIFFTAG_MSFAX_DOCUMENT, -1,-1, TIFF_ASCII, FIELD_MSFAX_DOCUMENT,
      TRUE, FALSE, "MyDocumentTag" },
    { TIFFTAG_MSFAX_COVERPAGESUBJECT, -1,-1, TIFF_ASCII, FIELD_MSFAX_COVERPAGESUBJECT,
      TRUE, FALSE, "MyCoverPageSubjectTag" },
    { TIFFTAG_MSFAX_RETRIES, 1, 1, TIFF_LONG, FIELD_MSFAX_RETRIES,
      TRUE, FALSE, "MyRetriesTag" },
    { TIFFTAG_MSFAX_PRIORITY, 1, 1, TIFF_LONG, FIELD_MSFAX_PRIORITY,
      TRUE, FALSE, "MyPriorityTag" },
    { TIFFTAG_MSFAX_PARENTJOBID, sizeof(uint64), sizeof(uint64),
      TIFF_UNDEFINED, FIELD_MSFAX_PARENTJOBID, TRUE, FALSE, "MyParentJobIdTag" },
    { TIFFTAG_MSFAX_SUBMISSIONTIME, sizeof(FILETIME), sizeof(FILETIME),
      TIFF_UNDEFINED, FIELD_MSFAX_SUBMISSIONTIME, TRUE, FALSE, "MySubmissionTimeTag" },
    { TIFFTAG_MSFAX_SCHEDULED, sizeof(FILETIME), sizeof(FILETIME),
      TIFF_UNDEFINED, FIELD_MSFAX_SCHEDULED, TRUE, FALSE, "MyScheduledTag" },
    { TIFFTAG_MSFAX_TOTALPAGES, 1, 1, TIFF_LONG, FIELD_MSFAX_TOTALPAGES,
      TRUE, FALSE, "MyTotalPagesTag" },
    { TIFFTAG_MSFAX_TYPE, 1, 1, TIFF_LONG, FIELD_MSFAX_TYPE,
      TRUE, FALSE, "MyTypeTag" },
    { TIFFTAG_MSFAX_40048, 1, 1, TIFF_LONG, FIELD_MSFAX_40048,
      TRUE, FALSE, "My40048Tag" },
    { TIFFTAG_MSFAX_ERRORCODE, 1, 1, TIFF_LONG, FIELD_MSFAX_ERRORCODE,
      TRUE, FALSE, "MyErrorCodeTag" },
    { TIFFTAG_MSFAX_40050, -1,-1, TIFF_ASCII, FIELD_MSFAX_40050,
      TRUE, FALSE, "My40050Tag" },
    { TIFFTAG_MSFAX_STARTTIME, sizeof(FILETIME), sizeof(FILETIME),
      TIFF_UNDEFINED, FIELD_MSFAX_STARTTIME, TRUE, FALSE, "MyStartTimeTag" },
    { TIFFTAG_MSFAX_ENDTIME, sizeof(FILETIME), sizeof(FILETIME),
      TIFF_UNDEFINED, FIELD_MSFAX_ENDTIME, TRUE, FALSE, "MyEndTimeTag" },
    { TIFFTAG_MSFAX_40053, 1, 1, TIFF_LONG, FIELD_MSFAX_40053,
      TRUE, FALSE, "My40053Tag" },
//    { TIFFTAG_EXAMPLE_MULTI, -1,-1, TIFF_DOUBLE, FIELD_EXAMPLE_MULTI,
//      TRUE, TRUE, "MyMultivaluedTag" },
//    { TIFFTAG_EXAMPLE_SINGLE, 1, 1, TIFF_LONG, FIELD_EXAMPLE_SINGLE,
//      TRUE, FALSE, "MySingleLongTag" },
//    { TIFFTAG_EXAMPLE_ASCII, -1,-1, TIFF_ASCII, FIELD_EXAMPLE_ASCII,
//      TRUE, FALSE, "MyAsciiTag" },
};
#define N(a)  (sizeof (a) / sizeof (a[0]))


static void
_XTIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
{
  xtiff *xt = XTIFFDIR(tif);
  XTIFFDirectory *xd = &xt->xtif_dir;

  /* call the inherited method */
  if (PARENT(xt,printdir))
    (PARENT(xt,printdir))(tif,fd,flags);

  /* XXX Add field printing here. Replace the three example
         *    tags implemented below with your own.
         */

  fprintf(fd,"--My MSFax Tags--\n");
//  fprintf(fd,"--My Example Tags--\n");

  if (TIFFFieldSet(tif,FIELD_MSFAX_CSID))
  {
    _TIFFprintAsciiTag(fd,"My CalledStationId Tag",
       xd->xd_msfax_csid);
  }

  if (TIFFFieldSet(tif,FIELD_MSFAX_TSID))
  {
    _TIFFprintAsciiTag(fd,"My TransmitStationId Tag",
       xd->xd_msfax_tsid);
  }

  if (TIFFFieldSet(tif,FIELD_MSFAX_DEVICE))
  {
    _TIFFprintAsciiTag(fd,"My Device Tag",
       xd->xd_msfax_device);
  }

  if (TIFFFieldSet(tif,FIELD_MSFAX_ROUTINGINFO))
  {
    _TIFFprintAsciiTag(fd,"My RoutingInfo Tag",
       xd->xd_msfax_routinginfo);
  }

  if (TIFFFieldSet(tif,FIELD_MSFAX_CALLERID))
  {
    _TIFFprintAsciiTag(fd,"My CallerId Tag",
       xd->xd_msfax_callerid);
  }

  if (TIFFFieldSet(tif,FIELD_MSFAX_RECIPIENTNAME))
  {
    _TIFFprintAsciiTag(fd,"My RecipientName Tag",
       xd->xd_msfax_recipientname);
  }

  if (TIFFFieldSet(tif,FIELD_MSFAX_RECIPIENTFAXNUMBER))
  {
    _TIFFprintAsciiTag(fd,"My RecipientFaxNumber Tag",
       xd->xd_msfax_recipientfaxnumber);
  }
/*
  if (TIFFFieldSet(tif,FIELD_MSFAX_40008))
  {
    _TIFFprintAsciiTag(fd,"My 40008 Tag",
       xd->xd_msfax_40008);
  }

  if (TIFFFieldSet(tif,FIELD_MSFAX_40009))
  {
    _TIFFprintAsciiTag(fd,"My 40009 Tag",
       xd->xd_msfax_40009);
  }

  if (TIFFFieldSet(tif,FIELD_MSFAX_40010))
  {
    _TIFFprintAsciiTag(fd,"My 40010 Tag",
       xd->xd_msfax_40010);
  }

  if (TIFFFieldSet(tif,FIELD_MSFAX_40011))
  {
    _TIFFprintAsciiTag(fd,"My 40011 Tag",
       xd->xd_msfax_40011);
  }

  if (TIFFFieldSet(tif,FIELD_MSFAX_40012))
  {
    _TIFFprintAsciiTag(fd,"My 40012 Tag",
       xd->xd_msfax_40012);
  }

  if (TIFFFieldSet(tif,FIELD_MSFAX_40013))
  {
    _TIFFprintAsciiTag(fd,"My 40013 Tag",
       xd->xd_msfax_40013);
  }

  if (TIFFFieldSet(tif,FIELD_MSFAX_40014))
  {
    _TIFFprintAsciiTag(fd,"My 40014 Tag",
       xd->xd_msfax_40014);
  }

  if (TIFFFieldSet(tif,FIELD_MSFAX_40015))
  {
    _TIFFprintAsciiTag(fd,"My 40015 Tag",
       xd->xd_msfax_40015);
  }

  if (TIFFFieldSet(tif,FIELD_MSFAX_40016))
  {
    _TIFFprintAsciiTag(fd,"My 40016 Tag",
       xd->xd_msfax_40016);
  }

  if (TIFFFieldSet(tif,FIELD_MSFAX_40017))
  {
    _TIFFprintAsciiTag(fd,"My 40017 Tag",
       xd->xd_msfax_40017);
  }

  if (TIFFFieldSet(tif,FIELD_MSFAX_40018))
  {
    _TIFFprintAsciiTag(fd,"My 40018 Tag",
       xd->xd_msfax_40018);
  }

  if (TIFFFieldSet(tif,FIELD_MSFAX_40019))
  {
    _TIFFprintAsciiTag(fd,"My 40019 Tag",
       xd->xd_msfax_40019);
  }

  if (TIFFFieldSet(tif,FIELD_MSFAX_40020))
  {
    _TIFFprintAsciiTag(fd,"My 40020 Tag",
       xd->xd_msfax_40020);
  }
*/
  if (TIFFFieldSet(tif,FIELD_MSFAX_SENDERNAME))
  {
    _TIFFprintAsciiTag(fd,"My SenderName Tag",
       xd->xd_msfax_sendername);
  }

  if (TIFFFieldSet(tif,FIELD_MSFAX_SENDERFAXNUMBER))
  {
    _TIFFprintAsciiTag(fd,"My SenderFaxNumber Tag",
       xd->xd_msfax_senderfaxnumber);
  }
/*
  if (TIFFFieldSet(tif,FIELD_MSFAX_SENDERCOMPANY))
  {
    _TIFFprintAsciiTag(fd,"My SenderCompany Tag",
       xd->xd_msfax_sendercompany);
  }

  if (TIFFFieldSet(tif,FIELD_MSFAX_40024))
  {
    _TIFFprintAsciiTag(fd,"My 40024 Tag",
       xd->xd_msfax_40024);
  }

  if (TIFFFieldSet(tif,FIELD_MSFAX_40025))
  {
    _TIFFprintAsciiTag(fd,"My 40025 Tag",
       xd->xd_msfax_40025);
  }

  if (TIFFFieldSet(tif,FIELD_MSFAX_40026))
  {
    _TIFFprintAsciiTag(fd,"My 40026 Tag",
       xd->xd_msfax_40026);
  }

  if (TIFFFieldSet(tif,FIELD_MSFAX_40027))
  {
    _TIFFprintAsciiTag(fd,"My 40027 Tag",
       xd->xd_msfax_40027);
  }

  if (TIFFFieldSet(tif,FIELD_MSFAX_40028))
  {
    _TIFFprintAsciiTag(fd,"My 40028 Tag",
       xd->xd_msfax_40028);
  }

  if (TIFFFieldSet(tif,FIELD_MSFAX_40029))
  {
    _TIFFprintAsciiTag(fd,"My 40029 Tag",
       xd->xd_msfax_40029);
  }

  if (TIFFFieldSet(tif,FIELD_MSFAX_40030))
  {
    _TIFFprintAsciiTag(fd,"My 40030 Tag",
       xd->xd_msfax_40030);
  }

  if (TIFFFieldSet(tif,FIELD_MSFAX_40031))
  {
    _TIFFprintAsciiTag(fd,"My 40031 Tag",
       xd->xd_msfax_40031);
  }

  if (TIFFFieldSet(tif,FIELD_MSFAX_40032))
  {
    _TIFFprintAsciiTag(fd,"My 40032 Tag",
       xd->xd_msfax_40032);
  }

  if (TIFFFieldSet(tif,FIELD_MSFAX_40033))
  {
    _TIFFprintAsciiTag(fd,"My 40033 Tag",
       xd->xd_msfax_40033);
  }

  if (TIFFFieldSet(tif,FIELD_MSFAX_40034))
  {
    _TIFFprintAsciiTag(fd,"My 40034 Tag",
       xd->xd_msfax_40034);
  }

  if (TIFFFieldSet(tif,FIELD_MSFAX_40035))
  {
    _TIFFprintAsciiTag(fd,"My 40035 Tag",
       xd->xd_msfax_40035);
  }
*/
  if (TIFFFieldSet(tif,FIELD_MSFAX_BILLINGCODE))
  {
    _TIFFprintAsciiTag(fd,"My BillingCode Tag",
       xd->xd_msfax_billingcode);
  }

  if (TIFFFieldSet(tif,FIELD_MSFAX_USERNAME))
  {
    _TIFFprintAsciiTag(fd,"My UserName Tag",
       xd->xd_msfax_username);
  }

  if (TIFFFieldSet(tif,FIELD_MSFAX_40038))
  {
    _TIFFprintAsciiTag(fd,"My 40038 Tag",
       xd->xd_msfax_40038);
  }

  if (TIFFFieldSet(tif,FIELD_MSFAX_DOCUMENT))
  {
    _TIFFprintAsciiTag(fd,"My Document Tag",
       xd->xd_msfax_document);
  }

  if (TIFFFieldSet(tif,FIELD_MSFAX_COVERPAGESUBJECT))
  {
    _TIFFprintAsciiTag(fd,"My CoverPageSubject Tag",
       xd->xd_msfax_coverpagesubject);
  }

  if (TIFFFieldSet(tif,FIELD_MSFAX_RETRIES))
  {
    fprintf(fd, "  My Retries Tag:  %lu\n", xd->xd_msfax_retries);
  }

  if (TIFFFieldSet(tif,FIELD_MSFAX_PRIORITY))
  {
    fprintf(fd, "  My Priority Tag:  %lu\n", xd->xd_msfax_priority);
  }

//  if (TIFFFieldSet(tif,FIELD_MSFAX_PARENTJOBID   "My ParentJobId Tag"  xd_msfax_parentjobid
//  if (TIFFFieldSet(tif,FIELD_MSFAX_SUBMISSIONTIME      "My SubmissionTime Tag"  xd_msfax_submissiontime
//  if (TIFFFieldSet(tif,FIELD_MSFAX_SCHEDULED       "My Scheduled Tag"  xd_msfax_scheduled

  if (TIFFFieldSet(tif,FIELD_MSFAX_TOTALPAGES))
  {
    fprintf(fd, "  My TotalPages Tag:  %lu\n", xd->xd_msfax_totalpages);
  }

  if (TIFFFieldSet(tif,FIELD_MSFAX_TYPE))
  {
    fprintf(fd, "  My Type Tag:  %lu\n", xd->xd_msfax_type);
  }

  if (TIFFFieldSet(tif,FIELD_MSFAX_40048))
  {
    fprintf(fd, "  My 40048 Tag:  %lu\n", xd->xd_msfax_40048);
  }

  if (TIFFFieldSet(tif,FIELD_MSFAX_ERRORCODE))
  {
    fprintf(fd, "  My ErrorCode Tag:  %lu\n", xd->xd_msfax_errorcode);
  }

  if (TIFFFieldSet(tif,FIELD_MSFAX_40050))
  {
    _TIFFprintAsciiTag(fd,"My 40050 Tag",
       xd->xd_msfax_40050);
  }

//  if (TIFFFieldSet(tif,FIELD_MSFAX_STARTTIME   "My StartTime Tag"  xd_msfax_starttime
//  if (TIFFFieldSet(tif,FIELD_MSFAX_ENDTIME   "My EndTime Tag"  xd_msfax_endtime

  if (TIFFFieldSet(tif,FIELD_MSFAX_40053))
  {
    fprintf(fd, "  My 40053 Tag:  %lu\n", xd->xd_msfax_40053);
  }

  /* Our first example tag may have a lot of values, so we
         * will only print them out if the TIFFPRINT_MYMULTIDOUBLES
         * flag is passed into the print method.
         */
/*
  if (TIFFFieldSet(tif,FIELD_EXAMPLE_MULTI))
  {
    int i,num;
    fprintf(fd, "  My Multi-Valued Doubles:");
    if (flags & TIFFPRINT_MYMULTIDOUBLES)
    {
      double *value = xd->xd_example_multi;

      num = xd->xd_num_multi;
      fprintf(fd,"(");
      for (i=0;i<num;i++) fprintf(fd, " %lg", *value++);
      fprintf(fd,")\n");
    } else
      fprintf(fd, "(present)\n");
  }

  if (TIFFFieldSet(tif,FIELD_EXAMPLE_SINGLE))
  {
    fprintf(fd, "  My Single Long Tag:  %lu\n", xd->xd_example_single);
  }

  if (TIFFFieldSet(tif,FIELD_EXAMPLE_ASCII))
  {
    _TIFFprintAsciiTag(fd,"My ASCII Tag",
       xd->xd_example_ascii);
  }
*/
}

static int
_XTIFFVSetField(TIFF* tif, ttag_t tag, va_list ap)
{
  xtiff *xt = XTIFFDIR(tif);
  XTIFFDirectory* xd = &xt->xtif_dir;
  int status = 1;
  uint32 v32=0;
  int i=0, v=0;
  va_list ap1 = ap;

  /* va_start is called by the calling routine */

  switch (tag) {
    /*
                 * XXX put your extended tags here; replace the implemented
                 *     example tags with your own.
                 */
  case TIFFTAG_MSFAX_CSID:
    _TIFFsetString(&xd->xd_msfax_csid, va_arg(ap, char*));
    break;
  case TIFFTAG_MSFAX_TSID:
    _TIFFsetString(&xd->xd_msfax_tsid, va_arg(ap, char*));
    break;
  case TIFFTAG_MSFAX_DEVICE:
    _TIFFsetString(&xd->xd_msfax_device, va_arg(ap, char*));
    break;
  case TIFFTAG_MSFAX_ROUTINGINFO:
    _TIFFsetString(&xd->xd_msfax_routinginfo, va_arg(ap, char*));
    break;
  case TIFFTAG_MSFAX_CALLERID:
    _TIFFsetString(&xd->xd_msfax_callerid, va_arg(ap, char*));
    break;
  case TIFFTAG_MSFAX_RECIPIENTNAME:
    _TIFFsetString(&xd->xd_msfax_recipientname, va_arg(ap, char*));
    break;
  case TIFFTAG_MSFAX_RECIPIENTFAXNUMBER:
    _TIFFsetString(&xd->xd_msfax_recipientfaxnumber, va_arg(ap, char*));
    break;
/*
  case TIFFTAG_MSFAX_40008:
    _TIFFsetString(&xd->xd_msfax_40008, va_arg(ap, char*));
    break;
  case TIFFTAG_MSFAX_40009:
    _TIFFsetString(&xd->xd_msfax_40009, va_arg(ap, char*));
    break;
  case TIFFTAG_MSFAX_40010:
    _TIFFsetString(&xd->xd_msfax_40010, va_arg(ap, char*));
    break;
  case TIFFTAG_MSFAX_40011:
    _TIFFsetString(&xd->xd_msfax_40011, va_arg(ap, char*));
    break;
  case TIFFTAG_MSFAX_40012:
    _TIFFsetString(&xd->xd_msfax_40012, va_arg(ap, char*));
    break;
  case TIFFTAG_MSFAX_40013:
    _TIFFsetString(&xd->xd_msfax_40013, va_arg(ap, char*));
    break;
  case TIFFTAG_MSFAX_40014:
    _TIFFsetString(&xd->xd_msfax_40014, va_arg(ap, char*));
    break;
  case TIFFTAG_MSFAX_40015:
    _TIFFsetString(&xd->xd_msfax_40015, va_arg(ap, char*));
    break;
  case TIFFTAG_MSFAX_40016:
    _TIFFsetString(&xd->xd_msfax_40016, va_arg(ap, char*));
    break;
  case TIFFTAG_MSFAX_40017:
    _TIFFsetString(&xd->xd_msfax_40017, va_arg(ap, char*));
    break;
  case TIFFTAG_MSFAX_40018:
    _TIFFsetString(&xd->xd_msfax_40018, va_arg(ap, char*));
    break;
  case TIFFTAG_MSFAX_40019:
    _TIFFsetString(&xd->xd_msfax_40019, va_arg(ap, char*));
    break;
  case TIFFTAG_MSFAX_40020:
    _TIFFsetString(&xd->xd_msfax_40020, va_arg(ap, char*));
    break;
*/
  case TIFFTAG_MSFAX_SENDERNAME:
    _TIFFsetString(&xd->xd_msfax_sendername, va_arg(ap, char*));
    break;
  case TIFFTAG_MSFAX_SENDERFAXNUMBER:
    _TIFFsetString(&xd->xd_msfax_senderfaxnumber, va_arg(ap, char*));
    break;
/*
  case TIFFTAG_MSFAX_SENDERCOMPANY:
    _TIFFsetString(&xd->xd_msfax_sendercompany, va_arg(ap, char*));
    break;
  case TIFFTAG_MSFAX_40024:
    _TIFFsetString(&xd->xd_msfax_40024, va_arg(ap, char*));
    break;
  case TIFFTAG_MSFAX_40025:
    _TIFFsetString(&xd->xd_msfax_40025, va_arg(ap, char*));
    break;
  case TIFFTAG_MSFAX_40026:
    _TIFFsetString(&xd->xd_msfax_40026, va_arg(ap, char*));
    break;
  case TIFFTAG_MSFAX_40027:
    _TIFFsetString(&xd->xd_msfax_40027, va_arg(ap, char*));
    break;
  case TIFFTAG_MSFAX_40028:
    _TIFFsetString(&xd->xd_msfax_40028, va_arg(ap, char*));
    break;
  case TIFFTAG_MSFAX_40029:
    _TIFFsetString(&xd->xd_msfax_40029, va_arg(ap, char*));
    break;
  case TIFFTAG_MSFAX_40030:
    _TIFFsetString(&xd->xd_msfax_40030, va_arg(ap, char*));
    break;
  case TIFFTAG_MSFAX_40031:
    _TIFFsetString(&xd->xd_msfax_40031, va_arg(ap, char*));
    break;
  case TIFFTAG_MSFAX_40032:
    _TIFFsetString(&xd->xd_msfax_40032, va_arg(ap, char*));
    break;
  case TIFFTAG_MSFAX_40033:
    _TIFFsetString(&xd->xd_msfax_40033, va_arg(ap, char*));
    break;
  case TIFFTAG_MSFAX_40034:
    _TIFFsetString(&xd->xd_msfax_40034, va_arg(ap, char*));
    break;
  case TIFFTAG_MSFAX_40035:
    _TIFFsetString(&xd->xd_msfax_40035, va_arg(ap, char*));
    break;
*/
  case TIFFTAG_MSFAX_BILLINGCODE:
    _TIFFsetString(&xd->xd_msfax_billingcode, va_arg(ap, char*));
    break;
  case TIFFTAG_MSFAX_USERNAME:
    _TIFFsetString(&xd->xd_msfax_username, va_arg(ap, char*));
    break;
  case TIFFTAG_MSFAX_40038:
    _TIFFsetString(&xd->xd_msfax_40038, va_arg(ap, char*));
    break;
  case TIFFTAG_MSFAX_DOCUMENT:
    _TIFFsetString(&xd->xd_msfax_document, va_arg(ap, char*));
    break;
  case TIFFTAG_MSFAX_COVERPAGESUBJECT:
    _TIFFsetString(&xd->xd_msfax_coverpagesubject, va_arg(ap, char*));
    break;
  case TIFFTAG_MSFAX_RETRIES:
    xd->xd_msfax_retries = va_arg(ap, uint32);
    break;
  case TIFFTAG_MSFAX_PRIORITY:
    xd->xd_msfax_priority = va_arg(ap, uint32);
    break;
  case TIFFTAG_MSFAX_PARENTJOBID:
//    xd->xd_msfax_parentjobid = va_arg(ap, int64);
    _TIFFsetByteArray(&xd->xd_msfax_parentjobid, va_arg(ap, uint8*),
      (long)sizeof(uint64));
    break;
  case TIFFTAG_MSFAX_SUBMISSIONTIME:
//    xd->xd_msfax_submissiontime = va_arg(ap, FILETIME);
    _TIFFsetByteArray(&xd->xd_msfax_submissiontime, va_arg(ap, uint8*),
      (long)sizeof(FILETIME));
    break;
  case TIFFTAG_MSFAX_SCHEDULED:
//    xd->xd_msfax_scheduled = va_arg(ap, FILETIME);
    _TIFFsetByteArray(&xd->xd_msfax_scheduled, va_arg(ap, uint8*),
      (long)sizeof(FILETIME));
    break;
  case TIFFTAG_MSFAX_TOTALPAGES:
    xd->xd_msfax_totalpages = va_arg(ap, uint32);
    break;
  case TIFFTAG_MSFAX_TYPE:
    xd->xd_msfax_type = va_arg(ap, uint32);
    break;
  case TIFFTAG_MSFAX_40048:
    xd-> xd_msfax_40048 = va_arg(ap, uint32);
    break;
  case TIFFTAG_MSFAX_ERRORCODE:
    xd->xd_msfax_errorcode = va_arg(ap, uint32);
    break;
  case TIFFTAG_MSFAX_40050:
    _TIFFsetString(&xd->xd_msfax_40050, va_arg(ap, char*));
    break;
  case TIFFTAG_MSFAX_STARTTIME:
//    xd->xd_msfax_starttime = va_arg(ap, FILETIME);
    _TIFFsetByteArray(&xd->xd_msfax_starttime, va_arg(ap, uint8*),
      (long)sizeof(FILETIME));
    break;
  case TIFFTAG_MSFAX_ENDTIME:
//    xd->xd_msfax_endtime = va_arg(ap, FILETIME);
    _TIFFsetByteArray(&xd->xd_msfax_endtime, va_arg(ap, uint8*),
      (long)sizeof(FILETIME));
    break;
  case TIFFTAG_MSFAX_40053:
    xd->xd_msfax_40053 = va_arg(ap, uint32);
    break;
/*
  case TIFFTAG_EXAMPLE_MULTI:
    // multi-valued tags need to store the count as well
    xd->xd_num_multi = (uint16) va_arg(ap, int);
    _TIFFsetDoubleArray(&xd->xd_example_multi, va_arg(ap, double*),
      (long) xd->xd_num_multi);
    break;
  case TIFFTAG_EXAMPLE_SINGLE:
    xd->xd_example_single = va_arg(ap, uint32);
    break;
  case TIFFTAG_EXAMPLE_ASCII:
    _TIFFsetString(&xd->xd_example_ascii, va_arg(ap, char*));
    break;
*/
  default:
    /* call the inherited method */
    return (PARENT(xt,vsetfield))(tif,tag,ap);
    break;
  }
  if (status) {
    /* we have to override the print method here,
     * after the compression tags have gotten to it.
     * This makes sense because the only time we would
     * need the extended print method is if an extended
     * tag is set by the reader.
     */
    if (!(xt->xtif_flags & XTIFFP_PRINT))
    {
            PARENT(xt,printdir) =  TIFFMEMBER(tif,printdir);
              TIFFMEMBER(tif,printdir) = _XTIFFPrintDirectory;
      xt->xtif_flags |= XTIFFP_PRINT;
    }
    TIFFSetFieldBit(tif, _TIFFFieldWithTag(tif, tag)->field_bit);
    tif->tif_flags |= TIFF_DIRTYDIRECT;
  }
  va_end(ap);
  return (status);
badvalue:
  TIFFError(tif->tif_name, "%d: Bad value for \"%s\"", v,
      _TIFFFieldWithTag(tif, tag)->field_name);
  va_end(ap);
  return (0);
badvalue32:
  TIFFError(tif->tif_name, "%ld: Bad value for \"%s\"", v32,
      _TIFFFieldWithTag(tif, tag)->field_name);
  va_end(ap);
  return (0);
}


static int
_XTIFFVGetField(TIFF* tif, ttag_t tag, va_list ap)
{
  xtiff *xt = XTIFFDIR(tif);
  XTIFFDirectory* xd = &xt->xtif_dir;

  switch (tag) {
    /*
                 * XXX put your extended tags here; replace the implemented
                 *     example tags with your own.
                 */
  case TIFFTAG_MSFAX_CSID:
    *va_arg(ap, char**) = xd->xd_msfax_csid;
    break;
  case TIFFTAG_MSFAX_TSID:
    *va_arg(ap, char**) = xd->xd_msfax_tsid;
    break;
  case TIFFTAG_MSFAX_DEVICE:
    *va_arg(ap, char**) = xd->xd_msfax_device;
    break;
  case TIFFTAG_MSFAX_ROUTINGINFO:
    *va_arg(ap, char**) = xd->xd_msfax_routinginfo;
    break;
  case TIFFTAG_MSFAX_CALLERID:
    *va_arg(ap, char**) = xd->xd_msfax_callerid;
    break;
  case TIFFTAG_MSFAX_RECIPIENTNAME:
    *va_arg(ap, char**) = xd->xd_msfax_recipientname;
    break;
  case TIFFTAG_MSFAX_RECIPIENTFAXNUMBER:
    *va_arg(ap, char**) = xd->xd_msfax_recipientfaxnumber;
    break;
/*
  case TIFFTAG_MSFAX_40008:
    *va_arg(ap, char**) = xd->xd_msfax_40008;
    break;
  case TIFFTAG_MSFAX_40009:
    *va_arg(ap, char**) = xd->xd_msfax_40009;
    break;
  case TIFFTAG_MSFAX_40010:
    *va_arg(ap, char**) = xd->xd_msfax_40010;
    break;
  case TIFFTAG_MSFAX_40011:
    *va_arg(ap, char**) = xd->xd_msfax_40011;
    break;
  case TIFFTAG_MSFAX_40012:
    *va_arg(ap, char**) = xd->xd_msfax_40012;
    break;
  case TIFFTAG_MSFAX_40013:
    *va_arg(ap, char**) = xd->xd_msfax_40013;
    break;
  case TIFFTAG_MSFAX_40014:
    *va_arg(ap, char**) = xd->xd_msfax_40014;
    break;
  case TIFFTAG_MSFAX_40015:
    *va_arg(ap, char**) = xd->xd_msfax_40015;
    break;
  case TIFFTAG_MSFAX_40016:
    *va_arg(ap, char**) = xd->xd_msfax_40016;
    break;
  case TIFFTAG_MSFAX_40017:
    *va_arg(ap, char**) = xd->xd_msfax_40017;
    break;
  case TIFFTAG_MSFAX_40018:
    *va_arg(ap, char**) = xd->xd_msfax_40018;
    break;
  case TIFFTAG_MSFAX_40019:
    *va_arg(ap, char**) = xd->xd_msfax_40019;
    break;
  case TIFFTAG_MSFAX_40020:
    *va_arg(ap, char**) = xd->xd_msfax_40020;
    break;
*/
  case TIFFTAG_MSFAX_SENDERNAME:
    *va_arg(ap, char**) = xd->xd_msfax_sendername;
    break;
  case TIFFTAG_MSFAX_SENDERFAXNUMBER:
    *va_arg(ap, char**) = xd->xd_msfax_senderfaxnumber;
    break;
/*
  case TIFFTAG_MSFAX_SENDERCOMPANY:
    *va_arg(ap, char**) = xd->xd_msfax_sendercompany;
    break;
  case TIFFTAG_MSFAX_40024:
    *va_arg(ap, char**) = xd->xd_msfax_40024;
    break;
  case TIFFTAG_MSFAX_40025:
    *va_arg(ap, char**) = xd->xd_msfax_40025;
    break;
  case TIFFTAG_MSFAX_40026:
    *va_arg(ap, char**) = xd->xd_msfax_40026;
    break;
  case TIFFTAG_MSFAX_40027:
    *va_arg(ap, char**) = xd->xd_msfax_40027;
    break;
  case TIFFTAG_MSFAX_40028:
    *va_arg(ap, char**) = xd->xd_msfax_40028;
    break;
  case TIFFTAG_MSFAX_40029:
    *va_arg(ap, char**) = xd->xd_msfax_40029;
    break;
  case TIFFTAG_MSFAX_40030:
    *va_arg(ap, char**) = xd->xd_msfax_40030;
    break;
  case TIFFTAG_MSFAX_40031:
    *va_arg(ap, char**) = xd->xd_msfax_40031;
    break;
  case TIFFTAG_MSFAX_40032:
    *va_arg(ap, char**) = xd->xd_msfax_40032;
    break;
  case TIFFTAG_MSFAX_40033:
    *va_arg(ap, char**) = xd->xd_msfax_40033;
    break;
  case TIFFTAG_MSFAX_40034:
    *va_arg(ap, char**) = xd->xd_msfax_40034;
    break;
  case TIFFTAG_MSFAX_40035:
    *va_arg(ap, char**) = xd->xd_msfax_40035;
    break;
*/
  case TIFFTAG_MSFAX_BILLINGCODE:
    *va_arg(ap, char**) = xd->xd_msfax_billingcode;
    break;
  case TIFFTAG_MSFAX_USERNAME:
    *va_arg(ap, char**) = xd->xd_msfax_username;
    break;
  case TIFFTAG_MSFAX_40038:
    *va_arg(ap, char**) = xd->xd_msfax_40038;
    break;
  case TIFFTAG_MSFAX_DOCUMENT:
    *va_arg(ap, char**) = xd->xd_msfax_document;
    break;
  case TIFFTAG_MSFAX_COVERPAGESUBJECT:
    *va_arg(ap, char**) = xd->xd_msfax_coverpagesubject;
    break;
  case TIFFTAG_MSFAX_RETRIES:
    *va_arg(ap, uint32*) = xd->xd_msfax_retries;
    break;
  case TIFFTAG_MSFAX_PRIORITY:
    *va_arg(ap, uint32*) = xd->xd_msfax_priority;
    break;
  case TIFFTAG_MSFAX_PARENTJOBID:
    *va_arg(ap, uint64**) = xd->xd_msfax_parentjobid;
    break;
  case TIFFTAG_MSFAX_SUBMISSIONTIME:
    *va_arg(ap, FILETIME**) = xd->xd_msfax_submissiontime;
    break;
  case TIFFTAG_MSFAX_SCHEDULED:
    *va_arg(ap, FILETIME**) = xd->xd_msfax_scheduled;
    break;
  case TIFFTAG_MSFAX_TOTALPAGES:
    *va_arg(ap, uint32*) = xd->xd_msfax_totalpages;
    break;
  case TIFFTAG_MSFAX_TYPE:
    *va_arg(ap, uint32*) = xd->xd_msfax_type;
    break;
  case TIFFTAG_MSFAX_40048:
    *va_arg(ap, uint32*) = xd->xd_msfax_40048;
    break;
  case TIFFTAG_MSFAX_ERRORCODE:
    *va_arg(ap, uint32*) = xd->xd_msfax_errorcode;
    break;
  case TIFFTAG_MSFAX_40050:
    *va_arg(ap, char**) = xd->xd_msfax_40050;
    break;
  case TIFFTAG_MSFAX_STARTTIME:
    *va_arg(ap, FILETIME**) = xd->xd_msfax_starttime;
    break;
  case TIFFTAG_MSFAX_ENDTIME:
    *va_arg(ap, FILETIME**) = xd->xd_msfax_endtime;
    break;
  case TIFFTAG_MSFAX_40053:
    *va_arg(ap, uint32*) = xd->xd_msfax_40053;
    break;
/*
  case TIFFTAG_EXAMPLE_MULTI:
    *va_arg(ap, uint16*) = xd->xd_num_multi;
    *va_arg(ap, double**) = xd->xd_example_multi;
    break;
  case TIFFTAG_EXAMPLE_SINGLE:
    *va_arg(ap, uint32*) = xd->xd_example_single;
    break;
  case TIFFTAG_EXAMPLE_ASCII:
    *va_arg(ap, char**) = xd->xd_example_ascii;
    break;*/
  default:
    /* return inherited method */
    return (PARENT(xt,vgetfield))(tif,tag,ap);
    break;
  }
  return (1);
}

#define CleanupField(member) {    \
    if (xd->member) {     \
  _TIFFfree(xd->member);    \
  xd->member = 0;     \
    }         \
}
/*
 * Release storage associated with a directory.
 */
static void
_XTIFFFreeDirectory(xtiff* xt)
{
  XTIFFDirectory* xd = &xt->xtif_dir;

  /*
   *  XXX - Purge all Your allocated memory except
   *  for the xtiff directory itself. This includes
   *  all fields that require a _TIFFsetXXX call in
   *  _XTIFFVSetField().
   */

  CleanupField(xd_msfax_csid);
  CleanupField(xd_msfax_tsid);
  CleanupField(xd_msfax_device);
  CleanupField(xd_msfax_routinginfo);
  CleanupField(xd_msfax_callerid);
  CleanupField(xd_msfax_recipientname);
  CleanupField(xd_msfax_recipientfaxnumber);
/*
  CleanupField(xd_msfax_40008);
  CleanupField(xd_msfax_40009);
  CleanupField(xd_msfax_40010);
  CleanupField(xd_msfax_40011);
  CleanupField(xd_msfax_40012);
  CleanupField(xd_msfax_40013);
  CleanupField(xd_msfax_40014);
  CleanupField(xd_msfax_40015);
  CleanupField(xd_msfax_40016);
  CleanupField(xd_msfax_40017);
  CleanupField(xd_msfax_40018);
  CleanupField(xd_msfax_40019);
  CleanupField(xd_msfax_40020);
*/
  CleanupField(xd_msfax_sendername);
  CleanupField(xd_msfax_senderfaxnumber);
/*
  CleanupField(xd_msfax_sendercompany);
  CleanupField(xd_msfax_40024);
  CleanupField(xd_msfax_40025);
  CleanupField(xd_msfax_40026);
  CleanupField(xd_msfax_40027);
  CleanupField(xd_msfax_40028);
  CleanupField(xd_msfax_40029);
  CleanupField(xd_msfax_40030);
  CleanupField(xd_msfax_40031);
  CleanupField(xd_msfax_40032);
  CleanupField(xd_msfax_40033);
  CleanupField(xd_msfax_40034);
  CleanupField(xd_msfax_40035);
*/
  CleanupField(xd_msfax_billingcode);
  CleanupField(xd_msfax_username);
  CleanupField(xd_msfax_40038);
  CleanupField(xd_msfax_document);
  CleanupField(xd_msfax_coverpagesubject);
  CleanupField(xd_msfax_parentjobid);
  CleanupField(xd_msfax_submissiontime);
  CleanupField(xd_msfax_scheduled);
  CleanupField(xd_msfax_40050);
  CleanupField(xd_msfax_starttime);
  CleanupField(xd_msfax_endtime);

//  CleanupField(xd_example_multi);
//  CleanupField(xd_example_ascii);
}
#undef CleanupField

static void _XTIFFLocalDefaultDirectory(TIFF *tif)
{
  xtiff *xt = XTIFFDIR(tif);
  XTIFFDirectory* xd = &xt->xtif_dir;

  /* Install the extended Tag field info */
  _TIFFMergeFieldInfo(tif, xtiffFieldInfo, N(xtiffFieldInfo));

  /*
   *  free up any dynamically allocated arrays
   *  before the new directory is read in.
   */

  _XTIFFFreeDirectory(xt);
  _TIFFmemset(xt,0,sizeof(xtiff));

  /* Override the tag access methods */

  PARENT(xt,vsetfield) =  TIFFMEMBER(tif,vsetfield);
  TIFFMEMBER(tif,vsetfield) = _XTIFFVSetField;
  PARENT(xt,vgetfield) =  TIFFMEMBER(tif,vgetfield);
  TIFFMEMBER(tif,vgetfield) = _XTIFFVGetField;


  /*
   * XXX Set up any default values here.
   */

  xd->xd_msfax_csid = "40001";
  xd->xd_msfax_tsid = "40002";
  xd->xd_msfax_device = "40003";
  xd->xd_msfax_routinginfo = "40004";
  xd->xd_msfax_callerid = "40005";
  xd->xd_msfax_recipientname = "40006";
  xd->xd_msfax_recipientfaxnumber = "40007";
/*
  xd->xd_msfax_40008 = "40008";
  xd->xd_msfax_40009 = "40009";
  xd->xd_msfax_40010 = "40010";
  xd->xd_msfax_40011 = "40011";
  xd->xd_msfax_40012 = "40012";
  xd->xd_msfax_40013 = "40013";
  xd->xd_msfax_40014 = "40014";
  xd->xd_msfax_40015 = "40015";
  xd->xd_msfax_40016 = "40016";
  xd->xd_msfax_40017 = "40017";
  xd->xd_msfax_40018 = "40018";
  xd->xd_msfax_40019 = "40019";
  xd->xd_msfax_40020 = "40020";
*/
  xd->xd_msfax_sendername = "40021";
  xd->xd_msfax_senderfaxnumber = "40022";
/*
  xd->xd_msfax_sendercompany = "40023";
  xd->xd_msfax_40024 = "40024";
  xd->xd_msfax_40025 = "40025";
  xd->xd_msfax_40026 = "40026";
  xd->xd_msfax_40027 = "40027";
  xd->xd_msfax_40028 = "40028";
  xd->xd_msfax_40029 = "40029";
  xd->xd_msfax_40030 = "40030";
  xd->xd_msfax_40031 = "40031";
  xd->xd_msfax_40032 = "40032";
  xd->xd_msfax_40033 = "40033";
  xd->xd_msfax_40034 = "40034";
  xd->xd_msfax_40035 = "40035";
*/
  xd->xd_msfax_billingcode = "40036";
  xd->xd_msfax_username = "40037";
  xd->xd_msfax_40038 = "40038";
  xd->xd_msfax_document = "40039";
  xd->xd_msfax_coverpagesubject = "40040";
  xd->xd_msfax_retries = 40041;
  xd->xd_msfax_priority = 40042;
  xd->xd_msfax_parentjobid = "40043";
  xd->xd_msfax_submissiontime = "40044";
  xd->xd_msfax_scheduled = "40045";
  xd->xd_msfax_totalpages = 40046;
  xd->xd_msfax_type = 40047;
  xd->xd_msfax_40048 = 40048;
  xd->xd_msfax_errorcode = 40049;
  xd->xd_msfax_40050 = "40050";
  xd->xd_msfax_starttime = "40051";
  xd->xd_msfax_endtime = "40052";
  xd->xd_msfax_40053 = 40053;

//  xd->xd_example_single = 234;
}



/**********************************************************************
 *    Nothing below this line should need to be changed.
 **********************************************************************/

static TIFFExtendProc _ParentExtender;

/*
 *  This is the callback procedure, and is
 *  called by the DefaultDirectory method
 *  every time a new TIFF directory is opened.
 */

static void
_XTIFFDefaultDirectory(TIFF *tif)
{
  xtiff *xt;

  /* Allocate Directory Structure if first time, and install it */
  if (!(tif->tif_flags & XTIFF_INITIALIZED))
  {
    xt = _TIFFmalloc(sizeof(xtiff));
    if (!xt)
    {
      /* handle memory allocation failure here ! */
      return;
    }
    _TIFFmemset(xt,0,sizeof(xtiff));
    /*
     * Install into TIFF structure.
     */
    TIFFMEMBER(tif,clientdir) = (tidata_t)xt;
    tif->tif_flags |= XTIFF_INITIALIZED; /* dont do this again! */
  }

  /* set up our own defaults */
  _XTIFFLocalDefaultDirectory(tif);

  /* Since an XTIFF client module may have overridden
   * the default directory method, we call it now to
   * allow it to set up the rest of its own methods.
         */

  if (_ParentExtender)
    (*_ParentExtender)(tif);

}

/*
 *  XTIFF Initializer -- sets up the callback
 *   procedure for the TIFF module.
 */

static
void _XTIFFInitialize(void)
{
  static first_time=1;

  if (! first_time) return; /* Been there. Done that. */
  first_time = 0;

  /* Grab the inherited method and install */
  _ParentExtender = TIFFSetTagExtender(_XTIFFDefaultDirectory);
}


/*
 * Public File I/O Routines.
 */
TIFF*
XTIFFOpen(const char* name, const char* mode)
{
  /* Set up the callback */
  _XTIFFInitialize();

  /* Open the file; the callback will set everything up
   */
  return TIFFOpen(name, mode);
}

TIFF*
XTIFFFdOpen(int fd, const char* name, const char* mode)
{
  /* Set up the callback */
  _XTIFFInitialize();

  /* Open the file; the callback will set everything up
   */
  return TIFFFdOpen(fd, name, mode);
}


void
XTIFFClose(TIFF *tif)
{
  xtiff *xt = XTIFFDIR(tif);

  /* call inherited function first */
  TIFFClose(tif);

  /* Free up extended allocated memory */
  _XTIFFFreeDirectory(xt);
  _TIFFfree(xt);
}