File: ncio.h

package info (click to toggle)
vtk 5.0.4-1.1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 51,084 kB
  • ctags: 70,426
  • sloc: cpp: 524,166; ansic: 220,276; tcl: 43,377; python: 14,037; perl: 3,102; java: 1,436; yacc: 1,033; sh: 339; lex: 248; makefile: 197; asm: 154
file content (144 lines) | stat: -rw-r--r-- 3,445 bytes parent folder | download | duplicates (2)
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
/*
 *  Copyright 1996, University Corporation for Atmospheric Research
 *  See netcdf/COPYRIGHT file for copying and redistribution conditions.
 */
/* $Id: ncio.h,v 1.1 2005/07/15 21:56:39 andy Exp $ */

#ifndef _NCIO_H_
#define _NCIO_H_

#include <stddef.h>  /* size_t */
#include <sys/types.h>  /* off_t */
#include "netcdf.h"

typedef struct ncio ncio;  /* forward reference */

/*
 * A value which is an invalid off_t
 */
#define OFF_NONE  ((off_t)(-1))

/*
 * Flags used by the region layer,
 *  'rflags' argument to ncio.rel() and ncio.get().
 */
#define RGN_NOLOCK  0x1  /* Don't lock region.
         * Used when contention control handled
         * elsewhere.
         */
#define RGN_NOWAIT  0x2  /* return immediate if can't lock, else wait */

#define RGN_WRITE  0x4  /* we intend to modify, else read only */

#define RGN_MODIFIED  0x8  /* we did modify, else, discard */


/*
 * The next four typedefs define the signatures
 * of function pointers in struct ncio below.
 * They are not used outside of this file and ncio.h,
 * They just some casts in the ncio.c more readable.
 */
  /*
   * Indicate that you are done with the region which begins
   * at offset. Only reasonable flag value is RGN_MODIFIED.
   */
typedef int ncio_relfunc(ncio *const nciop,
     off_t offset, int rflags);

  /*
   * Request that the region (offset, extent)
   * be made available through *vpp.
   */
typedef int ncio_getfunc(ncio *const nciop,
      off_t offset, size_t extent,
      int rflags,
      void **const vpp);

  /*
   * Like memmove(), safely move possibly overlapping data.
   * Only reasonable flag value is RGN_NOLOCK.
   */
typedef int ncio_movefunc(ncio *const nciop, off_t to, off_t from,
      size_t nbytes, int rflags);

  /*
   * Write out any dirty buffers to disk and
   * ensure that next read will get data from disk.
   */
typedef int ncio_syncfunc(ncio *const nciop);

  /*
   * Don't call this. 
   * Internal function called at close to
   * free up anything hanging off pvt;
   */
typedef void ncio_freefunc(void *const pvt);

/* Get around cplusplus "const xxx in class ncio without constructor" error */
#if defined(__cplusplus)
#define NCIO_CONST
#else
#define NCIO_CONST const
#endif

/*
 * netcdf i/o abstraction
 */
struct ncio {
  /*
   * A copy of the ioflags argument passed in to ncio_open()
   * or ncio_create().
   */
  int ioflags;
#ifdef __PARAGON__
  int is_file_pfs;
#endif

  /*
   * The file descriptor of the netcdf file.
   * This gets handed to the user as the netcdf id.
   */
  NCIO_CONST int fd;

  /* member functions do the work */

  ncio_relfunc *NCIO_CONST rel;

  ncio_getfunc *NCIO_CONST get;

  ncio_movefunc *NCIO_CONST move;

  ncio_syncfunc *NCIO_CONST sync;

  ncio_freefunc *NCIO_CONST free; /* Implementation private */

  /*
   * A copy of the 'path' argument passed in to ncio_open()
   * or ncio_create(). Used by ncabort() to remove (unlink)
   * the file and by error messages.
   */
  const char *path;

  /* implementation private stuff */
  void *NCIO_CONST pvt;
};

#undef NCIO_CONST

extern int
ncio_create(const char *path, int ioflags,
  size_t initialsz,
  off_t igeto, size_t igetsz, size_t *sizehintp,
  ncio **nciopp, void **const igetvpp);

extern int
ncio_open(const char *path,
  int ioflags,
  off_t igeto, size_t igetsz, size_t *sizehintp,
  ncio **nciopp, void **const igetvpp);

extern int 
ncio_close(ncio *nciop, int doUnlink);

#endif /* _NCIO_H_ */