1 /*
2  *	Copyright 1996, University Corporation for Atmospheric Research
3  *      See netcdf/COPYRIGHT file for copying and redistribution conditions.
4  */
5 #ifndef _NC_H_
6 #define _NC_H_
7 
8 #include "config.h"
9 #include "xxxnetcdf.h"
10 
11    /* There's an external ncid (ext_ncid) and an internal ncid
12     * (int_ncid). The ext_ncid is the ncid returned to the user. If
13     * the user has opened or created a netcdf-4 file, then the
14     * ext_ncid is the same as the int_ncid. If he has opened or
15     * created a netcdf-3 file ext_ncid (which the user sees) is
16     * different from the int_ncid, which is the ncid returned by the
17     * netcdf-3 layer, which insists on inventing its own ncids,
18     * regardless of what is already in use due to previously opened
19     * netcdf-4 files. The ext_ncid contains the ncid for the root
20     * group (i.e. group zero). */
21 
22 /* Common Shared Structure for all Dispatched Objects */
23 typedef struct NC {
24 	int ext_ncid;
25 	int int_ncid;
26 	struct NC_Dispatch* dispatch;
27 	void* dispatchdata; /*per-'file' data; points to e.g. NC3_INFO data*/
28 	char* path;
29 	int   mode; /* as provided to nc_open/nc_create */
30 #ifdef USE_REFCOUNT
31 	int   refcount; /* To enable multiple name-based opens */
32 #endif
33 } NC;
34 
35 /*
36  * Counted string for names and such
37  */
38 typedef struct {
39 	/* all xdr'd */
40 	size_t nchars;
41 	char *cp;
42 
43 } NC_string;
44 
45 /* Define functions that are used across multiple dispatchers */
46 
47 /* Begin defined in string.c */
48 extern void
49 free_NC_string(NC_string *ncstrp);
50 
51 extern int
52 NC_check_name(const char *name);
53 
54 extern NC_string *
55 new_NC_string(size_t slen, const char *str);
56 extern int
57 set_NC_string(NC_string *ncstrp, const char *str);
58 
59 /* End defined in string.c */
60 
61 extern int
62 NC_check_id(int ncid, NC **ncpp);
63 
64 /* Create a pseudo file descriptor that does not
65    overlap real file descriptors */
66 extern int nc__pseudofd(void);
67 
68 /* This function gets a current default create flag */
69 extern int nc_get_default_format(void);
70 
71 extern int add_to_NCList(NC*);
72 extern void del_from_NCList(NC*);/* does not free object */
73 extern NC* find_in_NCList(int ext_ncid);
74 extern NC* find_in_NCList_by_name(const char*);
75 extern void free_NCList(void);/* reclaim whole list */
76 extern int count_NCList(void); /* return # of entries in NClist */
77 extern int iterate_NCList(int i,NC**); /* Walk from 0 ...; ERANGE return => stop */
78 
79 /* Defined in nc.c */
80 extern void free_NC(NC*);
81 extern int new_NC(struct NC_Dispatch*, const char*, int, NC**);
82 
83 /* Defined in nc.c */
84 extern int ncdebug;
85 
86 #endif /* _NC_H_ */
87