Changeset 7cb7f91 in git


Ignore:
Timestamp:
20/09/11 07:38:27 (8 years ago)
Author:
Olly Betts <olly@…>
Branches:
svn/1.0, svn/tags/1.0.40
Children:
02ac18d
Parents:
b8bf5bc
Message:

Backport change from 1.2.0:
configure.in,src/img.c,src/img.h: Sync latest versions of img.c and
img.h from trunk, and configure code to define GETC and PUTC macros.

git-svn-id: file:///home/survex-svn/survex/branches/1.0@3677 4b37db11-9a0c-4f06-9ece-9ab7cdaee568

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • ChangeLog

    rb8bf5bc r7cb7f91  
     1Tue Sep 20 06:36:54 GMT 2011  Olly Betts <olly@survex.com>
     2
     3        * Backport change from 1.2.0:
     4        * configure.in,src/img.c,src/img.h: Sync latest versions of img.c and
     5          img.h from trunk, and configure code to define GETC and PUTC macros.
     6
    17Tue Sep 20 06:28:24 GMT 2011  Olly Betts <olly@survex.com>
    28
  • configure.in

    rb8bf5bc r7cb7f91  
    293293AC_CHECK_FUNCS(difftime)
    294294
     295dnl Much faster than using getc()/putc(), at least on Linux.
     296AC_CHECK_FUNCS([getc_unlocked putc_unlocked])
     297
    295298dnl try to find a case-insensitive compare
    296299
     
    384387fi
    385388
     389AH_BOTTOM(
     390[/* Use getc_unlocked() and putc_unlocked() where available, since they are
     391 * faster, and we don't multithread file accesses.
     392 */
     393
     394#ifdef HAVE_GETC_UNLOCKED
     395# define GETC(F) getc_unlocked(F)
     396#else
     397# define GETC(F) getc(F)
     398#endif
     399#ifdef HAVE_PUTC_UNLOCKED
     400# define PUTC(C, F) putc_unlocked(C, F)
     401#else
     402# define PUTC(C, F) putc(C, F)
     403#endif
     404])
     405
    386406AC_OUTPUT(Makefile src/Makefile doc/Makefile lib/Makefile lib/icons/Makefile
    387407 tests/Makefile debian/Makefile survex.iss doc/index.htm doc/survex.1
  • src/img.c

    rb8bf5bc r7cb7f91  
    11/* img.c
    22 * Routines for reading and writing Survex ".3d" image files
    3  * Copyright (C) 1993-2004,2005,2006,2010 Olly Betts
     3 * Copyright (C) 1993-2004,2005,2006,2010,2011 Olly Betts
    44 *
    55 * This program is free software; you can redistribute it and/or modify
     
    3131#include "img.h"
    3232
    33 #define LATEST_IMG_VERSION 6
     33#ifndef IMG_API_VERSION
     34# define IMG_API_VERSION 0
     35#elif IMG_API_VERSION > 1
     36# error IMG_API_VERSION > 1 too new
     37#endif
    3438
    3539#ifdef IMG_HOSTED
     
    4145# define TIMENA msg(/*Date and time not available.*/108)
    4246# define TIMEFMT msg(/*%a,%Y.%m.%d %H:%M:%S %Z*/107)
     47# define INT32_T int32_t
    4348#else
    4449# define INT32_T int
     
    5863/* path isn't used in img.c, but EXT is */
    5964# define fopenWithPthAndExt(PTH,FNM,EXT,MODE,X) fopen(FNM,MODE)
     65# define PUTC(C, FH) putc(C, FH)
     66# define GETC(FH) getc(FH)
    6067# define fFalse 0
    6168# define fTrue 1
     
    6572 * to work as intended
    6673 */
    67 # define fputsnl(S, FH) do {fputs((S), (FH)); putc('\n', (FH));} while(0)
     74# define fputsnl(S, FH) do {fputs((S), (FH)); PUTC('\n', (FH));} while(0)
    6875# define SVX_ASSERT(X)
    6976
     
    7178get32(FILE *fh)
    7279{
    73    INT32_T w = getc(fh);
    74    w |= (INT32_T)getc(fh) << 8l;
    75    w |= (INT32_T)getc(fh) << 16l;
    76    w |= (INT32_T)getc(fh) << 24l;
     80   INT32_T w = GETC(fh);
     81   w |= (INT32_T)GETC(fh) << 8l;
     82   w |= (INT32_T)GETC(fh) << 16l;
     83   w |= (INT32_T)GETC(fh) << 24l;
    7784   return w;
    7885}
     
    8188put32(long w, FILE *fh)
    8289{
    83    putc((char)(w), fh);
    84    putc((char)(w >> 8l), fh);
    85    putc((char)(w >> 16l), fh);
    86    putc((char)(w >> 24l), fh);
     90   PUTC((char)(w), fh);
     91   PUTC((char)(w >> 8l), fh);
     92   PUTC((char)(w >> 16l), fh);
     93   PUTC((char)(w >> 24l), fh);
    8794}
    8895
     
    9097get16(FILE *fh)
    9198{
    92    short w = getc(fh);
    93    w |= (long)getc(fh) << 8l;
     99   short w = GETC(fh);
     100   w |= (short)GETC(fh) << 8l;
    94101   return w;
    95102}
     
    98105put16(short w, FILE *fh)
    99106{
    100    putc((char)(w), fh);
    101    putc((char)(w >> 8l), fh);
     107   PUTC((char)(w), fh);
     108   PUTC((char)(w >> 8l), fh);
    102109}
    103110
     
    125132}
    126133#endif
     134
     135static unsigned short
     136getu16(FILE *fh)
     137{
     138   return (unsigned short)get16(fh);
     139}
    127140
    128141#include <math.h>
     
    154167#endif
    155168
    156 unsigned int img_output_version = LATEST_IMG_VERSION;
     169unsigned int img_output_version = IMG_VERSION_MAX;
    157170
    158171#ifdef IMG_HOSTED
     
    206219   if (!buf) return NULL;
    207220
    208    ch = getc(fh);
     221   ch = GETC(fh);
    209222   while (ch != '\n' && ch != '\r' && ch != EOF) {
    210223      buf[i++] = ch;
     
    219232         buf = p;
    220233      }
    221       ch = getc(fh);
     234      ch = GETC(fh);
    222235   }
    223236   if (ch == '\n' || ch == '\r') {
    224237      int otherone = ch ^ ('\n' ^ '\r');
    225       ch = getc(fh);
     238      ch = GETC(fh);
    226239      /* if it's not the other eol character, put it back */
    227240      if (ch != otherone) ungetc(ch, fh);
     
    313326   pimg->survey_len = 0;
    314327   pimg->separator = '.';
    315    pimg->date1 = 0;
    316    pimg->date2 = 0;
     328#if IMG_API_VERSION == 0
     329   pimg->date1 = pimg->date2 = 0;
     330#else /* IMG_API_VERSION == 1 */
     331   pimg->days1 = pimg->days2 = -1;
     332#endif
    317333   pimg->is_extended_elevation = 0;
    318334
     
    385401      }
    386402      while (1) {
    387          ch = getc(pimg->fh);
     403         ch = GETC(pimg->fh);
    388404         switch (ch) {
    389405          case '\x1a':
     
    437453         }
    438454         while (ch != '\n' && ch != '\r') {
    439             ch = getc(pimg->fh);
     455            ch = GETC(pimg->fh);
    440456         }
    441457      }
     
    538554
    539555   /* check file format version */
    540    ch = getc(pimg->fh);
     556   ch = GETC(pimg->fh);
    541557   pimg->version = 0;
    542558   if (tolower(ch) == 'b') {
    543559      /* binary file iff B/b prefix */
    544560      pimg->version = 1;
    545       ch = getc(pimg->fh);
     561      ch = GETC(pimg->fh);
    546562   }
    547563   if (ch != 'v') {
     
    549565      goto error;
    550566   }
    551    ch = getc(pimg->fh);
     567   ch = GETC(pimg->fh);
    552568   if (ch == '0') {
    553569      if (fread(buf, 4, 1, pimg->fh) != 1 || memcmp(buf, ".01\n", 4) != 0) {
     
    557573      /* nothing special to do */
    558574   } else if (pimg->version == 0) {
    559       if (ch < '2' || ch > '0' + LATEST_IMG_VERSION || getc(pimg->fh) != '\n') {
     575      if (ch < '2' || ch > '0' + IMG_VERSION_MAX || GETC(pimg->fh) != '\n') {
    560576         img_errno = IMG_TOONEW;
    561577         goto error;
     
    666682      fputs("Bv0.01\n", pimg->fh); /* binary file format version number */
    667683   } else {
    668       pimg->version = (img_output_version > LATEST_IMG_VERSION) ? LATEST_IMG_VERSION : img_output_version;
     684      pimg->version = (img_output_version > IMG_VERSION_MAX) ? IMG_VERSION_MAX : img_output_version;
    669685      fprintf(pimg->fh, "v%d\n", pimg->version); /* file format version no. */
    670686   }
     
    695711   pimg->label_len = 0;
    696712
    697    pimg->date1 = 0;
    698    pimg->date2 = 0;
    699 
    700    pimg->olddate1 = 0;
    701    pimg->olddate2 = 0;
     713#if IMG_API_VERSION == 0
     714   pimg->date1 = pimg->date2 = 0;
     715   pimg->olddate1 = pimg->olddate2 = 0;
     716#else /* IMG_API_VERSION == 1 */
     717   pimg->days1 = pimg->days2 = -1;
     718   pimg->olddays1 = pimg->olddays2 = -1;
     719#endif
    702720
    703721   pimg->l = pimg->r = pimg->u = pimg->d = -1.0;
     
    778796{
    779797   char *q;
    780    long len = getc(pimg->fh);
     798   long len = GETC(pimg->fh);
    781799   if (len == EOF) {
    782800      img_errno = feof(pimg->fh) ? IMG_BADFORMAT : IMG_READERROR;
     
    842860      again3: /* label to goto if we get a prefix, date, or lrud */
    843861      pimg->label = pimg->label_buf;
    844       opt = getc(pimg->fh);
     862      opt = GETC(pimg->fh);
    845863      if (opt == EOF) {
    846864         img_errno = feof(pimg->fh) ? IMG_BADFORMAT : IMG_READERROR;
     
    882900             switch (opt) {
    883901                 case 0x20: /* Single date */
    884                      pimg->date1 = get32(pimg->fh);
    885                      pimg->date2 = pimg->date1;
     902                     if (pimg->version < 7) {
     903                         int date1 = get32(pimg->fh);
     904#if IMG_API_VERSION == 0
     905                         pimg->date2 = pimg->date1 = date1;
     906#else /* IMG_API_VERSION == 1 */
     907                         if (date1 != 0) {
     908                             pimg->days2 = pimg->days1 = (date1 / 86400) + 25567;
     909                         } else {
     910                             pimg->days2 = pimg->days1 = -1;
     911                         }
     912#endif
     913                     } else {
     914                         int days1 = (int)getu16(pimg->fh);
     915#if IMG_API_VERSION == 0
     916                         pimg->date2 = pimg->date1 = (days1 - 25567) * 86400;
     917#else /* IMG_API_VERSION == 1 */
     918                         pimg->days2 = pimg->days1 = days1;
     919#endif
     920                     }
    886921                     break;
    887                  case 0x21: /* Date range */
    888                      pimg->date1 = get32(pimg->fh);
    889                      pimg->date2 = get32(pimg->fh);
     922                 case 0x21: /* Date range (short for v7+) */
     923                     if (pimg->version < 7) {
     924                         INT32_T date1 = get32(pimg->fh);
     925                         INT32_T date2 = get32(pimg->fh);
     926#if IMG_API_VERSION == 0
     927                         pimg->date1 = date1;
     928                         pimg->date2 = date2;
     929#else /* IMG_API_VERSION == 1 */
     930                         pimg->days1 = (date1 / 86400) + 25567;
     931                         pimg->days2 = (date2 / 86400) + 25567;
     932#endif
     933                     } else {
     934                         int days1 = (int)getu16(pimg->fh);
     935                         int days2 = days1 + GETC(pimg->fh) + 1;
     936#if IMG_API_VERSION == 0
     937                         pimg->date1 = (days1 - 25567) * 86400;
     938                         pimg->date2 = (days2 - 25567) * 86400;
     939#else /* IMG_API_VERSION == 1 */
     940                         pimg->days1 = days1;
     941                         pimg->days2 = days2;
     942#endif
     943                     }
    890944                     break;
    891945                 case 0x22: /* Error info */
     
    896950                     pimg->V = get32(pimg->fh) / 100.0;
    897951                     return img_ERROR_INFO;
     952                 case 0x23: { /* v7+: Date range (long) */
     953                     if (pimg->version < 7) {
     954                         img_errno = IMG_BADFORMAT;
     955                         return img_BAD;
     956                     }
     957                     int days1 = (int)getu16(pimg->fh);
     958                     int days2 = (int)getu16(pimg->fh);
     959#if IMG_API_VERSION == 0
     960                     pimg->date1 = (days1 - 25567) * 86400;
     961                     pimg->date2 = (days2 - 25567) * 86400;
     962#else /* IMG_API_VERSION == 1 */
     963                     pimg->days1 = days1;
     964                     pimg->days2 = days2;
     965#endif
     966                     break;
     967                 }
     968                 case 0x24: { /* v7+: No date info */
     969#if IMG_API_VERSION == 0
     970                     pimg->date1 = pimg->date2 = 0;
     971#else /* IMG_API_VERSION == 1 */
     972                     pimg->days1 = pimg->days2 = -1;
     973#endif
     974                     break;
     975                 }
    898976                 case 0x30: case 0x31: /* LRUD */
    899977                 case 0x32: case 0x33: /* Big LRUD! */
     
    9281006                     }
    9291007                     return img_XSECT;
    930                  default: /* 0x23 - 0x2f and 0x34 - 0x3f are currently unallocated. */
     1008                 default: /* 0x25 - 0x2f and 0x34 - 0x3f are currently unallocated. */
    9311009                     img_errno = IMG_BADFORMAT;
    9321010                     return img_BAD;
     
    10151093         }
    10161094      } else {
    1017          opt = getc(pimg->fh);
     1095         opt = GETC(pimg->fh);
    10181096      }
    10191097
     
    10411119         int ch;
    10421120         result = img_LABEL;
    1043          ch = getc(pimg->fh);
     1121         ch = GETC(pimg->fh);
    10441122         if (ch == EOF) {
    10451123            img_errno = feof(pimg->fh) ? IMG_BADFORMAT : IMG_READERROR;
     
    10731151
    10741152         if (opt == 7)
    1075             pimg->flags = getc(pimg->fh);
     1153            pimg->flags = GETC(pimg->fh);
    10761154         else
    10771155            pimg->flags = img_SFLAG_UNDERGROUND; /* no flags given... */
     
    12131291         } else if (strcmp(cmd, "name") == 0) {
    12141292            size_t off = 0;
    1215             int ch = getc(pimg->fh);
    1216             if (ch == ' ') ch = getc(pimg->fh);
     1293            int ch = GETC(pimg->fh);
     1294            if (ch == ' ') ch = GETC(pimg->fh);
    12171295            while (ch != ' ') {
    12181296               if (ch == '\n' || ch == EOF) {
     
    12271305               }
    12281306               pimg->label_buf[off++] = ch;
    1229                ch = getc(pimg->fh);
     1307               ch = GETC(pimg->fh);
    12301308            }
    12311309            pimg->label_buf[off] = '\0';
     
    12751353         /* ignore rest of line */
    12761354         do {
    1277             ch = getc(pimg->fh);
     1355            ch = GETC(pimg->fh);
    12781356         } while (ch != '\n' && ch != '\r' && ch != EOF);
    12791357      }
     
    13261404         char *q;
    13271405         size_t len = 0;
    1328          int ch = getc(pimg->fh);
     1406         int ch = GETC(pimg->fh);
    13291407
    13301408         switch (ch) {
     
    13381416               while (1) {
    13391417                  do {
    1340                      ch = getc(pimg->fh);
     1418                     ch = GETC(pimg->fh);
    13411419                  } while (ch != '\n' && ch != '\r' && ch != EOF);
    1342                   while (ch == '\n' || ch == '\r') ch = getc(pimg->fh);
     1420                  while (ch == '\n' || ch == '\r') ch = GETC(pimg->fh);
    13431421                  if (ch == 'N') break;
    13441422                  if (ch == '\x1a' || ch == EOF) return img_STOP;
     
    13771455                     fpos = ftell(pimg->fh) - 1;
    13781456                     fseek(pimg->fh, pimg->start, SEEK_SET);
    1379                      ch = getc(pimg->fh);
     1457                     ch = GETC(pimg->fh);
    13801458                     pimg->pending = 0;
    13811459                  } else {
     
    15891667   n = pimg->label_len - len;
    15901668   if (len == 0) {
    1591       if (pimg->label_len) putc(0, pimg->fh);
     1669      if (pimg->label_len) PUTC(0, pimg->fh);
    15921670   } else if (n <= 16) {
    1593       if (n) putc(n + 15, pimg->fh);
     1671      if (n) PUTC(n + 15, pimg->fh);
    15941672   } else if (dot == 0) {
    1595       if (pimg->label_len) putc(0, pimg->fh);
     1673      if (pimg->label_len) PUTC(0, pimg->fh);
    15961674      len = 0;
    15971675   } else {
     
    16021680      }
    16031681      if (n <= 14) {
    1604          putc(n, pimg->fh);
     1682         PUTC(n, pimg->fh);
    16051683         len = dot;
    16061684      } else {
    1607          if (pimg->label_len) putc(0, pimg->fh);
     1685         if (pimg->label_len) PUTC(0, pimg->fh);
    16081686         len = 0;
    16091687      }
     
    16111689
    16121690   n = strlen(s + len);
    1613    putc(opt, pimg->fh);
     1691   PUTC(opt, pimg->fh);
    16141692   if (n < 0xfe) {
    1615       putc(n, pimg->fh);
     1693      PUTC(n, pimg->fh);
    16161694   } else if (n < 0xffff + 0xfe) {
    1617       putc(0xfe, pimg->fh);
     1695      PUTC(0xfe, pimg->fh);
    16181696      put16((short)(n - 0xfe), pimg->fh);
    16191697   } else {
    1620       putc(0xff, pimg->fh);
     1698      PUTC(0xff, pimg->fh);
    16211699      put32(n, pimg->fh);
    16221700   }
     
    16351713img_write_item_date(img *pimg)
    16361714{
    1637     if (pimg->date1 != pimg->olddate1 ||
    1638             pimg->date2 != pimg->olddate2) {
    1639         /* Only write dates when they've changed. */
    1640         if (pimg->date1 == pimg->date2) {
    1641             putc(0x20, pimg->fh);
     1715    int same, unset;
     1716    /* Only write dates when they've changed. */
     1717#if IMG_API_VERSION == 0
     1718    if (pimg->date1 == pimg->olddate1 && pimg->date2 == pimg->olddate2)
     1719        return;
     1720
     1721    same = (pimg->date1 == pimg->date2);
     1722    unset = (pimg->date1 == 0);
     1723#else /* IMG_API_VERSION == 1 */
     1724    if (pimg->days1 == pimg->olddays1 && pimg->days2 == pimg->olddays2)
     1725        return;
     1726
     1727    same = (pimg->days1 == pimg->days2);
     1728    unset = (pimg->days1 == -1);
     1729#endif
     1730
     1731    if (same) {
     1732        if (img_output_version < 7) {
     1733            PUTC(0x20, pimg->fh);
     1734#if IMG_API_VERSION == 0
    16421735            put32(pimg->date1, pimg->fh);
     1736#else /* IMG_API_VERSION == 1 */
     1737            put32((pimg->days1 - 25567) * 86400, pimg->fh);
     1738#endif
    16431739        } else {
    1644             putc(0x21, pimg->fh);
     1740            if (unset) {
     1741                PUTC(0x24, pimg->fh);
     1742            } else {
     1743                PUTC(0x20, pimg->fh);
     1744#if IMG_API_VERSION == 0
     1745                put16(pimg->date1 / 86400 + 25567, pimg->fh);
     1746#else /* IMG_API_VERSION == 1 */
     1747                put16(pimg->days1, pimg->fh);
     1748#endif
     1749            }
     1750        }
     1751    } else {
     1752        if (img_output_version < 7) {
     1753            PUTC(0x21, pimg->fh);
     1754#if IMG_API_VERSION == 0
    16451755            put32(pimg->date1, pimg->fh);
    16461756            put32(pimg->date2, pimg->fh);
     1757#else /* IMG_API_VERSION == 1 */
     1758            put32((pimg->days1 - 25567) * 86400, pimg->fh);
     1759            put32((pimg->days2 - 25567) * 86400, pimg->fh);
     1760#endif
     1761        } else {
     1762#if IMG_API_VERSION == 0
     1763            int diff = (pimg->date2 - pimg->date1) / 86400;
     1764            if (diff > 0 && diff <= 256) {
     1765                PUTC(0x21, pimg->fh);
     1766                put16(pimg->date1 / 86400 + 25567, pimg->fh);
     1767                PUTC(diff - 1, pimg->fh);
     1768            } else {
     1769                PUTC(0x23, pimg->fh);
     1770                put16(pimg->date1 / 86400 + 25567, pimg->fh);
     1771                put16(pimg->date2 / 86400 + 25567, pimg->fh);
     1772            }
     1773#else /* IMG_API_VERSION == 1 */
     1774            int diff = pimg->days2 - pimg->days1;
     1775            if (diff > 0 && diff <= 256) {
     1776                PUTC(0x21, pimg->fh);
     1777                put16(pimg->days1, pimg->fh);
     1778                PUTC(diff - 1, pimg->fh);
     1779            } else {
     1780                PUTC(0x23, pimg->fh);
     1781                put16(pimg->days1, pimg->fh);
     1782                put16(pimg->days2, pimg->fh);
     1783            }
     1784#endif
    16471785        }
    1648         pimg->olddate1 = pimg->date1;
    1649         pimg->olddate2 = pimg->date2;
    16501786    }
     1787#if IMG_API_VERSION == 0
     1788    pimg->olddate1 = pimg->date1;
     1789    pimg->olddate2 = pimg->date2;
     1790#else /* IMG_API_VERSION == 1 */
     1791    pimg->olddays1 = pimg->days1;
     1792    pimg->olddays2 = pimg->days2;
     1793#endif
    16511794}
    16521795
     
    17071850         return;
    17081851      }
    1709       if (opt) putc(opt, pimg->fh);
     1852      if (opt) PUTC(opt, pimg->fh);
    17101853      /* Output in cm */
    17111854      put32((INT32_T)my_round(x * 100.0), pimg->fh);
     
    17301873             * 3d files will need these, so better not to force incompatibility
    17311874             * with a new version I think... */
    1732             putc(7, pimg->fh);
    1733             putc(flags, pimg->fh);
     1875            PUTC(7, pimg->fh);
     1876            PUTC(flags, pimg->fh);
    17341877            put32(len, pimg->fh);
    17351878            fputs(s, pimg->fh);
    17361879         } else {
    1737             putc(0x40 | (flags & 0x3f), pimg->fh);
     1880            PUTC(0x40 | (flags & 0x3f), pimg->fh);
    17381881            fputsnl(s, pimg->fh);
    17391882         }
     
    17561899         put32(opt, pimg->fh);
    17571900      } else {
    1758          if (opt) putc(opt, pimg->fh);
     1901         if (opt) PUTC(opt, pimg->fh);
    17591902      }
    17601903      /* Output in cm */
     
    17761919                 double E, double H, double V)
    17771920{
    1778     putc(0x22, pimg->fh);
     1921    PUTC(0x22, pimg->fh);
    17791922    put32(n_legs, pimg->fh);
    17801923    put32((INT32_T)my_round(length * 100.0), pimg->fh);
     
    18011944               break;
    18021945             case 2:
    1803                putc(0, pimg->fh);
     1946               PUTC(0, pimg->fh);
    18041947               break;
    18051948             default:
    1806                if (pimg->label_len) putc(0, pimg->fh);
    1807                putc(0, pimg->fh);
     1949               if (pimg->label_len) PUTC(0, pimg->fh);
     1950               PUTC(0, pimg->fh);
    18081951               break;
    18091952            }
  • src/img.h

    rb8bf5bc r7cb7f91  
    11/* img.h
    22 * Header file for routines to read and write Survex ".3d" image files
    3  * Copyright (C) Olly Betts 1993,1994,1997,2001,2002,2003,2004,2005,2006
     3 * Copyright (C) Olly Betts 1993,1994,1997,2001,2002,2003,2004,2005,2006,2010,2011
    44 *
    55 * This program is free software; you can redistribute it and/or modify
     
    2020#ifndef IMG_H
    2121# define IMG_H
     22
     23/* Define IMG_API_VERSION if you want more recent versions of the img API.
     24 *
     25 * 0 (default)  The old API.  date1 and date2 give the survey date as time_t.
     26 *              Set to 0 for "unknown".
     27 * 1            days1 and days2 give survey dates as days since 1st Jan 1900.
     28 *              Set to -1 for "unknown".
     29 */
     30#ifndef IMG_API_VERSION
     31# define IMG_API_VERSION 0
     32#elif IMG_API_VERSION > 1
     33# error IMG_API_VERSION > 1 too new
     34#endif
    2235
    2336#ifdef __cplusplus
     
    6982   char *datestamp;
    7083   char separator; /* character used to separate survey levels ('.' usually) */
     84#if IMG_API_VERSION == 0
    7185   time_t date1, date2;
     86#else /* IMG_API_VERSION == 1 */
     87   int days1, days2;
     88#endif
    7289   double l, r, u, d;
    7390   /* Error information - valid when IMG_ERROR is returned: */
     
    101118    *   5 => LRUD info
    102119    *   6 => error info
     120    *   7 => more compact dates with wider range
    103121    */
    104122   int version;
     
    107125   int pending; /* for old style text format files and survey filtering */
    108126   img_point mv;
     127#if IMG_API_VERSION == 0
    109128   time_t olddate1, olddate2;
     129#else /* IMG_API_VERSION == 1 */
     130   int olddays1, olddays2;
     131#endif
    110132} img;
    111133
    112134/* Which version of the file format to output (defaults to newest) */
    113135extern unsigned int img_output_version;
     136
     137/* Minimum supported value for img_output_version: */
     138#define IMG_VERSION_MIN 1
     139
     140/* Maximum supported value for img_output_version: */
     141#define IMG_VERSION_MAX 7
    114142
    115143/* Open a .3d file for reading
Note: See TracChangeset for help on using the changeset viewer.