df.h 7.45 KB
Newer Older
xuebingbing's avatar
xuebingbing committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Copyright by The HDF Group.                                               *
 * Copyright by the Board of Trustees of the University of Illinois.         *
 * All rights reserved.                                                      *
 *                                                                           *
 * This file is part of HDF.  The full HDF copyright notice, including       *
 * terms governing use, modification, and redistribution, is contained in    *
 * the COPYING file, which can be found at the root of the source code       *
 * distribution tree, or in https://support.hdfgroup.org/ftp/HDF/releases/.  *
 * If you do not have access to either file, you may request a copy from     *
 * help@hdfgroup.org.                                                        *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

/* $Id$ */

/*-----------------------------------------------------------------------------
 * File:    df.h
 * Purpose: header file for HDF routines
 * Invokes: dfi.h
 * Contents:
 *  Structure definitions: DFddh, DFdd, DFdesc, DFdle, DF, DFdi, DFdata
 *  Procedure type definitions
 *  Global variables
 *  Tag definitions
 *  Error return codes
 *  Logical constants
 * Remarks: This file is included with user programs
 *          Since it includes stdio.h etc., do not include these after df.h
 *---------------------------------------------------------------------------*/

#ifndef DF_H    /* avoid re-inclusion */
#define DF_H

#include "H4api_adpt.h"

/* include DF (internal) header information */
#include "hdf.h"

/*-------------------------------------------------------------------------*/
/*                      Type declarations                                   */

typedef struct DFddh
  {                             /*format of data descriptor headers in file */
      int16       dds;          /* number of dds in header block */
      int32       next;         /* offset of next header block */
  }
DFddh;

typedef struct DFdd
  {                             /* format of data descriptors as in file */
      uint16      tag;          /* data tag */
      uint16      ref;          /* data reference number */
      int32       offset;       /* offset of data element in file */
      int32       length;       /* number of bytes */
  }
DFdd;

/* descriptor structure is same as dd structure.  ###Note: may be changed */
typedef DFdd DFdesc;

/* DLE is the internal structure which stores data descriptor information */
/* It is a linked list of DDs */
typedef struct DFdle
  {                             /* Data List element */
      struct DFdle *next;       /* link to next dle */
      DFddh       ddh;          /* To store headers */
      DFdd        dd[1];        /* dummy size */
  }
DFdle;

/* DF is the internal structure associated with each DF file */
/* It holds information associated with the file as a whole */
/* ### Note: there are hooks for having multiple DF files open at a time */
typedef struct DF
  {
      DFdle      *list;         /* Pointer to the DLE list */
      DFdle      *last_dle;     /* last_dle and last_dd are used in searches */
      /* to indicate element returned */
      /* by previous call to DFfind */
      DFdd       *up_dd;        /* DD of element being read/updated, */
      /* used by DFstart */
      uint16      last_tag;     /* Last tag searched for by DFfind */
      uint16      last_ref;     /* Last reference number searched for */
      intn        type;         /* 0= not in use, 1= normal, -1 = multiple */
      /* this is a hook for when */
      /* multiple files are open */
      intn        access;       /* permitted access types: */
      /* 0=none, 1=r, 2=w, 3=r/w */
      intn        changed;      /* True if anything in DDs modified */
      /* since last write */
      intn        last_dd;      /* see last_dle */
      intn        defdds;       /* default numer of DD's in each block */
      intn        up_access;    /* access permissions to element being */
      /* read/updated. Used by DFstart */
      /* File handle is a file pointer or file descriptor depending on whether */
      /* we use buffered or unbuffered I/O.  But, since this structure is a */
      /* fake, it doesn't matter whether I/O is buffered or not. */
      intn        file;         /* file descriptor */
  }
DF;

typedef struct DFdata
  {                             /* structure for returning status information */
      int32       version;      /* version number of program */
  }
DFdata;

/*--------------------------------------------------------------------------*/
/*                          Procedure types                                 */

#if defined c_plusplus || defined __cplusplus
extern      "C"
{
#endif                          /* c_plusplus || __cplusplus */

/* prototypes for dfstubs.c */
    HDFLIBAPI DF  *DFopen
                (char *name, int acc_mode, int ndds);

    HDFLIBAPI int  DFclose
                (DF * dfile);

    HDFLIBAPI int  DFdescriptors
                (DF * dfile, DFdesc ptr[], int begin, int num);

    HDFLIBAPI int  DFnumber
                (DF * dfile, uint16 tag);

    HDFLIBAPI int  DFsetfind
                (DF * dfile, uint16 tag, uint16 ref);

    HDFLIBAPI int  DFfind
                (DF * dfile, DFdesc * ptr);

    HDFLIBAPI int  DFaccess
                (DF * dfile, uint16 tag, uint16 ref, char *acc_mode);

    HDFLIBAPI int  DFstart
                (DF * dfile, uint16 tag, uint16 ref, char *acc_mode);

    HDFLIBAPI int32 DFread
                (DF * dfile, char *ptr, int32 len);

    HDFLIBAPI int32 DFseek
                (DF * dfile, int32 offset);

    HDFLIBAPI int32 DFwrite
                (DF * dfile, char *ptr, int32 len);

    HDFLIBAPI int  DFupdate
                (DF * dfile);

    HDFLIBAPI int  DFstat
                (DF * dfile, DFdata * dfinfo);

    HDFLIBAPI int32 DFgetelement
                (DF * dfile, uint16 tag, uint16 ref, char *ptr);

    HDFLIBAPI int32 DFputelement
                (DF * dfile, uint16 tag, uint16 ref, char *ptr, int32 len);

    HDFLIBAPI int  DFdup
                (DF * dfile, uint16 itag, uint16 iref, uint16 otag, uint16 oref);

    HDFLIBAPI int  DFdel
                (DF * dfile, uint16 tag, uint16 ref);

    HDFLIBAPI uint16 DFnewref
                (DF * dfile);

    HDFLIBAPI int  DFishdf
                (char *filename);

    HDFLIBAPI int  DFerrno
                (void);

    HDFLIBAPI int  DFIerr
                (DF * dfile);

    HDFLIBAPI int  DFImemcopy
                (char *from, char *to, int length);

    HDFLIBAPI void *DFIgetspace
                (uint32 qty);

    HDFLIBAPI void *DFIfreespace
                (void *ptr);

    HDFLIBAPI int  DFIc2fstr
                (char *str, int len);

    HDFLIBAPI char *DFIf2cstring
                (_fcd fdesc, intn len);

/* prototypes for dfconv.c */
    HDFLIBAPI int  DFconvert
                (uint8 *source, uint8 *dest, int ntype, int sourcetype, int desttype, int32 size);

#if defined c_plusplus || defined __cplusplus
}
#endif                          /* c_plusplus || __cplusplus */

/*--------------------------------------------------------------------------*/
/*                          Global Variables                                */

#ifndef DFMASTER
HDFLIBAPI
#endif                          /*DFMASTER */
int DFerror;            /* Error code for DF routines */

#define DFSETERR(error) (DFerror=(DFerror?DFerror:error))

#define DFTOFID(df) (int32)(df->list)

#endif /* DF_H */