From 78885c901b654794c00632b9fbbd5c5d02550d41 Mon Sep 17 00:00:00 2001 From: Russ Rew Date: Thu, 3 Jun 2010 17:01:41 +0000 Subject: [PATCH 01/18] creating branch for russ From 1033ba1e4eae0d10bb43bcb6ce3527faf6a795ff Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Thu, 17 Jun 2010 16:16:16 +0000 Subject: [PATCH 02/18] turned off too much error output from tst_h_vl2.c --- libsrc4/tst_h_vl2.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libsrc4/tst_h_vl2.c b/libsrc4/tst_h_vl2.c index bd1121986..b43d17537 100644 --- a/libsrc4/tst_h_vl2.c +++ b/libsrc4/tst_h_vl2.c @@ -91,10 +91,10 @@ main() { if (attid > 0) H5Aclose(attid); - if ((attid = H5Aopen_idx(grpid, (unsigned int)i)) < 0) ERR; - if (H5Aget_name(attid, NC_MAX_NAME + 1, obj_name) < 0) ERR; + if ((attid = H5Aopen_idx(grpid, (unsigned int)i)) < 0) ERR_RET; + if (H5Aget_name(attid, NC_MAX_NAME + 1, obj_name) < 0) ERR_RET; LOG((4, "reading attribute of _netCDF group, named %s", obj_name)); - if ((attid && H5Aclose(attid))) ERR; + if ((attid && H5Aclose(attid))) ERR_RET; } /* Open the HDF5 attribute. */ From 8c64a1e8feb786965bbca259628e84e15ff51d86 Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Thu, 17 Jun 2010 16:21:13 +0000 Subject: [PATCH 03/18] turned off more bad error output from tst_h_vl2.c. --- libsrc4/tst_h_vl2.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/libsrc4/tst_h_vl2.c b/libsrc4/tst_h_vl2.c index b43d17537..810531cea 100644 --- a/libsrc4/tst_h_vl2.c +++ b/libsrc4/tst_h_vl2.c @@ -43,13 +43,13 @@ main() for (i = 0; i < num_obj; i++) { if (H5Oget_info_by_idx(grpid, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, - i, &obj_info, H5P_DEFAULT) < 0) ERR; + i, &obj_info, H5P_DEFAULT) < 0) ERR_RET; obj_class = obj_info.type; if ((size = H5Lget_name_by_idx(grpid, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, i, - NULL, 0, H5P_DEFAULT)) < 0) ERR; - if (size > NC_MAX_NAME) ERR; + NULL, 0, H5P_DEFAULT)) < 0) ERR_RET; + if (size > NC_MAX_NAME) ERR_RET; if (H5Lget_name_by_idx(grpid, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, i, - obj_name, size+1, H5P_DEFAULT) < 0) ERR; + obj_name, size+1, H5P_DEFAULT) < 0) ERR_RET; /*printf("nc4_rec_read_metadata: encountered HDF5 object obj_class %d obj_name %s.\n", obj_class, obj_name);*/ /* Deal with groups and datasets. */ @@ -63,14 +63,14 @@ main() break; case H5O_TYPE_NAMED_DATATYPE: printf("type\n"); - if ((hdf_typeid = H5Topen2(grpid, obj_name, H5P_DEFAULT)) < 0) ERR; - if ((class = H5Tget_class(hdf_typeid)) < 0) ERR; + if ((hdf_typeid = H5Topen2(grpid, obj_name, H5P_DEFAULT)) < 0) ERR_RET; + if ((class = H5Tget_class(hdf_typeid)) < 0) ERR_RET; switch (class) { case H5T_VLEN: /* Find the base type of this vlen (i.e. what is this a * vlen of?) and its size. */ - if (!(base_hdf_typeid = H5Tget_super(hdf_typeid))) ERR; - if (!(type_size = H5Tget_size(base_hdf_typeid))) ERR; + if (!(base_hdf_typeid = H5Tget_super(hdf_typeid))) ERR_RET; + if (!(type_size = H5Tget_size(base_hdf_typeid))) ERR_RET; break; default: LOG((0, "unknown datatype class")); From fe8fb995a61d8479caa82f6626e09ef3d98b43a8 Mon Sep 17 00:00:00 2001 From: Russ Rew Date: Tue, 22 Jun 2010 05:02:17 +0000 Subject: [PATCH 04/18] deprecated _ubyte functions in C API and documented this in C User's Guide --- man4/netcdf-c.texi | 115 +++++++++++++++++++++++++++++---------------- netcdf.h | 91 ++++++++++++++++------------------- 2 files changed, 116 insertions(+), 90 deletions(-) diff --git a/man4/netcdf-c.texi b/man4/netcdf-c.texi index fe99e825d..0c3f78b83 100644 --- a/man4/netcdf-c.texi +++ b/man4/netcdf-c.texi @@ -202,6 +202,7 @@ Variables * nc_rename_var:: Rename a Variable * nc_copy_var:: * nc_var_par_access:: +* nc_var_ubyte:: Reading and Writing Character String Values @@ -6349,6 +6350,7 @@ See the example section for @ref{nc_inq_enum} for a full example. * nc_rename_var:: Rename a Variable * nc_copy_var:: * nc_var_par_access:: +* nc_var_ubyte:: Deprecated variable ``_ubyte'' functions @end menu @node Variable Introduction, Variable Types, Variables, Variables @@ -7913,7 +7915,6 @@ if (status != NC_NOERR) handle_error(status); @findex nc_put_var1_long @findex nc_put_var1_float @findex nc_put_var1_double -@findex nc_put_var1_ubyte @findex nc_put_var1_ushort @findex nc_put_var1_uint @findex nc_put_var1_longlong @@ -7953,8 +7954,6 @@ int nc_put_var1_float (int ncid, int varid, const size_t index[], const float *fp); int nc_put_var1_double(int ncid, int varid, const size_t index[], const double *dp); -int nc_put_var1_ubyte (int ncid, int varid, const size_t index[], - const unsigned char *up); int nc_put_var1_ushort(int ncid, int varid, const size_t index[], const unsigned short *sp); int nc_put_var1_uint (int ncid, int varid, const size_t index[], @@ -8072,7 +8071,6 @@ if (status != NC_NOERR) handle_error(status); @findex nc_put_var_long @findex nc_put_var_float @findex nc_put_var_double -@findex nc_put_var_ubyte @findex nc_put_var_ushort @findex nc_put_var_uint @findex nc_put_var_longlong @@ -8116,7 +8114,6 @@ int nc_put_var_int (int ncid, int varid, const int *ip); int nc_put_var_long (int ncid, int varid, const long *lp); int nc_put_var_float (int ncid, int varid, const float *fp); int nc_put_var_double(int ncid, int varid, const double *dp); -int nc_put_var_ubyte (int ncid, int varid, const unsigned char *op); int nc_put_var_ushort(int ncid, int varid, const unsigned short *op); int nc_put_var_uint (int ncid, int varid, const unsigned int *op); int nc_put_var_longlong (int ncid, int varid, const long long *op); @@ -8223,7 +8220,6 @@ if (status != NC_NOERR) handle_error(status); @findex nc_put_vara_long @findex nc_put_vara_float @findex nc_put_vara_double -@findex nc_put_vara_ubyte @findex nc_put_vara_ushort @findex nc_put_vara_uint @findex nc_put_vara_longlong @@ -8267,8 +8263,6 @@ int nc_put_vara_float (int ncid, int varid, const size_t start[], const size_t count[], const float *fp); int nc_put_vara_double(int ncid, int varid, const size_t start[], const size_t count[], const double *dp); -int nc_put_vara_ubyte (int ncid, int varid, const size_t *startp, - const size_t *countp, const unsigned char *op); int nc_put_vara_ushort(int ncid, int varid, const size_t *startp, const size_t *countp, const unsigned short *op); int nc_put_vara_uint (int ncid, int varid, const size_t *startp, @@ -8425,7 +8419,6 @@ if (status != NC_NOERR) handle_error(status); @findex nc_put_vars_long @findex nc_put_vars_float @findex nc_put_vars_double -@findex nc_put_vars_ubyte @findex nc_put_vars_ushort @findex nc_put_vars_uint @findex nc_put_vars_longlong @@ -8474,9 +8467,6 @@ int nc_put_vars_float (int ncid, int varid, const size_t start[], int nc_put_vars_double(int ncid, int varid, const size_t start[], const size_t count[], const ptrdiff_t stride[], const double *dp); -int nc_put_vars_ubyte (int ncid, int varid, const size_t *startp, - const size_t *countp, const ptrdiff_t *stridep, - const unsigned char *op); int nc_put_vars_ushort(int ncid, int varid, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, const unsigned short *op); @@ -8647,7 +8637,6 @@ if (status != NC_NOERR) handle_error(status); @findex nc_put_varm_long @findex nc_put_varm_float @findex nc_put_varm_double -@findex nc_put_varm_ubyte @findex nc_put_varm_ushort @findex nc_put_varm_uint @findex nc_put_varm_longlong @@ -8699,9 +8688,6 @@ int nc_put_varm_float (int ncid, int varid, const size_t start[], int nc_put_varm_double(int ncid, int varid, const size_t start[], const size_t count[], const ptrdiff_t stride[], const ptrdiff_t imap[], const double *dp); -int nc_put_varm_ubyte (int ncid, int varid, const size_t *startp, - const size_t *countp, const ptrdiff_t *stridep, - const ptrdiff_t * imapp, const unsigned char *op); int nc_put_varm_ushort(int ncid, int varid, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, const ptrdiff_t * imapp, const unsigned short *op); @@ -8934,7 +8920,6 @@ if (status != NC_NOERR) handle_error(status); @findex nc_get_var1_long @findex nc_get_var1_float @findex nc_get_var1_double -@findex nc_get_var1_ubyte @findex nc_get_var1_ushort @findex nc_get_var1_uint @findex nc_get_var1_longlong @@ -8975,8 +8960,6 @@ int nc_get_var1_float (int ncid, int varid, const size_t index[], float *fp); int nc_get_var1_double(int ncid, int varid, const size_t index[], double *dp); -int nc_get_var1_ubyte (int ncid, int varid, const size_t *indexp, - unsigned char *ip); int nc_get_var1_ushort(int ncid, int varid, const size_t *indexp, unsigned short *ip); int nc_get_var1_uint (int ncid, int varid, const size_t *indexp, @@ -9106,7 +9089,6 @@ if (status != NC_NOERR) handle_error(status); @findex nc_get_var_long @findex nc_get_var_float @findex nc_get_var_double -@findex nc_get_var_ubyte @findex nc_get_var_ushort @findex nc_get_var_uint @findex nc_get_var_longlong @@ -9145,7 +9127,6 @@ int nc_get_var_int (int ncid, int varid, int *ip); int nc_get_var_long (int ncid, int varid, long *lp); int nc_get_var_float (int ncid, int varid, float *fp); int nc_get_var_double(int ncid, int varid, double *dp); -int nc_get_var_ubyte (int ncid, int varid, unsigned char *ip); int nc_get_var_ushort(int ncid, int varid, unsigned short *ip); int nc_get_var_uint (int ncid, int varid, unsigned int *ip); int nc_get_var_longlong (int ncid, int varid, long long *ip); @@ -9264,7 +9245,6 @@ if (status != NC_NOERR) handle_error(status); @findex nc_get_vara_long @findex nc_get_vara_float @findex nc_get_vara_double -@findex nc_get_vara_ubyte @findex nc_get_vara_ushort @findex nc_get_vara_uint @findex nc_get_vara_longlong @@ -9304,8 +9284,6 @@ int nc_get_vara_float (int ncid, int varid, const size_t start[], const size_t count[], float *fp); int nc_get_vara_double(int ncid, int varid, const size_t start[], const size_t count[], double *dp); -int nc_get_vara_ubyte (int ncid, int varid, const size_t *startp, - const size_t *countp, unsigned char *ip); int nc_get_vara_ushort(int ncid, int varid, const size_t *startp, const size_t *countp, unsigned short *ip); int nc_get_vara_uint (int ncid, int varid, const size_t *startp, @@ -9444,7 +9422,6 @@ if (status != NC_NOERR) handle_error(status); @findex nc_get_vars_long @findex nc_get_vars_float @findex nc_get_vars_double -@findex nc_get_vars_ubyte @findex nc_get_vars_ushort @findex nc_get_vars_uint @findex nc_get_vars_longlong @@ -9493,9 +9470,6 @@ int nc_get_vars_float (int ncid, int varid, const size_t start[], int nc_get_vars_double(int ncid, int varid, const size_t start[], const size_t count[], const ptrdiff_t stride[], double *dp) -int nc_get_vars_ubyte (int ncid, int varid, const size_t *startp, - const size_t *countp, const ptrdiff_t *stridep, - unsigned char *ip); int nc_get_vars_ushort(int ncid, int varid, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, unsigned short *ip); @@ -9660,7 +9634,6 @@ if (status != NC_NOERR) handle_error(status); @findex nc_get_varm_long @findex nc_get_varm_float @findex nc_get_varm_double -@findex nc_get_varm_ubyte @findex nc_get_varm_ushort @findex nc_get_varm_uint @findex nc_get_varm_longlong @@ -9713,9 +9686,6 @@ int nc_get_varm_float (int ncid, int varid, const size_t start[], int nc_get_varm_double(int ncid, int varid, const size_t start[], const size_t count[], const ptrdiff_t stride[], const ptrdiff_t imap[], double *dp); -int nc_get_varm_ubyte (int ncid, int varid, const size_t *startp, - const size_t *countp, const ptrdiff_t *stridep, - const ptrdiff_t * imapp, unsigned char *ip); int nc_get_varm_ushort(int ncid, int varid, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, const ptrdiff_t * imapp, unsigned short *ip); @@ -10280,10 +10250,17 @@ This function will copy a variable from one file to another. It works even if the files are different formats, (i.e. classic vs. netCDF-4/HDF5.) -If you're copying into a netcdf-3 file, from a netcdf-4 file, you must -be copying a var of one of the six netcdf-3 types. Similarly for the +If you're copying into a netCDF-3 file, from a netCDF-4 file, you must +be copying a var of one of the six netCDF-3 types. Similarly for the attributes. +For large netCDF-3 files, this can be a very inefficient way to copy +data from one file to another, because adding a new variable to the +target file may require more space in the header and thus result in +moving data for other variables in the target file. This is not a problem +for netCDF-4 files, which support efficient addition of variables +without moving data for other variables. + @heading Usage @example @@ -10332,7 +10309,7 @@ One or more values out of range. @example @end example -@node nc_var_par_access, , nc_copy_var, Variables +@node nc_var_par_access, nc_var_ubyte, nc_copy_var, Variables @section Change between Collective and Independent Parallel Access: nc_var_par_access @findex nc_var_par_access @cindex nc_var_par_access, example @@ -10424,6 +10401,48 @@ Here is an example using nc_var_par_access: @end example +@node nc_var_ubyte, , nc_var_par_access, Variables +@section Deprecated ``_ubyte'' variable functions +@findex nc_put_var1_ubyte +@findex nc_put_var_ubyte +@findex nc_put_vara_ubyte +@findex nc_put_vars_ubyte +@findex nc_put_varm_ubyte +@findex nc_get_var1_ubyte +@findex nc_get_var_ubyte +@findex nc_get_vara_ubyte +@findex nc_get_vars_ubyte +@findex nc_get_varm_ubyte + +Note: the following functions are also defined but deprecated, as they +are identical in arguments and behavior to the corresponding functions +with ``uchar'' substituted for ``ubyte'' in the function name. + +@example +int nc_put_var1_ubyte (int ncid, int varid, const size_t index[], + const unsigned char *up); +int nc_put_var_ubyte (int ncid, int varid, const unsigned char *op); +int nc_put_vara_ubyte (int ncid, int varid, const size_t *startp, + const size_t *countp, const unsigned char *op); +int nc_put_vars_ubyte (int ncid, int varid, const size_t *startp, + const size_t *countp, const ptrdiff_t *stridep, + const unsigned char *op); +int nc_put_varm_ubyte (int ncid, int varid, const size_t *startp, + const size_t *countp, const ptrdiff_t *stridep, + const ptrdiff_t * imapp, const unsigned char *op); +int nc_get_var1_ubyte (int ncid, int varid, const size_t *indexp, + unsigned char *ip); +int nc_get_var_ubyte (int ncid, int varid, unsigned char *ip); +int nc_get_vara_ubyte (int ncid, int varid, const size_t *startp, + const size_t *countp, unsigned char *ip); +int nc_get_vars_ubyte (int ncid, int varid, const size_t *startp, + const size_t *countp, const ptrdiff_t *stridep, + unsigned char *ip); +int nc_get_varm_ubyte (int ncid, int varid, const size_t *startp, + const size_t *countp, const ptrdiff_t *stridep, + const ptrdiff_t * imapp, unsigned char *ip); +@end example + @node Attributes, Summary of C Interface, Variables, Top @chapter Attributes @@ -10435,6 +10454,7 @@ Here is an example using nc_var_par_access: * nc_copy_att:: * nc_rename_att:: * nc_del_att:: +* nc_att_ubyte:: Deprecated attribute ``_ubyte'' functions @end menu @node Attributes Introduction, nc_put_att_ type, Attributes, Attributes @@ -10534,8 +10554,6 @@ int nc_put_att_float (int ncid, int varid, const char *name, nc_type xtype, size_t len, const float *fp); int nc_put_att_double (int ncid, int varid, const char *name, nc_type xtype, size_t len, const double *dp); -int nc_put_att_ubyte (int ncid, int varid, const char *name, nc_type xtype, - size_t len, const unsigned char *op); int nc_put_att_ushort (int ncid, int varid, const char *name, nc_type xtype, size_t len, const unsigned short *op); int nc_put_att_uint (int ncid, int varid, const char *name, nc_type xtype, @@ -10840,7 +10858,6 @@ int nc_get_att_int (int ncid, int varid, const char *name, int *ip); int nc_get_att_long (int ncid, int varid, const char *name, long *lp); int nc_get_att_float (int ncid, int varid, const char *name, float *fp); int nc_get_att_double (int ncid, int varid, const char *name, double *dp); -int nc_get_att_ubyte (int ncid, int varid, const char *name, unsigned char *ip); int nc_get_att_ushort (int ncid, int varid, const char *name, unsigned short *ip); int nc_get_att_uint (int ncid, int varid, const char *name, unsigned int *ip); int nc_get_att_longlong (int ncid, int varid, const char *name, long long *ip); @@ -11139,7 +11156,7 @@ status = nc_rename_att(ncid, rh_id, "units", "Units"); if (status != NC_NOERR) handle_error(status); @end example -@node nc_del_att, , nc_rename_att, Attributes +@node nc_del_att, nc_att_ubyte, nc_rename_att, Attributes @section Delete an Attribute: nc_del_att @findex nc_del_att @cindex nc_del_att, example @@ -11211,6 +11228,21 @@ status = nc_enddef(ncid); /* leave define mode */ if (status != NC_NOERR) handle_error(status); @end example +@node nc_att_ubyte, , nc_del_att, Attributes +@findex nc_put_att_ubyte +@findex nc_get_att_ubyte + +Note: the following functions are also defined but deprecated, as they +are identical in arguments and behavior to the corresponding functions +with ``uchar'' substituted for ``ubyte'' in the function name. + +@example +int nc_put_att_ubyte (int ncid, int varid, const char *name, nc_type xtype, + size_t len, const unsigned char *op); +int nc_get_att_ubyte (int ncid, int varid, const char *name, unsigned char *ip); +@end example + + @node Summary of C Interface, NetCDF 3 Transition Guide, Attributes, Top @appendix Summary of C Interface @cindex API, C summary @@ -11882,7 +11914,10 @@ treat NC_BYTE as signed for the purposes of conversion to short, int, long, float, or double. (Of course, no conversion takes place when the internal type is signed char.) In the _uchar functions, we treat NC_BYTE as if it were unsigned. Thus, no NC_ERANGE error can occur -converting between NC_BYTE and unsigned char. +converting between NC_BYTE and unsigned char. The _uchar and _schar +functions will behave differently when writing data or attribute +values to a larger type, because the type conversion is from unsigned +or signed to the larger type, respectively. @section Error handling diff --git a/netcdf.h b/netcdf.h index 7c11b9b0a..abab1fd80 100644 --- a/netcdf.h +++ b/netcdf.h @@ -904,14 +904,6 @@ nc_put_att_double(int ncid, int varid, const char *name, nc_type xtype, EXTERNL int nc_get_att_double(int ncid, int varid, const char *name, double *ip); -EXTERNL int -nc_put_att_ubyte(int ncid, int varid, const char *name, nc_type xtype, - size_t len, const unsigned char *op); - -EXTERNL int -nc_get_att_ubyte(int ncid, int varid, const char *name, - unsigned char *ip); - EXTERNL int nc_put_att_ushort(int ncid, int varid, const char *name, nc_type xtype, size_t len, const unsigned short *op); @@ -1045,14 +1037,6 @@ nc_put_var1_double(int ncid, int varid, const size_t *indexp, const double *op); EXTERNL int nc_get_var1_double(int ncid, int varid, const size_t *indexp, double *ip); -EXTERNL int -nc_put_var1_ubyte(int ncid, int varid, const size_t *indexp, - const unsigned char *op); - -EXTERNL int -nc_get_var1_ubyte(int ncid, int varid, const size_t *indexp, - unsigned char *ip); - EXTERNL int nc_put_var1_ushort(int ncid, int varid, const size_t *indexp, const unsigned short *op); @@ -1160,14 +1144,6 @@ EXTERNL int nc_get_vara_double(int ncid, int varid, const size_t *startp, const size_t *countp, double *ip); -EXTERNL int -nc_put_vara_ubyte(int ncid, int varid, const size_t *startp, - const size_t *countp, const unsigned char *op); - -EXTERNL int -nc_get_vara_ubyte(int ncid, int varid, const size_t *startp, - const size_t *countp, unsigned char *ip); - EXTERNL int nc_put_vara_ushort(int ncid, int varid, const size_t *startp, const size_t *countp, const unsigned short *op); @@ -1291,16 +1267,6 @@ nc_get_vars_double(int ncid, int varid, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, double *ip); -EXTERNL int -nc_put_vars_ubyte(int ncid, int varid, const size_t *startp, - const size_t *countp, const ptrdiff_t *stridep, - const unsigned char *op); - -EXTERNL int -nc_get_vars_ubyte(int ncid, int varid, const size_t *startp, - const size_t *countp, const ptrdiff_t *stridep, - unsigned char *ip); - EXTERNL int nc_put_vars_ushort(int ncid, int varid, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, @@ -1434,16 +1400,6 @@ nc_get_varm_double(int ncid, int varid, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, const ptrdiff_t * imapp, double *ip); -EXTERNL int -nc_put_varm_ubyte(int ncid, int varid, const size_t *startp, - const size_t *countp, const ptrdiff_t *stridep, - const ptrdiff_t * imapp, const unsigned char *op); - -EXTERNL int -nc_get_varm_ubyte(int ncid, int varid, const size_t *startp, - const size_t *countp, const ptrdiff_t *stridep, - const ptrdiff_t * imapp, unsigned char *ip); - EXTERNL int nc_put_varm_ushort(int ncid, int varid, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, @@ -1545,12 +1501,6 @@ nc_put_var_double(int ncid, int varid, const double *op); EXTERNL int nc_get_var_double(int ncid, int varid, double *ip); -EXTERNL int -nc_put_var_ubyte(int ncid, int varid, const unsigned char *op); - -EXTERNL int -nc_get_var_ubyte(int ncid, int varid, unsigned char *ip); - EXTERNL int nc_put_var_ushort(int ncid, int varid, const unsigned short *op); @@ -1581,6 +1531,47 @@ nc_put_var_string(int ncid, int varid, const char **op); EXTERNL int nc_get_var_string(int ncid, int varid, char **ip); +/* Begin Deprecated, same as functions with "_ubyte" replaced by "_uchar" */ +EXTERNL int +nc_put_att_ubyte(int ncid, int varid, const char *name, nc_type xtype, + size_t len, const unsigned char *op); +EXTERNL int +nc_get_att_ubyte(int ncid, int varid, const char *name, + unsigned char *ip); +EXTERNL int +nc_put_var1_ubyte(int ncid, int varid, const size_t *indexp, + const unsigned char *op); +EXTERNL int +nc_get_var1_ubyte(int ncid, int varid, const size_t *indexp, + unsigned char *ip); +EXTERNL int +nc_put_vara_ubyte(int ncid, int varid, const size_t *startp, + const size_t *countp, const unsigned char *op); +EXTERNL int +nc_get_vara_ubyte(int ncid, int varid, const size_t *startp, + const size_t *countp, unsigned char *ip); +EXTERNL int +nc_put_vars_ubyte(int ncid, int varid, const size_t *startp, + const size_t *countp, const ptrdiff_t *stridep, + const unsigned char *op); +EXTERNL int +nc_get_vars_ubyte(int ncid, int varid, const size_t *startp, + const size_t *countp, const ptrdiff_t *stridep, + unsigned char *ip); +EXTERNL int +nc_put_varm_ubyte(int ncid, int varid, const size_t *startp, + const size_t *countp, const ptrdiff_t *stridep, + const ptrdiff_t * imapp, const unsigned char *op); +EXTERNL int +nc_get_varm_ubyte(int ncid, int varid, const size_t *startp, + const size_t *countp, const ptrdiff_t *stridep, + const ptrdiff_t * imapp, unsigned char *ip); +EXTERNL int +nc_put_var_ubyte(int ncid, int varid, const unsigned char *op); +EXTERNL int +nc_get_var_ubyte(int ncid, int varid, unsigned char *ip); +/* End Deprecated */ + #ifdef LOGGING /* Set the log level. 0 shows only errors, 1 only major messages, From e5512f4e560077d78b032cb9fb5a31076b873624 Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Tue, 22 Jun 2010 10:18:15 +0000 Subject: [PATCH 05/18] removed v2 test in nc_test4 when --enable-c-only is used --- libsrc4/nc4internal.h | 2 +- libsrc4/nc4var.c | 6 ++++-- nc_test4/Makefile.am | 8 ++++---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/libsrc4/nc4internal.h b/libsrc4/nc4internal.h index e96b86d6c..9aca3a031 100644 --- a/libsrc4/nc4internal.h +++ b/libsrc4/nc4internal.h @@ -108,7 +108,7 @@ typedef struct NC_DIM_INFO int dirty; unsigned char coord_var_in_grp; struct NC_VAR_INFO *coord_var; /* The coord var, if it exists. */ - int too_long; /* True is len it too big to fit in local size_t. */ + int too_long; /* True if len it too big to fit in local size_t. */ } NC_DIM_INFO_T; typedef struct diff --git a/libsrc4/nc4var.c b/libsrc4/nc4var.c index cec0383af..ce8e75e8a 100644 --- a/libsrc4/nc4var.c +++ b/libsrc4/nc4var.c @@ -78,7 +78,8 @@ nc4_reopen_dataset(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var) /* Set chunk cache size for a variable. */ int -NC4_set_var_chunk_cache(int ncid, int varid, size_t size, size_t nelems, float preemption) +NC4_set_var_chunk_cache(int ncid, int varid, size_t size, size_t nelems, + float preemption) { NC_FILE_INFO_T *nc; NC_GRP_INFO_T *grp; @@ -144,7 +145,8 @@ nc_set_var_chunk_cache_ints(int ncid, int varid, int size, int nelems, /* Get chunk cache size for a variable. */ int -NC4_get_var_chunk_cache(int ncid, int varid, size_t *sizep, size_t *nelemsp, float *preemptionp) +NC4_get_var_chunk_cache(int ncid, int varid, size_t *sizep, + size_t *nelemsp, float *preemptionp) { NC_FILE_INFO_T *nc; NC_GRP_INFO_T *grp; diff --git a/nc_test4/Makefile.am b/nc_test4/Makefile.am index 16abb60fc..b55db6511 100644 --- a/nc_test4/Makefile.am +++ b/nc_test4/Makefile.am @@ -15,15 +15,15 @@ AM_CPPFLAGS += -I$(top_srcdir)/libsrc4 -I$(top_srcdir)/libsrc # Our test programs and sources... NC4_TEST_PROGS = t_type cdm_sea_soundings tst_camrun tst_vl tst_atts \ -tst_atts2 tst_vars2 tst_v2 +tst_atts2 tst_vars2 cdm_sea_soundings_SOURCES = cdm_sea_soundings.c tests.h tst_camrun_SOURCES = tst_camrun.c tests.h check_PROGRAMS = $(NC4_TEST_PROGS) TESTS = $(NC4_TEST_PROGS) -#if BUILD_V2 -#TESTS += tst_v2 -#endif # BUILD_V2 +if BUILD_V2 +TESTS += tst_v2 +endif # BUILD_V2 if LARGE_FILE_TESTS tst_large_SOURCES = tst_large.c tests.h From ad5bb5a1b4603f344737aace8aed5bc611862d26 Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Tue, 22 Jun 2010 15:04:06 +0000 Subject: [PATCH 06/18] fixed tst_v2 in nc_test4/Makefile.am --- nc_test4/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/nc_test4/Makefile.am b/nc_test4/Makefile.am index b55db6511..5872b48d1 100644 --- a/nc_test4/Makefile.am +++ b/nc_test4/Makefile.am @@ -22,6 +22,7 @@ check_PROGRAMS = $(NC4_TEST_PROGS) TESTS = $(NC4_TEST_PROGS) if BUILD_V2 +check_PROGRAMS += tst_v2 TESTS += tst_v2 endif # BUILD_V2 From 8a013d4f51dd183027d30a8ff624afce8bcd6949 Mon Sep 17 00:00:00 2001 From: Russ Rew Date: Tue, 22 Jun 2010 22:41:04 +0000 Subject: [PATCH 07/18] Changed calls in tests from deprecated _ubyte functions to equivalent _uchar functions. --- configure.ac | 2 +- libdispatch/copy.c | 4 +- libncdap3/cetab.c | 370 ++++++++++++++++++++++++++---------------- libncdap3/cetab.h | 34 ++-- libncdap4/t_dap.c | 2 +- libsrc4/tst_vars.c | 4 +- nc_test4/tst_types.c | 14 +- ncdap_test/test_cvt.c | 2 +- ncgen/genbin.c | 2 +- ncgen/ncgentab.c | 268 +++++++++++++++--------------- 10 files changed, 394 insertions(+), 308 deletions(-) diff --git a/configure.ac b/configure.ac index 0dc8e59b7..868a435ab 100644 --- a/configure.ac +++ b/configure.ac @@ -261,7 +261,7 @@ AC_MSG_CHECKING([whether a default chunk size in bytes was specified]) AC_ARG_WITH([default-chunk-size], [AS_HELP_STRING([--with-default-chunk-size=], [Specify default size of chunks in bytes.])], - [DEFAULTT_CHUNK_SIZE=$with_default_chunk_size], [DEFAULT_CHUNK_SIZE=4194304]) + [DEFAULT_CHUNK_SIZE=$with_default_chunk_size], [DEFAULT_CHUNK_SIZE=4194304]) AC_MSG_RESULT([$DEFAULT_CHUNK_SIZE]) AC_DEFINE_UNQUOTED([DEFAULT_CHUNK_SIZE], [$DEFAULT_CHUNK_SIZE], [default chunk size in bytes]) diff --git a/libdispatch/copy.c b/libdispatch/copy.c index 44eb9e185..fa0240c4e 100644 --- a/libdispatch/copy.c +++ b/libdispatch/copy.c @@ -351,10 +351,10 @@ nc_copy_var(int ncid_in, int varid_in, int ncid_out) (double *)data); break; case NC_UBYTE: - retval = nc_get_vara_ubyte(ncid_in, varid_in, start, count, + retval = nc_get_vara_uchar(ncid_in, varid_in, start, count, (unsigned char *)data); if (!retval) - retval = nc_put_vara_ubyte(ncid_out, varid_out, start, count, + retval = nc_put_vara_uchar(ncid_out, varid_out, start, count, (unsigned char *)data); break; case NC_USHORT: diff --git a/libncdap3/cetab.c b/libncdap3/cetab.c index b8d883bbf..0b8eeca90 100644 --- a/libncdap3/cetab.c +++ b/libncdap3/cetab.c @@ -1,24 +1,23 @@ -/* A Bison parser, made by GNU Bison 2.3. */ + +/* A Bison parser, made by GNU Bison 2.4.1. */ /* Skeleton implementation for Bison's Yacc-like parsers in C - - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify + + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ + along with this program. If not, see . */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work @@ -29,7 +28,7 @@ special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. - + This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ @@ -47,7 +46,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.3" +#define YYBISON_VERSION "2.4.1" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -55,42 +54,34 @@ /* Pure parsers. */ #define YYPURE 1 +/* Push parsers. */ +#define YYPUSH 0 + +/* Pull parsers. */ +#define YYPULL 1 + /* Using locations. */ #define YYLSP_NEEDED 0 /* Substitute the variable and function names. */ -#define yyparse ceparse -#define yylex celex -#define yyerror ceerror -#define yylval celval -#define yychar cechar -#define yydebug cedebug -#define yynerrs cenerrs - - -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - SCAN_WORD = 258, - SCAN_STRINGCONST = 259, - SCAN_NUMBERCONST = 260 - }; -#endif -/* Tokens. */ -#define SCAN_WORD 258 -#define SCAN_STRINGCONST 259 -#define SCAN_NUMBERCONST 260 - - +#define yyparse ceparse +#define yylex celex +#define yyerror ceerror +#define yylval celval +#define yychar cechar +#define yydebug cedebug +#define yynerrs cenerrs /* Copy the first part of user declarations. */ + +/* Line 189 of yacc.c */ #line 11 "../oc/ce.y" #include "ceparselex.h" +/* Line 189 of yacc.c */ +#line 84 "ce.tab.c" + /* Enabling traces. */ #ifndef YYDEBUG # define YYDEBUG 1 @@ -109,20 +100,34 @@ # define YYTOKEN_TABLE 0 #endif -#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED -typedef int YYSTYPE; -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + SCAN_WORD = 258, + SCAN_STRINGCONST = 259, + SCAN_NUMBERCONST = 260 + }; #endif +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef int YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +#endif + + /* Copy the second part of user declarations. */ -/* Line 216 of yacc.c. */ -#line 126 "ce.tab.c" +/* Line 264 of yacc.c */ +#line 131 "ce.tab.c" #ifdef short # undef short @@ -197,14 +202,14 @@ typedef short int yytype_int16; #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static int -YYID (int i) +YYID (int yyi) #else static int -YYID (i) - int i; +YYID (yyi) + int yyi; #endif { - return i; + return yyi; } #endif @@ -285,9 +290,9 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ /* A type that is properly aligned for any stack member. */ union yyalloc { - yytype_int16 yyss; - YYSTYPE yyvs; - }; + yytype_int16 yyss_alloc; + YYSTYPE yyvs_alloc; +}; /* The size of the maximum gap between one aligned stack and the next. */ # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) @@ -321,12 +326,12 @@ union yyalloc elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ -# define YYSTACK_RELOCATE(Stack) \ +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ do \ { \ YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack, Stack, yysize); \ - Stack = &yyptr->Stack; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ @@ -759,17 +764,20 @@ yy_symbol_print (yyoutput, yytype, yyvaluep, parsestate) #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void -yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) #else static void -yy_stack_print (bottom, top) - yytype_int16 *bottom; - yytype_int16 *top; +yy_stack_print (yybottom, yytop) + yytype_int16 *yybottom; + yytype_int16 *yytop; #endif { YYFPRINTF (stderr, "Stack now"); - for (; bottom <= top; ++bottom) - YYFPRINTF (stderr, " %d", *bottom); + for (; yybottom <= yytop; yybottom++) + { + int yybot = *yybottom; + YYFPRINTF (stderr, " %d", yybot); + } YYFPRINTF (stderr, "\n"); } @@ -804,11 +812,11 @@ yy_reduce_print (yyvsp, yyrule, parsestate) /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { - fprintf (stderr, " $%d = ", yyi + 1); + YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], &(yyvsp[(yyi + 1) - (yynrhs)]) , parsestate); - fprintf (stderr, "\n"); + YYFPRINTF (stderr, "\n"); } } @@ -1090,10 +1098,8 @@ yydestruct (yymsg, yytype, yyvaluep, parsestate) break; } } - /* Prevent warnings from -Wmissing-prototypes. */ - #ifdef YYPARSE_PARAM #if defined __STDC__ || defined __cplusplus int yyparse (void *YYPARSE_PARAM); @@ -1112,10 +1118,9 @@ int yyparse (); - -/*----------. -| yyparse. | -`----------*/ +/*-------------------------. +| yyparse or yypush_parse. | +`-------------------------*/ #ifdef YYPARSE_PARAM #if (defined __STDC__ || defined __C99__FUNC__ \ @@ -1139,22 +1144,46 @@ yyparse (parsestate) #endif #endif { - /* The look-ahead symbol. */ +/* The lookahead symbol. */ int yychar; -/* The semantic value of the look-ahead symbol. */ +/* The semantic value of the lookahead symbol. */ YYSTYPE yylval; -/* Number of syntax errors so far. */ -int yynerrs; + /* Number of syntax errors so far. */ + int yynerrs; + + int yystate; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + + /* The stacks and their tools: + `yyss': related to states. + `yyvs': related to semantic values. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs; + YYSTYPE *yyvsp; + + YYSIZE_T yystacksize; - int yystate; int yyn; int yyresult; - /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; - /* Look-ahead token as an internal (translated) token number. */ - int yytoken = 0; + /* Lookahead token as an internal (translated) token number. */ + int yytoken; + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + #if YYERROR_VERBOSE /* Buffer for error messages, and its allocated size. */ char yymsgbuf[128]; @@ -1162,51 +1191,28 @@ int yynerrs; YYSIZE_T yymsg_alloc = sizeof yymsgbuf; #endif - /* Three stacks and their tools: - `yyss': related to states, - `yyvs': related to semantic values, - `yyls': related to locations. - - Refer to the stacks thru separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ - - /* The state stack. */ - yytype_int16 yyssa[YYINITDEPTH]; - yytype_int16 *yyss = yyssa; - yytype_int16 *yyssp; - - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs = yyvsa; - YYSTYPE *yyvsp; - - - #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) - YYSIZE_T yystacksize = YYINITDEPTH; - - /* The variables used to return semantic value and location from the - action routines. */ - YYSTYPE yyval; - - /* The number of symbols on the RHS of the reduced rule. Keep to zero when no symbol should be popped. */ int yylen = 0; + yytoken = 0; + yyss = yyssa; + yyvs = yyvsa; + yystacksize = YYINITDEPTH; + YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ + yychar = YYEMPTY; /* Cause a token to be read. */ /* Initialize stack pointers. Waste one element of value and location stack so that they stay on the same level as the state stack. The wasted elements are never initialized. */ - yyssp = yyss; yyvsp = yyvs; @@ -1236,7 +1242,6 @@ int yynerrs; YYSTYPE *yyvs1 = yyvs; yytype_int16 *yyss1 = yyss; - /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. This used to be a conditional around just the two extra args, but that might @@ -1244,7 +1249,6 @@ int yynerrs; yyoverflow (YY_("memory exhausted"), &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), - &yystacksize); yyss = yyss1; @@ -1267,9 +1271,8 @@ int yynerrs; (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) goto yyexhaustedlab; - YYSTACK_RELOCATE (yyss); - YYSTACK_RELOCATE (yyvs); - + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); # undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); @@ -1280,7 +1283,6 @@ int yynerrs; yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; - YYDPRINTF ((stderr, "Stack size increased to %lu\n", (unsigned long int) yystacksize)); @@ -1290,6 +1292,9 @@ int yynerrs; YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + if (yystate == YYFINAL) + YYACCEPT; + goto yybackup; /*-----------. @@ -1298,16 +1303,16 @@ int yynerrs; yybackup: /* Do appropriate processing given the current state. Read a - look-ahead token if we need one and don't already have one. */ + lookahead token if we need one and don't already have one. */ - /* First try to decide what to do without reference to look-ahead token. */ + /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; if (yyn == YYPACT_NINF) goto yydefault; - /* Not known => get a look-ahead token if don't already have one. */ + /* Not known => get a lookahead token if don't already have one. */ - /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); @@ -1339,20 +1344,16 @@ yybackup: goto yyreduce; } - if (yyn == YYFINAL) - YYACCEPT; - /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; - /* Shift the look-ahead token. */ + /* Shift the lookahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - /* Discard the shifted token unless it is eof. */ - if (yychar != YYEOF) - yychar = YYEMPTY; + /* Discard the shifted token. */ + yychar = YYEMPTY; yystate = yyn; *++yyvsp = yylval; @@ -1392,231 +1393,323 @@ yyreduce: switch (yyn) { case 2: + +/* Line 1455 of yacc.c */ #line 24 "../oc/ce.y" {projections(parsestate,(yyvsp[(1) - (1)]));;} break; case 3: + +/* Line 1455 of yacc.c */ #line 25 "../oc/ce.y" {selections(parsestate,(yyvsp[(1) - (1)]));;} break; case 4: + +/* Line 1455 of yacc.c */ #line 27 "../oc/ce.y" {projections(parsestate,(yyvsp[(1) - (2)])); selections(parsestate,(yyvsp[(2) - (2)]));;} break; case 5: + +/* Line 1455 of yacc.c */ #line 31 "../oc/ce.y" {(yyval)=(yyvsp[(1) - (1)]);;} break; case 6: + +/* Line 1455 of yacc.c */ #line 34 "../oc/ce.y" {(yyval)=(yyvsp[(1) - (1)]);;} break; case 7: + +/* Line 1455 of yacc.c */ #line 39 "../oc/ce.y" {(yyval)=projectionlist(parsestate,null,(yyvsp[(1) - (1)]));;} break; case 8: + +/* Line 1455 of yacc.c */ #line 41 "../oc/ce.y" {(yyval)=projectionlist(parsestate,(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]));;} break; case 9: + +/* Line 1455 of yacc.c */ #line 47 "../oc/ce.y" {(yyval)=projection(parsestate,(yyvsp[(1) - (1)]));;} break; case 10: + +/* Line 1455 of yacc.c */ #line 53 "../oc/ce.y" {(yyval)=segmentlist(parsestate,null,(yyvsp[(1) - (1)]));;} break; case 11: + +/* Line 1455 of yacc.c */ #line 55 "../oc/ce.y" {(yyval)=segmentlist(parsestate,(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]));;} break; case 12: + +/* Line 1455 of yacc.c */ #line 61 "../oc/ce.y" {(yyval)=segment(parsestate,(yyvsp[(1) - (1)]),null);;} break; case 13: + +/* Line 1455 of yacc.c */ #line 63 "../oc/ce.y" {(yyval)=segment(parsestate,(yyvsp[(1) - (2)]),(yyvsp[(2) - (2)]));;} break; case 14: + +/* Line 1455 of yacc.c */ #line 69 "../oc/ce.y" {(yyval)=array_indices(parsestate,null,(yyvsp[(1) - (1)]));;} break; case 15: + +/* Line 1455 of yacc.c */ #line 71 "../oc/ce.y" {(yyval)=array_indices(parsestate,(yyvsp[(1) - (2)]),(yyvsp[(2) - (2)]));;} break; case 16: + +/* Line 1455 of yacc.c */ #line 76 "../oc/ce.y" {(yyval)=(yyvsp[(1) - (1)]);;} break; case 17: + +/* Line 1455 of yacc.c */ #line 82 "../oc/ce.y" {(yyval)=range(parsestate,(yyvsp[(1) - (1)]),null,null);;} break; case 18: + +/* Line 1455 of yacc.c */ #line 84 "../oc/ce.y" {(yyval)=range(parsestate,(yyvsp[(2) - (5)]),null,(yyvsp[(4) - (5)]));;} break; case 19: + +/* Line 1455 of yacc.c */ #line 86 "../oc/ce.y" {(yyval)=range(parsestate,(yyvsp[(2) - (7)]),(yyvsp[(4) - (7)]),(yyvsp[(6) - (7)]));;} break; case 20: + +/* Line 1455 of yacc.c */ #line 89 "../oc/ce.y" {(yyval)=(yyvsp[(2) - (3)]);;} break; case 21: + +/* Line 1455 of yacc.c */ #line 94 "../oc/ce.y" {(yyval)=selectionlist(parsestate,null,(yyvsp[(2) - (2)]));;} break; case 22: + +/* Line 1455 of yacc.c */ #line 96 "../oc/ce.y" {(yyval)=selectionlist(parsestate,(yyvsp[(1) - (2)]),(yyvsp[(2) - (2)]));;} break; case 23: + +/* Line 1455 of yacc.c */ #line 102 "../oc/ce.y" {(yyval)=sel_clause(parsestate,1,(yyvsp[(1) - (5)]),(yyvsp[(2) - (5)]),(yyvsp[(4) - (5)]));;} break; case 24: + +/* Line 1455 of yacc.c */ #line 104 "../oc/ce.y" {(yyval)=sel_clause(parsestate,2,(yyvsp[(1) - (3)]),(yyvsp[(2) - (3)]),(yyvsp[(3) - (3)]));;} break; case 26: + +/* Line 1455 of yacc.c */ #line 111 "../oc/ce.y" {(yyval)=(yyvsp[(1) - (1)]);;} break; case 27: + +/* Line 1455 of yacc.c */ #line 116 "../oc/ce.y" {(yyvsp[(1) - (1)])=selectionpath(parsestate,null,(yyvsp[(1) - (1)]));;} break; case 28: + +/* Line 1455 of yacc.c */ #line 118 "../oc/ce.y" {(yyval)=selectionpath(parsestate,(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]));;} break; case 29: + +/* Line 1455 of yacc.c */ #line 123 "../oc/ce.y" {(yyval)=function(parsestate,(yyvsp[(1) - (3)]),null);;} break; case 30: + +/* Line 1455 of yacc.c */ #line 125 "../oc/ce.y" {(yyval)=function(parsestate,(yyvsp[(1) - (4)]),(yyvsp[(3) - (4)]));;} break; case 31: + +/* Line 1455 of yacc.c */ #line 130 "../oc/ce.y" {(yyval)=arg_list(parsestate,null,(yyvsp[(1) - (1)]));;} break; case 32: + +/* Line 1455 of yacc.c */ #line 132 "../oc/ce.y" {(yyval)=arg_list(parsestate,(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]));;} break; case 33: + +/* Line 1455 of yacc.c */ #line 137 "../oc/ce.y" {(yyval)=value_list(parsestate,null,(yyvsp[(1) - (1)]));;} break; case 34: + +/* Line 1455 of yacc.c */ #line 139 "../oc/ce.y" {(yyval)=value_list(parsestate,(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]));;} break; case 35: + +/* Line 1455 of yacc.c */ #line 144 "../oc/ce.y" {(yyval)=value(parsestate,(yyvsp[(1) - (1)]),SCAN_WORD);;} break; case 36: + +/* Line 1455 of yacc.c */ #line 146 "../oc/ce.y" {(yyval)=value(parsestate,(yyvsp[(1) - (1)]),SCAN_NUMBERCONST);;} break; case 37: + +/* Line 1455 of yacc.c */ #line 148 "../oc/ce.y" {(yyval)=value(parsestate,(yyvsp[(1) - (1)]),SCAN_STRINGCONST);;} break; case 38: + +/* Line 1455 of yacc.c */ #line 153 "../oc/ce.y" {(yyval)=(Object)ST_EQ;;} break; case 39: + +/* Line 1455 of yacc.c */ #line 154 "../oc/ce.y" {(yyval)=(Object)ST_GT;;} break; case 40: + +/* Line 1455 of yacc.c */ #line 155 "../oc/ce.y" {(yyval)=(Object)ST_LT;;} break; case 41: + +/* Line 1455 of yacc.c */ #line 156 "../oc/ce.y" {(yyval)=(Object)ST_NEQ;;} break; case 42: + +/* Line 1455 of yacc.c */ #line 157 "../oc/ce.y" {(yyval)=(Object)ST_RE;;} break; case 43: + +/* Line 1455 of yacc.c */ #line 158 "../oc/ce.y" {(yyval)=(Object)ST_GE;;} break; case 44: + +/* Line 1455 of yacc.c */ #line 159 "../oc/ce.y" {(yyval)=(Object)ST_LE;;} break; case 45: + +/* Line 1455 of yacc.c */ #line 165 "../oc/ce.y" {(yyval)=arrayelement(parsestate,(yyvsp[(1) - (1)]),null);;} break; case 46: + +/* Line 1455 of yacc.c */ #line 167 "../oc/ce.y" {(yyval)=arrayelement(parsestate,(yyvsp[(1) - (2)]),(yyvsp[(2) - (2)]));;} break; case 47: + +/* Line 1455 of yacc.c */ #line 171 "../oc/ce.y" {(yyval) = (yyvsp[(1) - (1)]);;} break; case 48: + +/* Line 1455 of yacc.c */ #line 175 "../oc/ce.y" { unsigned long tmp = 0; if(sscanf((char*)(yyvsp[(1) - (1)]),"%lu",&tmp) != 1) { @@ -1627,23 +1720,30 @@ yyreduce: break; case 49: + +/* Line 1455 of yacc.c */ #line 184 "../oc/ce.y" {(yyval) = (yyvsp[(1) - (1)]);;} break; case 50: + +/* Line 1455 of yacc.c */ #line 188 "../oc/ce.y" {(yyval) = (yyvsp[(1) - (1)]);;} break; case 51: + +/* Line 1455 of yacc.c */ #line 192 "../oc/ce.y" {(yyval) = (yyvsp[(1) - (1)]);;} break; -/* Line 1267 of yacc.c. */ -#line 1647 "ce.tab.c" + +/* Line 1455 of yacc.c */ +#line 1747 "ce.tab.c" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -1654,7 +1754,6 @@ yyreduce: *++yyvsp = yyval; - /* Now `shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ @@ -1719,7 +1818,7 @@ yyerrlab: if (yyerrstatus == 3) { - /* If just tried and failed to reuse look-ahead token after an + /* If just tried and failed to reuse lookahead token after an error, discard it. */ if (yychar <= YYEOF) @@ -1736,7 +1835,7 @@ yyerrlab: } } - /* Else will try to reuse look-ahead token after shifting the error + /* Else will try to reuse lookahead token after shifting the error token. */ goto yyerrlab1; @@ -1793,9 +1892,6 @@ yyerrlab1: YY_STACK_PRINT (yyss, yyssp); } - if (yyn == YYFINAL) - YYACCEPT; - *++yyvsp = yylval; @@ -1820,7 +1916,7 @@ yyabortlab: yyresult = 1; goto yyreturn; -#ifndef yyoverflow +#if !defined(yyoverflow) || YYERROR_VERBOSE /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ @@ -1831,7 +1927,7 @@ yyexhaustedlab: #endif yyreturn: - if (yychar != YYEOF && yychar != YYEMPTY) + if (yychar != YYEMPTY) yydestruct ("Cleanup: discarding lookahead", yytoken, &yylval, parsestate); /* Do not reclaim the symbols of the rule which action triggered @@ -1857,6 +1953,8 @@ yyreturn: } + +/* Line 1675 of yacc.c */ #line 195 "../oc/ce.y" diff --git a/libncdap3/cetab.h b/libncdap3/cetab.h index a065c2240..46737ca96 100644 --- a/libncdap3/cetab.h +++ b/libncdap3/cetab.h @@ -1,24 +1,23 @@ -/* A Bison parser, made by GNU Bison 2.3. */ + +/* A Bison parser, made by GNU Bison 2.4.1. */ /* Skeleton interface for Bison's Yacc-like parsers in C - - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify + + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ + along with this program. If not, see . */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work @@ -29,10 +28,11 @@ special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. - + This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ + /* Tokens. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE @@ -44,20 +44,16 @@ SCAN_NUMBERCONST = 260 }; #endif -/* Tokens. */ -#define SCAN_WORD 258 -#define SCAN_STRINGCONST 259 -#define SCAN_NUMBERCONST 260 - #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef int YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 #endif + diff --git a/libncdap4/t_dap.c b/libncdap4/t_dap.c index 7ba8bcf43..8b3b4306e 100644 --- a/libncdap4/t_dap.c +++ b/libncdap4/t_dap.c @@ -306,7 +306,7 @@ int main() #ifdef USE_NETCDF4 CHECK(nc_inq_varid(ncid, "b", &varid)); - CHECK(nc_get_var_ubyte(ncid,varid,uint8)); + CHECK(nc_get_var_uchar(ncid,varid,uint8)); #ifdef GENERATE printf("static %s ubyte_data[DIMSIZE]={","unsigned char"); for(i=0;iname,typid,len,data); + stat = nc_put_att_uchar(grpid,varid,asym->name,typid,len,data); check_err(stat,__LINE__,__FILE__); } break; case NC_USHORT: { diff --git a/ncgen/ncgentab.c b/ncgen/ncgentab.c index 84a6afba3..1c294a59a 100644 --- a/ncgen/ncgentab.c +++ b/ncgen/ncgentab.c @@ -1,9 +1,10 @@ -/* A Bison parser, made by GNU Bison 2.4.2. */ + +/* A Bison parser, made by GNU Bison 2.4.1. */ /* Skeleton implementation for Bison's Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2006, 2009-2010 Free Software - Foundation, Inc. + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -45,7 +46,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.4.2" +#define YYBISON_VERSION "2.4.1" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -78,7 +79,7 @@ #line 9 "ncgen.y" /* -static char SccsId[] = "$Id: ncgentab.c,v 1.53 2010/05/18 21:32:46 dmh Exp $"; +static char SccsId[] = "$Id: ncgen.y,v 1.42 2010/05/18 21:32:46 dmh Exp $"; */ #include "includes.h" #include "offsets.h" @@ -189,7 +190,7 @@ extern int lex_init(void); /* Line 189 of yacc.c */ -#line 193 "ncgen.tab.c" +#line 194 "ncgen.tab.c" /* Enabling traces. */ #ifndef YYDEBUG @@ -285,7 +286,7 @@ Constant constant; /* Line 214 of yacc.c */ -#line 289 "ncgen.tab.c" +#line 290 "ncgen.tab.c" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ @@ -297,7 +298,7 @@ Constant constant; /* Line 264 of yacc.c */ -#line 301 "ncgen.tab.c" +#line 302 "ncgen.tab.c" #ifdef short # undef short @@ -347,7 +348,7 @@ typedef short int yytype_int16; #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) #ifndef YY_ -# if defined YYENABLE_NLS && YYENABLE_NLS +# if YYENABLE_NLS # if ENABLE_NLS # include /* INFRINGES ON USER NAME SPACE */ # define YY_(msgid) dgettext ("bison-runtime", msgid) @@ -945,18 +946,9 @@ static const yytype_uint8 yystos[] = /* Like YYERROR except do call yyerror. This remains here temporarily to ease the transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. However, - YYFAIL appears to be in use. Nevertheless, it is formally deprecated - in Bison 2.4.2's NEWS entry, where a plan to phase it out is - discussed. */ + Once GCC version 2 has supplanted version 1, this can go. */ #define YYFAIL goto yyerrlab -#if defined YYFAIL - /* This is here to suppress warnings from the GCC cpp's - -Wunused-macros. Normally we don't worry about that warning, but - some users do, and we want to make it easy for users to remove - YYFAIL uses, which will produce warnings from Bison 2.5. */ -#endif #define YYRECOVERING() (!!yyerrstatus) @@ -1013,7 +1005,7 @@ while (YYID (0)) we won't break user code: when these are the locations we know. */ #ifndef YY_LOCATION_PRINT -# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +# if YYLTYPE_IS_TRIVIAL # define YY_LOCATION_PRINT(File, Loc) \ fprintf (File, "%d.%d-%d.%d", \ (Loc).first_line, (Loc).first_column, \ @@ -1752,14 +1744,14 @@ yyreduce: { case 2: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 201 "ncgen.y" {if (derror_count > 0) exit(6);;} break; case 7: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 221 "ncgen.y" { if(usingclassic) {verror("Group specification");} @@ -1771,28 +1763,28 @@ yyreduce: case 8: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 229 "ncgen.y" {listpop(groupstack);;} break; case 11: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 235 "ncgen.y" {;} break; case 12: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 236 "ncgen.y" {if(usingclassic)verror("Type specification");;} break; case 15: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 242 "ncgen.y" { /* Use when defining a type */ (yyvsp[(1) - (1)].sym)->objectclass = NC_TYPE; @@ -1805,21 +1797,21 @@ yyreduce: case 16: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 251 "ncgen.y" {;} break; case 17: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 251 "ncgen.y" {;} break; case 22: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 257 "ncgen.y" { int i; @@ -1851,14 +1843,14 @@ yyreduce: case 23: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 286 "ncgen.y" {(yyval.mark)=listlength(stack); listpush(stack,(elem_t)(yyvsp[(1) - (1)].sym));;} break; case 24: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 288 "ncgen.y" { int i; @@ -1878,7 +1870,7 @@ yyreduce: case 25: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 305 "ncgen.y" { (yyvsp[(1) - (3)].sym)->objectclass=NC_TYPE; @@ -1890,7 +1882,7 @@ yyreduce: case 26: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 314 "ncgen.y" { addtogroup((yyvsp[(5) - (5)].sym)); /*sets prefix*/ @@ -1904,7 +1896,7 @@ yyreduce: case 27: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 325 "ncgen.y" { Symbol* basetype = (yyvsp[(1) - (5)].sym); @@ -1920,7 +1912,7 @@ yyreduce: case 28: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 338 "ncgen.y" { int i,j; @@ -1954,21 +1946,21 @@ yyreduce: case 29: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 369 "ncgen.y" {(yyval.mark)=(yyvsp[(1) - (2)].mark);;} break; case 30: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 370 "ncgen.y" {(yyval.mark)=(yyvsp[(1) - (3)].mark);;} break; case 31: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 374 "ncgen.y" { int i; @@ -1985,112 +1977,112 @@ yyreduce: case 32: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 387 "ncgen.y" { (yyval.sym) = primsymbols[NC_CHAR]; ;} break; case 33: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 388 "ncgen.y" { (yyval.sym) = primsymbols[NC_BYTE]; ;} break; case 34: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 389 "ncgen.y" { (yyval.sym) = primsymbols[NC_SHORT]; ;} break; case 35: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 390 "ncgen.y" { (yyval.sym) = primsymbols[NC_INT]; ;} break; case 36: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 391 "ncgen.y" { (yyval.sym) = primsymbols[NC_FLOAT]; ;} break; case 37: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 392 "ncgen.y" { (yyval.sym) = primsymbols[NC_DOUBLE]; ;} break; case 38: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 393 "ncgen.y" { (yyval.sym) = primsymbols[NC_UBYTE]; ;} break; case 39: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 394 "ncgen.y" { (yyval.sym) = primsymbols[NC_USHORT]; ;} break; case 40: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 395 "ncgen.y" { (yyval.sym) = primsymbols[NC_UINT]; ;} break; case 41: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 396 "ncgen.y" { (yyval.sym) = primsymbols[NC_INT64]; ;} break; case 42: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 397 "ncgen.y" { (yyval.sym) = primsymbols[NC_UINT64]; ;} break; case 44: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 401 "ncgen.y" {;} break; case 45: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 402 "ncgen.y" {;} break; case 48: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 409 "ncgen.y" {;} break; case 49: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 409 "ncgen.y" {;} break; case 52: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 417 "ncgen.y" { (yyvsp[(1) - (3)].sym)->dim.declsize = (size_t)uint32_val; @@ -2099,7 +2091,7 @@ yyreduce: case 53: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 421 "ncgen.y" { if(int32_val <= 0) { @@ -2112,7 +2104,7 @@ yyreduce: case 54: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 429 "ncgen.y" { /* for rare case where 2^31 < dimsize < 2^32 */ if (double_val <= 0) @@ -2127,7 +2119,7 @@ yyreduce: case 55: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 439 "ncgen.y" { if(usingclassic) { @@ -2142,7 +2134,7 @@ yyreduce: case 56: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 451 "ncgen.y" { (yyvsp[(1) - (1)].sym)->objectclass=NC_DIM; @@ -2157,35 +2149,35 @@ yyreduce: case 58: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 463 "ncgen.y" {;} break; case 59: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 464 "ncgen.y" {;} break; case 62: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 471 "ncgen.y" {;} break; case 63: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 471 "ncgen.y" {;} break; case 64: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 474 "ncgen.y" { int i; @@ -2210,7 +2202,7 @@ yyreduce: case 65: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 496 "ncgen.y" {(yyval.mark)=listlength(stack); listpush(stack,(elem_t)(yyvsp[(1) - (1)].sym)); @@ -2219,14 +2211,14 @@ yyreduce: case 66: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 500 "ncgen.y" {(yyval.mark)=(yyvsp[(1) - (3)].mark); listpush(stack,(elem_t)(yyvsp[(3) - (3)].sym));;} break; case 67: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 504 "ncgen.y" { int i; @@ -2256,35 +2248,35 @@ yyreduce: case 68: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 530 "ncgen.y" {(yyval.mark)=listlength(stack);;} break; case 69: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 531 "ncgen.y" {(yyval.mark)=(yyvsp[(2) - (3)].mark);;} break; case 70: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 534 "ncgen.y" {(yyval.mark)=listlength(stack); listpush(stack,(elem_t)(yyvsp[(1) - (1)].sym));;} break; case 71: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 536 "ncgen.y" {(yyval.mark)=(yyvsp[(1) - (3)].mark); listpush(stack,(elem_t)(yyvsp[(3) - (3)].sym));;} break; case 72: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 540 "ncgen.y" {Symbol* dimsym = (yyvsp[(1) - (1)].sym); dimsym->objectclass = NC_DIM; @@ -2300,7 +2292,7 @@ yyreduce: case 73: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 554 "ncgen.y" {(yyval.mark)=listlength(stack); listpush(stack,(elem_t)(yyvsp[(1) - (1)].sym)); @@ -2309,14 +2301,14 @@ yyreduce: case 74: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 558 "ncgen.y" {(yyval.mark)=(yyvsp[(1) - (3)].mark); listpush(stack,(elem_t)(yyvsp[(3) - (3)].sym));;} break; case 75: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 563 "ncgen.y" { int i; @@ -2348,35 +2340,35 @@ yyreduce: case 76: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 591 "ncgen.y" {(yyval.mark)=listlength(stack);;} break; case 77: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 592 "ncgen.y" {(yyval.mark)=(yyvsp[(2) - (3)].mark);;} break; case 78: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 596 "ncgen.y" {(yyval.mark)=listlength(stack); listpush(stack,(elem_t)(yyvsp[(1) - (1)].sym));;} break; case 79: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 598 "ncgen.y" {(yyval.mark)=(yyvsp[(1) - (3)].mark); listpush(stack,(elem_t)(yyvsp[(3) - (3)].sym));;} break; case 80: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 603 "ncgen.y" { /* Anonymous integer dimension. Can only occur in type definitions*/ @@ -2391,7 +2383,7 @@ yyreduce: case 81: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 613 "ncgen.y" { /* Anonymous integer dimension. Can only occur in type definitions*/ @@ -2410,7 +2402,7 @@ yyreduce: case 82: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 633 "ncgen.y" {Symbol* vsym = (yyvsp[(1) - (1)].sym); if(vsym->objectclass != NC_VAR) { @@ -2423,7 +2415,7 @@ yyreduce: case 83: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 644 "ncgen.y" {Symbol* tsym = (yyvsp[(1) - (1)].sym); if(tsym->objectclass != NC_TYPE) { @@ -2436,7 +2428,7 @@ yyreduce: case 84: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 655 "ncgen.y" {Symbol* tvsym = (yyvsp[(1) - (1)].sym); Symbol* sym; /* disambiguate*/ @@ -2460,35 +2452,35 @@ yyreduce: case 85: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 673 "ncgen.y" {(yyval.sym)=(yyvsp[(1) - (1)].sym);;} break; case 86: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 680 "ncgen.y" {;} break; case 87: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 680 "ncgen.y" {;} break; case 88: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 684 "ncgen.y" { (yyval.sym)=makeattribute((yyvsp[(2) - (4)].sym),NULL,NULL,(yyvsp[(4) - (4)].datalist),ATTRGLOBAL);;} break; case 89: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 686 "ncgen.y" {Symbol* tsym = (yyvsp[(1) - (6)].sym); Symbol* vsym = (yyvsp[(2) - (6)].sym); Symbol* asym = (yyvsp[(4) - (6)].sym); if(vsym->objectclass == NC_VAR) { @@ -2502,7 +2494,7 @@ yyreduce: case 90: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 695 "ncgen.y" {Symbol* sym = (yyvsp[(1) - (5)].sym); Symbol* asym = (yyvsp[(3) - (5)].sym); if(sym->objectclass == NC_VAR) { @@ -2518,70 +2510,70 @@ yyreduce: case 91: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 706 "ncgen.y" {(yyval.sym) = makespecial(_FILLVALUE_FLAG,(yyvsp[(1) - (5)].sym),NULL,(void*)(yyvsp[(5) - (5)].datalist),0);;} break; case 92: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 708 "ncgen.y" {(yyval.sym) = makespecial(_FILLVALUE_FLAG,(yyvsp[(2) - (6)].sym),(yyvsp[(1) - (6)].sym),(void*)(yyvsp[(6) - (6)].datalist),0);;} break; case 93: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 710 "ncgen.y" {(yyval.sym) = makespecial(_STORAGE_FLAG,(yyvsp[(1) - (5)].sym),NULL,(void*)&(yyvsp[(5) - (5)].constant),1);;} break; case 94: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 712 "ncgen.y" {(yyval.sym) = makespecial(_CHUNKSIZES_FLAG,(yyvsp[(1) - (5)].sym),NULL,(void*)(yyvsp[(5) - (5)].datalist),0);;} break; case 95: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 714 "ncgen.y" {(yyval.sym) = makespecial(_FLETCHER32_FLAG,(yyvsp[(1) - (5)].sym),NULL,(void*)&(yyvsp[(5) - (5)].constant),1);;} break; case 96: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 716 "ncgen.y" {(yyval.sym) = makespecial(_DEFLATE_FLAG,(yyvsp[(1) - (5)].sym),NULL,(void*)&(yyvsp[(5) - (5)].constant),1);;} break; case 97: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 718 "ncgen.y" {(yyval.sym) = makespecial(_SHUFFLE_FLAG,(yyvsp[(1) - (5)].sym),NULL,(void*)&(yyvsp[(5) - (5)].constant),1);;} break; case 98: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 720 "ncgen.y" {(yyval.sym) = makespecial(_ENDIAN_FLAG,(yyvsp[(1) - (5)].sym),NULL,(void*)&(yyvsp[(5) - (5)].constant),1);;} break; case 99: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 722 "ncgen.y" {(yyval.sym) = makespecial(_NOFILL_FLAG,(yyvsp[(1) - (5)].sym),NULL,(void*)&(yyvsp[(5) - (5)].constant),1);;} break; case 100: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 724 "ncgen.y" { (yyval.sym) = makespecial(_FORMAT_FLAG,NULL,NULL,(void*)&(yyvsp[(4) - (4)].constant),1); @@ -2590,7 +2582,7 @@ yyreduce: case 101: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 731 "ncgen.y" { (yyval.sym)=(yyvsp[(1) - (1)].sym); @@ -2601,7 +2593,7 @@ yyreduce: case 102: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 737 "ncgen.y" { (yyval.sym)=(yyvsp[(1) - (1)].sym); @@ -2613,246 +2605,246 @@ yyreduce: case 104: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 746 "ncgen.y" {;} break; case 105: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 747 "ncgen.y" {;} break; case 108: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 755 "ncgen.y" {(yyvsp[(1) - (3)].sym)->data = (yyvsp[(3) - (3)].datalist);;} break; case 109: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 758 "ncgen.y" {(yyval.datalist) = (yyvsp[(1) - (1)].datalist);;} break; case 110: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 759 "ncgen.y" {(yyval.datalist) = (yyvsp[(1) - (1)].datalist);;} break; case 111: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 763 "ncgen.y" {(yyval.datalist) = builddatalist(0);;} break; case 112: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 767 "ncgen.y" {(yyval.datalist) = builddatalist(0); datalistextend((yyval.datalist),&((yyvsp[(1) - (1)].constant)));;} break; case 113: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 769 "ncgen.y" {datalistextend((yyvsp[(1) - (3)].datalist),&((yyvsp[(3) - (3)].constant))); (yyval.datalist)=(yyvsp[(1) - (3)].datalist);;} break; case 114: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 773 "ncgen.y" {(yyval.constant)=(yyvsp[(1) - (1)].constant);;} break; case 115: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 774 "ncgen.y" {(yyval.constant)=builddatasublist((yyvsp[(2) - (3)].datalist));;} break; case 116: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 778 "ncgen.y" {(yyval.constant)=makeconstdata(NC_CHAR);;} break; case 117: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 779 "ncgen.y" {(yyval.constant)=makeconstdata(NC_BYTE);;} break; case 118: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 780 "ncgen.y" {(yyval.constant)=makeconstdata(NC_SHORT);;} break; case 119: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 781 "ncgen.y" {(yyval.constant)=makeconstdata(NC_INT);;} break; case 120: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 782 "ncgen.y" {(yyval.constant)=makeconstdata(NC_INT64);;} break; case 121: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 783 "ncgen.y" {(yyval.constant)=makeconstdata(NC_UBYTE);;} break; case 122: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 784 "ncgen.y" {(yyval.constant)=makeconstdata(NC_USHORT);;} break; case 123: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 785 "ncgen.y" {(yyval.constant)=makeconstdata(NC_UINT);;} break; case 124: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 786 "ncgen.y" {(yyval.constant)=makeconstdata(NC_UINT64);;} break; case 125: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 787 "ncgen.y" {(yyval.constant)=makeconstdata(NC_FLOAT);;} break; case 126: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 788 "ncgen.y" {(yyval.constant)=makeconstdata(NC_DOUBLE);;} break; case 127: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 789 "ncgen.y" {(yyval.constant)=makeconstdata(NC_STRING);;} break; case 128: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 790 "ncgen.y" {(yyval.constant)=makeconstdata(NC_OPAQUE);;} break; case 129: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 791 "ncgen.y" {(yyval.constant)=makeenumconst((yyvsp[(1) - (1)].sym));;} break; case 130: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 792 "ncgen.y" {(yyval.constant)=makeconstdata(NC_FILLVALUE);;} break; case 131: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 796 "ncgen.y" {(yyval.datalist) = builddatalist(0); datalistextend((yyval.datalist),&((yyvsp[(1) - (1)].constant)));;} break; case 132: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 797 "ncgen.y" {(yyval.datalist)=(yyvsp[(1) - (3)].datalist); datalistextend((yyvsp[(1) - (3)].datalist),&((yyvsp[(3) - (3)].constant)));;} break; case 133: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 802 "ncgen.y" {(yyval.constant)=makeconstdata(NC_INT);;} break; case 134: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 804 "ncgen.y" {(yyval.constant)=makeconstdata(NC_UINT);;} break; case 135: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 806 "ncgen.y" {(yyval.constant)=makeconstdata(NC_INT64);;} break; case 136: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 808 "ncgen.y" {(yyval.constant)=makeconstdata(NC_UINT64);;} break; case 137: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 812 "ncgen.y" {(yyval.constant)=makeconstdata(NC_STRING);;} break; case 138: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 816 "ncgen.y" {(yyval.constant)=(yyvsp[(1) - (1)].constant);;} break; case 139: -/* Line 1464 of yacc.c */ +/* Line 1455 of yacc.c */ #line 817 "ncgen.y" {(yyval.constant)=(yyvsp[(1) - (1)].constant);;} break; -/* Line 1464 of yacc.c */ -#line 2856 "ncgen.tab.c" +/* Line 1455 of yacc.c */ +#line 2848 "ncgen.tab.c" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -3063,7 +3055,7 @@ yyreturn: -/* Line 1684 of yacc.c */ +/* Line 1675 of yacc.c */ #line 821 "ncgen.y" From 204685b257aad9fb0932f657c40700586c059af8 Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Wed, 23 Jun 2010 13:20:39 +0000 Subject: [PATCH 08/18] got valgrind tests to pass --- libsrc4/run_valgrind_tests.sh | 6 +++--- nc_test4/Makefile.am | 8 +++++++- nc_test4/run_valgrind_tests.sh | 27 +++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 4 deletions(-) create mode 100755 nc_test4/run_valgrind_tests.sh diff --git a/libsrc4/run_valgrind_tests.sh b/libsrc4/run_valgrind_tests.sh index 1706e35bd..fa6e76a78 100755 --- a/libsrc4/run_valgrind_tests.sh +++ b/libsrc4/run_valgrind_tests.sh @@ -14,9 +14,9 @@ list='tst_h_dimscales tst_h_vl2 tst_h_files '\ 'tst_h_grps tst_h_wrt_cmp tst_h_rd_cmp tst_h_vl tst_h_atts '\ 'tst_h_dimscales3 tst_h_files2 tst_h_compounds '\ 'tst_h_vars tst_h_opaques tst_h_compounds2 '\ -'tst_atts tst_atts2 tst_vl tst_compounds '\ -'tst_files tst_utf8 tst_fillbug tst_v2 '\ -'tst_vars2 tst_vars3 tst_xplatform tst_dims '\ +'tst_vl tst_compounds '\ +'tst_files tst_utf8 tst_fillbug '\ +'tst_vars3 tst_xplatform tst_dims '\ 'tst_dims2 tst_dims3 tst_varms tst_unlim_vars '\ 'tst_endian_fill tst_compounds2' diff --git a/nc_test4/Makefile.am b/nc_test4/Makefile.am index 5872b48d1..684109deb 100644 --- a/nc_test4/Makefile.am +++ b/nc_test4/Makefile.am @@ -64,6 +64,12 @@ tst_interops2_LDADD = ${lib_LTLIBRARIES} -lmfhdf -ldf -ljpeg -lhdf5_hl \ -lhdf5 -lz endif # USE_HDF4 +# This will run a bunch of the test programs with valgrind, the memory +# checking tool. (Valgrind must be present for this to work.) +if USE_VALGRIND_TESTS +TESTS += run_valgrind_tests.sh +endif # USE_VALGRIND_TESTS + CLEANFILES = cdm_sea_soundings.nc bm_chunking.nc bm_radar.nc \ bm_radar1.nc radar_3d_compression_test.txt radar_3d_compression.txt \ radar_2d_compression.txt radar_3d_chunking.txt tst_floats_1D.cdl \ @@ -89,7 +95,7 @@ EXTRA_DIST = run_par_test.sh run_bm.sh run_bm_test1.sh run_bm_test2.sh \ run_bm_radar_2D.sh run_bm_radar_2D_compression1.sh run_par_bm_test.sh \ run_bm_elena.sh run_par_bm_radar_2D.sh run_bm_radar_2D_endianness1.sh \ run_tst_chunks.sh ref_chunks1.cdl ref_chunks2.cdl run_pnetcdf_test.sh \ -run_get_hdf4_files.sh +run_get_hdf4_files.sh run_valgrind_tests.sh if USE_HDF4_FILE_TESTS DISTCLEANFILES = AMSR_E_L2_Rain_V10_200905312326_A.hdf \ diff --git a/nc_test4/run_valgrind_tests.sh b/nc_test4/run_valgrind_tests.sh new file mode 100755 index 000000000..4fad27a04 --- /dev/null +++ b/nc_test4/run_valgrind_tests.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +# This shell runs the tests with valgrind. + +# $Id: run_valgrind_tests.sh,v 1.9 2010/01/26 20:24:18 ed Exp $ + +set -e +echo "" +echo "Testing programs with valgrind..." + +# These are my test programs. +list='tst_v2 '\ +'tst_vars2 tst_atts tst_atts2 ' + +# These don't work yet: tst_h_vars3 +# tst_h_strings tst_h_atts3 tst_h_vars2 tst_vars tst_fills tst_chunks +# tst_coords tst_xplatform2 + +for tst in $list; do + echo "" + echo "Memory testing with $tst:" + valgrind -q --error-exitcode=2 --leak-check=full ./$tst +done + +echo "SUCCESS!!!" + +exit 0 From f6447ee94c298204ba22ee82397a0612b658b6db Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Wed, 23 Jun 2010 13:57:33 +0000 Subject: [PATCH 09/18] fixed extra-test libsrc4/tst_h_vl2 problem and valgrind test problems --- libsrc4/Makefile.am | 10 +++++----- nc_test4/Makefile.am | 4 ++-- {libsrc4 => nc_test4}/tst_h_vl2.c | 8 +------- 3 files changed, 8 insertions(+), 14 deletions(-) rename {libsrc4 => nc_test4}/tst_h_vl2.c (96%) diff --git a/libsrc4/Makefile.am b/libsrc4/Makefile.am index 5c516b36d..fc94a5ced 100644 --- a/libsrc4/Makefile.am +++ b/libsrc4/Makefile.am @@ -140,7 +140,7 @@ tst_h_atts3 tst_h_vars tst_h_vars2 tst_h_vars3 tst_h_grps \ tst_h_compounds tst_h_compounds2 tst_h_wrt_cmp tst_h_rd_cmp tst_h_vl \ tst_h_opaques tst_h_strings tst_h_strings1 tst_h_dimscales \ tst_h_dimscales1 tst_h_dimscales2 tst_h_dimscales3 tst_h_enums \ -tst_h_vl2 tst_dims tst_dims2 tst_dims3 tst_files tst_files4 tst_vars \ +tst_dims tst_dims2 tst_dims3 tst_files tst_files4 tst_vars \ tst_varms tst_unlim_vars tst_converts tst_converts2 tst_grps \ tst_compounds tst_compounds2 tst_compounds3 tst_opaques tst_strings \ tst_interops tst_interops4 tst_interops5 tst_enums tst_coords \ @@ -163,10 +163,10 @@ tst_h_strings1 tst_h_dimscales tst_h_dimscales1 tst_h_dimscales2 \ tst_h_dimscales3 tst_h_enums tst_dims tst_dims2 tst_dims3 tst_files \ tst_files4 tst_vars tst_varms tst_unlim_vars tst_converts \ tst_converts2 tst_grps tst_compounds tst_compounds2 tst_compounds3 \ -tst_h_vl2 tst_opaques tst_strings tst_interops tst_interops4 \ -tst_interops5 tst_enums tst_vars3 tst_chunks tst_coords tst_coords2 \ -tst_coords3 tst_utf8 tst_fills tst_fillbug tst_xplatform \ -tst_xplatform2 tst_h_atts2 tst_endian_fill +tst_opaques tst_strings tst_interops tst_interops4 tst_interops5 \ +tst_enums tst_vars3 tst_chunks tst_coords tst_coords2 tst_coords3 \ +tst_utf8 tst_fills tst_fillbug tst_xplatform tst_xplatform2 \ +tst_h_atts2 tst_endian_fill EXTRA_DIST = ref_tst_compounds.nc ref_tst_h_compounds.h5 \ ref_tst_h_compounds2.h5 run_par_tests.sh run_valgrind_tests.sh \ diff --git a/nc_test4/Makefile.am b/nc_test4/Makefile.am index 684109deb..e8ac044ba 100644 --- a/nc_test4/Makefile.am +++ b/nc_test4/Makefile.am @@ -13,9 +13,9 @@ AM_CPPFLAGS = -I$(top_srcdir) -I$(top_builddir)/liblib @EXTERN_CFLAGS@ # Unfortunately, libsrc4 contains nc_test.h AM_CPPFLAGS += -I$(top_srcdir)/libsrc4 -I$(top_srcdir)/libsrc -# Our test programs and sources... +# Our test programs and sources. (tst_h_vl2 must come after tst_vl.) NC4_TEST_PROGS = t_type cdm_sea_soundings tst_camrun tst_vl tst_atts \ -tst_atts2 tst_vars2 +tst_atts2 tst_vars2 tst_h_vl2 cdm_sea_soundings_SOURCES = cdm_sea_soundings.c tests.h tst_camrun_SOURCES = tst_camrun.c tests.h check_PROGRAMS = $(NC4_TEST_PROGS) diff --git a/libsrc4/tst_h_vl2.c b/nc_test4/tst_h_vl2.c similarity index 96% rename from libsrc4/tst_h_vl2.c rename to nc_test4/tst_h_vl2.c index 810531cea..f0471ca58 100644 --- a/libsrc4/tst_h_vl2.c +++ b/nc_test4/tst_h_vl2.c @@ -15,8 +15,7 @@ int main() { printf("\n*** Checking HDF5 VLEN types even more.\n"); -#ifdef EXTRA_TESTS - printf("*** Reading reference file..."); + printf("*** Reading file created by netcdf-4 tests tst_vl..."); { hid_t fileid, grpid, fapl_id, hdf_typeid = 0, base_hdf_typeid = 0, attid = 0; hid_t file_typeid, spaceid, native_typeid; @@ -56,13 +55,10 @@ main() switch (obj_class) { case H5O_TYPE_GROUP: - printf("group\n"); break; case H5O_TYPE_DATASET: - printf("dataset\n"); break; case H5O_TYPE_NAMED_DATATYPE: - printf("type\n"); if ((hdf_typeid = H5Topen2(grpid, obj_name, H5P_DEFAULT)) < 0) ERR_RET; if ((class = H5Tget_class(hdf_typeid)) < 0) ERR_RET; switch (class) @@ -128,7 +124,5 @@ main() } SUMMARIZE_ERR; -#endif - FINAL_RESULTS; } From 6c6f545968a6a30766efb567d03d53b20cb544c4 Mon Sep 17 00:00:00 2001 From: Dennis Heimbigner Date: Wed, 23 Jun 2010 20:18:56 +0000 Subject: [PATCH 10/18] fix name conflicts --- oc/Make0 | 19 +-- oc/curlfunctions.c | 64 +++++++-- oc/dap.y | 90 ++++++------ oc/daplex.c | 4 +- oc/dapparse.c | 36 ++--- oc/dapparselex.h | 34 ++--- oc/http.c | 50 ------- oc/oc.c | 52 ++++++- oc/oc.h | 6 + oc/ocinternal.c | 345 ++++++++++++++++++++++++++++++++++++++------- oc/ocinternal.h | 32 +++++ oc/ocutil.c | 2 + oc/rc.c | 132 +++++++---------- oc/rc.h | 17 +-- oc/read.c | 3 + 15 files changed, 589 insertions(+), 297 deletions(-) diff --git a/oc/Make0 b/oc/Make0 index 0c3c29f99..b4ddf8c22 100755 --- a/oc/Make0 +++ b/oc/Make0 @@ -6,10 +6,11 @@ all:: makeoc:: rm -f ${THISDIR}/*.[chy] for f in ${OCDIR}/*.[chy]; do \ - base=`basename $$f` ; \ - cat $$f | tr -d ' ' >${THISDIR}/$$base; done + base=`basename $$f` ; \ + cat $$f | tr -d ' ' >${THISDIR}/$$base; \ + done rm -f i.* apitest.* getoc.* imain.* main.* - rm -f config.h dap.tab.c dap.tab.h ce.y ceparselex.* + rm -f config.h dap.tab.c dap.tab.h ceparselex.* rm -f ocshadow.* rm -f octest.c rm -f ocinternal.h @@ -17,20 +18,22 @@ makeoc:: < ${OCDIR}/ocinternal.h | tr -d '\r' >./ocinternal.h diffoc:: - for f in ${THISDIR}/*.[chy] ; do \ + for f in ${OCDIR}/*.[chy] ; do \ x=`basename $$f | tr -d ' ' ` ; \ if test "x$$x" = "xdaptab.c"; then continue ; fi ; \ if test -e ${THISDIR}/$$x ; then \ - diff -qw ${THISDIR}/$$x $$f ; \ + diff -q ${THISDIR}/$$x $$f ; \ + else \ + echo "new file: $$f"; \ fi; \ done for f in ${OCDIR}/*.[chy] ; do \ x=`basename $$f|tr -d ' ' ` ; \ if test "x$$x" = "xdaptab.c"; then continue ; fi ; \ if test -e ${THISDIR}/$$x ; then \ - if ! diff -qw ${THISDIR}/$$x $$f > /dev/null ; then \ - echo diff -w ${THISDIR}/$$x $$f ;\ - diff -w ${THISDIR}/$$x $$f ; \ + if ! diff -q ${THISDIR}/$$x $$f > /dev/null ; then \ + echo diff ${THISDIR}/$$x $$f ;\ + diff -bBw ${THISDIR}/$$x $$f ; \ fi; \ fi; \ done diff --git a/oc/curlfunctions.c b/oc/curlfunctions.c index 2e46c5ee2..a1e0780d7 100644 --- a/oc/curlfunctions.c +++ b/oc/curlfunctions.c @@ -9,6 +9,21 @@ #include "rc.h" +/* Set various general curl flags */ +int +set_curl_flags(CURL* curl, struct OCcurlflags* flags) +{ + if (flags->verify) + {if (set_verify(curl) != OC_NOERR) goto fail;} + if (flags->compress) + {if (set_compression(curl) != OC_NOERR) goto fail;} + if (flags->cookies) + {if (set_cookies(curl, flags->cookies) != OC_NOERR) goto fail;} + return OC_NOERR; +fail: + return OC_ECURL; +} + /* This is called with arguments while the other functions in this file are * used with global values read from the.dodsrc file. */ @@ -43,28 +58,28 @@ set_user_password(CURL* curl, const char *userC, const char *passwordC) } int -set_proxy(CURL* curl, struct OCproxy *pstructProxy) +set_proxy(CURL* curl, struct OCproxy *proxy) { CURLcode cstat; - cstat = curl_easy_setopt(curl, CURLOPT_PROXY, pstructProxy->host); + cstat = curl_easy_setopt(curl, CURLOPT_PROXY, proxy->host); if (cstat != CURLE_OK) return OC_ECURL; - cstat = curl_easy_setopt(curl, CURLOPT_PROXYPORT, pstructProxy->port); + cstat = curl_easy_setopt(curl, CURLOPT_PROXYPORT, proxy->port); if (cstat != CURLE_OK) return OC_ECURL; - if (pstructProxy->user) { - int userPassSize = strlen(pstructProxy->user) + strlen( - pstructProxy->password) + 2; + if (proxy->username) { + int userPassSize = strlen(proxy->username) + strlen( + proxy->password) + 2; char *userPassword = malloc(sizeof(char) * userPassSize); if (!userPassword) { oc_log(LOGERR, "Out of Memory\n"); return OC_ENOMEM; } - strncpy(userPassword, pstructProxy->user, userPassSize); + strncpy(userPassword, proxy->username, userPassSize); strncat(userPassword, ":", userPassSize); - strncat(userPassword, pstructProxy->password, userPassSize); + strncat(userPassword, proxy->password, userPassSize); cstat = curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, userPassword); if (cstat != CURLE_OK) { free(userPassword); @@ -122,3 +137,36 @@ set_compression(CURL* curl) return OC_NOERR; } +int +set_credentials(CURL* curl, struct OCcredentials* creds) +{ + CURLcode cstat = CURLE_OK; + if(creds->ssl_certificate) { + cstat = curl_easy_setopt(curl, CURLOPT_SSLCERT, creds->ssl_certificate); + if(cstat != CURLE_OK) goto fail; + } + if(creds->ssl_key) { + cstat = curl_easy_setopt(curl, CURLOPT_SSLKEY, creds->ssl_key); + if(cstat != CURLE_OK) goto fail; + } + if(creds->cainfo) { + cstat = curl_easy_setopt(curl, CURLOPT_CAINFO, creds->cainfo); + if(cstat != CURLE_OK) goto fail; + } + if(creds->capath) { + cstat = curl_easy_setopt(curl, CURLOPT_CAPATH, creds->capath); + if(cstat != CURLE_OK) goto fail; + } + if(creds->cookiefile) { + cstat = curl_easy_setopt(curl, CURLOPT_COOKIEFILE, creds->cookiefile); + if(cstat != CURLE_OK) goto fail; + } + if(creds->cookiejar) { + cstat = curl_easy_setopt(curl, CURLOPT_COOKIEJAR, creds->cookiejar); + if(cstat != CURLE_OK) goto fail; + } + return OC_NOERR; + +fail: + return OC_ECURL; +} diff --git a/oc/dap.y b/oc/dap.y index 31590097d..f782ee986 100644 --- a/oc/dap.y +++ b/oc/dap.y @@ -48,32 +48,32 @@ start: | SCAN_ATTR dassetup attributebody | SCAN_ERROR errorbody | error - {$$=unrecognizedresponse(parsestate);} + {$$=dap_unrecognizedresponse(parsestate);} ; datasetbody: '{' declarations '}' datasetname ';' - {datasetbody(parsestate,$4,$2);} + {dap_datasetbody(parsestate,$4,$2);} ; declarations: - /* empty */ {$$=declarations(parsestate,null,null);} - | declarations declaration {$$=declarations(parsestate,$1,$2);} + /* empty */ {$$=dap_declarations(parsestate,null,null);} + | declarations declaration {$$=dap_declarations(parsestate,$1,$2);} ; /* 01/21/08: James says: no dimensions for grids or sequences */ /* 05/08/09: James says: no duplicate map names */ declaration: base_type var_name array_decls ';' - {$$=makebase(parsestate,$2,$1,$3);} + {$$=dap_makebase(parsestate,$2,$1,$3);} | SCAN_STRUCTURE '{' declarations '}' var_name array_decls ';' - {if(($$ = makestructure(parsestate,$5,$6,$3))==null) {YYABORT;}} + {if(($$=dap_makestructure(parsestate,$5,$6,$3))==null) {YYABORT;}} | SCAN_SEQUENCE '{' declarations '}' var_name ';' - {if(($$ = makesequence(parsestate,$5,$3))==null) {YYABORT;}} + {if(($$=dap_makesequence(parsestate,$5,$3))==null) {YYABORT;}} | SCAN_GRID '{' SCAN_ARRAY ':' declaration SCAN_MAPS ':' declarations '}' var_name ';' - {if(($$ = makegrid(parsestate,$10,$5,$8))==null) {YYABORT;}} + {if(($$=dap_makegrid(parsestate,$10,$5,$8))==null) {YYABORT;}} | error {daperror(parsestate,"Unrecognized type"); YYABORT;} ; @@ -92,13 +92,13 @@ base_type: ; array_decls: - /* empty */ {$$=arraydecls(parsestate,null,null);} - | array_decls array_decl {$$=arraydecls(parsestate,$1,$2);} + /* empty */ {$$=dap_arraydecls(parsestate,null,null);} + | array_decls array_decl {$$=dap_arraydecls(parsestate,$1,$2);} ; array_decl: - '[' SCAN_WORD ']' {$$=arraydecl(parsestate,null,$2);} - | '[' name '=' SCAN_WORD ']' {$$=arraydecl(parsestate,$2,$4);} + '[' SCAN_WORD ']' {$$=dap_arraydecl(parsestate,null,$2);} + | '[' name '=dap_' SCAN_WORD ']' {$$=dap_arraydecl(parsestate,$2,$4);} | error {daperror(parsestate,"Illegal dimension declaration"); YYABORT;} ; @@ -111,84 +111,84 @@ datasetname: var_name: name {$$=$1;}; -dassetup: {dassetup(parsestate);} +dassetup: {dap_dassetup(parsestate);} attributebody: - '{' attr_list '}' {attributebody(parsestate,$2);} + '{' attr_list '}' {dap_attributebody(parsestate,$2);} | error {daperror(parsestate,"Illegal DAS body"); YYABORT;} ; attr_list: - /* empty */ {$$=attrlist(parsestate,null,null);} - | attr_list attribute {$$=attrlist(parsestate,$1,$2);} + /* empty */ {$$=dap_attrlist(parsestate,null,null);} + | attr_list attribute {$$=dap_attrlist(parsestate,$1,$2);} ; attribute: alias ';' {$$=null;} /* ignored */ | SCAN_BYTE name bytes ';' - {$$=attribute(parsestate,$2,$3,(Object)SCAN_BYTE);} + {$$=dap_attribute(parsestate,$2,$3,(Object)SCAN_BYTE);} | SCAN_INT16 name int16 ';' - {$$=attribute(parsestate,$2,$3,(Object)SCAN_INT16);} + {$$=dap_attribute(parsestate,$2,$3,(Object)SCAN_INT16);} | SCAN_UINT16 name uint16 ';' - {$$=attribute(parsestate,$2,$3,(Object)SCAN_UINT16);} + {$$=dap_attribute(parsestate,$2,$3,(Object)SCAN_UINT16);} | SCAN_INT32 name int32 ';' - {$$=attribute(parsestate,$2,$3,(Object)SCAN_INT32);} + {$$=dap_attribute(parsestate,$2,$3,(Object)SCAN_INT32);} | SCAN_UINT32 name uint32 ';' - {$$=attribute(parsestate,$2,$3,(Object)SCAN_UINT32);} + {$$=dap_attribute(parsestate,$2,$3,(Object)SCAN_UINT32);} | SCAN_FLOAT32 name float32 ';' - {$$=attribute(parsestate,$2,$3,(Object)SCAN_FLOAT32);} + {$$=dap_attribute(parsestate,$2,$3,(Object)SCAN_FLOAT32);} | SCAN_FLOAT64 name float64 ';' - {$$=attribute(parsestate,$2,$3,(Object)SCAN_FLOAT64);} + {$$=dap_attribute(parsestate,$2,$3,(Object)SCAN_FLOAT64);} | SCAN_STRING name strs ';' - {$$=attribute(parsestate,$2,$3,(Object)SCAN_STRING);} + {$$=dap_attribute(parsestate,$2,$3,(Object)SCAN_STRING);} | SCAN_URL name urls ';' - {$$=attribute(parsestate,$2,$3,(Object)SCAN_URL);} - | name '{' attr_list '}' {$$=attrset(parsestate,$1,$3);} + {$$=dap_attribute(parsestate,$2,$3,(Object)SCAN_URL);} + | name '{' attr_list '}' {$$=dap_attrset(parsestate,$1,$3);} | error {daperror(parsestate,"Illegal attribute"); YYABORT;} ; bytes: - SCAN_WORD {$$=attrvalue(parsestate,null,$1,(Object)SCAN_BYTE);} + SCAN_WORD {$$=dap_attrvalue(parsestate,null,$1,(Object)SCAN_BYTE);} | bytes ',' SCAN_WORD - {$$=attrvalue(parsestate,$1,$3,(Object)SCAN_BYTE);} + {$$=dap_attrvalue(parsestate,$1,$3,(Object)SCAN_BYTE);} ; int16: - SCAN_WORD {$$=attrvalue(parsestate,null,$1,(Object)SCAN_INT16);} + SCAN_WORD {$$=dap_attrvalue(parsestate,null,$1,(Object)SCAN_INT16);} | int16 ',' SCAN_WORD - {$$=attrvalue(parsestate,$1,$3,(Object)SCAN_INT16);} + {$$=dap_attrvalue(parsestate,$1,$3,(Object)SCAN_INT16);} ; uint16: - SCAN_WORD {$$=attrvalue(parsestate,null,$1,(Object)SCAN_UINT16);} + SCAN_WORD {$$=dap_attrvalue(parsestate,null,$1,(Object)SCAN_UINT16);} | uint16 ',' SCAN_WORD - {$$=attrvalue(parsestate,$1,$3,(Object)SCAN_UINT16);} + {$$=dap_attrvalue(parsestate,$1,$3,(Object)SCAN_UINT16);} ; int32: - SCAN_WORD {$$=attrvalue(parsestate,null,$1,(Object)SCAN_INT32);} + SCAN_WORD {$$=dap_attrvalue(parsestate,null,$1,(Object)SCAN_INT32);} | int32 ',' SCAN_WORD - {$$=attrvalue(parsestate,$1,$3,(Object)SCAN_INT32);} + {$$=dap_attrvalue(parsestate,$1,$3,(Object)SCAN_INT32);} ; uint32: - SCAN_WORD {$$=attrvalue(parsestate,null,$1,(Object)SCAN_UINT32);} - | uint32 ',' SCAN_WORD {$$=attrvalue(parsestate,$1,$3,(Object)SCAN_UINT32);} + SCAN_WORD {$$=dap_attrvalue(parsestate,null,$1,(Object)SCAN_UINT32);} + | uint32 ',' SCAN_WORD {$$=dap_attrvalue(parsestate,$1,$3,(Object)SCAN_UINT32);} ; float32: - SCAN_WORD {$$=attrvalue(parsestate,null,$1,(Object)SCAN_FLOAT32);} - | float32 ',' SCAN_WORD {$$=attrvalue(parsestate,$1,$3,(Object)SCAN_FLOAT32);} + SCAN_WORD {$$=dap_attrvalue(parsestate,null,$1,(Object)SCAN_FLOAT32);} + | float32 ',' SCAN_WORD {$$=dap_attrvalue(parsestate,$1,$3,(Object)SCAN_FLOAT32);} ; float64: - SCAN_WORD {$$=attrvalue(parsestate,null,$1,(Object)SCAN_FLOAT64);} - | float64 ',' SCAN_WORD {$$=attrvalue(parsestate,$1,$3,(Object)SCAN_FLOAT64);} + SCAN_WORD {$$=dap_attrvalue(parsestate,null,$1,(Object)SCAN_FLOAT64);} + | float64 ',' SCAN_WORD {$$=dap_attrvalue(parsestate,$1,$3,(Object)SCAN_FLOAT64);} ; strs: - str_or_id {$$=attrvalue(parsestate,null,$1,(Object)SCAN_STRING);} - | strs ',' str_or_id {$$=attrvalue(parsestate,$1,$3,(Object)SCAN_STRING);} + str_or_id {$$=dap_attrvalue(parsestate,null,$1,(Object)SCAN_STRING);} + | strs ',' str_or_id {$$=dap_attrvalue(parsestate,$1,$3,(Object)SCAN_STRING);} ; urls: - url {$$=attrvalue(parsestate,null,$1,(Object)SCAN_URL);} - | urls ',' url {$$=attrvalue(parsestate,$1,$3,(Object)SCAN_URL);} + url {$$=dap_attrvalue(parsestate,null,$1,(Object)SCAN_URL);} + | urls ',' url {$$=dap_attrvalue(parsestate,$1,$3,(Object)SCAN_URL);} ; url: @@ -211,7 +211,7 @@ alias: errorbody: '{' errorcode errormsg errorptype errorprog '}' ';' - {$$=errorbody(parsestate,$2,$3,$4,$5);} + {$$=dap_errorbody(parsestate,$2,$3,$4,$5);} ; errorcode: /*empty*/ {$$=null;} | SCAN_CODE '=' SCAN_WORD ';' {$$=$3;} diff --git a/oc/daplex.c b/oc/daplex.c index 4a4053981..b8e5f0ef9 100644 --- a/oc/daplex.c +++ b/oc/daplex.c @@ -248,7 +248,7 @@ Simple lexer */ void -setwordchars(DAPlexstate* lexstate, int kind) +dapsetwordchars(DAPlexstate* lexstate, int kind) { switch (kind) { case 0: @@ -281,7 +281,7 @@ daplexinit(char* input, DAPlexstate** lexstatep) lexstate->next = lexstate->input; lexstate->yytext = ocbytesnew(); lexstate->reclaim = oclistnew(); - setwordchars(lexstate,0); /* Assume DDS */ + dapsetwordchars(lexstate,0); /* Assume DDS */ } void diff --git a/oc/dapparse.c b/oc/dapparse.c index 0a108116f..a8acff915 100644 --- a/oc/dapparse.c +++ b/oc/dapparse.c @@ -16,13 +16,13 @@ static int check_int32(char* val, long* value); /* Switch to DAS parsing SCAN_WORD definition */ void -dassetup(DAPparsestate* state) +dap_dassetup(DAPparsestate* state) { - setwordchars(state->lexstate,1); + dapsetwordchars(state->lexstate,1); } Object -datasetbody(DAPparsestate* state, Object name, Object decls) +dap_datasetbody(DAPparsestate* state, Object name, Object decls) { OCnode* node = newocnode((char*)name,OC_Dataset,state); node->subnodes = (OClist*)decls; @@ -35,7 +35,7 @@ datasetbody(DAPparsestate* state, Object name, Object decls) } Object -attributebody(DAPparsestate* state, Object attrlist) +dap_attributebody(DAPparsestate* state, Object attrlist) { OCnode* node = newocnode(NULL,OC_Attributeset,state); OCASSERT((state->root == NULL)); @@ -48,7 +48,7 @@ attributebody(DAPparsestate* state, Object attrlist) } Object -errorbody(DAPparsestate* state, +dap_errorbody(DAPparsestate* state, Object code, Object msg, Object ptype, Object prog) { state->svcerror = 1; @@ -59,13 +59,13 @@ errorbody(DAPparsestate* state, } Object -unrecognizedresponse(DAPparsestate* state) +dap_unrecognizedresponse(DAPparsestate* state) { - return errorbody(state,"0",state->lexstate->input,NULL,NULL); + return dap_errorbody(state,"0",state->lexstate->input,NULL,NULL); } Object -declarations(DAPparsestate* state, Object decls, Object decl) +dap_declarations(DAPparsestate* state, Object decls, Object decl) { OClist* alist = (OClist*)decls; if(alist == NULL) @@ -76,7 +76,7 @@ declarations(DAPparsestate* state, Object decls, Object decl) } Object -arraydecls(DAPparsestate* state, Object arraydecls, Object arraydecl) +dap_arraydecls(DAPparsestate* state, Object arraydecls, Object arraydecl) { OClist* alist = (OClist*)arraydecls; if(alist == NULL) @@ -87,7 +87,7 @@ arraydecls(DAPparsestate* state, Object arraydecls, Object arraydecl) } Object -arraydecl(DAPparsestate* state, Object name, Object size) +dap_arraydecl(DAPparsestate* state, Object name, Object size) { long value; OCnode* dim; @@ -102,7 +102,7 @@ arraydecl(DAPparsestate* state, Object name, Object size) } Object -attrlist(DAPparsestate* state, Object attrlist, Object attrtuple) +dap_attrlist(DAPparsestate* state, Object attrlist, Object attrtuple) { OClist* alist = (OClist*)attrlist; if(alist == NULL) @@ -122,7 +122,7 @@ attrlist(DAPparsestate* state, Object attrlist, Object attrtuple) } Object -attrvalue(DAPparsestate* state, Object valuelist, Object value, Object etype) +dap_attrvalue(DAPparsestate* state, Object valuelist, Object value, Object etype) { OClist* alist = (OClist*)valuelist; if(alist == NULL) alist = oclistnew(); @@ -133,7 +133,7 @@ attrvalue(DAPparsestate* state, Object valuelist, Object value, Object etype) } Object -attribute(DAPparsestate* state, Object name, Object values, Object etype) +dap_attribute(DAPparsestate* state, Object name, Object values, Object etype) { OCnode* att; att = newocnode((char*)name,OC_Attribute,state); @@ -143,7 +143,7 @@ attribute(DAPparsestate* state, Object name, Object values, Object etype) } Object -attrset(DAPparsestate* state, Object name, Object attributes) +dap_attrset(DAPparsestate* state, Object name, Object attributes) { OCnode* attset; attset = newocnode((char*)name,OC_Attributeset,state); @@ -204,7 +204,7 @@ dimnameanon(char* basename, unsigned int index) } Object -makebase(DAPparsestate* state, Object name, Object etype, Object dimensions) +dap_makebase(DAPparsestate* state, Object name, Object etype, Object dimensions) { OCnode* node; node = newocnode((char*)name,OC_Primitive,state); @@ -214,7 +214,7 @@ makebase(DAPparsestate* state, Object name, Object etype, Object dimensions) } Object -makestructure(DAPparsestate* state, Object name, Object dimensions, Object fields) +dap_makestructure(DAPparsestate* state, Object name, Object dimensions, Object fields) { OCnode* node; char* dupname; @@ -230,7 +230,7 @@ makestructure(DAPparsestate* state, Object name, Object dimensions, Object field } Object -makesequence(DAPparsestate* state, Object name, Object members) +dap_makesequence(DAPparsestate* state, Object name, Object members) { OCnode* node; char* dupname; @@ -245,7 +245,7 @@ makesequence(DAPparsestate* state, Object name, Object members) } Object -makegrid(DAPparsestate* state, Object name, Object arraydecl, Object mapdecls) +dap_makegrid(DAPparsestate* state, Object name, Object arraydecl, Object mapdecls) { OCnode* node; /* Check for duplicate map names */ diff --git a/oc/dapparselex.h b/oc/dapparselex.h index df778e548..b78a01ffd 100644 --- a/oc/dapparselex.h +++ b/oc/dapparselex.h @@ -63,30 +63,30 @@ extern void dap_parse_error(DAPparsestate*,const char *fmt, ...); /* bison parse entry point */ extern int dapparse(DAPparsestate*); -extern Object datasetbody(DAPparsestate*,Object decls, Object name); -extern Object declarations(DAPparsestate*,Object decls, Object decl); -extern Object arraydecls(DAPparsestate*,Object arraydecls, Object arraydecl); -extern Object arraydecl(DAPparsestate*,Object name, Object size); +extern Object dap_datasetbody(DAPparsestate*,Object decls, Object name); +extern Object dap_declarations(DAPparsestate*,Object decls, Object decl); +extern Object dap_arraydecls(DAPparsestate*,Object arraydecls, Object arraydecl); +extern Object dap_arraydecl(DAPparsestate*,Object name, Object size); -extern void dassetup(DAPparsestate*); -extern Object attributebody(DAPparsestate*,Object attrlist); -extern Object attrlist(DAPparsestate*,Object attrlist, Object attrtuple); -extern Object attribute(DAPparsestate*,Object name, Object value, Object etype); -extern Object attrset(DAPparsestate*,Object name, Object attributes); -extern Object attrvalue(DAPparsestate*,Object valuelist, Object value, Object etype); +extern void dap_dassetup(DAPparsestate*); +extern Object dap_attributebody(DAPparsestate*,Object attrlist); +extern Object dap_attrlist(DAPparsestate*,Object attrlist, Object attrtuple); +extern Object dap_attribute(DAPparsestate*,Object name, Object value, Object etype); +extern Object dap_attrset(DAPparsestate*,Object name, Object attributes); +extern Object dap_attrvalue(DAPparsestate*,Object valuelist, Object value, Object etype); -extern Object makebase(DAPparsestate*,Object name, Object etype, Object dimensions); -extern Object makestructure(DAPparsestate*,Object name, Object dimensions, Object fields); -extern Object makesequence(DAPparsestate*,Object name, Object members); -extern Object makegrid(DAPparsestate*,Object name, Object arraydecl, Object mapdecls); +extern Object dap_makebase(DAPparsestate*,Object name, Object etype, Object dimensions); +extern Object dap_makestructure(DAPparsestate*,Object name, Object dimensions, Object fields); +extern Object dap_makesequence(DAPparsestate*,Object name, Object members); +extern Object dap_makegrid(DAPparsestate*,Object name, Object arraydecl, Object mapdecls); -extern Object errorbody(DAPparsestate*, Object, Object, Object, Object); -extern Object unrecognizedresponse(DAPparsestate*); +extern Object dap_errorbody(DAPparsestate*, Object, Object, Object, Object); +extern Object dap_unrecognizedresponse(DAPparsestate*); /* Lexer entry points */ extern int daplex(YYSTYPE*, DAPparsestate*); extern void daplexinit(char* input, DAPlexstate** lexstatep); extern void daplexcleanup(DAPlexstate** lexstatep); -extern void setwordchars(DAPlexstate* lexstate, int kind); +extern void dapsetwordchars(DAPlexstate* lexstate, int kind); #endif /*DAPPARSELEX_H*/ diff --git a/oc/http.c b/oc/http.c index f6726e6fb..052b1df87 100644 --- a/oc/http.c +++ b/oc/http.c @@ -11,7 +11,6 @@ static size_t WriteFileCallback(void*, size_t, size_t, void*); static size_t WriteMemoryCallback(void*, size_t, size_t, void*); -static int ocsetcurlproperties(CURL* curl, const char*); struct Fetchdata { FILE* stream; @@ -37,9 +36,6 @@ ocfetchurl_file(CURL* curl, char* url, FILE* stream, CURLcode cstat = CURLE_OK; struct Fetchdata fetchdata; - - if((stat = ocsetcurlproperties(curl,url)) != OC_NOERR) goto fail; - /* Set the URL */ cstat = curl_easy_setopt(curl, CURLOPT_URL, (void*)url); if (cstat != CURLE_OK) @@ -87,8 +83,6 @@ ocfetchurl(CURL* curl, char* url, OCbytes* buf, long* filetime) CURLcode cstat = CURLE_OK; size_t len; - if((stat = ocsetcurlproperties(curl,url)) != OC_NOERR) goto fail; - /* Set the URL */ cstat = curl_easy_setopt(curl, CURLOPT_URL, (void*)url); if (cstat != CURLE_OK) @@ -242,56 +236,12 @@ occurlclose(CURL* curl) curl_easy_cleanup(curl); } -static int -ocsetcurlproperties(CURL* curl, const char* url) -{ - CURLcode cstat = CURLE_OK; - /* These conditionals look for value in four globals set when the - * .dodsrc file was read. - */ - if (dods_verify) { - if (set_verify(curl) != OC_NOERR) - goto fail; - } - if (dods_compress) { - if (set_compression(curl) != OC_NOERR) - goto fail; - } - if (pstructProxy) { - if (set_proxy(curl, pstructProxy) != OC_NOERR) - goto fail; - } - if (cook) { - if (set_cookies(curl, cook) != OC_NOERR) - goto fail; - } - - if (credentials_in_url(url)) { - char *result_url = NULL; - if (extract_credentials(url, &userName, &password, &result_url) != OC_NOERR) - goto fail; - url = result_url; - } - - if (userName && password) { - if (set_user_password(curl, userName, password) != OC_NOERR) - goto fail; - } - return OC_NOERR; - -fail: - oc_log(LOGERR, "curl error: %s", curl_easy_strerror(cstat)); - return THROW(OC_ECURL); -} - int ocfetchlastmodified(CURL* curl, char* url, long* filetime) { int stat = OC_NOERR; CURLcode cstat = CURLE_OK; - if((stat = ocsetcurlproperties(curl,url)) != OC_NOERR) goto fail; - /* Set the URL */ cstat = curl_easy_setopt(curl, CURLOPT_URL, (void*)url); if (cstat != CURLE_OK) diff --git a/oc/oc.c b/oc/oc.c index d9ce57208..20cd2ce90 100644 --- a/oc/oc.c +++ b/oc/oc.c @@ -9,12 +9,27 @@ #include "oclog.h" #include "occlientparams.h" +#ifdef ENABLE_RC +#include "ocrc.h" +#endif + #undef TRACK /**************************************************/ -/* Track legal ids */ -static OClist* ocmap = NULL; +static int ocinitialized = 0; + +/**************************************************/ +/* .rc file info */ +#ifdef ENABLE_RC +struct OCrcfile { + char* rcfilename; + ocrcnode* root; +} ocrcfile = {NULL,NULL}; +#endif + +/**************************************************/ +/* Track legal ids */ #ifdef OC_FASTCONSISTENCY @@ -25,6 +40,8 @@ static OClist* ocmap = NULL; #else /*!OC_FASTCONSISTENCY*/ +static OClist* ocmap = NULL; + static int ocverify(unsigned long object) { @@ -78,15 +95,27 @@ fprintf(stderr,"assign: %lu\n",(unsigned long)object); fflush(stderr); /**************************************************/ +static int +oc_initialize(void) +{ + int status = OC_NOERR; +#ifndef OC_FASTCONSISTENCY + ocmap = oclistnew(); + oclistsetalloc(ocmap,1024); +#endif + status = ocinternalinitialize(); + ocinitialized = 1; + return status; +} + +/**************************************************/ + OCerror oc_open(const char* url, OCconnection* connp) { OCerror ocerr; OCstate* state; - if(ocmap == NULL) { - ocmap = oclistnew(); - oclistsetalloc(ocmap,1024); - } + if(!ocinitialized) oc_initialize(); ocerr = ocopen(&state,url); if(ocerr == OC_NOERR && connp) { *connp = (OCconnection)ocassign(state); @@ -1034,3 +1063,14 @@ oc_dumpnode(OCconnection conn, OCobject root0) ocdumpnode(root); return ocerr; } + +OCerror +oc_setrcfile(char* rcfile) +{ +#ifdef ENABLE_RC + return ocsetrcfile(rcfile); +#else + return OC_EINVAL; +#endif + +} diff --git a/oc/oc.h b/oc/oc.h index 9a3e07776..adb79f5ef 100644 --- a/oc/oc.h +++ b/oc/oc.h @@ -84,6 +84,7 @@ typedef int OCerror; #define OC_EDAS (-21) #define OC_EDDS (-22) #define OC_EDATADDS (-23) +#define OC_ERCFILE (-24) typedef enum OCmode { OCFIELDMODE = OC_Structure, @@ -448,6 +449,11 @@ extern OCerror oc_update_lastmodified_data(OClink); /* Get last known modification time; -1 => data unknown */ extern long oc_get_lastmodified_data(OClink); +/**************************************************/ +/* New .rc file system support */ + +extern OCerror oc_setrcfile(char* rcfile); + /**************************************************/ #endif /*OCINTERNAL_H*/ diff --git a/oc/ocinternal.c b/oc/ocinternal.c index cb29ccaee..f1666b57c 100644 --- a/oc/ocinternal.c +++ b/oc/ocinternal.c @@ -15,6 +15,10 @@ #include "occontent.h" #include "occlientparams.h" #include "rc.h" +#include "curlfunctions.h" +#ifdef ENABLE_RC +#include "ocrc.h" +#endif #include "http.h" #include "read.h" @@ -26,9 +30,15 @@ /*#define TMPPATH "/tmp/"*/ #endif #define TMPPATH "./" -#define BUFSIZE 512 -#define DODSRC_SIZE 9 -#define DODSRC "/.dodsrc" + +/* Define default rc files */ +#define DODSRC ".dodsrc" +#define OPENDAPRC ".opendap.rc" + +#ifdef ENABLE_RC +static char* defaultrc = NULL; +static ocrcnode* ocrcroot = NULL; +#endif static int ocextractdds(OCstate*,OCtree*); static char* constraintescape(const char* url); @@ -36,8 +46,14 @@ static char* constraintescape(const char* url); static OCerror createtempfile(OCstate*,OCtree*); #endif +static void ocsetcurlproperties(OCstate*); + extern OCnode* makeunlimiteddimension(void); +#ifdef ENABLE_RC +static void loadrc(OCstate* state, ocrcnode* root); +#endif + #ifdef WIN32 #include #define _S_IREAD 256 @@ -59,15 +75,10 @@ int oc_network_order; /* network order is big endian */ int oc_invert_xdr_double; int oc_curl_file_supported; -static int ocinitialized = 0; - -static int -ocinitialize(void) +int +ocinternalinitialize(void) { int stat = OC_NOERR; - char buf[BUFSIZE]; - char *env; - int len; /* Compute if we are same as network order v-a-v xdr */ #ifdef XDRBYTEORDER @@ -129,37 +140,6 @@ ocinitialize(void) } oc_loginit(); - /* read/write configuration file */ - env = getenv("HOME"); - if (env != NULL) { - len = strlen(env); - if (len >= BUFSIZE - DODSRC_SIZE) { - oc_log(LOGERR, "length of home directory is too long\n"); - stat = OC_EIO; - goto end; - } - strncpy(buf, env, BUFSIZE - 1); - buf[len] = '\0'; - strncat(buf, DODSRC, BUFSIZE - 1); - buf[len + DODSRC_SIZE] = '\0'; - - if (ocdebug > 1) - fprintf(stderr, "Your RC file: %s\n", buf); - - /* stat = OC_NOERR; */ - if (access(buf, R_OK) != 0) { - if (write_dodsrc(buf) != OC_NOERR) { - oc_log(LOGERR, "Error getting buffer\n"); - stat = OC_EIO; - } - } - - if (read_dodsrc(buf) != OC_NOERR) { - oc_log(LOGERR, "Error parsing buffer\n"); - stat = OC_EIO; - } - } - /* Determine if this version of curl supports "file://..." urls.*/ { const char* const* proto; /*weird*/ @@ -174,9 +154,6 @@ ocinitialize(void) } } - ocinitialized = 1; - -end: return THROW(stat); } @@ -191,11 +168,6 @@ ocopen(OCstate** statep, const char* url) memset((void*)&tmpurl,0,sizeof(tmpurl)); - if(!ocinitialized) { - stat=ocinitialize(); - if(stat) {THROWCHK(stat=OC_EBADURL); goto fail;} - } - if(!dapurlparse(url,&tmpurl)) {THROWCHK(stat=OC_EBADURL); goto fail;} stat = occurlopen(&curl); @@ -216,6 +188,10 @@ ocopen(OCstate** statep, const char* url) } state->packet = ocbytesnew(); ocbytessetalloc(state->packet,DFALTPACKETSIZE); /*initial reasonable size*/ + + /* set curl properties for this link */ + ocsetcurlproperties(state); + if(statep) *statep = state; return THROW(stat); @@ -528,3 +504,274 @@ ocupdatelastmodifieddata(OCstate* state) } return status; } + +/* + Set curl properties for link based on rc files +*/ +static void +ocsetcurlproperties(OCstate* state) +{ + CURL* curl = state->curl; + CURLcode cstat = CURLE_OK; + char* userName = NULL; + char* password = NULL; + int stat = OC_NOERR; + char *homepath; + char* path = NULL; + + /* Load dodsrc file */ + /* locate the configuration files */ + homepath = getenv("HOME"); + if (homepath!= NULL) { + path = (char*)malloc(strlen(homepath)+1+strlen(DODSRC)+1); + strcpy(path,homepath); + strcat(path,"/"); + strcat(path,DODSRC); + if (ocdebug > 1) + fprintf(stderr, "DODS RC file: %s\n", path); + if(read_dodsrc(path,state) != OC_NOERR) { + oc_log(LOGERR, "Error parsing %s\n",path); + goto fail; + } + } else {/*complain*/ + oc_log(LOGWARN,"Cannot find runtime .dodsrc configuration file"); + goto fail; + } + if(path != NULL) {free(path) ; path = NULL;} + + if (credentials_in_url(state->url.url)) { + char *result_url = NULL; + if(userName) free(userName); + if(password) free(password); + if (extract_credentials(state->url.url, &userName, &password, &result_url) != OC_NOERR) + goto fail; + dapurlclear(&state->url); + dapurlparse(result_url,&state->url); + } + +#ifdef ENABLE_RC + path = NULL; + if(defaultrc == NULL || strlen(defaultrc) == 0) { + if(defaultrc != NULL) free(defaultrc); + defaultrc = strdup(OPENDAPRC); + } + if(defaultrc[0] == '/') { + path = (char*)malloc(strlen(defaultrc)+1); + } else if (homepath!= NULL) { + path = (char*)malloc(strlen(homepath)+1+strlen(defaultrc)+1); + strcpy(path,homepath); + strcat(path,"/"); + strcat(path,defaultrc); + } + if(path!= NULL) { + FILE* rcfile; + ocrcerror err; + if (ocdebug > 1) + fprintf(stderr, "OPENDAP RC file: %s\n", path); + rcfile = fopen(path,"r"); + if(rcfile != NULL) { + if(!ocrc(rcfile,&ocrcroot,&err)) { + oc_log(LOGERR, "Error parsing %s; %s: lineno=%d charno=%d\n", + path,err.errmsg,err.lineno,err.charno); + goto fail; + } + } else { /* complain */ + oc_log(LOGWARN,"Cannot find runtime configuration file"); + goto fail; + } + loadrc(state,ocrcroot); + } else {/*complain*/ + oc_log(LOGWARN,"Cannot find runtime configuration file"); + goto fail; + } + if(path != NULL) {free(path) ; path = NULL;} + +#endif + + if(state->credentials.password) free(state->credentials.password); + state->credentials.password = password; password = NULL; + if(state->credentials.identity) free(state->credentials.identity); + state->credentials.identity = userName; userName = NULL; + + /* Set curl properties */ + if((stat=set_curl_flags(curl,state)) != OC_NOERR) goto fail; + return; + +fail: + if(path != NULL) free(path); + if(cstat != CURLE_OK) + oc_log(LOGERR, "curl error: %s", curl_easy_strerror(cstat)); + return; +} + +#ifdef ENABLE_RC +/* +Presumed format of the .rc file +... +curl : { + : { + compress: true|false + verify: true|false + cookies: + verbose: true|false + followlocation: true|false + maxredirs: + useragent: + credentials: { + identity: + password: + ssl-certificate: + ssl-key: + ssl-authority : + capath: + cookiefile: + cookiejar: + } //credentials + proxy: { + host: + port: + username: + password: + } //proxy + } + : { + ... + } +} // curl + +oc : { + : { // oc specific flags per url + ... + } +} //oc +... +*/ + +static void +processproxy(OCstate* state, ocrcnode* creds) +{ + ocrcnode* value; + if((value=ocrc_lookup(creds,"host"))) { + if(value->nodeclass == ocrc_const) + state->proxy.host = strdup(value->constvalue); + } else if((value=ocrc_lookup(creds,"port"))) { + if(value->nodeclass == ocrc_const && value->constclass == ocrc_number) + state->proxy.port = atoi(value->constvalue); + } else if((value=ocrc_lookup(creds,"username"))) { + if(value->nodeclass == ocrc_const) + state->proxy.username = strdup(value->constvalue); + } else if((value=ocrc_lookup(creds,"password"))) { + if(value->nodeclass == ocrc_const && value->constclass == ocrc_number) + state->proxy.password = strdup(value->constvalue); + } +} + +static void +processcreds(OCstate* state, ocrcnode* match) +{ + ocrcnode* value; + ocrcnode* creds = ocrc_lookup(match,"credentials"); + if((value=ocrc_lookup(match,"compress"))) { + if(value->nodeclass == ocrc_const) + state->credentials.identity = strdup(value->constvalue); + } else if((value=ocrc_lookup(match,"verify"))) { + if(value->nodeclass == ocrc_const && value->constclass == ocrc_number) + state->curlflags.verify = atoi(value->constvalue); + } else if((value=ocrc_lookup(creds,"identity"))) { + if(value->nodeclass == ocrc_const) + state->credentials.identity = strdup(value->constvalue); + } else if((value=ocrc_lookup(creds,"password"))) { + if(value->nodeclass == ocrc_const) + state->credentials.password = strdup(value->constvalue); + } else if((value=ocrc_lookup(creds,"ssl-certificate"))) { + if(value->nodeclass == ocrc_const) + state->credentials.ssl_certificate = strdup(value->constvalue); + } else if((value=ocrc_lookup(creds,"ssl-key"))) { + if(value->nodeclass == ocrc_const) + state->credentials.ssl_key = strdup(value->constvalue); + } else if((value=ocrc_lookup(creds,"ssl-authority "))) { + if(value->nodeclass == ocrc_const) + state->credentials.ssl_authority = strdup(value->constvalue); + } else if((value=ocrc_lookup(creds,"capath"))) { + if(value->nodeclass == ocrc_const) + state->credentials.capath = strdup(value->constvalue); + } else if((value=ocrc_lookup(creds,"cookiefile"))) { + if(value->nodeclass == ocrc_const) + state->credentials.cookiefile = strdup(value->constvalue); + } else if((value=ocrc_lookup(creds,"cookiejar"))) { + if(value->nodeclass == ocrc_const) + state->credentials.cookiejar = strdup(value->constvalue); + } +} + +static void +processmatch(OCstate* state, ocrcnode* match) +{ + ocrcnode* value; + if((value=ocrc_lookup(match,"compress"))) { + if(value == ocrc_const_true) state->curlflags.compress = 1; + } else if((value=ocrc_lookup(match,"verify"))) { + if(value == ocrc_const_true) state->curlflags.verify = 1; + } else if((value=ocrc_lookup(match,"cookies"))) { + if(value->nodeclass == ocrc_const) + state->curlflags.cookies = strdup(value->constvalue); + } else if((value=ocrc_lookup(match,"verbose"))) { + if(value == ocrc_const_true) state->curlflags.verbose = 1; + } else if((value=ocrc_lookup(match,"followlocation"))) { + if(value == ocrc_const_true) state->curlflags.followlocation = 1; + } else if((value=ocrc_lookup(match,"maxredirs"))) { + if(value->nodeclass == ocrc_const) + state->curlflags.cookies = strdup(value->constvalue); + } else if((value=ocrc_lookup(match,"useragent"))) { + if(value->nodeclass == ocrc_const) + state->curlflags.useragent = strdup(value->constvalue); + } else if((value=ocrc_lookup(match,"credentials"))) { + processcreds(state,value); + } else if((value=ocrc_lookup(match,"proxy"))) { + processproxy(state,value); + } +} + +static void +loadrc(OCstate* state, ocrcnode* root) +{ + /* Get curl : {...} for matching urls */ + char* url = state->url.base; + ocrcnode** matches; + ocrcnode* ocroot; + int i; + + ocrcnode* curlroot = ocrc_lookup(root,"curl"); + if(curlroot->nodeclass != ocrc_map) { + oc_log(LOGERR, "non-map oc in rc file"); + fprintf(stderr,"non-map oc in rc file\n"); + goto fail; + } + if(curlroot != NULL) { + int nmatches = ocrc_urlmatch(curlroot,url,&matches); + if(nmatches == 0) goto oc; + for(i=0;i"; diff --git a/oc/rc.c b/oc/rc.c index 3871f9abd..1da3ff9b4 100644 --- a/oc/rc.c +++ b/oc/rc.c @@ -19,13 +19,7 @@ /* These globals are where information from the .dodsrc file is stored. See the * functions in curlfunctions.c */ -int dods_compress = 0; -int dods_verify = 0; struct OCproxy *pstructProxy = NULL; -char *cook = NULL; - -char *userName = NULL; -char *password = NULL; /* The Username and password are in the URL if the URL is of the form: * http://:@/.... @@ -98,32 +92,11 @@ extract_credentials(const char *url, char **name, char **pw, char **result_url) } } -int -set_credentials(const char *name, const char *pw) -{ - if (!(name && pw)) { - oc_log(LOGERR, "Both username and password must be given."); - return OC_EIO; - } - - userName = malloc(sizeof(char) * (strlen(name) + 1)); - if (!userName) - return OC_ENOMEM; - strcpy(userName, name); - - password = malloc(sizeof(char) * (strlen(pw) + 1)); - if (!password) - return OC_ENOMEM; - strcpy(password, pw); - - return OC_NOERR; -} - /*Allows for a .dodsrc file to be read in and parsed in order to get authentication information*/ int -read_dodsrc(char *in_file_name) +read_dodsrc(char *in_file_name, OCstate* state) { - char *p; + char *p; char more[1024]; char *v; FILE *in_file; @@ -132,7 +105,7 @@ read_dodsrc(char *in_file_name) in_file = fopen(in_file_name, "r"); /* Open the file to read it */ if (in_file == NULL) { oc_log(LOGERR, "Could not open the .dodsrc file"); - return OC_EIO; + return OC_EPERM; } unsupported[0] = '\0'; @@ -143,48 +116,39 @@ read_dodsrc(char *in_file_name) *p = '\0'; if (strcmp(more, "USE_CACHE") == 0) { - strcat(unsupported,",USE_CACHE"); + /*strcat(unsupported,",USE_CACHE");*/ } else if (strcmp(more, "MAX_CACHE_SIZE") == 0) { - strcat(unsupported,",USE_CACHE"); + /*strcat(unsupported,",USE_CACHE");*/ } else if (strcmp(more, "MAX_CACHED_OBJ") == 0) { - strcat(unsupported,",MAX_CACHED_OBJ"); + /*strcat(unsupported,",MAX_CACHED_OBJ");*/ } else if (strcmp(more, "IGNORE_EXPIRES") == 0) { - strcat(unsupported,",IGNORE_EXPIRES"); + /*strcat(unsupported,",IGNORE_EXPIRES");*/ } else if (strcmp(more, "CACHE_ROOT") == 0) { - strcat(unsupported,",CACHE_ROOT"); + /*strcat(unsupported,",CACHE_ROOT");*/ } else if (strcmp(more, "DEFAULT_EXPIRES") == 0) { - strcat(unsupported,",DEFAULT_EXPIRES"); + /*strcat(unsupported,",DEFAULT_EXPIRES");*/ } else if (strcmp(more, "ALWAYS_VALIDATE") == 0) { - strcat(unsupported,",ALWAYS_VALIDATE"); + /*strcat(unsupported,",ALWAYS_VALIDATE");*/ } else if (strcmp(more, "DEFLATE") == 0) { /* int v_len = strlen(v); unused */ - dods_compress = atoi(v); + if(atoi(v)) state->curlflags.compress = 1; if (ocdebug > 1) - oc_log(LOGNOTE,"Compression: %d", dods_compress); + oc_log(LOGNOTE,"Compression: %d", state->curlflags.compress); } else if (strcmp(more, "VALIDATE_SSL") == 0) { - dods_verify = atoi(v); + if(atoi(v)) state->curlflags.verify = 1; if (ocdebug > 1) - oc_log(LOGNOTE,"SSL Verification: %d", dods_verify); + oc_log(LOGNOTE,"SSL Verification: %d", state->curlflags.verify); } else if (strcmp(more, "PROXY_SERVER") == 0) { char *host_pos = NULL; char *port_pos = NULL; /* int v_len = strlen(v); unused */ if(strlen(v) == 0) continue; /* nothing there*/ - pstructProxy = malloc(sizeof(struct OCproxy)); - if (!pstructProxy) - return OC_ENOMEM; - if (credentials_in_url(v)) { char *result_url = NULL; - extract_credentials(v, &pstructProxy->user, &pstructProxy->password, &result_url); + extract_credentials(v, &state->proxy.username, &state->proxy.password, &result_url); v = result_url; } - else { - pstructProxy->user = NULL; - pstructProxy->password = NULL; - } - /* allocating a bit more than likely needed ... */ host_pos = strstr(v, "http://"); if (host_pos) @@ -197,79 +161,82 @@ read_dodsrc(char *in_file_name) port_pos++; *port_sep = '\0'; host_len = strlen(host_pos); - pstructProxy->host = malloc(sizeof(char) * host_len + 1); - if (!pstructProxy->host) + state->proxy.host = malloc(sizeof(char) * host_len + 1); + if (!state->proxy.host) return OC_ENOMEM; - strncpy(pstructProxy->host, host_pos, host_len); - pstructProxy->host[host_len + 1] = '\0'; + strncpy(state->proxy.host, host_pos, host_len); + state->proxy.host[host_len + 1] = '\0'; - pstructProxy->port = atoi(port_pos); + state->proxy.port = atoi(port_pos); } else { int host_len = strlen(host_pos); - pstructProxy->host = malloc(sizeof(char) * host_len + 1); - if (!pstructProxy->host) + state->proxy.host = malloc(sizeof(char) * host_len + 1); + if (!state->proxy.host) return OC_ENOMEM; - strncpy(pstructProxy->host, host_pos, host_len); - pstructProxy->host[host_len + 1] = '\0'; + strncpy(state->proxy.host, host_pos, host_len); + state->proxy.host[host_len + 1] = '\0'; - pstructProxy->port = 80; + state->proxy.port = 80; } #if 0 - pstructProxy->host[v_len] = '\0'; + state->proxy.host[v_len] = '\0'; - pstructProxy->port = atoi(v); + state->proxy.port = atoi(v); s_len = strlen(v); - pstructProxy->user = malloc(sizeof(char) * s_len + 1); - if (!pstructProxy->user) + state->proxy.user = malloc(sizeof(char) * s_len + 1); + if (!state->proxy.user) return OC_ENOMEM; - strncpy(pstructProxy->user, v, s_len); - pstructProxy->user[s_len] = '\0'; + strncpy(state->proxy.user, v, s_len); + state->proxy.user[s_len] = '\0'; p_len = strlen(v); - pstructProxy->password = malloc(sizeof(char) * p_len + 1); - if (!pstructProxy->password) + state->proxy.password = malloc(sizeof(char) * p_len + 1); + if (!state->proxy.password) return OC_ENOMEM; - strncpy(pstructProxy->password, v, p_len); - pstructProxy->password[p_len] = '\0'; + strncpy(state->proxy.password, v, p_len); + state->proxy.password[p_len] = '\0'; #endif if (ocdebug > 1) { - oc_log(LOGNOTE,"host name: %s", pstructProxy->host); - oc_log(LOGNOTE,"user name: %s", pstructProxy->user); - oc_log(LOGNOTE,"password name: %s", pstructProxy->password); - oc_log(LOGNOTE,"port number: %d", pstructProxy->port); + oc_log(LOGNOTE,"host name: %s", state->proxy.host); + oc_log(LOGNOTE,"user name: %s", state->proxy.username); + oc_log(LOGNOTE,"password name: %s", state->proxy.password); + oc_log(LOGNOTE,"port number: %d", state->proxy.port); } } else if (strcmp(more, "NO_PROXY_FOR") == 0) { - strcat(unsupported,",NO_PROXY_FOR"); + /*strcat(unsupported,",NO_PROXY_FOR");*/ } else if (strcmp(more, "AIS_DATABASE") == 0) { - strcat(unsupported,",AIS_DATABASE"); + /*strcat(unsupported,",AIS_DATABASE");*/ } else if (strcmp(more, "COOKIE_JAR") == 0) { int v_len = strlen(v); - cook = malloc(sizeof(char) * v_len + 1); - if (!cook) + state->curlflags.cookies = malloc(sizeof(char) * v_len + 1); + if (!state->curlflags.cookies) return OC_ENOMEM; - strncpy(cook, v, v_len); - cook[v_len] = '\0'; + strncpy(state->curlflags.cookies, v, v_len); + state->curlflags.cookies[v_len] = '\0'; if (ocdebug > 1) - oc_log(LOGNOTE,"Cookie jar name: %s", cook); + oc_log(LOGNOTE,"Cookie jar name: %s", state->curlflags.cookies); } } } fclose(in_file); +#ifdef IGNORE if(unsupported[0] != '\0') { unsupported[0] = ' '; /* Elide leading comma */ oc_log(LOGNOTE,"Not currently supported in .dodsrc: %s",unsupported); } +#endif return OC_NOERR; } +#ifdef OBSOLETE /*Allows for a .dodsrc file to be created if one does not currently exist for default authentication * values*/ int @@ -317,3 +284,4 @@ write_dodsrc(char *out_file_name) return OC_NOERR; } +#endif diff --git a/oc/rc.h b/oc/rc.h index 85c21538b..7815230bc 100644 --- a/oc/rc.h +++ b/oc/rc.h @@ -8,13 +8,6 @@ #ifndef RC_H_ #define RC_H_ -struct OCproxy { - char *host; - int port; - char *user; - char *password; -}; - extern int dods_compress; extern int dods_verify; extern struct OCproxy *pstructProxy; @@ -24,13 +17,13 @@ extern char *password; extern int credentials_in_url(const char *url); extern int extract_credentials(const char *url, char **name, char **pw, char **result_url); -extern int set_credentials(const char *name, const char *pw); -extern int read_dodsrc(char *in_file_name); +extern int set_credentials(CURL* curl, struct OCcredentials* creds); +extern int read_dodsrc(char *in_file_name, OCstate* state); +#ifdef OBSOLETE extern int write_dodsrc(char *out_file_name); +#endif -extern int set_user_password(CURL* curl, const char *userC, - const char *passwordC); -extern int set_proxy(CURL* curl, struct OCproxy *pstructProxy); +extern int set_proxy(CURL* curl, struct OCproxy*); extern int set_cookies(CURL* curl, const char *cook); extern int set_verify(CURL* curl); extern int set_compression(CURL* curl); diff --git a/oc/read.c b/oc/read.c index 5c4503adc..9acb2e907 100644 --- a/oc/read.c +++ b/oc/read.c @@ -12,6 +12,7 @@ #include "ocdebug.h" #include "http.h" #include "read.h" +#include "rc.h" extern int oc_curl_file_supported; @@ -177,3 +178,5 @@ readfile(char* path, char* suffix, OCbytes* packet) close(fd); return THROW(stat); } + + From 6e19cb61f21fea21622f98fbb12c124951b96e0c Mon Sep 17 00:00:00 2001 From: Dennis Heimbigner Date: Wed, 23 Jun 2010 22:52:53 +0000 Subject: [PATCH 11/18] --- oc/Makefile.am | 37 +++--- oc/celex.c | 197 ++++++++++++++++++++++++++++++ oc/ceparse.c | 298 +++++++++++++++++++++++++++++++++++++++++++++ oc/curlfunctions.h | 22 ++++ 4 files changed, 535 insertions(+), 19 deletions(-) create mode 100644 oc/celex.c create mode 100644 oc/ceparse.c create mode 100644 oc/curlfunctions.h diff --git a/oc/Makefile.am b/oc/Makefile.am index f286984b0..666fc9016 100755 --- a/oc/Makefile.am +++ b/oc/Makefile.am @@ -18,47 +18,47 @@ CURL_LIBS = @CURL_LIBS@ # OC Sources SRC=\ -curlfunctions.c \ +oc.c \ +occontent.c \ +ocdata.c \ +ocdebug.c \ +ocdump.c \ +oclog.c \ +ocnode.c \ +ocutil.c \ +occompile.c \ dapparse.c \ daplex.c \ dapurl.c \ http.c \ -ocbytes.c \ -oc.c \ -occompile.c \ -occontent.c \ -ocdata.c \ -ocdebug.c \ -ocdrno.c \ -ocdump.c \ +read.c \ +curlfunctions.c \ ocinternal.c \ oclist.c \ -oclog.c \ -ocnode.c \ -ocutil.c \ -occlientparams.c \ +ocbytes.c \ +ocdrno.c \ ocxdr_stdio.c \ -rc.c \ -read.c +occlientparams.c \ +rc.c HDRS=\ +oc.h \ constraints.h \ +curlfunctions.h \ dapparselex.h \ dapurl.h \ http.h \ ocbytes.h \ +occlientparams.h \ occontent.h \ ocdata.h \ ocdatatypes.h \ ocdebug.h \ -ocdrno.h \ ocdump.h \ -oc.h \ ocinternal.h \ oclist.h \ oclog.h \ ocnode.h \ -occlientparams.h \ ocutil.h \ rc.h \ read.h @@ -87,4 +87,3 @@ daptab.c daptab.h: dap.y mv dap.tab.c daptab.c; mv dap.tab.h daptab.h test: check - diff --git a/oc/celex.c b/oc/celex.c new file mode 100644 index 000000000..33e796292 --- /dev/null +++ b/oc/celex.c @@ -0,0 +1,197 @@ +/* Copyright 2009, UCAR/Unidata and OPeNDAP, Inc. + See the COPYRIGHT file for more information. */ + +#include "ceparselex.h" + +/* Forward */ +static void dumptoken(CElexstate* lexstate); +static int tohex(int c); +static void ceaddyytext(CElexstate* lex, int c); + +/****************************************************/ +static char* worddelims = + "{}[]:;=,"; + +/* Define 1 and > 1st legal characters */ +static char* wordchars1 = + "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-+_/%\\"; +static char* wordcharsn = + "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-+_/%\\"; + +/* Number characters */ +static char* numchars1="+-0123456789"; +static char* numcharsn="Ee.+-0123456789"; + +/**************************************************/ + +int +celex(YYSTYPE* lvalp, CEparsestate* state) +{ + CElexstate* lexstate = state->lexstate; + int token; + int c; + char* p=lexstate->next; + token = 0; + ncbytesclear(lexstate->yytext); + p=lexstate->next; + while(token == 0 && (c=*p)) { + if(c <= ' ' || c >= '\177') {p++; continue;} + if(c == '"') { + int more = 1; + /* We have a SCAN_STRINGCONST */ + while(more && (c=*(++p))) { + switch (c) { + case '"': p++; more=0; break; + case '\\': + c=*(++p); + switch (c) { + case 'r': c = '\r'; break; + case 'n': c = '\n'; break; + case 'f': c = '\f'; break; + case 't': c = '\t'; break; + case 'x': { + int d1,d2; + c = '?'; + ++p; + d1 = tohex(*p++); + if(d1 < 0) { + ceerror(state,"Illegal \\xDD in SCAN_STRING"); + } else { + d2 = tohex(*p++); + if(d2 < 0) { + ceerror(state,"Illegal \\xDD in SCAN_STRING"); + } else { + c=(((unsigned int)d1)<<4) | (unsigned int)d2; + } + } + } break; + default: break; + } + break; + default: break; + } + ceaddyytext(lexstate,c); + } + token=SCAN_STRINGCONST; + } else if(strchr(numchars1,c) != NULL) { + /* we might have a SCAN_NUMBERCONST */ + int isnumber = 0; + double number; + char* yytext; + ceaddyytext(lexstate,c); + for(p++;(c=*p);p++) { + if(strchr(numcharsn,c) == NULL) break; + ceaddyytext(lexstate,c); + } + /* See if this is a number */ + yytext = ncbytescontents(lexstate->yytext); + if(sscanf(yytext,"%lg",&number) == 1 + || sscanf(yytext,"%lG",&number) == 1) + isnumber = 1; /* maybe */ + /* A number followed by an id char is assumed to just be + a funny id */ + if(isnumber && (*p == '\0' || strchr(wordcharsn,*p) == NULL)) { + token = SCAN_NUMBERCONST; + } else { + /* Now, if the funny word has a "." in it, + we have to back up to that dot */ + char* dotpoint = strchr(yytext,'.'); + if(dotpoint != NULL) { + p = dotpoint; + *dotpoint = '\0'; + } + token = SCAN_WORD; + } + } else if(strchr(wordchars1,c) != NULL) { + /* we have a SCAN_WORD */ + ceaddyytext(lexstate,c); + for(p++;(c=*p);p++) { + if(strchr(wordcharsn,c) == NULL) break; + ceaddyytext(lexstate,c); + } + token=SCAN_WORD; + } else { + /* we have a single char token */ + token = c; + p++; + } + } + lexstate->next = p; + strncpy(lexstate->lasttokentext,ncbytescontents(lexstate->yytext),MAX_TOKEN_LENGTH); + lexstate->lasttoken = token; + if(cedebug) dumptoken(lexstate); + + /*Put return value onto Bison stack*/ + + if(ncbyteslength(lexstate->yytext) == 0) + *lvalp = NULL; + else { + *lvalp = ncbytesdup(lexstate->yytext); + nclistpush(lexstate->reclaim,(ncelem)*lvalp); + } + + return token; +} + +static void +ceaddyytext(CElexstate* lex, int c) +{ + ncbytesappend(lex->yytext,(char)c); +} + +static int +tohex(int c) +{ + if(c >= 'a' && c <= 'f') return (c - 'a') + 0xa; + if(c >= 'A' && c <= 'F') return (c - 'A') + 0xa; + if(c >= '0' && c <= '9') return (c - '0'); + return -1; +} + +static void +dumptoken(CElexstate* lexstate) +{ + switch (lexstate->lasttoken) { + case SCAN_STRINGCONST: + fprintf(stderr,"TOKEN = |\"%s\"|\n",lexstate->lasttokentext); + break; + case SCAN_WORD: + case SCAN_NUMBERCONST: + default: + fprintf(stderr,"TOKEN = |%s|\n",lexstate->lasttokentext); + break; + } +} + +void +celexinit(char* input, CElexstate** lexstatep) +{ + CElexstate* lexstate = (CElexstate*)malloc(sizeof(CElexstate)); + if(lexstatep) *lexstatep = lexstate; + if(lexstate == NULL) return; + memset((void*)lexstate,0,sizeof(CElexstate)); + lexstate->input = strdup(input); + lexstate->next = lexstate->input; + lexstate->yytext = ncbytesnew(); + lexstate->reclaim = nclistnew(); +} + +void +celexcleanup(CElexstate** lexstatep) +{ + unsigned int i; + CElexstate* lexstate = *lexstatep; + if(lexstate == NULL) return; + if(lexstate->input != NULL) free(lexstate->input); + if(lexstate->reclaim != NULL) { + while(nclistlength(lexstate->reclaim) > 0) { + char* word = (char*)nclistpop(lexstate->reclaim); + if(word) free(word); + } + nclistfree(lexstate->reclaim); + } + ncbytesfree(lexstate->yytext); + free(lexstate); + *lexstatep = NULL; +} + diff --git a/oc/ceparse.c b/oc/ceparse.c new file mode 100644 index 000000000..1e7246e86 --- /dev/null +++ b/oc/ceparse.c @@ -0,0 +1,298 @@ +/* Copyright 2009, UCAR/Unidata and OPeNDAP, Inc. + See the COPYRIGHT file for more information. */ + +/* Parser actions for constraint expressions */ + +/* Since oc does not use the constraint parser, + they functions all just abort if called. +*/ + +#include "ceparselex.h" + +static Object collectlist(Object list0, Object decl); + +void +projections(CEparsestate* state, Object list0) +{ + state->projections = (NClist*)list0; +#ifdef DEBUG +fprintf(stderr," ce.projections: %s\n", + dumpprojections(state->projections)); +#endif +} + +void +selections(CEparsestate* state, Object list0) +{ + state->selections = (NClist*)list0; +#ifdef DEBUG +fprintf(stderr," ce.selections: %s\n", + dumpselections(state->selections)); +#endif +} + + +Object +projectionlist(CEparsestate* state, Object list0, Object decl) +{ + return collectlist(list0,decl); +} + +Object +projection(CEparsestate* state, Object segmentlist) +{ + NCprojection* p = createncprojection(); + p->segments = (NClist*)segmentlist; +#ifdef DEBUG +fprintf(stderr," ce.projection: %s\n", + dumpprojection1(p)); +#endif + return p; +} + +Object +segmentlist(CEparsestate* state, Object list0, Object decl) +{ + return collectlist(list0,decl); +} + +Object +segment(CEparsestate* state, Object name, Object slices0) +{ + NCsegment* segment = createncsegment(); + NClist* slices = (NClist*)slices0; + segment->name = strdup((char*)name); + segment->slicerank = nclistlength(slices); + if(slices != NULL) { + int i; + ASSERT(nclistlength(slices) > 0); + for(i=0;islices[i] = *slice; + free(slice); + } + segment->slicesdefined = 1; + } else + segment->slicesdefined = 0; +#ifdef DEBUG +fprintf(stderr," ce.segment: %s\n", + dumpsegment(segment)); +#endif + return segment; +} + +Object +array_indices(CEparsestate* state, Object list0, Object decl) +{ + return collectlist(list0,decl); +} + +Object +range(CEparsestate* state, Object sfirst, Object sstride, Object slast) +{ + NCslice* slice = createncslice(); + unsigned long first,stride,last; + + /* Note: that incoming arguments are strings; we must convert to size_t; + but we do know they are legal integers or NULL */ + sscanf((char*)sfirst,"%lu",&first); /* always defined */ + if(slast != NULL) + sscanf((char*)slast,"%lu",&last); + else + last = first; + if(sstride != NULL) + sscanf((char*)sstride,"%lu",&stride); + else + stride = 1; /* default */ + + if(stride == 0) + ceerror(state,"Illegal index for range stride"); + if(last < first) + ceerror(state,"Illegal index for range last index"); + slice->first = first; + slice->stride = stride; + slice->stop = last + 1; + slice->length = slice->stop - slice->first; + slice->count = slice->length / slice->stride; +#ifdef DEBUG +fprintf(stderr," ce.slice: %s\n", + dumpslice(slice)); +#endif + return slice; +} + +/* Selection Procedures */ + +Object +selectionlist(CEparsestate* state, Object list0, Object decl) +{ + return collectlist(list0,decl); +} + +Object +sel_clause(CEparsestate* state, int selcase, + Object path0, Object relop0, Object values) +{ + NCselection* sel = createncselection(); + sel->operator = (SelectionTag)relop0; + sel->segments = (NClist*)path0; + sel->values = (NClist*)values; + sel->leaf = NULL; + return sel; +} + +Object +selectionpath(CEparsestate* state, Object list0, Object segment) +{ + ASSERT(segment != NULL); + return collectlist(list0,segment); +} + +Object +arrayelement(CEparsestate* state, Object name, Object index) +{ + NCsegment* segment = createncsegment(); + segment->name = (char*)name; + if(index != null) {/* create a simple slice */ + /* Make sure this is a number */ + NCslice* slice = &segment->slices[0]; + if(sscanf((char*)index,"%lu",slice->first) != 1) + ceerror(state,"Illegal index for selection variable"); + slice->count = 1; + slice->length = 1; + slice->stride = 1; + slice->stop = slice->first+1; + slice->declsize = 0; + segment->slicerank = 1; + segment->slicesdefined = 1; + } + return segment; +} + + +Object +function(CEparsestate* state, Object fcnname, Object args) +{ + NCselection* sel = createncselection(); + sel->operator = ST_FCN; + sel->fcn = nulldup((char*)fcnname); + return sel; +} + +Object +arg_list(CEparsestate* state, Object list0, Object decl) +{ + return collectlist(list0,decl); +} + +Object +value_list(CEparsestate* state, Object list0, Object decl) +{ + return collectlist(list0,decl); +} + +Object +value(CEparsestate* state, Object text, int tag) +{ + NCvalue* value = createncvalue(); + switch (tag) { + case SCAN_STRINGCONST: + value->kind = ST_STR; + value->value.text = text; + break; + case SCAN_NUMBERCONST: + if(sscanf(text,"%lld",&value->value.intvalue)==1) + value->kind = ST_INT; + else if(sscanf(text,"%lg",&value->value.floatvalue)==1) + value->kind = ST_FLOAT; + else { + sscanf(text,"%lG",&value->value.floatvalue); + value->kind = ST_FLOAT; + } + break; + case SCAN_WORD: + default: + /* In this case, text is actually a path list */ + value->kind = ST_VAR; + value->value.var.segments = (NClist*)text; /* fill-in cdfnode later */ + break; + } + return value; +} + +static Object +collectlist(Object list0, Object decl) +{ + NClist* list = (NClist*)list0; + if(list == NULL) list = nclistnew(); + nclistpush(list,(ncelem)decl); + return list; +} + +int +ceerror(CEparsestate* state, char* msg) +{ + strcpy(state->errorbuf,msg); + state->errorcode=1; + return 0; +} + +static void +ce_parse_cleanup(CEparsestate* state) +{ + celexcleanup(&state->lexstate); /* will free */ +} + +static CEparsestate* +ce_parse_init(char* input, int ncconstraint) +{ + CEparsestate* state = NULL; + if(input==NULL) { + ceerror(state,"ce_parse_init: no input buffer"); + } else { + state = (CEparsestate*)emalloc(sizeof(CEparsestate)); + MEMCHECK(state,(CEparsestate*)NULL); + memset((void*)state,0,sizeof(CEparsestate)); /* Zero memory*/ + state->errorbuf[0] = '\0'; + state->errorcode = 0; + celexinit(input,&state->lexstate); + state->projections = NULL; + state->selections = NULL; + state->ncconstraint = ncconstraint; + } + return state; +} + + +/* Wrapper for ceparse */ +int +ncceparse(char* input, int ncconstraint, + NClist** projectionsp, NClist** selectionsp, char** errmsgp) +{ + CEparsestate* state; + int errcode = 0; + + if(input != NULL) { +#ifdef DEBUG +fprintf(stderr,"ncceparse: input=%s\n",input); +#endif + state = ce_parse_init(input,ncconstraint); + if(ceparse(state) == 0) { +#ifdef DEBUG +if(state->projections) +fprintf(stderr,"ncceparse: projections=%s\n",dumpprojections(state->projections)); +#endif + if(projectionsp) *projectionsp = state->projections; +#ifdef DEBUG +if(state->selections) +fprintf(stderr,"ncceparse: selections=%s\n",dumpselections(state->selections)); +#endif + if(selectionsp) *selectionsp = state->selections; + } else { + if(errmsgp) *errmsgp = nulldup(state->errorbuf); + } + errcode = state->errorcode; + ce_parse_cleanup(state); + } + return errcode; +} diff --git a/oc/curlfunctions.h b/oc/curlfunctions.h new file mode 100644 index 000000000..88bd4d184 --- /dev/null +++ b/oc/curlfunctions.h @@ -0,0 +1,22 @@ +/* + * rc.h + * + * Created on: Mar 5, 2009 + * Author: rikki + */ + +#ifndef _CURLFUNCTION_H_ +#define _CURLFUNCTION_H_ + +extern int set_curl_flags(CURL*, OCstate*); +extern int set_user_password(CURL*, const char *userC, const char *passwordC); +extern int set_proxy(CURL*, struct OCproxy*); +extern int set_cookies(CURL*, const char *cook); +extern int set_verify(CURL* curl); +extern int set_compression(CURL* curl); +extern int set_credentials(CURL*, struct OCcredentials*); + +#endif /*_CURLFUNCTION_H_*/ + + + From 2ddea973a35b7f2b74bdc04a6c70265b4224388c Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Thu, 24 Jun 2010 08:52:03 +0000 Subject: [PATCH 12/18] fixed valgrind tests some more --- libsrc4/run_valgrind_tests.sh | 2 +- nc_test4/run_valgrind_tests.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libsrc4/run_valgrind_tests.sh b/libsrc4/run_valgrind_tests.sh index fa6e76a78..723d8f398 100755 --- a/libsrc4/run_valgrind_tests.sh +++ b/libsrc4/run_valgrind_tests.sh @@ -9,7 +9,7 @@ echo "" echo "Testing programs with valgrind..." # These are my test programs. -list='tst_h_dimscales tst_h_vl2 tst_h_files '\ +list='tst_h_dimscales tst_h_files '\ 'tst_h_atts2 tst_h_dimscales2 tst_h_enums '\ 'tst_h_grps tst_h_wrt_cmp tst_h_rd_cmp tst_h_vl tst_h_atts '\ 'tst_h_dimscales3 tst_h_files2 tst_h_compounds '\ diff --git a/nc_test4/run_valgrind_tests.sh b/nc_test4/run_valgrind_tests.sh index 4fad27a04..57918a063 100755 --- a/nc_test4/run_valgrind_tests.sh +++ b/nc_test4/run_valgrind_tests.sh @@ -10,7 +10,7 @@ echo "Testing programs with valgrind..." # These are my test programs. list='tst_v2 '\ -'tst_vars2 tst_atts tst_atts2 ' +'tst_vars2 tst_atts tst_atts2 tst_h_vl2' # These don't work yet: tst_h_vars3 # tst_h_strings tst_h_atts3 tst_h_vars2 tst_vars tst_fills tst_chunks From 576b6a90d9b3b8fc1a0b04c3ec68d930fd76db2e Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Thu, 24 Jun 2010 09:43:53 +0000 Subject: [PATCH 13/18] rolled back changes version 129:128 and 124:123 to get back to a working build --- oc/Make0 | 19 ++- oc/Makefile.am | 37 ++--- oc/celex.c | 197 -------------------------- oc/ceparse.c | 298 --------------------------------------- oc/curlfunctions.c | 64 ++------- oc/curlfunctions.h | 22 --- oc/dap.y | 90 ++++++------ oc/daplex.c | 4 +- oc/dapparse.c | 36 ++--- oc/dapparselex.h | 34 ++--- oc/http.c | 50 +++++++ oc/oc.c | 52 +------ oc/oc.h | 6 - oc/ocinternal.c | 345 +++++++-------------------------------------- oc/ocinternal.h | 32 ----- oc/ocutil.c | 2 - oc/rc.c | 132 ++++++++++------- oc/rc.h | 17 ++- oc/read.c | 3 - 19 files changed, 316 insertions(+), 1124 deletions(-) delete mode 100644 oc/celex.c delete mode 100644 oc/ceparse.c delete mode 100644 oc/curlfunctions.h diff --git a/oc/Make0 b/oc/Make0 index b4ddf8c22..0c3c29f99 100755 --- a/oc/Make0 +++ b/oc/Make0 @@ -6,11 +6,10 @@ all:: makeoc:: rm -f ${THISDIR}/*.[chy] for f in ${OCDIR}/*.[chy]; do \ - base=`basename $$f` ; \ - cat $$f | tr -d ' ' >${THISDIR}/$$base; \ - done + base=`basename $$f` ; \ + cat $$f | tr -d ' ' >${THISDIR}/$$base; done rm -f i.* apitest.* getoc.* imain.* main.* - rm -f config.h dap.tab.c dap.tab.h ceparselex.* + rm -f config.h dap.tab.c dap.tab.h ce.y ceparselex.* rm -f ocshadow.* rm -f octest.c rm -f ocinternal.h @@ -18,22 +17,20 @@ makeoc:: < ${OCDIR}/ocinternal.h | tr -d '\r' >./ocinternal.h diffoc:: - for f in ${OCDIR}/*.[chy] ; do \ + for f in ${THISDIR}/*.[chy] ; do \ x=`basename $$f | tr -d ' ' ` ; \ if test "x$$x" = "xdaptab.c"; then continue ; fi ; \ if test -e ${THISDIR}/$$x ; then \ - diff -q ${THISDIR}/$$x $$f ; \ - else \ - echo "new file: $$f"; \ + diff -qw ${THISDIR}/$$x $$f ; \ fi; \ done for f in ${OCDIR}/*.[chy] ; do \ x=`basename $$f|tr -d ' ' ` ; \ if test "x$$x" = "xdaptab.c"; then continue ; fi ; \ if test -e ${THISDIR}/$$x ; then \ - if ! diff -q ${THISDIR}/$$x $$f > /dev/null ; then \ - echo diff ${THISDIR}/$$x $$f ;\ - diff -bBw ${THISDIR}/$$x $$f ; \ + if ! diff -qw ${THISDIR}/$$x $$f > /dev/null ; then \ + echo diff -w ${THISDIR}/$$x $$f ;\ + diff -w ${THISDIR}/$$x $$f ; \ fi; \ fi; \ done diff --git a/oc/Makefile.am b/oc/Makefile.am index 666fc9016..f286984b0 100755 --- a/oc/Makefile.am +++ b/oc/Makefile.am @@ -18,47 +18,47 @@ CURL_LIBS = @CURL_LIBS@ # OC Sources SRC=\ -oc.c \ -occontent.c \ -ocdata.c \ -ocdebug.c \ -ocdump.c \ -oclog.c \ -ocnode.c \ -ocutil.c \ -occompile.c \ +curlfunctions.c \ dapparse.c \ daplex.c \ dapurl.c \ http.c \ -read.c \ -curlfunctions.c \ +ocbytes.c \ +oc.c \ +occompile.c \ +occontent.c \ +ocdata.c \ +ocdebug.c \ +ocdrno.c \ +ocdump.c \ ocinternal.c \ oclist.c \ -ocbytes.c \ -ocdrno.c \ -ocxdr_stdio.c \ +oclog.c \ +ocnode.c \ +ocutil.c \ occlientparams.c \ -rc.c +ocxdr_stdio.c \ +rc.c \ +read.c HDRS=\ -oc.h \ constraints.h \ -curlfunctions.h \ dapparselex.h \ dapurl.h \ http.h \ ocbytes.h \ -occlientparams.h \ occontent.h \ ocdata.h \ ocdatatypes.h \ ocdebug.h \ +ocdrno.h \ ocdump.h \ +oc.h \ ocinternal.h \ oclist.h \ oclog.h \ ocnode.h \ +occlientparams.h \ ocutil.h \ rc.h \ read.h @@ -87,3 +87,4 @@ daptab.c daptab.h: dap.y mv dap.tab.c daptab.c; mv dap.tab.h daptab.h test: check + diff --git a/oc/celex.c b/oc/celex.c deleted file mode 100644 index 33e796292..000000000 --- a/oc/celex.c +++ /dev/null @@ -1,197 +0,0 @@ -/* Copyright 2009, UCAR/Unidata and OPeNDAP, Inc. - See the COPYRIGHT file for more information. */ - -#include "ceparselex.h" - -/* Forward */ -static void dumptoken(CElexstate* lexstate); -static int tohex(int c); -static void ceaddyytext(CElexstate* lex, int c); - -/****************************************************/ -static char* worddelims = - "{}[]:;=,"; - -/* Define 1 and > 1st legal characters */ -static char* wordchars1 = - "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-+_/%\\"; -static char* wordcharsn = - "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-+_/%\\"; - -/* Number characters */ -static char* numchars1="+-0123456789"; -static char* numcharsn="Ee.+-0123456789"; - -/**************************************************/ - -int -celex(YYSTYPE* lvalp, CEparsestate* state) -{ - CElexstate* lexstate = state->lexstate; - int token; - int c; - char* p=lexstate->next; - token = 0; - ncbytesclear(lexstate->yytext); - p=lexstate->next; - while(token == 0 && (c=*p)) { - if(c <= ' ' || c >= '\177') {p++; continue;} - if(c == '"') { - int more = 1; - /* We have a SCAN_STRINGCONST */ - while(more && (c=*(++p))) { - switch (c) { - case '"': p++; more=0; break; - case '\\': - c=*(++p); - switch (c) { - case 'r': c = '\r'; break; - case 'n': c = '\n'; break; - case 'f': c = '\f'; break; - case 't': c = '\t'; break; - case 'x': { - int d1,d2; - c = '?'; - ++p; - d1 = tohex(*p++); - if(d1 < 0) { - ceerror(state,"Illegal \\xDD in SCAN_STRING"); - } else { - d2 = tohex(*p++); - if(d2 < 0) { - ceerror(state,"Illegal \\xDD in SCAN_STRING"); - } else { - c=(((unsigned int)d1)<<4) | (unsigned int)d2; - } - } - } break; - default: break; - } - break; - default: break; - } - ceaddyytext(lexstate,c); - } - token=SCAN_STRINGCONST; - } else if(strchr(numchars1,c) != NULL) { - /* we might have a SCAN_NUMBERCONST */ - int isnumber = 0; - double number; - char* yytext; - ceaddyytext(lexstate,c); - for(p++;(c=*p);p++) { - if(strchr(numcharsn,c) == NULL) break; - ceaddyytext(lexstate,c); - } - /* See if this is a number */ - yytext = ncbytescontents(lexstate->yytext); - if(sscanf(yytext,"%lg",&number) == 1 - || sscanf(yytext,"%lG",&number) == 1) - isnumber = 1; /* maybe */ - /* A number followed by an id char is assumed to just be - a funny id */ - if(isnumber && (*p == '\0' || strchr(wordcharsn,*p) == NULL)) { - token = SCAN_NUMBERCONST; - } else { - /* Now, if the funny word has a "." in it, - we have to back up to that dot */ - char* dotpoint = strchr(yytext,'.'); - if(dotpoint != NULL) { - p = dotpoint; - *dotpoint = '\0'; - } - token = SCAN_WORD; - } - } else if(strchr(wordchars1,c) != NULL) { - /* we have a SCAN_WORD */ - ceaddyytext(lexstate,c); - for(p++;(c=*p);p++) { - if(strchr(wordcharsn,c) == NULL) break; - ceaddyytext(lexstate,c); - } - token=SCAN_WORD; - } else { - /* we have a single char token */ - token = c; - p++; - } - } - lexstate->next = p; - strncpy(lexstate->lasttokentext,ncbytescontents(lexstate->yytext),MAX_TOKEN_LENGTH); - lexstate->lasttoken = token; - if(cedebug) dumptoken(lexstate); - - /*Put return value onto Bison stack*/ - - if(ncbyteslength(lexstate->yytext) == 0) - *lvalp = NULL; - else { - *lvalp = ncbytesdup(lexstate->yytext); - nclistpush(lexstate->reclaim,(ncelem)*lvalp); - } - - return token; -} - -static void -ceaddyytext(CElexstate* lex, int c) -{ - ncbytesappend(lex->yytext,(char)c); -} - -static int -tohex(int c) -{ - if(c >= 'a' && c <= 'f') return (c - 'a') + 0xa; - if(c >= 'A' && c <= 'F') return (c - 'A') + 0xa; - if(c >= '0' && c <= '9') return (c - '0'); - return -1; -} - -static void -dumptoken(CElexstate* lexstate) -{ - switch (lexstate->lasttoken) { - case SCAN_STRINGCONST: - fprintf(stderr,"TOKEN = |\"%s\"|\n",lexstate->lasttokentext); - break; - case SCAN_WORD: - case SCAN_NUMBERCONST: - default: - fprintf(stderr,"TOKEN = |%s|\n",lexstate->lasttokentext); - break; - } -} - -void -celexinit(char* input, CElexstate** lexstatep) -{ - CElexstate* lexstate = (CElexstate*)malloc(sizeof(CElexstate)); - if(lexstatep) *lexstatep = lexstate; - if(lexstate == NULL) return; - memset((void*)lexstate,0,sizeof(CElexstate)); - lexstate->input = strdup(input); - lexstate->next = lexstate->input; - lexstate->yytext = ncbytesnew(); - lexstate->reclaim = nclistnew(); -} - -void -celexcleanup(CElexstate** lexstatep) -{ - unsigned int i; - CElexstate* lexstate = *lexstatep; - if(lexstate == NULL) return; - if(lexstate->input != NULL) free(lexstate->input); - if(lexstate->reclaim != NULL) { - while(nclistlength(lexstate->reclaim) > 0) { - char* word = (char*)nclistpop(lexstate->reclaim); - if(word) free(word); - } - nclistfree(lexstate->reclaim); - } - ncbytesfree(lexstate->yytext); - free(lexstate); - *lexstatep = NULL; -} - diff --git a/oc/ceparse.c b/oc/ceparse.c deleted file mode 100644 index 1e7246e86..000000000 --- a/oc/ceparse.c +++ /dev/null @@ -1,298 +0,0 @@ -/* Copyright 2009, UCAR/Unidata and OPeNDAP, Inc. - See the COPYRIGHT file for more information. */ - -/* Parser actions for constraint expressions */ - -/* Since oc does not use the constraint parser, - they functions all just abort if called. -*/ - -#include "ceparselex.h" - -static Object collectlist(Object list0, Object decl); - -void -projections(CEparsestate* state, Object list0) -{ - state->projections = (NClist*)list0; -#ifdef DEBUG -fprintf(stderr," ce.projections: %s\n", - dumpprojections(state->projections)); -#endif -} - -void -selections(CEparsestate* state, Object list0) -{ - state->selections = (NClist*)list0; -#ifdef DEBUG -fprintf(stderr," ce.selections: %s\n", - dumpselections(state->selections)); -#endif -} - - -Object -projectionlist(CEparsestate* state, Object list0, Object decl) -{ - return collectlist(list0,decl); -} - -Object -projection(CEparsestate* state, Object segmentlist) -{ - NCprojection* p = createncprojection(); - p->segments = (NClist*)segmentlist; -#ifdef DEBUG -fprintf(stderr," ce.projection: %s\n", - dumpprojection1(p)); -#endif - return p; -} - -Object -segmentlist(CEparsestate* state, Object list0, Object decl) -{ - return collectlist(list0,decl); -} - -Object -segment(CEparsestate* state, Object name, Object slices0) -{ - NCsegment* segment = createncsegment(); - NClist* slices = (NClist*)slices0; - segment->name = strdup((char*)name); - segment->slicerank = nclistlength(slices); - if(slices != NULL) { - int i; - ASSERT(nclistlength(slices) > 0); - for(i=0;islices[i] = *slice; - free(slice); - } - segment->slicesdefined = 1; - } else - segment->slicesdefined = 0; -#ifdef DEBUG -fprintf(stderr," ce.segment: %s\n", - dumpsegment(segment)); -#endif - return segment; -} - -Object -array_indices(CEparsestate* state, Object list0, Object decl) -{ - return collectlist(list0,decl); -} - -Object -range(CEparsestate* state, Object sfirst, Object sstride, Object slast) -{ - NCslice* slice = createncslice(); - unsigned long first,stride,last; - - /* Note: that incoming arguments are strings; we must convert to size_t; - but we do know they are legal integers or NULL */ - sscanf((char*)sfirst,"%lu",&first); /* always defined */ - if(slast != NULL) - sscanf((char*)slast,"%lu",&last); - else - last = first; - if(sstride != NULL) - sscanf((char*)sstride,"%lu",&stride); - else - stride = 1; /* default */ - - if(stride == 0) - ceerror(state,"Illegal index for range stride"); - if(last < first) - ceerror(state,"Illegal index for range last index"); - slice->first = first; - slice->stride = stride; - slice->stop = last + 1; - slice->length = slice->stop - slice->first; - slice->count = slice->length / slice->stride; -#ifdef DEBUG -fprintf(stderr," ce.slice: %s\n", - dumpslice(slice)); -#endif - return slice; -} - -/* Selection Procedures */ - -Object -selectionlist(CEparsestate* state, Object list0, Object decl) -{ - return collectlist(list0,decl); -} - -Object -sel_clause(CEparsestate* state, int selcase, - Object path0, Object relop0, Object values) -{ - NCselection* sel = createncselection(); - sel->operator = (SelectionTag)relop0; - sel->segments = (NClist*)path0; - sel->values = (NClist*)values; - sel->leaf = NULL; - return sel; -} - -Object -selectionpath(CEparsestate* state, Object list0, Object segment) -{ - ASSERT(segment != NULL); - return collectlist(list0,segment); -} - -Object -arrayelement(CEparsestate* state, Object name, Object index) -{ - NCsegment* segment = createncsegment(); - segment->name = (char*)name; - if(index != null) {/* create a simple slice */ - /* Make sure this is a number */ - NCslice* slice = &segment->slices[0]; - if(sscanf((char*)index,"%lu",slice->first) != 1) - ceerror(state,"Illegal index for selection variable"); - slice->count = 1; - slice->length = 1; - slice->stride = 1; - slice->stop = slice->first+1; - slice->declsize = 0; - segment->slicerank = 1; - segment->slicesdefined = 1; - } - return segment; -} - - -Object -function(CEparsestate* state, Object fcnname, Object args) -{ - NCselection* sel = createncselection(); - sel->operator = ST_FCN; - sel->fcn = nulldup((char*)fcnname); - return sel; -} - -Object -arg_list(CEparsestate* state, Object list0, Object decl) -{ - return collectlist(list0,decl); -} - -Object -value_list(CEparsestate* state, Object list0, Object decl) -{ - return collectlist(list0,decl); -} - -Object -value(CEparsestate* state, Object text, int tag) -{ - NCvalue* value = createncvalue(); - switch (tag) { - case SCAN_STRINGCONST: - value->kind = ST_STR; - value->value.text = text; - break; - case SCAN_NUMBERCONST: - if(sscanf(text,"%lld",&value->value.intvalue)==1) - value->kind = ST_INT; - else if(sscanf(text,"%lg",&value->value.floatvalue)==1) - value->kind = ST_FLOAT; - else { - sscanf(text,"%lG",&value->value.floatvalue); - value->kind = ST_FLOAT; - } - break; - case SCAN_WORD: - default: - /* In this case, text is actually a path list */ - value->kind = ST_VAR; - value->value.var.segments = (NClist*)text; /* fill-in cdfnode later */ - break; - } - return value; -} - -static Object -collectlist(Object list0, Object decl) -{ - NClist* list = (NClist*)list0; - if(list == NULL) list = nclistnew(); - nclistpush(list,(ncelem)decl); - return list; -} - -int -ceerror(CEparsestate* state, char* msg) -{ - strcpy(state->errorbuf,msg); - state->errorcode=1; - return 0; -} - -static void -ce_parse_cleanup(CEparsestate* state) -{ - celexcleanup(&state->lexstate); /* will free */ -} - -static CEparsestate* -ce_parse_init(char* input, int ncconstraint) -{ - CEparsestate* state = NULL; - if(input==NULL) { - ceerror(state,"ce_parse_init: no input buffer"); - } else { - state = (CEparsestate*)emalloc(sizeof(CEparsestate)); - MEMCHECK(state,(CEparsestate*)NULL); - memset((void*)state,0,sizeof(CEparsestate)); /* Zero memory*/ - state->errorbuf[0] = '\0'; - state->errorcode = 0; - celexinit(input,&state->lexstate); - state->projections = NULL; - state->selections = NULL; - state->ncconstraint = ncconstraint; - } - return state; -} - - -/* Wrapper for ceparse */ -int -ncceparse(char* input, int ncconstraint, - NClist** projectionsp, NClist** selectionsp, char** errmsgp) -{ - CEparsestate* state; - int errcode = 0; - - if(input != NULL) { -#ifdef DEBUG -fprintf(stderr,"ncceparse: input=%s\n",input); -#endif - state = ce_parse_init(input,ncconstraint); - if(ceparse(state) == 0) { -#ifdef DEBUG -if(state->projections) -fprintf(stderr,"ncceparse: projections=%s\n",dumpprojections(state->projections)); -#endif - if(projectionsp) *projectionsp = state->projections; -#ifdef DEBUG -if(state->selections) -fprintf(stderr,"ncceparse: selections=%s\n",dumpselections(state->selections)); -#endif - if(selectionsp) *selectionsp = state->selections; - } else { - if(errmsgp) *errmsgp = nulldup(state->errorbuf); - } - errcode = state->errorcode; - ce_parse_cleanup(state); - } - return errcode; -} diff --git a/oc/curlfunctions.c b/oc/curlfunctions.c index a1e0780d7..2e46c5ee2 100644 --- a/oc/curlfunctions.c +++ b/oc/curlfunctions.c @@ -9,21 +9,6 @@ #include "rc.h" -/* Set various general curl flags */ -int -set_curl_flags(CURL* curl, struct OCcurlflags* flags) -{ - if (flags->verify) - {if (set_verify(curl) != OC_NOERR) goto fail;} - if (flags->compress) - {if (set_compression(curl) != OC_NOERR) goto fail;} - if (flags->cookies) - {if (set_cookies(curl, flags->cookies) != OC_NOERR) goto fail;} - return OC_NOERR; -fail: - return OC_ECURL; -} - /* This is called with arguments while the other functions in this file are * used with global values read from the.dodsrc file. */ @@ -58,28 +43,28 @@ set_user_password(CURL* curl, const char *userC, const char *passwordC) } int -set_proxy(CURL* curl, struct OCproxy *proxy) +set_proxy(CURL* curl, struct OCproxy *pstructProxy) { CURLcode cstat; - cstat = curl_easy_setopt(curl, CURLOPT_PROXY, proxy->host); + cstat = curl_easy_setopt(curl, CURLOPT_PROXY, pstructProxy->host); if (cstat != CURLE_OK) return OC_ECURL; - cstat = curl_easy_setopt(curl, CURLOPT_PROXYPORT, proxy->port); + cstat = curl_easy_setopt(curl, CURLOPT_PROXYPORT, pstructProxy->port); if (cstat != CURLE_OK) return OC_ECURL; - if (proxy->username) { - int userPassSize = strlen(proxy->username) + strlen( - proxy->password) + 2; + if (pstructProxy->user) { + int userPassSize = strlen(pstructProxy->user) + strlen( + pstructProxy->password) + 2; char *userPassword = malloc(sizeof(char) * userPassSize); if (!userPassword) { oc_log(LOGERR, "Out of Memory\n"); return OC_ENOMEM; } - strncpy(userPassword, proxy->username, userPassSize); + strncpy(userPassword, pstructProxy->user, userPassSize); strncat(userPassword, ":", userPassSize); - strncat(userPassword, proxy->password, userPassSize); + strncat(userPassword, pstructProxy->password, userPassSize); cstat = curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, userPassword); if (cstat != CURLE_OK) { free(userPassword); @@ -137,36 +122,3 @@ set_compression(CURL* curl) return OC_NOERR; } -int -set_credentials(CURL* curl, struct OCcredentials* creds) -{ - CURLcode cstat = CURLE_OK; - if(creds->ssl_certificate) { - cstat = curl_easy_setopt(curl, CURLOPT_SSLCERT, creds->ssl_certificate); - if(cstat != CURLE_OK) goto fail; - } - if(creds->ssl_key) { - cstat = curl_easy_setopt(curl, CURLOPT_SSLKEY, creds->ssl_key); - if(cstat != CURLE_OK) goto fail; - } - if(creds->cainfo) { - cstat = curl_easy_setopt(curl, CURLOPT_CAINFO, creds->cainfo); - if(cstat != CURLE_OK) goto fail; - } - if(creds->capath) { - cstat = curl_easy_setopt(curl, CURLOPT_CAPATH, creds->capath); - if(cstat != CURLE_OK) goto fail; - } - if(creds->cookiefile) { - cstat = curl_easy_setopt(curl, CURLOPT_COOKIEFILE, creds->cookiefile); - if(cstat != CURLE_OK) goto fail; - } - if(creds->cookiejar) { - cstat = curl_easy_setopt(curl, CURLOPT_COOKIEJAR, creds->cookiejar); - if(cstat != CURLE_OK) goto fail; - } - return OC_NOERR; - -fail: - return OC_ECURL; -} diff --git a/oc/curlfunctions.h b/oc/curlfunctions.h deleted file mode 100644 index 88bd4d184..000000000 --- a/oc/curlfunctions.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * rc.h - * - * Created on: Mar 5, 2009 - * Author: rikki - */ - -#ifndef _CURLFUNCTION_H_ -#define _CURLFUNCTION_H_ - -extern int set_curl_flags(CURL*, OCstate*); -extern int set_user_password(CURL*, const char *userC, const char *passwordC); -extern int set_proxy(CURL*, struct OCproxy*); -extern int set_cookies(CURL*, const char *cook); -extern int set_verify(CURL* curl); -extern int set_compression(CURL* curl); -extern int set_credentials(CURL*, struct OCcredentials*); - -#endif /*_CURLFUNCTION_H_*/ - - - diff --git a/oc/dap.y b/oc/dap.y index f782ee986..31590097d 100644 --- a/oc/dap.y +++ b/oc/dap.y @@ -48,32 +48,32 @@ start: | SCAN_ATTR dassetup attributebody | SCAN_ERROR errorbody | error - {$$=dap_unrecognizedresponse(parsestate);} + {$$=unrecognizedresponse(parsestate);} ; datasetbody: '{' declarations '}' datasetname ';' - {dap_datasetbody(parsestate,$4,$2);} + {datasetbody(parsestate,$4,$2);} ; declarations: - /* empty */ {$$=dap_declarations(parsestate,null,null);} - | declarations declaration {$$=dap_declarations(parsestate,$1,$2);} + /* empty */ {$$=declarations(parsestate,null,null);} + | declarations declaration {$$=declarations(parsestate,$1,$2);} ; /* 01/21/08: James says: no dimensions for grids or sequences */ /* 05/08/09: James says: no duplicate map names */ declaration: base_type var_name array_decls ';' - {$$=dap_makebase(parsestate,$2,$1,$3);} + {$$=makebase(parsestate,$2,$1,$3);} | SCAN_STRUCTURE '{' declarations '}' var_name array_decls ';' - {if(($$=dap_makestructure(parsestate,$5,$6,$3))==null) {YYABORT;}} + {if(($$ = makestructure(parsestate,$5,$6,$3))==null) {YYABORT;}} | SCAN_SEQUENCE '{' declarations '}' var_name ';' - {if(($$=dap_makesequence(parsestate,$5,$3))==null) {YYABORT;}} + {if(($$ = makesequence(parsestate,$5,$3))==null) {YYABORT;}} | SCAN_GRID '{' SCAN_ARRAY ':' declaration SCAN_MAPS ':' declarations '}' var_name ';' - {if(($$=dap_makegrid(parsestate,$10,$5,$8))==null) {YYABORT;}} + {if(($$ = makegrid(parsestate,$10,$5,$8))==null) {YYABORT;}} | error {daperror(parsestate,"Unrecognized type"); YYABORT;} ; @@ -92,13 +92,13 @@ base_type: ; array_decls: - /* empty */ {$$=dap_arraydecls(parsestate,null,null);} - | array_decls array_decl {$$=dap_arraydecls(parsestate,$1,$2);} + /* empty */ {$$=arraydecls(parsestate,null,null);} + | array_decls array_decl {$$=arraydecls(parsestate,$1,$2);} ; array_decl: - '[' SCAN_WORD ']' {$$=dap_arraydecl(parsestate,null,$2);} - | '[' name '=dap_' SCAN_WORD ']' {$$=dap_arraydecl(parsestate,$2,$4);} + '[' SCAN_WORD ']' {$$=arraydecl(parsestate,null,$2);} + | '[' name '=' SCAN_WORD ']' {$$=arraydecl(parsestate,$2,$4);} | error {daperror(parsestate,"Illegal dimension declaration"); YYABORT;} ; @@ -111,84 +111,84 @@ datasetname: var_name: name {$$=$1;}; -dassetup: {dap_dassetup(parsestate);} +dassetup: {dassetup(parsestate);} attributebody: - '{' attr_list '}' {dap_attributebody(parsestate,$2);} + '{' attr_list '}' {attributebody(parsestate,$2);} | error {daperror(parsestate,"Illegal DAS body"); YYABORT;} ; attr_list: - /* empty */ {$$=dap_attrlist(parsestate,null,null);} - | attr_list attribute {$$=dap_attrlist(parsestate,$1,$2);} + /* empty */ {$$=attrlist(parsestate,null,null);} + | attr_list attribute {$$=attrlist(parsestate,$1,$2);} ; attribute: alias ';' {$$=null;} /* ignored */ | SCAN_BYTE name bytes ';' - {$$=dap_attribute(parsestate,$2,$3,(Object)SCAN_BYTE);} + {$$=attribute(parsestate,$2,$3,(Object)SCAN_BYTE);} | SCAN_INT16 name int16 ';' - {$$=dap_attribute(parsestate,$2,$3,(Object)SCAN_INT16);} + {$$=attribute(parsestate,$2,$3,(Object)SCAN_INT16);} | SCAN_UINT16 name uint16 ';' - {$$=dap_attribute(parsestate,$2,$3,(Object)SCAN_UINT16);} + {$$=attribute(parsestate,$2,$3,(Object)SCAN_UINT16);} | SCAN_INT32 name int32 ';' - {$$=dap_attribute(parsestate,$2,$3,(Object)SCAN_INT32);} + {$$=attribute(parsestate,$2,$3,(Object)SCAN_INT32);} | SCAN_UINT32 name uint32 ';' - {$$=dap_attribute(parsestate,$2,$3,(Object)SCAN_UINT32);} + {$$=attribute(parsestate,$2,$3,(Object)SCAN_UINT32);} | SCAN_FLOAT32 name float32 ';' - {$$=dap_attribute(parsestate,$2,$3,(Object)SCAN_FLOAT32);} + {$$=attribute(parsestate,$2,$3,(Object)SCAN_FLOAT32);} | SCAN_FLOAT64 name float64 ';' - {$$=dap_attribute(parsestate,$2,$3,(Object)SCAN_FLOAT64);} + {$$=attribute(parsestate,$2,$3,(Object)SCAN_FLOAT64);} | SCAN_STRING name strs ';' - {$$=dap_attribute(parsestate,$2,$3,(Object)SCAN_STRING);} + {$$=attribute(parsestate,$2,$3,(Object)SCAN_STRING);} | SCAN_URL name urls ';' - {$$=dap_attribute(parsestate,$2,$3,(Object)SCAN_URL);} - | name '{' attr_list '}' {$$=dap_attrset(parsestate,$1,$3);} + {$$=attribute(parsestate,$2,$3,(Object)SCAN_URL);} + | name '{' attr_list '}' {$$=attrset(parsestate,$1,$3);} | error {daperror(parsestate,"Illegal attribute"); YYABORT;} ; bytes: - SCAN_WORD {$$=dap_attrvalue(parsestate,null,$1,(Object)SCAN_BYTE);} + SCAN_WORD {$$=attrvalue(parsestate,null,$1,(Object)SCAN_BYTE);} | bytes ',' SCAN_WORD - {$$=dap_attrvalue(parsestate,$1,$3,(Object)SCAN_BYTE);} + {$$=attrvalue(parsestate,$1,$3,(Object)SCAN_BYTE);} ; int16: - SCAN_WORD {$$=dap_attrvalue(parsestate,null,$1,(Object)SCAN_INT16);} + SCAN_WORD {$$=attrvalue(parsestate,null,$1,(Object)SCAN_INT16);} | int16 ',' SCAN_WORD - {$$=dap_attrvalue(parsestate,$1,$3,(Object)SCAN_INT16);} + {$$=attrvalue(parsestate,$1,$3,(Object)SCAN_INT16);} ; uint16: - SCAN_WORD {$$=dap_attrvalue(parsestate,null,$1,(Object)SCAN_UINT16);} + SCAN_WORD {$$=attrvalue(parsestate,null,$1,(Object)SCAN_UINT16);} | uint16 ',' SCAN_WORD - {$$=dap_attrvalue(parsestate,$1,$3,(Object)SCAN_UINT16);} + {$$=attrvalue(parsestate,$1,$3,(Object)SCAN_UINT16);} ; int32: - SCAN_WORD {$$=dap_attrvalue(parsestate,null,$1,(Object)SCAN_INT32);} + SCAN_WORD {$$=attrvalue(parsestate,null,$1,(Object)SCAN_INT32);} | int32 ',' SCAN_WORD - {$$=dap_attrvalue(parsestate,$1,$3,(Object)SCAN_INT32);} + {$$=attrvalue(parsestate,$1,$3,(Object)SCAN_INT32);} ; uint32: - SCAN_WORD {$$=dap_attrvalue(parsestate,null,$1,(Object)SCAN_UINT32);} - | uint32 ',' SCAN_WORD {$$=dap_attrvalue(parsestate,$1,$3,(Object)SCAN_UINT32);} + SCAN_WORD {$$=attrvalue(parsestate,null,$1,(Object)SCAN_UINT32);} + | uint32 ',' SCAN_WORD {$$=attrvalue(parsestate,$1,$3,(Object)SCAN_UINT32);} ; float32: - SCAN_WORD {$$=dap_attrvalue(parsestate,null,$1,(Object)SCAN_FLOAT32);} - | float32 ',' SCAN_WORD {$$=dap_attrvalue(parsestate,$1,$3,(Object)SCAN_FLOAT32);} + SCAN_WORD {$$=attrvalue(parsestate,null,$1,(Object)SCAN_FLOAT32);} + | float32 ',' SCAN_WORD {$$=attrvalue(parsestate,$1,$3,(Object)SCAN_FLOAT32);} ; float64: - SCAN_WORD {$$=dap_attrvalue(parsestate,null,$1,(Object)SCAN_FLOAT64);} - | float64 ',' SCAN_WORD {$$=dap_attrvalue(parsestate,$1,$3,(Object)SCAN_FLOAT64);} + SCAN_WORD {$$=attrvalue(parsestate,null,$1,(Object)SCAN_FLOAT64);} + | float64 ',' SCAN_WORD {$$=attrvalue(parsestate,$1,$3,(Object)SCAN_FLOAT64);} ; strs: - str_or_id {$$=dap_attrvalue(parsestate,null,$1,(Object)SCAN_STRING);} - | strs ',' str_or_id {$$=dap_attrvalue(parsestate,$1,$3,(Object)SCAN_STRING);} + str_or_id {$$=attrvalue(parsestate,null,$1,(Object)SCAN_STRING);} + | strs ',' str_or_id {$$=attrvalue(parsestate,$1,$3,(Object)SCAN_STRING);} ; urls: - url {$$=dap_attrvalue(parsestate,null,$1,(Object)SCAN_URL);} - | urls ',' url {$$=dap_attrvalue(parsestate,$1,$3,(Object)SCAN_URL);} + url {$$=attrvalue(parsestate,null,$1,(Object)SCAN_URL);} + | urls ',' url {$$=attrvalue(parsestate,$1,$3,(Object)SCAN_URL);} ; url: @@ -211,7 +211,7 @@ alias: errorbody: '{' errorcode errormsg errorptype errorprog '}' ';' - {$$=dap_errorbody(parsestate,$2,$3,$4,$5);} + {$$=errorbody(parsestate,$2,$3,$4,$5);} ; errorcode: /*empty*/ {$$=null;} | SCAN_CODE '=' SCAN_WORD ';' {$$=$3;} diff --git a/oc/daplex.c b/oc/daplex.c index b8e5f0ef9..4a4053981 100644 --- a/oc/daplex.c +++ b/oc/daplex.c @@ -248,7 +248,7 @@ Simple lexer */ void -dapsetwordchars(DAPlexstate* lexstate, int kind) +setwordchars(DAPlexstate* lexstate, int kind) { switch (kind) { case 0: @@ -281,7 +281,7 @@ daplexinit(char* input, DAPlexstate** lexstatep) lexstate->next = lexstate->input; lexstate->yytext = ocbytesnew(); lexstate->reclaim = oclistnew(); - dapsetwordchars(lexstate,0); /* Assume DDS */ + setwordchars(lexstate,0); /* Assume DDS */ } void diff --git a/oc/dapparse.c b/oc/dapparse.c index a8acff915..0a108116f 100644 --- a/oc/dapparse.c +++ b/oc/dapparse.c @@ -16,13 +16,13 @@ static int check_int32(char* val, long* value); /* Switch to DAS parsing SCAN_WORD definition */ void -dap_dassetup(DAPparsestate* state) +dassetup(DAPparsestate* state) { - dapsetwordchars(state->lexstate,1); + setwordchars(state->lexstate,1); } Object -dap_datasetbody(DAPparsestate* state, Object name, Object decls) +datasetbody(DAPparsestate* state, Object name, Object decls) { OCnode* node = newocnode((char*)name,OC_Dataset,state); node->subnodes = (OClist*)decls; @@ -35,7 +35,7 @@ dap_datasetbody(DAPparsestate* state, Object name, Object decls) } Object -dap_attributebody(DAPparsestate* state, Object attrlist) +attributebody(DAPparsestate* state, Object attrlist) { OCnode* node = newocnode(NULL,OC_Attributeset,state); OCASSERT((state->root == NULL)); @@ -48,7 +48,7 @@ dap_attributebody(DAPparsestate* state, Object attrlist) } Object -dap_errorbody(DAPparsestate* state, +errorbody(DAPparsestate* state, Object code, Object msg, Object ptype, Object prog) { state->svcerror = 1; @@ -59,13 +59,13 @@ dap_errorbody(DAPparsestate* state, } Object -dap_unrecognizedresponse(DAPparsestate* state) +unrecognizedresponse(DAPparsestate* state) { - return dap_errorbody(state,"0",state->lexstate->input,NULL,NULL); + return errorbody(state,"0",state->lexstate->input,NULL,NULL); } Object -dap_declarations(DAPparsestate* state, Object decls, Object decl) +declarations(DAPparsestate* state, Object decls, Object decl) { OClist* alist = (OClist*)decls; if(alist == NULL) @@ -76,7 +76,7 @@ dap_declarations(DAPparsestate* state, Object decls, Object decl) } Object -dap_arraydecls(DAPparsestate* state, Object arraydecls, Object arraydecl) +arraydecls(DAPparsestate* state, Object arraydecls, Object arraydecl) { OClist* alist = (OClist*)arraydecls; if(alist == NULL) @@ -87,7 +87,7 @@ dap_arraydecls(DAPparsestate* state, Object arraydecls, Object arraydecl) } Object -dap_arraydecl(DAPparsestate* state, Object name, Object size) +arraydecl(DAPparsestate* state, Object name, Object size) { long value; OCnode* dim; @@ -102,7 +102,7 @@ dap_arraydecl(DAPparsestate* state, Object name, Object size) } Object -dap_attrlist(DAPparsestate* state, Object attrlist, Object attrtuple) +attrlist(DAPparsestate* state, Object attrlist, Object attrtuple) { OClist* alist = (OClist*)attrlist; if(alist == NULL) @@ -122,7 +122,7 @@ dap_attrlist(DAPparsestate* state, Object attrlist, Object attrtuple) } Object -dap_attrvalue(DAPparsestate* state, Object valuelist, Object value, Object etype) +attrvalue(DAPparsestate* state, Object valuelist, Object value, Object etype) { OClist* alist = (OClist*)valuelist; if(alist == NULL) alist = oclistnew(); @@ -133,7 +133,7 @@ dap_attrvalue(DAPparsestate* state, Object valuelist, Object value, Object etype } Object -dap_attribute(DAPparsestate* state, Object name, Object values, Object etype) +attribute(DAPparsestate* state, Object name, Object values, Object etype) { OCnode* att; att = newocnode((char*)name,OC_Attribute,state); @@ -143,7 +143,7 @@ dap_attribute(DAPparsestate* state, Object name, Object values, Object etype) } Object -dap_attrset(DAPparsestate* state, Object name, Object attributes) +attrset(DAPparsestate* state, Object name, Object attributes) { OCnode* attset; attset = newocnode((char*)name,OC_Attributeset,state); @@ -204,7 +204,7 @@ dimnameanon(char* basename, unsigned int index) } Object -dap_makebase(DAPparsestate* state, Object name, Object etype, Object dimensions) +makebase(DAPparsestate* state, Object name, Object etype, Object dimensions) { OCnode* node; node = newocnode((char*)name,OC_Primitive,state); @@ -214,7 +214,7 @@ dap_makebase(DAPparsestate* state, Object name, Object etype, Object dimensions) } Object -dap_makestructure(DAPparsestate* state, Object name, Object dimensions, Object fields) +makestructure(DAPparsestate* state, Object name, Object dimensions, Object fields) { OCnode* node; char* dupname; @@ -230,7 +230,7 @@ dap_makestructure(DAPparsestate* state, Object name, Object dimensions, Object f } Object -dap_makesequence(DAPparsestate* state, Object name, Object members) +makesequence(DAPparsestate* state, Object name, Object members) { OCnode* node; char* dupname; @@ -245,7 +245,7 @@ dap_makesequence(DAPparsestate* state, Object name, Object members) } Object -dap_makegrid(DAPparsestate* state, Object name, Object arraydecl, Object mapdecls) +makegrid(DAPparsestate* state, Object name, Object arraydecl, Object mapdecls) { OCnode* node; /* Check for duplicate map names */ diff --git a/oc/dapparselex.h b/oc/dapparselex.h index b78a01ffd..df778e548 100644 --- a/oc/dapparselex.h +++ b/oc/dapparselex.h @@ -63,30 +63,30 @@ extern void dap_parse_error(DAPparsestate*,const char *fmt, ...); /* bison parse entry point */ extern int dapparse(DAPparsestate*); -extern Object dap_datasetbody(DAPparsestate*,Object decls, Object name); -extern Object dap_declarations(DAPparsestate*,Object decls, Object decl); -extern Object dap_arraydecls(DAPparsestate*,Object arraydecls, Object arraydecl); -extern Object dap_arraydecl(DAPparsestate*,Object name, Object size); +extern Object datasetbody(DAPparsestate*,Object decls, Object name); +extern Object declarations(DAPparsestate*,Object decls, Object decl); +extern Object arraydecls(DAPparsestate*,Object arraydecls, Object arraydecl); +extern Object arraydecl(DAPparsestate*,Object name, Object size); -extern void dap_dassetup(DAPparsestate*); -extern Object dap_attributebody(DAPparsestate*,Object attrlist); -extern Object dap_attrlist(DAPparsestate*,Object attrlist, Object attrtuple); -extern Object dap_attribute(DAPparsestate*,Object name, Object value, Object etype); -extern Object dap_attrset(DAPparsestate*,Object name, Object attributes); -extern Object dap_attrvalue(DAPparsestate*,Object valuelist, Object value, Object etype); +extern void dassetup(DAPparsestate*); +extern Object attributebody(DAPparsestate*,Object attrlist); +extern Object attrlist(DAPparsestate*,Object attrlist, Object attrtuple); +extern Object attribute(DAPparsestate*,Object name, Object value, Object etype); +extern Object attrset(DAPparsestate*,Object name, Object attributes); +extern Object attrvalue(DAPparsestate*,Object valuelist, Object value, Object etype); -extern Object dap_makebase(DAPparsestate*,Object name, Object etype, Object dimensions); -extern Object dap_makestructure(DAPparsestate*,Object name, Object dimensions, Object fields); -extern Object dap_makesequence(DAPparsestate*,Object name, Object members); -extern Object dap_makegrid(DAPparsestate*,Object name, Object arraydecl, Object mapdecls); +extern Object makebase(DAPparsestate*,Object name, Object etype, Object dimensions); +extern Object makestructure(DAPparsestate*,Object name, Object dimensions, Object fields); +extern Object makesequence(DAPparsestate*,Object name, Object members); +extern Object makegrid(DAPparsestate*,Object name, Object arraydecl, Object mapdecls); -extern Object dap_errorbody(DAPparsestate*, Object, Object, Object, Object); -extern Object dap_unrecognizedresponse(DAPparsestate*); +extern Object errorbody(DAPparsestate*, Object, Object, Object, Object); +extern Object unrecognizedresponse(DAPparsestate*); /* Lexer entry points */ extern int daplex(YYSTYPE*, DAPparsestate*); extern void daplexinit(char* input, DAPlexstate** lexstatep); extern void daplexcleanup(DAPlexstate** lexstatep); -extern void dapsetwordchars(DAPlexstate* lexstate, int kind); +extern void setwordchars(DAPlexstate* lexstate, int kind); #endif /*DAPPARSELEX_H*/ diff --git a/oc/http.c b/oc/http.c index 052b1df87..f6726e6fb 100644 --- a/oc/http.c +++ b/oc/http.c @@ -11,6 +11,7 @@ static size_t WriteFileCallback(void*, size_t, size_t, void*); static size_t WriteMemoryCallback(void*, size_t, size_t, void*); +static int ocsetcurlproperties(CURL* curl, const char*); struct Fetchdata { FILE* stream; @@ -36,6 +37,9 @@ ocfetchurl_file(CURL* curl, char* url, FILE* stream, CURLcode cstat = CURLE_OK; struct Fetchdata fetchdata; + + if((stat = ocsetcurlproperties(curl,url)) != OC_NOERR) goto fail; + /* Set the URL */ cstat = curl_easy_setopt(curl, CURLOPT_URL, (void*)url); if (cstat != CURLE_OK) @@ -83,6 +87,8 @@ ocfetchurl(CURL* curl, char* url, OCbytes* buf, long* filetime) CURLcode cstat = CURLE_OK; size_t len; + if((stat = ocsetcurlproperties(curl,url)) != OC_NOERR) goto fail; + /* Set the URL */ cstat = curl_easy_setopt(curl, CURLOPT_URL, (void*)url); if (cstat != CURLE_OK) @@ -236,12 +242,56 @@ occurlclose(CURL* curl) curl_easy_cleanup(curl); } +static int +ocsetcurlproperties(CURL* curl, const char* url) +{ + CURLcode cstat = CURLE_OK; + /* These conditionals look for value in four globals set when the + * .dodsrc file was read. + */ + if (dods_verify) { + if (set_verify(curl) != OC_NOERR) + goto fail; + } + if (dods_compress) { + if (set_compression(curl) != OC_NOERR) + goto fail; + } + if (pstructProxy) { + if (set_proxy(curl, pstructProxy) != OC_NOERR) + goto fail; + } + if (cook) { + if (set_cookies(curl, cook) != OC_NOERR) + goto fail; + } + + if (credentials_in_url(url)) { + char *result_url = NULL; + if (extract_credentials(url, &userName, &password, &result_url) != OC_NOERR) + goto fail; + url = result_url; + } + + if (userName && password) { + if (set_user_password(curl, userName, password) != OC_NOERR) + goto fail; + } + return OC_NOERR; + +fail: + oc_log(LOGERR, "curl error: %s", curl_easy_strerror(cstat)); + return THROW(OC_ECURL); +} + int ocfetchlastmodified(CURL* curl, char* url, long* filetime) { int stat = OC_NOERR; CURLcode cstat = CURLE_OK; + if((stat = ocsetcurlproperties(curl,url)) != OC_NOERR) goto fail; + /* Set the URL */ cstat = curl_easy_setopt(curl, CURLOPT_URL, (void*)url); if (cstat != CURLE_OK) diff --git a/oc/oc.c b/oc/oc.c index 20cd2ce90..d9ce57208 100644 --- a/oc/oc.c +++ b/oc/oc.c @@ -9,28 +9,13 @@ #include "oclog.h" #include "occlientparams.h" -#ifdef ENABLE_RC -#include "ocrc.h" -#endif - #undef TRACK -/**************************************************/ - -static int ocinitialized = 0; - -/**************************************************/ -/* .rc file info */ -#ifdef ENABLE_RC -struct OCrcfile { - char* rcfilename; - ocrcnode* root; -} ocrcfile = {NULL,NULL}; -#endif - /**************************************************/ /* Track legal ids */ +static OClist* ocmap = NULL; + #ifdef OC_FASTCONSISTENCY #define ocverify(object) ((object) != NULL && (*(object) == OCMAGIC)?1:0) @@ -40,8 +25,6 @@ struct OCrcfile { #else /*!OC_FASTCONSISTENCY*/ -static OClist* ocmap = NULL; - static int ocverify(unsigned long object) { @@ -95,27 +78,15 @@ fprintf(stderr,"assign: %lu\n",(unsigned long)object); fflush(stderr); /**************************************************/ -static int -oc_initialize(void) -{ - int status = OC_NOERR; -#ifndef OC_FASTCONSISTENCY - ocmap = oclistnew(); - oclistsetalloc(ocmap,1024); -#endif - status = ocinternalinitialize(); - ocinitialized = 1; - return status; -} - -/**************************************************/ - OCerror oc_open(const char* url, OCconnection* connp) { OCerror ocerr; OCstate* state; - if(!ocinitialized) oc_initialize(); + if(ocmap == NULL) { + ocmap = oclistnew(); + oclistsetalloc(ocmap,1024); + } ocerr = ocopen(&state,url); if(ocerr == OC_NOERR && connp) { *connp = (OCconnection)ocassign(state); @@ -1063,14 +1034,3 @@ oc_dumpnode(OCconnection conn, OCobject root0) ocdumpnode(root); return ocerr; } - -OCerror -oc_setrcfile(char* rcfile) -{ -#ifdef ENABLE_RC - return ocsetrcfile(rcfile); -#else - return OC_EINVAL; -#endif - -} diff --git a/oc/oc.h b/oc/oc.h index adb79f5ef..9a3e07776 100644 --- a/oc/oc.h +++ b/oc/oc.h @@ -84,7 +84,6 @@ typedef int OCerror; #define OC_EDAS (-21) #define OC_EDDS (-22) #define OC_EDATADDS (-23) -#define OC_ERCFILE (-24) typedef enum OCmode { OCFIELDMODE = OC_Structure, @@ -449,11 +448,6 @@ extern OCerror oc_update_lastmodified_data(OClink); /* Get last known modification time; -1 => data unknown */ extern long oc_get_lastmodified_data(OClink); -/**************************************************/ -/* New .rc file system support */ - -extern OCerror oc_setrcfile(char* rcfile); - /**************************************************/ #endif /*OCINTERNAL_H*/ diff --git a/oc/ocinternal.c b/oc/ocinternal.c index f1666b57c..cb29ccaee 100644 --- a/oc/ocinternal.c +++ b/oc/ocinternal.c @@ -15,10 +15,6 @@ #include "occontent.h" #include "occlientparams.h" #include "rc.h" -#include "curlfunctions.h" -#ifdef ENABLE_RC -#include "ocrc.h" -#endif #include "http.h" #include "read.h" @@ -30,15 +26,9 @@ /*#define TMPPATH "/tmp/"*/ #endif #define TMPPATH "./" - -/* Define default rc files */ -#define DODSRC ".dodsrc" -#define OPENDAPRC ".opendap.rc" - -#ifdef ENABLE_RC -static char* defaultrc = NULL; -static ocrcnode* ocrcroot = NULL; -#endif +#define BUFSIZE 512 +#define DODSRC_SIZE 9 +#define DODSRC "/.dodsrc" static int ocextractdds(OCstate*,OCtree*); static char* constraintescape(const char* url); @@ -46,14 +36,8 @@ static char* constraintescape(const char* url); static OCerror createtempfile(OCstate*,OCtree*); #endif -static void ocsetcurlproperties(OCstate*); - extern OCnode* makeunlimiteddimension(void); -#ifdef ENABLE_RC -static void loadrc(OCstate* state, ocrcnode* root); -#endif - #ifdef WIN32 #include #define _S_IREAD 256 @@ -75,10 +59,15 @@ int oc_network_order; /* network order is big endian */ int oc_invert_xdr_double; int oc_curl_file_supported; -int -ocinternalinitialize(void) +static int ocinitialized = 0; + +static int +ocinitialize(void) { int stat = OC_NOERR; + char buf[BUFSIZE]; + char *env; + int len; /* Compute if we are same as network order v-a-v xdr */ #ifdef XDRBYTEORDER @@ -140,6 +129,37 @@ ocinternalinitialize(void) } oc_loginit(); + /* read/write configuration file */ + env = getenv("HOME"); + if (env != NULL) { + len = strlen(env); + if (len >= BUFSIZE - DODSRC_SIZE) { + oc_log(LOGERR, "length of home directory is too long\n"); + stat = OC_EIO; + goto end; + } + strncpy(buf, env, BUFSIZE - 1); + buf[len] = '\0'; + strncat(buf, DODSRC, BUFSIZE - 1); + buf[len + DODSRC_SIZE] = '\0'; + + if (ocdebug > 1) + fprintf(stderr, "Your RC file: %s\n", buf); + + /* stat = OC_NOERR; */ + if (access(buf, R_OK) != 0) { + if (write_dodsrc(buf) != OC_NOERR) { + oc_log(LOGERR, "Error getting buffer\n"); + stat = OC_EIO; + } + } + + if (read_dodsrc(buf) != OC_NOERR) { + oc_log(LOGERR, "Error parsing buffer\n"); + stat = OC_EIO; + } + } + /* Determine if this version of curl supports "file://..." urls.*/ { const char* const* proto; /*weird*/ @@ -154,6 +174,9 @@ ocinternalinitialize(void) } } + ocinitialized = 1; + +end: return THROW(stat); } @@ -168,6 +191,11 @@ ocopen(OCstate** statep, const char* url) memset((void*)&tmpurl,0,sizeof(tmpurl)); + if(!ocinitialized) { + stat=ocinitialize(); + if(stat) {THROWCHK(stat=OC_EBADURL); goto fail;} + } + if(!dapurlparse(url,&tmpurl)) {THROWCHK(stat=OC_EBADURL); goto fail;} stat = occurlopen(&curl); @@ -188,10 +216,6 @@ ocopen(OCstate** statep, const char* url) } state->packet = ocbytesnew(); ocbytessetalloc(state->packet,DFALTPACKETSIZE); /*initial reasonable size*/ - - /* set curl properties for this link */ - ocsetcurlproperties(state); - if(statep) *statep = state; return THROW(stat); @@ -504,274 +528,3 @@ ocupdatelastmodifieddata(OCstate* state) } return status; } - -/* - Set curl properties for link based on rc files -*/ -static void -ocsetcurlproperties(OCstate* state) -{ - CURL* curl = state->curl; - CURLcode cstat = CURLE_OK; - char* userName = NULL; - char* password = NULL; - int stat = OC_NOERR; - char *homepath; - char* path = NULL; - - /* Load dodsrc file */ - /* locate the configuration files */ - homepath = getenv("HOME"); - if (homepath!= NULL) { - path = (char*)malloc(strlen(homepath)+1+strlen(DODSRC)+1); - strcpy(path,homepath); - strcat(path,"/"); - strcat(path,DODSRC); - if (ocdebug > 1) - fprintf(stderr, "DODS RC file: %s\n", path); - if(read_dodsrc(path,state) != OC_NOERR) { - oc_log(LOGERR, "Error parsing %s\n",path); - goto fail; - } - } else {/*complain*/ - oc_log(LOGWARN,"Cannot find runtime .dodsrc configuration file"); - goto fail; - } - if(path != NULL) {free(path) ; path = NULL;} - - if (credentials_in_url(state->url.url)) { - char *result_url = NULL; - if(userName) free(userName); - if(password) free(password); - if (extract_credentials(state->url.url, &userName, &password, &result_url) != OC_NOERR) - goto fail; - dapurlclear(&state->url); - dapurlparse(result_url,&state->url); - } - -#ifdef ENABLE_RC - path = NULL; - if(defaultrc == NULL || strlen(defaultrc) == 0) { - if(defaultrc != NULL) free(defaultrc); - defaultrc = strdup(OPENDAPRC); - } - if(defaultrc[0] == '/') { - path = (char*)malloc(strlen(defaultrc)+1); - } else if (homepath!= NULL) { - path = (char*)malloc(strlen(homepath)+1+strlen(defaultrc)+1); - strcpy(path,homepath); - strcat(path,"/"); - strcat(path,defaultrc); - } - if(path!= NULL) { - FILE* rcfile; - ocrcerror err; - if (ocdebug > 1) - fprintf(stderr, "OPENDAP RC file: %s\n", path); - rcfile = fopen(path,"r"); - if(rcfile != NULL) { - if(!ocrc(rcfile,&ocrcroot,&err)) { - oc_log(LOGERR, "Error parsing %s; %s: lineno=%d charno=%d\n", - path,err.errmsg,err.lineno,err.charno); - goto fail; - } - } else { /* complain */ - oc_log(LOGWARN,"Cannot find runtime configuration file"); - goto fail; - } - loadrc(state,ocrcroot); - } else {/*complain*/ - oc_log(LOGWARN,"Cannot find runtime configuration file"); - goto fail; - } - if(path != NULL) {free(path) ; path = NULL;} - -#endif - - if(state->credentials.password) free(state->credentials.password); - state->credentials.password = password; password = NULL; - if(state->credentials.identity) free(state->credentials.identity); - state->credentials.identity = userName; userName = NULL; - - /* Set curl properties */ - if((stat=set_curl_flags(curl,state)) != OC_NOERR) goto fail; - return; - -fail: - if(path != NULL) free(path); - if(cstat != CURLE_OK) - oc_log(LOGERR, "curl error: %s", curl_easy_strerror(cstat)); - return; -} - -#ifdef ENABLE_RC -/* -Presumed format of the .rc file -... -curl : { - : { - compress: true|false - verify: true|false - cookies: - verbose: true|false - followlocation: true|false - maxredirs: - useragent: - credentials: { - identity: - password: - ssl-certificate: - ssl-key: - ssl-authority : - capath: - cookiefile: - cookiejar: - } //credentials - proxy: { - host: - port: - username: - password: - } //proxy - } - : { - ... - } -} // curl - -oc : { - : { // oc specific flags per url - ... - } -} //oc -... -*/ - -static void -processproxy(OCstate* state, ocrcnode* creds) -{ - ocrcnode* value; - if((value=ocrc_lookup(creds,"host"))) { - if(value->nodeclass == ocrc_const) - state->proxy.host = strdup(value->constvalue); - } else if((value=ocrc_lookup(creds,"port"))) { - if(value->nodeclass == ocrc_const && value->constclass == ocrc_number) - state->proxy.port = atoi(value->constvalue); - } else if((value=ocrc_lookup(creds,"username"))) { - if(value->nodeclass == ocrc_const) - state->proxy.username = strdup(value->constvalue); - } else if((value=ocrc_lookup(creds,"password"))) { - if(value->nodeclass == ocrc_const && value->constclass == ocrc_number) - state->proxy.password = strdup(value->constvalue); - } -} - -static void -processcreds(OCstate* state, ocrcnode* match) -{ - ocrcnode* value; - ocrcnode* creds = ocrc_lookup(match,"credentials"); - if((value=ocrc_lookup(match,"compress"))) { - if(value->nodeclass == ocrc_const) - state->credentials.identity = strdup(value->constvalue); - } else if((value=ocrc_lookup(match,"verify"))) { - if(value->nodeclass == ocrc_const && value->constclass == ocrc_number) - state->curlflags.verify = atoi(value->constvalue); - } else if((value=ocrc_lookup(creds,"identity"))) { - if(value->nodeclass == ocrc_const) - state->credentials.identity = strdup(value->constvalue); - } else if((value=ocrc_lookup(creds,"password"))) { - if(value->nodeclass == ocrc_const) - state->credentials.password = strdup(value->constvalue); - } else if((value=ocrc_lookup(creds,"ssl-certificate"))) { - if(value->nodeclass == ocrc_const) - state->credentials.ssl_certificate = strdup(value->constvalue); - } else if((value=ocrc_lookup(creds,"ssl-key"))) { - if(value->nodeclass == ocrc_const) - state->credentials.ssl_key = strdup(value->constvalue); - } else if((value=ocrc_lookup(creds,"ssl-authority "))) { - if(value->nodeclass == ocrc_const) - state->credentials.ssl_authority = strdup(value->constvalue); - } else if((value=ocrc_lookup(creds,"capath"))) { - if(value->nodeclass == ocrc_const) - state->credentials.capath = strdup(value->constvalue); - } else if((value=ocrc_lookup(creds,"cookiefile"))) { - if(value->nodeclass == ocrc_const) - state->credentials.cookiefile = strdup(value->constvalue); - } else if((value=ocrc_lookup(creds,"cookiejar"))) { - if(value->nodeclass == ocrc_const) - state->credentials.cookiejar = strdup(value->constvalue); - } -} - -static void -processmatch(OCstate* state, ocrcnode* match) -{ - ocrcnode* value; - if((value=ocrc_lookup(match,"compress"))) { - if(value == ocrc_const_true) state->curlflags.compress = 1; - } else if((value=ocrc_lookup(match,"verify"))) { - if(value == ocrc_const_true) state->curlflags.verify = 1; - } else if((value=ocrc_lookup(match,"cookies"))) { - if(value->nodeclass == ocrc_const) - state->curlflags.cookies = strdup(value->constvalue); - } else if((value=ocrc_lookup(match,"verbose"))) { - if(value == ocrc_const_true) state->curlflags.verbose = 1; - } else if((value=ocrc_lookup(match,"followlocation"))) { - if(value == ocrc_const_true) state->curlflags.followlocation = 1; - } else if((value=ocrc_lookup(match,"maxredirs"))) { - if(value->nodeclass == ocrc_const) - state->curlflags.cookies = strdup(value->constvalue); - } else if((value=ocrc_lookup(match,"useragent"))) { - if(value->nodeclass == ocrc_const) - state->curlflags.useragent = strdup(value->constvalue); - } else if((value=ocrc_lookup(match,"credentials"))) { - processcreds(state,value); - } else if((value=ocrc_lookup(match,"proxy"))) { - processproxy(state,value); - } -} - -static void -loadrc(OCstate* state, ocrcnode* root) -{ - /* Get curl : {...} for matching urls */ - char* url = state->url.base; - ocrcnode** matches; - ocrcnode* ocroot; - int i; - - ocrcnode* curlroot = ocrc_lookup(root,"curl"); - if(curlroot->nodeclass != ocrc_map) { - oc_log(LOGERR, "non-map oc in rc file"); - fprintf(stderr,"non-map oc in rc file\n"); - goto fail; - } - if(curlroot != NULL) { - int nmatches = ocrc_urlmatch(curlroot,url,&matches); - if(nmatches == 0) goto oc; - for(i=0;i"; diff --git a/oc/rc.c b/oc/rc.c index 1da3ff9b4..3871f9abd 100644 --- a/oc/rc.c +++ b/oc/rc.c @@ -19,7 +19,13 @@ /* These globals are where information from the .dodsrc file is stored. See the * functions in curlfunctions.c */ +int dods_compress = 0; +int dods_verify = 0; struct OCproxy *pstructProxy = NULL; +char *cook = NULL; + +char *userName = NULL; +char *password = NULL; /* The Username and password are in the URL if the URL is of the form: * http://:@/.... @@ -92,11 +98,32 @@ extract_credentials(const char *url, char **name, char **pw, char **result_url) } } +int +set_credentials(const char *name, const char *pw) +{ + if (!(name && pw)) { + oc_log(LOGERR, "Both username and password must be given."); + return OC_EIO; + } + + userName = malloc(sizeof(char) * (strlen(name) + 1)); + if (!userName) + return OC_ENOMEM; + strcpy(userName, name); + + password = malloc(sizeof(char) * (strlen(pw) + 1)); + if (!password) + return OC_ENOMEM; + strcpy(password, pw); + + return OC_NOERR; +} + /*Allows for a .dodsrc file to be read in and parsed in order to get authentication information*/ int -read_dodsrc(char *in_file_name, OCstate* state) +read_dodsrc(char *in_file_name) { - char *p; + char *p; char more[1024]; char *v; FILE *in_file; @@ -105,7 +132,7 @@ read_dodsrc(char *in_file_name, OCstate* state) in_file = fopen(in_file_name, "r"); /* Open the file to read it */ if (in_file == NULL) { oc_log(LOGERR, "Could not open the .dodsrc file"); - return OC_EPERM; + return OC_EIO; } unsupported[0] = '\0'; @@ -116,39 +143,48 @@ read_dodsrc(char *in_file_name, OCstate* state) *p = '\0'; if (strcmp(more, "USE_CACHE") == 0) { - /*strcat(unsupported,",USE_CACHE");*/ + strcat(unsupported,",USE_CACHE"); } else if (strcmp(more, "MAX_CACHE_SIZE") == 0) { - /*strcat(unsupported,",USE_CACHE");*/ + strcat(unsupported,",USE_CACHE"); } else if (strcmp(more, "MAX_CACHED_OBJ") == 0) { - /*strcat(unsupported,",MAX_CACHED_OBJ");*/ + strcat(unsupported,",MAX_CACHED_OBJ"); } else if (strcmp(more, "IGNORE_EXPIRES") == 0) { - /*strcat(unsupported,",IGNORE_EXPIRES");*/ + strcat(unsupported,",IGNORE_EXPIRES"); } else if (strcmp(more, "CACHE_ROOT") == 0) { - /*strcat(unsupported,",CACHE_ROOT");*/ + strcat(unsupported,",CACHE_ROOT"); } else if (strcmp(more, "DEFAULT_EXPIRES") == 0) { - /*strcat(unsupported,",DEFAULT_EXPIRES");*/ + strcat(unsupported,",DEFAULT_EXPIRES"); } else if (strcmp(more, "ALWAYS_VALIDATE") == 0) { - /*strcat(unsupported,",ALWAYS_VALIDATE");*/ + strcat(unsupported,",ALWAYS_VALIDATE"); } else if (strcmp(more, "DEFLATE") == 0) { /* int v_len = strlen(v); unused */ - if(atoi(v)) state->curlflags.compress = 1; + dods_compress = atoi(v); if (ocdebug > 1) - oc_log(LOGNOTE,"Compression: %d", state->curlflags.compress); + oc_log(LOGNOTE,"Compression: %d", dods_compress); } else if (strcmp(more, "VALIDATE_SSL") == 0) { - if(atoi(v)) state->curlflags.verify = 1; + dods_verify = atoi(v); if (ocdebug > 1) - oc_log(LOGNOTE,"SSL Verification: %d", state->curlflags.verify); + oc_log(LOGNOTE,"SSL Verification: %d", dods_verify); } else if (strcmp(more, "PROXY_SERVER") == 0) { char *host_pos = NULL; char *port_pos = NULL; /* int v_len = strlen(v); unused */ if(strlen(v) == 0) continue; /* nothing there*/ + pstructProxy = malloc(sizeof(struct OCproxy)); + if (!pstructProxy) + return OC_ENOMEM; + if (credentials_in_url(v)) { char *result_url = NULL; - extract_credentials(v, &state->proxy.username, &state->proxy.password, &result_url); + extract_credentials(v, &pstructProxy->user, &pstructProxy->password, &result_url); v = result_url; } + else { + pstructProxy->user = NULL; + pstructProxy->password = NULL; + } + /* allocating a bit more than likely needed ... */ host_pos = strstr(v, "http://"); if (host_pos) @@ -161,82 +197,79 @@ read_dodsrc(char *in_file_name, OCstate* state) port_pos++; *port_sep = '\0'; host_len = strlen(host_pos); - state->proxy.host = malloc(sizeof(char) * host_len + 1); - if (!state->proxy.host) + pstructProxy->host = malloc(sizeof(char) * host_len + 1); + if (!pstructProxy->host) return OC_ENOMEM; - strncpy(state->proxy.host, host_pos, host_len); - state->proxy.host[host_len + 1] = '\0'; + strncpy(pstructProxy->host, host_pos, host_len); + pstructProxy->host[host_len + 1] = '\0'; - state->proxy.port = atoi(port_pos); + pstructProxy->port = atoi(port_pos); } else { int host_len = strlen(host_pos); - state->proxy.host = malloc(sizeof(char) * host_len + 1); - if (!state->proxy.host) + pstructProxy->host = malloc(sizeof(char) * host_len + 1); + if (!pstructProxy->host) return OC_ENOMEM; - strncpy(state->proxy.host, host_pos, host_len); - state->proxy.host[host_len + 1] = '\0'; + strncpy(pstructProxy->host, host_pos, host_len); + pstructProxy->host[host_len + 1] = '\0'; - state->proxy.port = 80; + pstructProxy->port = 80; } #if 0 - state->proxy.host[v_len] = '\0'; + pstructProxy->host[v_len] = '\0'; - state->proxy.port = atoi(v); + pstructProxy->port = atoi(v); s_len = strlen(v); - state->proxy.user = malloc(sizeof(char) * s_len + 1); - if (!state->proxy.user) + pstructProxy->user = malloc(sizeof(char) * s_len + 1); + if (!pstructProxy->user) return OC_ENOMEM; - strncpy(state->proxy.user, v, s_len); - state->proxy.user[s_len] = '\0'; + strncpy(pstructProxy->user, v, s_len); + pstructProxy->user[s_len] = '\0'; p_len = strlen(v); - state->proxy.password = malloc(sizeof(char) * p_len + 1); - if (!state->proxy.password) + pstructProxy->password = malloc(sizeof(char) * p_len + 1); + if (!pstructProxy->password) return OC_ENOMEM; - strncpy(state->proxy.password, v, p_len); - state->proxy.password[p_len] = '\0'; + strncpy(pstructProxy->password, v, p_len); + pstructProxy->password[p_len] = '\0'; #endif if (ocdebug > 1) { - oc_log(LOGNOTE,"host name: %s", state->proxy.host); - oc_log(LOGNOTE,"user name: %s", state->proxy.username); - oc_log(LOGNOTE,"password name: %s", state->proxy.password); - oc_log(LOGNOTE,"port number: %d", state->proxy.port); + oc_log(LOGNOTE,"host name: %s", pstructProxy->host); + oc_log(LOGNOTE,"user name: %s", pstructProxy->user); + oc_log(LOGNOTE,"password name: %s", pstructProxy->password); + oc_log(LOGNOTE,"port number: %d", pstructProxy->port); } } else if (strcmp(more, "NO_PROXY_FOR") == 0) { - /*strcat(unsupported,",NO_PROXY_FOR");*/ + strcat(unsupported,",NO_PROXY_FOR"); } else if (strcmp(more, "AIS_DATABASE") == 0) { - /*strcat(unsupported,",AIS_DATABASE");*/ + strcat(unsupported,",AIS_DATABASE"); } else if (strcmp(more, "COOKIE_JAR") == 0) { int v_len = strlen(v); - state->curlflags.cookies = malloc(sizeof(char) * v_len + 1); - if (!state->curlflags.cookies) + cook = malloc(sizeof(char) * v_len + 1); + if (!cook) return OC_ENOMEM; - strncpy(state->curlflags.cookies, v, v_len); - state->curlflags.cookies[v_len] = '\0'; + strncpy(cook, v, v_len); + cook[v_len] = '\0'; if (ocdebug > 1) - oc_log(LOGNOTE,"Cookie jar name: %s", state->curlflags.cookies); + oc_log(LOGNOTE,"Cookie jar name: %s", cook); } } } fclose(in_file); -#ifdef IGNORE if(unsupported[0] != '\0') { unsupported[0] = ' '; /* Elide leading comma */ oc_log(LOGNOTE,"Not currently supported in .dodsrc: %s",unsupported); } -#endif return OC_NOERR; } -#ifdef OBSOLETE /*Allows for a .dodsrc file to be created if one does not currently exist for default authentication * values*/ int @@ -284,4 +317,3 @@ write_dodsrc(char *out_file_name) return OC_NOERR; } -#endif diff --git a/oc/rc.h b/oc/rc.h index 7815230bc..85c21538b 100644 --- a/oc/rc.h +++ b/oc/rc.h @@ -8,6 +8,13 @@ #ifndef RC_H_ #define RC_H_ +struct OCproxy { + char *host; + int port; + char *user; + char *password; +}; + extern int dods_compress; extern int dods_verify; extern struct OCproxy *pstructProxy; @@ -17,13 +24,13 @@ extern char *password; extern int credentials_in_url(const char *url); extern int extract_credentials(const char *url, char **name, char **pw, char **result_url); -extern int set_credentials(CURL* curl, struct OCcredentials* creds); -extern int read_dodsrc(char *in_file_name, OCstate* state); -#ifdef OBSOLETE +extern int set_credentials(const char *name, const char *pw); +extern int read_dodsrc(char *in_file_name); extern int write_dodsrc(char *out_file_name); -#endif -extern int set_proxy(CURL* curl, struct OCproxy*); +extern int set_user_password(CURL* curl, const char *userC, + const char *passwordC); +extern int set_proxy(CURL* curl, struct OCproxy *pstructProxy); extern int set_cookies(CURL* curl, const char *cook); extern int set_verify(CURL* curl); extern int set_compression(CURL* curl); diff --git a/oc/read.c b/oc/read.c index 9acb2e907..5c4503adc 100644 --- a/oc/read.c +++ b/oc/read.c @@ -12,7 +12,6 @@ #include "ocdebug.h" #include "http.h" #include "read.h" -#include "rc.h" extern int oc_curl_file_supported; @@ -178,5 +177,3 @@ readfile(char* path, char* suffix, OCbytes* packet) close(fd); return THROW(stat); } - - From dd47ffbf02a36bffd36e58bfa9d5916ae4007914 Mon Sep 17 00:00:00 2001 From: Dennis Heimbigner Date: Thu, 24 Jun 2010 17:31:07 +0000 Subject: [PATCH 14/18] --- libncdap3/Makefile.am | 10 +- libncdap3/cetab.c | 386 +++++++++++++++++++++++++++--------------- libncdap3/cetab.h | 35 ++-- 3 files changed, 266 insertions(+), 165 deletions(-) diff --git a/libncdap3/Makefile.am b/libncdap3/Makefile.am index 7b7da36bd..49fd916f3 100755 --- a/libncdap3/Makefile.am +++ b/libncdap3/Makefile.am @@ -97,11 +97,11 @@ endif # BUILD_DAP # Otherwise never invoked, but records how to do it. # BTW: note that renaming is essential because otherwise # autoconf will forcibly delete files of the name *.tab.* -cetab.c cetab.h: ${top_srcdir}/oc/ce.y - bison -d -t -p ce ${top_srcdir}/oc/ce.y - rm -f cetab.c cetab.h - mv ce.tab.c cetab.c - mv ce.tab.h cetab.h +#cetab.c cetab.h: ${top_srcdir}/oc/ce.y +# bison -d -t -p ce ${top_srcdir}/oc/ce.y +# rm -f cetab.c cetab.h +# mv ce.tab.c cetab.c +# mv ce.tab.h cetab.h test: check diff --git a/libncdap3/cetab.c b/libncdap3/cetab.c index b8d883bbf..cea8629ce 100644 --- a/libncdap3/cetab.c +++ b/libncdap3/cetab.c @@ -1,24 +1,22 @@ -/* A Bison parser, made by GNU Bison 2.3. */ +/* A Bison parser, made by GNU Bison 2.4.2. */ /* Skeleton implementation for Bison's Yacc-like parsers in C - - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 - Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify + + Copyright (C) 1984, 1989-1990, 2000-2006, 2009-2010 Free Software + Foundation, Inc. + + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ + along with this program. If not, see . */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work @@ -29,7 +27,7 @@ special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. - + This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ @@ -47,7 +45,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.3" +#define YYBISON_VERSION "2.4.2" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -55,42 +53,34 @@ /* Pure parsers. */ #define YYPURE 1 +/* Push parsers. */ +#define YYPUSH 0 + +/* Pull parsers. */ +#define YYPULL 1 + /* Using locations. */ #define YYLSP_NEEDED 0 /* Substitute the variable and function names. */ -#define yyparse ceparse -#define yylex celex -#define yyerror ceerror -#define yylval celval -#define yychar cechar -#define yydebug cedebug -#define yynerrs cenerrs - - -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - SCAN_WORD = 258, - SCAN_STRINGCONST = 259, - SCAN_NUMBERCONST = 260 - }; -#endif -/* Tokens. */ -#define SCAN_WORD 258 -#define SCAN_STRINGCONST 259 -#define SCAN_NUMBERCONST 260 - - +#define yyparse ceparse +#define yylex celex +#define yyerror ceerror +#define yylval celval +#define yychar cechar +#define yydebug cedebug +#define yynerrs cenerrs /* Copy the first part of user declarations. */ + +/* Line 189 of yacc.c */ #line 11 "../oc/ce.y" #include "ceparselex.h" +/* Line 189 of yacc.c */ +#line 83 "ce.tab.c" + /* Enabling traces. */ #ifndef YYDEBUG # define YYDEBUG 1 @@ -109,20 +99,34 @@ # define YYTOKEN_TABLE 0 #endif -#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED -typedef int YYSTYPE; -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + SCAN_WORD = 258, + SCAN_STRINGCONST = 259, + SCAN_NUMBERCONST = 260 + }; #endif +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef int YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +#endif + + /* Copy the second part of user declarations. */ -/* Line 216 of yacc.c. */ -#line 126 "ce.tab.c" +/* Line 264 of yacc.c */ +#line 130 "ce.tab.c" #ifdef short # undef short @@ -172,7 +176,7 @@ typedef short int yytype_int16; #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) #ifndef YY_ -# if YYENABLE_NLS +# if defined YYENABLE_NLS && YYENABLE_NLS # if ENABLE_NLS # include /* INFRINGES ON USER NAME SPACE */ # define YY_(msgid) dgettext ("bison-runtime", msgid) @@ -197,14 +201,14 @@ typedef short int yytype_int16; #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static int -YYID (int i) +YYID (int yyi) #else static int -YYID (i) - int i; +YYID (yyi) + int yyi; #endif { - return i; + return yyi; } #endif @@ -285,9 +289,9 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ /* A type that is properly aligned for any stack member. */ union yyalloc { - yytype_int16 yyss; - YYSTYPE yyvs; - }; + yytype_int16 yyss_alloc; + YYSTYPE yyvs_alloc; +}; /* The size of the maximum gap between one aligned stack and the next. */ # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) @@ -321,12 +325,12 @@ union yyalloc elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ -# define YYSTACK_RELOCATE(Stack) \ +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ do \ { \ YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack, Stack, yysize); \ - Stack = &yyptr->Stack; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ @@ -586,9 +590,18 @@ static const yytype_uint8 yystos[] = /* Like YYERROR except do call yyerror. This remains here temporarily to ease the transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. */ + Once GCC version 2 has supplanted version 1, this can go. However, + YYFAIL appears to be in use. Nevertheless, it is formally deprecated + in Bison 2.4.2's NEWS entry, where a plan to phase it out is + discussed. */ #define YYFAIL goto yyerrlab +#if defined YYFAIL + /* This is here to suppress warnings from the GCC cpp's + -Wunused-macros. Normally we don't worry about that warning, but + some users do, and we want to make it easy for users to remove + YYFAIL uses, which will produce warnings from Bison 2.5. */ +#endif #define YYRECOVERING() (!!yyerrstatus) @@ -645,7 +658,7 @@ while (YYID (0)) we won't break user code: when these are the locations we know. */ #ifndef YY_LOCATION_PRINT -# if YYLTYPE_IS_TRIVIAL +# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL # define YY_LOCATION_PRINT(File, Loc) \ fprintf (File, "%d.%d-%d.%d", \ (Loc).first_line, (Loc).first_column, \ @@ -759,17 +772,20 @@ yy_symbol_print (yyoutput, yytype, yyvaluep, parsestate) #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void -yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) #else static void -yy_stack_print (bottom, top) - yytype_int16 *bottom; - yytype_int16 *top; +yy_stack_print (yybottom, yytop) + yytype_int16 *yybottom; + yytype_int16 *yytop; #endif { YYFPRINTF (stderr, "Stack now"); - for (; bottom <= top; ++bottom) - YYFPRINTF (stderr, " %d", *bottom); + for (; yybottom <= yytop; yybottom++) + { + int yybot = *yybottom; + YYFPRINTF (stderr, " %d", yybot); + } YYFPRINTF (stderr, "\n"); } @@ -804,11 +820,11 @@ yy_reduce_print (yyvsp, yyrule, parsestate) /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { - fprintf (stderr, " $%d = ", yyi + 1); + YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], &(yyvsp[(yyi + 1) - (yynrhs)]) , parsestate); - fprintf (stderr, "\n"); + YYFPRINTF (stderr, "\n"); } } @@ -1090,10 +1106,8 @@ yydestruct (yymsg, yytype, yyvaluep, parsestate) break; } } - /* Prevent warnings from -Wmissing-prototypes. */ - #ifdef YYPARSE_PARAM #if defined __STDC__ || defined __cplusplus int yyparse (void *YYPARSE_PARAM); @@ -1112,10 +1126,9 @@ int yyparse (); - -/*----------. -| yyparse. | -`----------*/ +/*-------------------------. +| yyparse or yypush_parse. | +`-------------------------*/ #ifdef YYPARSE_PARAM #if (defined __STDC__ || defined __C99__FUNC__ \ @@ -1139,22 +1152,46 @@ yyparse (parsestate) #endif #endif { - /* The look-ahead symbol. */ +/* The lookahead symbol. */ int yychar; -/* The semantic value of the look-ahead symbol. */ +/* The semantic value of the lookahead symbol. */ YYSTYPE yylval; -/* Number of syntax errors so far. */ -int yynerrs; + /* Number of syntax errors so far. */ + int yynerrs; + + int yystate; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + + /* The stacks and their tools: + `yyss': related to states. + `yyvs': related to semantic values. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs; + YYSTYPE *yyvsp; + + YYSIZE_T yystacksize; - int yystate; int yyn; int yyresult; - /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; - /* Look-ahead token as an internal (translated) token number. */ - int yytoken = 0; + /* Lookahead token as an internal (translated) token number. */ + int yytoken; + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + #if YYERROR_VERBOSE /* Buffer for error messages, and its allocated size. */ char yymsgbuf[128]; @@ -1162,51 +1199,28 @@ int yynerrs; YYSIZE_T yymsg_alloc = sizeof yymsgbuf; #endif - /* Three stacks and their tools: - `yyss': related to states, - `yyvs': related to semantic values, - `yyls': related to locations. - - Refer to the stacks thru separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ - - /* The state stack. */ - yytype_int16 yyssa[YYINITDEPTH]; - yytype_int16 *yyss = yyssa; - yytype_int16 *yyssp; - - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs = yyvsa; - YYSTYPE *yyvsp; - - - #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) - YYSIZE_T yystacksize = YYINITDEPTH; - - /* The variables used to return semantic value and location from the - action routines. */ - YYSTYPE yyval; - - /* The number of symbols on the RHS of the reduced rule. Keep to zero when no symbol should be popped. */ int yylen = 0; + yytoken = 0; + yyss = yyssa; + yyvs = yyvsa; + yystacksize = YYINITDEPTH; + YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ + yychar = YYEMPTY; /* Cause a token to be read. */ /* Initialize stack pointers. Waste one element of value and location stack so that they stay on the same level as the state stack. The wasted elements are never initialized. */ - yyssp = yyss; yyvsp = yyvs; @@ -1236,7 +1250,6 @@ int yynerrs; YYSTYPE *yyvs1 = yyvs; yytype_int16 *yyss1 = yyss; - /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. This used to be a conditional around just the two extra args, but that might @@ -1244,7 +1257,6 @@ int yynerrs; yyoverflow (YY_("memory exhausted"), &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), - &yystacksize); yyss = yyss1; @@ -1267,9 +1279,8 @@ int yynerrs; (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) goto yyexhaustedlab; - YYSTACK_RELOCATE (yyss); - YYSTACK_RELOCATE (yyvs); - + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); # undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); @@ -1280,7 +1291,6 @@ int yynerrs; yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; - YYDPRINTF ((stderr, "Stack size increased to %lu\n", (unsigned long int) yystacksize)); @@ -1290,6 +1300,9 @@ int yynerrs; YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + if (yystate == YYFINAL) + YYACCEPT; + goto yybackup; /*-----------. @@ -1298,16 +1311,16 @@ int yynerrs; yybackup: /* Do appropriate processing given the current state. Read a - look-ahead token if we need one and don't already have one. */ + lookahead token if we need one and don't already have one. */ - /* First try to decide what to do without reference to look-ahead token. */ + /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; if (yyn == YYPACT_NINF) goto yydefault; - /* Not known => get a look-ahead token if don't already have one. */ + /* Not known => get a lookahead token if don't already have one. */ - /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); @@ -1339,20 +1352,16 @@ yybackup: goto yyreduce; } - if (yyn == YYFINAL) - YYACCEPT; - /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; - /* Shift the look-ahead token. */ + /* Shift the lookahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - /* Discard the shifted token unless it is eof. */ - if (yychar != YYEOF) - yychar = YYEMPTY; + /* Discard the shifted token. */ + yychar = YYEMPTY; yystate = yyn; *++yyvsp = yylval; @@ -1392,231 +1401,323 @@ yyreduce: switch (yyn) { case 2: + +/* Line 1464 of yacc.c */ #line 24 "../oc/ce.y" {projections(parsestate,(yyvsp[(1) - (1)]));;} break; case 3: + +/* Line 1464 of yacc.c */ #line 25 "../oc/ce.y" {selections(parsestate,(yyvsp[(1) - (1)]));;} break; case 4: + +/* Line 1464 of yacc.c */ #line 27 "../oc/ce.y" {projections(parsestate,(yyvsp[(1) - (2)])); selections(parsestate,(yyvsp[(2) - (2)]));;} break; case 5: + +/* Line 1464 of yacc.c */ #line 31 "../oc/ce.y" {(yyval)=(yyvsp[(1) - (1)]);;} break; case 6: + +/* Line 1464 of yacc.c */ #line 34 "../oc/ce.y" {(yyval)=(yyvsp[(1) - (1)]);;} break; case 7: + +/* Line 1464 of yacc.c */ #line 39 "../oc/ce.y" {(yyval)=projectionlist(parsestate,null,(yyvsp[(1) - (1)]));;} break; case 8: + +/* Line 1464 of yacc.c */ #line 41 "../oc/ce.y" {(yyval)=projectionlist(parsestate,(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]));;} break; case 9: + +/* Line 1464 of yacc.c */ #line 47 "../oc/ce.y" {(yyval)=projection(parsestate,(yyvsp[(1) - (1)]));;} break; case 10: + +/* Line 1464 of yacc.c */ #line 53 "../oc/ce.y" {(yyval)=segmentlist(parsestate,null,(yyvsp[(1) - (1)]));;} break; case 11: + +/* Line 1464 of yacc.c */ #line 55 "../oc/ce.y" {(yyval)=segmentlist(parsestate,(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]));;} break; case 12: + +/* Line 1464 of yacc.c */ #line 61 "../oc/ce.y" {(yyval)=segment(parsestate,(yyvsp[(1) - (1)]),null);;} break; case 13: + +/* Line 1464 of yacc.c */ #line 63 "../oc/ce.y" {(yyval)=segment(parsestate,(yyvsp[(1) - (2)]),(yyvsp[(2) - (2)]));;} break; case 14: + +/* Line 1464 of yacc.c */ #line 69 "../oc/ce.y" {(yyval)=array_indices(parsestate,null,(yyvsp[(1) - (1)]));;} break; case 15: + +/* Line 1464 of yacc.c */ #line 71 "../oc/ce.y" {(yyval)=array_indices(parsestate,(yyvsp[(1) - (2)]),(yyvsp[(2) - (2)]));;} break; case 16: + +/* Line 1464 of yacc.c */ #line 76 "../oc/ce.y" {(yyval)=(yyvsp[(1) - (1)]);;} break; case 17: + +/* Line 1464 of yacc.c */ #line 82 "../oc/ce.y" {(yyval)=range(parsestate,(yyvsp[(1) - (1)]),null,null);;} break; case 18: + +/* Line 1464 of yacc.c */ #line 84 "../oc/ce.y" {(yyval)=range(parsestate,(yyvsp[(2) - (5)]),null,(yyvsp[(4) - (5)]));;} break; case 19: + +/* Line 1464 of yacc.c */ #line 86 "../oc/ce.y" {(yyval)=range(parsestate,(yyvsp[(2) - (7)]),(yyvsp[(4) - (7)]),(yyvsp[(6) - (7)]));;} break; case 20: + +/* Line 1464 of yacc.c */ #line 89 "../oc/ce.y" {(yyval)=(yyvsp[(2) - (3)]);;} break; case 21: + +/* Line 1464 of yacc.c */ #line 94 "../oc/ce.y" {(yyval)=selectionlist(parsestate,null,(yyvsp[(2) - (2)]));;} break; case 22: + +/* Line 1464 of yacc.c */ #line 96 "../oc/ce.y" {(yyval)=selectionlist(parsestate,(yyvsp[(1) - (2)]),(yyvsp[(2) - (2)]));;} break; case 23: + +/* Line 1464 of yacc.c */ #line 102 "../oc/ce.y" {(yyval)=sel_clause(parsestate,1,(yyvsp[(1) - (5)]),(yyvsp[(2) - (5)]),(yyvsp[(4) - (5)]));;} break; case 24: + +/* Line 1464 of yacc.c */ #line 104 "../oc/ce.y" {(yyval)=sel_clause(parsestate,2,(yyvsp[(1) - (3)]),(yyvsp[(2) - (3)]),(yyvsp[(3) - (3)]));;} break; case 26: + +/* Line 1464 of yacc.c */ #line 111 "../oc/ce.y" {(yyval)=(yyvsp[(1) - (1)]);;} break; case 27: + +/* Line 1464 of yacc.c */ #line 116 "../oc/ce.y" {(yyvsp[(1) - (1)])=selectionpath(parsestate,null,(yyvsp[(1) - (1)]));;} break; case 28: + +/* Line 1464 of yacc.c */ #line 118 "../oc/ce.y" {(yyval)=selectionpath(parsestate,(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]));;} break; case 29: + +/* Line 1464 of yacc.c */ #line 123 "../oc/ce.y" {(yyval)=function(parsestate,(yyvsp[(1) - (3)]),null);;} break; case 30: + +/* Line 1464 of yacc.c */ #line 125 "../oc/ce.y" {(yyval)=function(parsestate,(yyvsp[(1) - (4)]),(yyvsp[(3) - (4)]));;} break; case 31: + +/* Line 1464 of yacc.c */ #line 130 "../oc/ce.y" {(yyval)=arg_list(parsestate,null,(yyvsp[(1) - (1)]));;} break; case 32: + +/* Line 1464 of yacc.c */ #line 132 "../oc/ce.y" {(yyval)=arg_list(parsestate,(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]));;} break; case 33: + +/* Line 1464 of yacc.c */ #line 137 "../oc/ce.y" {(yyval)=value_list(parsestate,null,(yyvsp[(1) - (1)]));;} break; case 34: + +/* Line 1464 of yacc.c */ #line 139 "../oc/ce.y" {(yyval)=value_list(parsestate,(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]));;} break; case 35: + +/* Line 1464 of yacc.c */ #line 144 "../oc/ce.y" {(yyval)=value(parsestate,(yyvsp[(1) - (1)]),SCAN_WORD);;} break; case 36: + +/* Line 1464 of yacc.c */ #line 146 "../oc/ce.y" {(yyval)=value(parsestate,(yyvsp[(1) - (1)]),SCAN_NUMBERCONST);;} break; case 37: + +/* Line 1464 of yacc.c */ #line 148 "../oc/ce.y" {(yyval)=value(parsestate,(yyvsp[(1) - (1)]),SCAN_STRINGCONST);;} break; case 38: + +/* Line 1464 of yacc.c */ #line 153 "../oc/ce.y" {(yyval)=(Object)ST_EQ;;} break; case 39: + +/* Line 1464 of yacc.c */ #line 154 "../oc/ce.y" {(yyval)=(Object)ST_GT;;} break; case 40: + +/* Line 1464 of yacc.c */ #line 155 "../oc/ce.y" {(yyval)=(Object)ST_LT;;} break; case 41: + +/* Line 1464 of yacc.c */ #line 156 "../oc/ce.y" {(yyval)=(Object)ST_NEQ;;} break; case 42: + +/* Line 1464 of yacc.c */ #line 157 "../oc/ce.y" {(yyval)=(Object)ST_RE;;} break; case 43: + +/* Line 1464 of yacc.c */ #line 158 "../oc/ce.y" {(yyval)=(Object)ST_GE;;} break; case 44: + +/* Line 1464 of yacc.c */ #line 159 "../oc/ce.y" {(yyval)=(Object)ST_LE;;} break; case 45: + +/* Line 1464 of yacc.c */ #line 165 "../oc/ce.y" {(yyval)=arrayelement(parsestate,(yyvsp[(1) - (1)]),null);;} break; case 46: + +/* Line 1464 of yacc.c */ #line 167 "../oc/ce.y" {(yyval)=arrayelement(parsestate,(yyvsp[(1) - (2)]),(yyvsp[(2) - (2)]));;} break; case 47: + +/* Line 1464 of yacc.c */ #line 171 "../oc/ce.y" {(yyval) = (yyvsp[(1) - (1)]);;} break; case 48: + +/* Line 1464 of yacc.c */ #line 175 "../oc/ce.y" { unsigned long tmp = 0; if(sscanf((char*)(yyvsp[(1) - (1)]),"%lu",&tmp) != 1) { @@ -1627,23 +1728,30 @@ yyreduce: break; case 49: + +/* Line 1464 of yacc.c */ #line 184 "../oc/ce.y" {(yyval) = (yyvsp[(1) - (1)]);;} break; case 50: + +/* Line 1464 of yacc.c */ #line 188 "../oc/ce.y" {(yyval) = (yyvsp[(1) - (1)]);;} break; case 51: + +/* Line 1464 of yacc.c */ #line 192 "../oc/ce.y" {(yyval) = (yyvsp[(1) - (1)]);;} break; -/* Line 1267 of yacc.c. */ -#line 1647 "ce.tab.c" + +/* Line 1464 of yacc.c */ +#line 1755 "ce.tab.c" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -1654,7 +1762,6 @@ yyreduce: *++yyvsp = yyval; - /* Now `shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ @@ -1719,7 +1826,7 @@ yyerrlab: if (yyerrstatus == 3) { - /* If just tried and failed to reuse look-ahead token after an + /* If just tried and failed to reuse lookahead token after an error, discard it. */ if (yychar <= YYEOF) @@ -1736,7 +1843,7 @@ yyerrlab: } } - /* Else will try to reuse look-ahead token after shifting the error + /* Else will try to reuse lookahead token after shifting the error token. */ goto yyerrlab1; @@ -1793,9 +1900,6 @@ yyerrlab1: YY_STACK_PRINT (yyss, yyssp); } - if (yyn == YYFINAL) - YYACCEPT; - *++yyvsp = yylval; @@ -1820,7 +1924,7 @@ yyabortlab: yyresult = 1; goto yyreturn; -#ifndef yyoverflow +#if !defined(yyoverflow) || YYERROR_VERBOSE /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ @@ -1831,7 +1935,7 @@ yyexhaustedlab: #endif yyreturn: - if (yychar != YYEOF && yychar != YYEMPTY) + if (yychar != YYEMPTY) yydestruct ("Cleanup: discarding lookahead", yytoken, &yylval, parsestate); /* Do not reclaim the symbols of the rule which action triggered @@ -1857,6 +1961,8 @@ yyreturn: } + +/* Line 1684 of yacc.c */ #line 195 "../oc/ce.y" diff --git a/libncdap3/cetab.h b/libncdap3/cetab.h index a065c2240..30f03a9b4 100644 --- a/libncdap3/cetab.h +++ b/libncdap3/cetab.h @@ -1,24 +1,22 @@ -/* A Bison parser, made by GNU Bison 2.3. */ +/* A Bison parser, made by GNU Bison 2.4.2. */ /* Skeleton interface for Bison's Yacc-like parsers in C - - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 - Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify + + Copyright (C) 1984, 1989-1990, 2000-2006, 2009-2010 Free Software + Foundation, Inc. + + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ + along with this program. If not, see . */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work @@ -29,10 +27,11 @@ special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. - + This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ + /* Tokens. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE @@ -44,20 +43,16 @@ SCAN_NUMBERCONST = 260 }; #endif -/* Tokens. */ -#define SCAN_WORD 258 -#define SCAN_STRINGCONST 259 -#define SCAN_NUMBERCONST 260 - #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef int YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 #endif + From ac1287d00bfe33fb20f703ff5c408d785d1b1c1a Mon Sep 17 00:00:00 2001 From: Dennis Heimbigner Date: Thu, 24 Jun 2010 17:32:29 +0000 Subject: [PATCH 15/18] --- ncgen/Makefile.am | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ncgen/Makefile.am b/ncgen/Makefile.am index fca988c5c..518603c4e 100644 --- a/ncgen/Makefile.am +++ b/ncgen/Makefile.am @@ -53,12 +53,12 @@ test: check # Otherwise never invoked, but records how to do it. # BTW: note that renaming is essential because otherwise # autoconf will forcibly delete files of the name *.tab.* -ncgenyy.c: ncgen.l - flex -Pncg -8 ncgen.l - rm -f ncgenyy.c - mv lex.ncg.c ncgenyy.c - -ncgentab.c: ncgen.y ncgenyy.c - bison -pncg -t ncgen.y - rm -f ncgentab.c - mv ncgen.tab.c ncgentab.c +#ncgenyy.c: ncgen.l +# flex -Pncg -8 ncgen.l +# rm -f ncgenyy.c +# mv lex.ncg.c ncgenyy.c +# +#ncgentab.c: ncgen.y ncgenyy.c +# bison -pncg -t ncgen.y +# rm -f ncgentab.c +# mv ncgen.tab.c ncgentab.c From 23727f55979634b70c8fd25429663766b4db7db8 Mon Sep 17 00:00:00 2001 From: Dennis Heimbigner Date: Thu, 24 Jun 2010 17:36:04 +0000 Subject: [PATCH 16/18] --- libncdap3/Makefile.am | 2 + libncdap3/ce.y | 195 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 197 insertions(+) create mode 100644 libncdap3/ce.y diff --git a/libncdap3/Makefile.am b/libncdap3/Makefile.am index 49fd916f3..7749da6e1 100755 --- a/libncdap3/Makefile.am +++ b/libncdap3/Makefile.am @@ -91,6 +91,8 @@ ${top_builddir}/libdispatch/libdispatch.la CLEANFILES += t_dap +EXTRA_DIST = ce.y + endif # BUILD_DAP # These rule are used if someone wants to rebuild the grammar files. diff --git a/libncdap3/ce.y b/libncdap3/ce.y new file mode 100644 index 000000000..e00a783ba --- /dev/null +++ b/libncdap3/ce.y @@ -0,0 +1,195 @@ +/* Copyright 2009, UCAR/Unidata and OPeNDAP, Inc. + See the COPYRIGHT file for more information. */ + +/*The lines down to DO NOT DELETE ... comment are specific to the C Parser. + They will be commennted out when building a java parser. +*/ + +%pure-parser +%lex-param {CEparsestate* parsestate} +%parse-param {CEparsestate* parsestate} +%{#include "ceparselex.h"%} + +/*DO NOT DELETE THIS LINE*/ + +%token SCAN_WORD +%token SCAN_STRINGCONST +%token SCAN_NUMBERCONST + +%start constraints + +%% + +constraints: + projections {projections(parsestate,$1);} + | selections {selections(parsestate,$1);} + | projections selections + {projections(parsestate,$1); selections(parsestate,$2);} + ; + +/* %type NClist */ +projections: projectionlist {$$=$1;} + +/* %type NClist */ +selections: selectionlist {$$=$1;} + +/* %type NClist */ +projectionlist: + projection + {$$=projectionlist(parsestate,null,$1);} + | projectionlist ',' projection + {$$=projectionlist(parsestate,$1,$3);} + ; + +/* %type NCprojection* */ +projection: + segmentlist + {$$=projection(parsestate,$1);} + ; + +/* %type NClist */ +segmentlist: + segment + {$$=segmentlist(parsestate,null,$1);} + | segmentlist '.' segment + {$$=segmentlist(parsestate,$1,$3);} + ; + +/* %type NCsegment */ +segment: + word + {$$=segment(parsestate,$1,null);} + | word array_indices + {$$=segment(parsestate,$1,$2);} + ; + +/* %type NClist */ +array_indices: /* appends indices to state->segment */ + array_index + {$$=array_indices(parsestate,null,$1);} + | array_indices array_index + {$$=array_indices(parsestate,$1,$2);} + ; + +/* %type NCslice* */ +array_index: + range {$$=$1;} + ; + +/* %type NCslice* */ +range: + range1 + {$$=range(parsestate,$1,null,null);} + | '[' index ':' index ']' + {$$=range(parsestate,$2,null,$4);} + | '[' index ':' index ':' index ']' + {$$=range(parsestate,$2,$4,$6);} + ; + +range1: '[' index ']' {$$=$2;} + +/* %type NClist */ +selectionlist: + '&' sel_clause + {$$=selectionlist(parsestate,null,$2);} + | selectionlist sel_clause + {$$=selectionlist(parsestate,$1,$2);} + ; + +/* %type NCselection* */ +sel_clause: + selectionvar rel_op '{' value_list '}' + {$$=sel_clause(parsestate,1,$1,$2,$4);} /*1,2 distinguish cases*/ + | selectionvar rel_op value + {$$=sel_clause(parsestate,2,$1,$2,$3);} + | function + ; + +/* %type NClist */ +selectionvar: + selectionpath + {$$=$1;} + ; +/* %type NClist */ +selectionpath: + arrayelement + {$1=selectionpath(parsestate,null,$1);} + | segment '.' arrayelement + {$$=selectionpath(parsestate,$1,$3);} + ; + +function: + ident '(' ')' + {$$=function(parsestate,$1,null);} + | ident '(' arg_list ')' + {$$=function(parsestate,$1,$3);} + ; + +arg_list: + value + {$$=arg_list(parsestate,null,$1);} + | value_list ',' value + {$$=arg_list(parsestate,$1,$3);} + ; + +value_list: + value + {$$=value_list(parsestate,null,$1);} + | value_list '|' value + {$$=value_list(parsestate,$1,$3);} + ; + +value: + selectionpath /* can be variable or an integer */ + {$$=value(parsestate,$1,SCAN_WORD);} + | number + {$$=value(parsestate,$1,SCAN_NUMBERCONST);} + | string + {$$=value(parsestate,$1,SCAN_STRINGCONST);} + ; + +/* %type SelectionTag */ +rel_op: + '=' {$$=(Object)ST_EQ;} + | '>' {$$=(Object)ST_GT;} + | '<' {$$=(Object)ST_LT;} + | '!' '=' {$$=(Object)ST_NEQ;} + | '=' '~' {$$=(Object)ST_RE;} + | '>' '=' {$$=(Object)ST_GE;} + | '<' '=' {$$=(Object)ST_LE;} + ; + +/* type NCsegment* */ +arrayelement: + word + {$$=arrayelement(parsestate,$1,null);} + | word range1 + {$$=arrayelement(parsestate,$1,$2);} + ; + +ident: word + {$$ = $1;} + ; + +index: number + { unsigned long tmp = 0; + if(sscanf((char*)$1,"%lu",&tmp) != 1) { + yyerror(parsestate,"Index is not an integer"); + } + $$ = $1; + } + ; + +word: SCAN_WORD + {$$ = $1;} + ; + +number: SCAN_NUMBERCONST + {$$ = $1;} + ; + +string: SCAN_STRINGCONST + {$$ = $1;} + ; + +%% From 4220dca07a109309f64e27fe6b6b08bc47735675 Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Fri, 25 Jun 2010 14:51:16 +0000 Subject: [PATCH 17/18] broke out test into libsrc/tst_interops6.c to help find memory problem --- libsrc4/Makefile.am | 14 +++---- libsrc4/nc4file.c | 11 +----- libsrc4/tst_interops.c | 88 ------------------------------------------ 3 files changed, 8 insertions(+), 105 deletions(-) diff --git a/libsrc4/Makefile.am b/libsrc4/Makefile.am index fc94a5ced..b544a7768 100644 --- a/libsrc4/Makefile.am +++ b/libsrc4/Makefile.am @@ -140,10 +140,10 @@ tst_h_atts3 tst_h_vars tst_h_vars2 tst_h_vars3 tst_h_grps \ tst_h_compounds tst_h_compounds2 tst_h_wrt_cmp tst_h_rd_cmp tst_h_vl \ tst_h_opaques tst_h_strings tst_h_strings1 tst_h_dimscales \ tst_h_dimscales1 tst_h_dimscales2 tst_h_dimscales3 tst_h_enums \ -tst_dims tst_dims2 tst_dims3 tst_files tst_files4 tst_vars \ -tst_varms tst_unlim_vars tst_converts tst_converts2 tst_grps \ -tst_compounds tst_compounds2 tst_compounds3 tst_opaques tst_strings \ -tst_interops tst_interops4 tst_interops5 tst_enums tst_coords \ +tst_dims tst_dims2 tst_dims3 tst_files tst_files4 tst_vars tst_varms \ +tst_unlim_vars tst_converts tst_converts2 tst_grps tst_compounds \ +tst_compounds2 tst_compounds3 tst_opaques tst_strings tst_interops \ +tst_interops4 tst_interops5 tst_interops6 tst_enums tst_coords \ tst_coords2 tst_coords3 tst_vars3 tst_chunks tst_utf8 tst_fills \ tst_fillbug tst_xplatform tst_xplatform2 tst_endian_fill @@ -164,9 +164,9 @@ tst_h_dimscales3 tst_h_enums tst_dims tst_dims2 tst_dims3 tst_files \ tst_files4 tst_vars tst_varms tst_unlim_vars tst_converts \ tst_converts2 tst_grps tst_compounds tst_compounds2 tst_compounds3 \ tst_opaques tst_strings tst_interops tst_interops4 tst_interops5 \ -tst_enums tst_vars3 tst_chunks tst_coords tst_coords2 tst_coords3 \ -tst_utf8 tst_fills tst_fillbug tst_xplatform tst_xplatform2 \ -tst_h_atts2 tst_endian_fill +tst_interops6 tst_enums tst_vars3 tst_chunks tst_coords tst_coords2 \ +tst_coords3 tst_utf8 tst_fills tst_fillbug tst_xplatform \ +tst_xplatform2 tst_h_atts2 tst_endian_fill EXTRA_DIST = ref_tst_compounds.nc ref_tst_h_compounds.h5 \ ref_tst_h_compounds2.h5 run_par_tests.sh run_valgrind_tests.sh \ diff --git a/libsrc4/nc4file.c b/libsrc4/nc4file.c index b539cdfdd..6cdb78055 100755 --- a/libsrc4/nc4file.c +++ b/libsrc4/nc4file.c @@ -417,7 +417,7 @@ read_scale(NC_GRP_INFO_T *grp, hid_t datasetid, char *obj_name, int *dim_without_var) { /*char *start_of_len;*/ - char dimscale_name_att[NC_MAX_NAME + 1]; + char dimscale_name_att[NC_MAX_NAME + 1] = ""; int natts, a; hid_t attid = 0; char att_name[NC_MAX_HDF5_NAME + 1]; @@ -485,15 +485,6 @@ read_scale(NC_GRP_INFO_T *grp, hid_t datasetid, char *obj_name, return retval; grp->dim->len = *lenp; } -/* else */ -/* { */ -/* start_of_len = dimscale_name_att + strlen(DIM_WITHOUT_VARIABLE); */ -/* #if (SIZEOF_SIZE_T < 8) */ -/* sscanf(start_of_len, "%d", (int *)&grp->dim->len); */ -/* #else */ -/* sscanf(start_of_len, "%ld", (size_t *)&grp->dim->len); */ -/* #endif */ -/* } */ (*dim_without_var)++; } } diff --git a/libsrc4/tst_interops.c b/libsrc4/tst_interops.c index d5d9eef44..ad3965d0c 100644 --- a/libsrc4/tst_interops.c +++ b/libsrc4/tst_interops.c @@ -401,94 +401,6 @@ main(int argc, char **argv) if (nc_close(ncid)) ERR; } SUMMARIZE_ERR; - printf("*** Checking a HDF5 file with scalar, fixed-length string dataset..."); - { -#define VAR_NAME "Gettysburg Address" - hid_t fapl_id, fcpl_id, fileid, grpid, spaceid, typeid, datasetid, plistid; - /*void *fillp;*/ - /*int ncid, nvars_in, ndims_in, natts_in, unlimdim_in, type_in;*/ - /*size_t size_in;*/ - char data[] = "Four score and seven years ago our fathers brought forth on " - "this continent, a new nation, conceived in Liberty, and dedicated to " - "the proposition that all men are created equal. Now we are engaged " - "in a great civil war, testing whether that nation, or any nation so " - "conceived and so dedicated, can long endure. We are met on a great " - "battle-field of that war. We have come to dedicate a portion of that " - "field, as a final resting place for those who here gave their lives " - "that that nation might live. It is altogether fitting and proper that " - "we should do this. But, in a larger sense, we can not dedicate -- we " - "can not consecrate -- we can not hallow -- this ground. The brave men, " - "living and dead, who struggled here, have consecrated it, far above our " - "poor power to add or detract. The world will little note, nor long " - "remember what we say here, but it can never forget what they did here. " - "It is for us the living, rather, to be dedicated here to the unfinished " - "work which they who fought here have thus far so nobly advanced. It is " - "rather for us to be here dedicated to the great task remaining before " - "us -- that from these honored dead we take increased devotion to that " - "cause for which they gave the last full measure of devotion -- that we " - "here highly resolve that these dead shall not have died in vain -- that " - "this nation, under God, shall have a new birth of freedom -- and that " - "government of the people, by the people, for the people, shall not " - "perish from the earth."; - char *empty = ""; - /*char *data_in2;*/ - - /* Create file access and create property lists. */ - if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) ERR; - if ((fcpl_id = H5Pcreate(H5P_FILE_CREATE)) < 0) ERR; - - /* Set latest_format in access propertly list. This ensures that - * the latest, greatest, HDF5 versions are used in the file. */ - if (H5Pset_libver_bounds(fapl_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) ERR; - - /* Set H5P_CRT_ORDER_TRACKED in the creation property list. This - * turns on HDF5 creation ordering in the file. */ - if (H5Pset_link_creation_order(fcpl_id, (H5P_CRT_ORDER_TRACKED | - H5P_CRT_ORDER_INDEXED)) < 0) ERR; - if (H5Pset_attr_creation_order(fcpl_id, (H5P_CRT_ORDER_TRACKED | - H5P_CRT_ORDER_INDEXED)) < 0) ERR; - - /* Create the file, open root group. */ - if ((fileid = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, fcpl_id, fapl_id)) < 0) ERR; - if ((grpid = H5Gopen2(fileid, "/", H5P_DEFAULT)) < 0) ERR; - - /* Create string type. */ - if ((typeid = H5Tcopy(H5T_C_S1)) < 0) ERR; - if (H5Tset_size(typeid, strlen(data) + 1) < 0) ERR; - - /* Create a scalar space. */ - if ((spaceid = H5Screate(H5S_SCALAR)) < 0) ERR; - - /* Write an scalar dataset of this type. */ - if ((plistid = H5Pcreate(H5P_DATASET_CREATE)) < 0) ERR; - if (H5Pset_fill_value(plistid, typeid, &empty) < 0) ERR; - if ((datasetid = H5Dcreate1(grpid, VAR_NAME, typeid, - spaceid, plistid)) < 0) ERR; - if (H5Dwrite(datasetid, typeid, spaceid, spaceid, - H5P_DEFAULT, data) < 0) ERR; - - /* Close up. */ - if (H5Dclose(datasetid) < 0) ERR; - if (H5Pclose(fapl_id) < 0) ERR; - if (H5Pclose(fcpl_id) < 0) ERR; - if (H5Pclose(plistid) < 0) ERR; - if (H5Tclose(typeid) < 0) ERR; - if (H5Gclose(grpid) < 0) ERR; - if (H5Fclose(fileid) < 0) ERR; - - /* Read the file with netCDF-4. */ -/* if (nc_open(FILE_NAME, NC_NOWRITE, &ncid)) ERR; */ -/* if (nc_inq(ncid, &ndims_in, &nvars_in, &natts_in, &unlimdim_in)) ERR; */ -/* if (ndims_in != 0 || nvars_in != 1 || natts_in != 0 || unlimdim_in != -1) ERR; */ -/* if (nc_inq_att(ncid, NC_GLOBAL, ATT_NAME2, &type_in, &size_in)) ERR; */ -/* if (type_in != NC_STRING || size_in != ATT_LEN) ERR; */ -/* if (nc_get_att_string(ncid, NC_GLOBAL, ATT_NAME2, data_in2)) ERR; */ -/* for (i = 0; i < size_in; i++) */ -/* if (strcmp(data[i], data_in2[i])) ERR; */ -/* if (nc_free_string(size_in, data_in2)) ERR; */ -/* if (nc_close(ncid)) ERR; */ - } - SUMMARIZE_ERR; /* printf("**** testing 2D coordinate variable..."); */ /* { */ From 0f7f58d85caf44665f365c78e54a9be3abff528b Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Fri, 25 Jun 2010 14:51:46 +0000 Subject: [PATCH 18/18] added tst_interops6.c --- libsrc4/tst_interops6.c | 180 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 180 insertions(+) create mode 100644 libsrc4/tst_interops6.c diff --git a/libsrc4/tst_interops6.c b/libsrc4/tst_interops6.c new file mode 100644 index 000000000..a80b5f6dd --- /dev/null +++ b/libsrc4/tst_interops6.c @@ -0,0 +1,180 @@ +/* This is part of the netCDF package. Copyright 2010 University + Corporation for Atmospheric Research/Unidata See COPYRIGHT file for + conditions of use. + + Test that HDF5 and NetCDF-4 can read and write the same file. + + $Id: tst_interops.c,v 1.24 2010/06/01 15:34:52 ed Exp $ +*/ +#include +#include +#include +#include + +#define FILE_NAME "tst_interops6.h5" + +int +main(int argc, char **argv) +{ + printf("\n*** Testing HDF5/NetCDF-4 interoperability yet again...\n"); + printf("*** Checking a HDF5 file with scalar, fixed-length string dataset..."); + { +#define VAR_NAME "Marcus_Aurelius" + hid_t fapl_id, fcpl_id, fileid, grpid, spaceid, typeid, datasetid, plistid; + int ncid, nvars_in, ndims_in, natts_in, unlimdim_in, type_in; + size_t size_in; + char data[] = "Thou art no dissatisfied, I suppose, because " + "thou weighest only so many liters and not three hundred. Be not " + "dissatisfied then that thou must live only so many years and not more; " + "for as thou art satisfied with the amount of substance which has " + "been assigned to thee, so be content with the time."; + char *empty = ""; + char *data_in2, name_in[NC_MAX_NAME + 1]; + + /* Create file access and create property lists. */ + if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) ERR; + if ((fcpl_id = H5Pcreate(H5P_FILE_CREATE)) < 0) ERR; + + /* Set latest_format in access propertly list. This ensures that + * the latest, greatest, HDF5 versions are used in the file. */ + if (H5Pset_libver_bounds(fapl_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) ERR; + + /* Set H5P_CRT_ORDER_TRACKED in the creation property list. This + * turns on HDF5 creation ordering in the file. */ + if (H5Pset_link_creation_order(fcpl_id, (H5P_CRT_ORDER_TRACKED | + H5P_CRT_ORDER_INDEXED)) < 0) ERR; + if (H5Pset_attr_creation_order(fcpl_id, (H5P_CRT_ORDER_TRACKED | + H5P_CRT_ORDER_INDEXED)) < 0) ERR; + + /* Create the file, open root group. */ + if ((fileid = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, fcpl_id, fapl_id)) < 0) ERR; + if ((grpid = H5Gopen2(fileid, "/", H5P_DEFAULT)) < 0) ERR; + + /* Create string type. */ + if ((typeid = H5Tcopy(H5T_C_S1)) < 0) ERR; + if (H5Tset_size(typeid, strlen(data) + 1) < 0) ERR; + + /* Create a scalar space. */ + if ((spaceid = H5Screate(H5S_SCALAR)) < 0) ERR; + + /* Write an scalar dataset of this type. */ + if ((plistid = H5Pcreate(H5P_DATASET_CREATE)) < 0) ERR; + if (H5Pset_fill_value(plistid, typeid, &empty) < 0) ERR; + if ((datasetid = H5Dcreate1(grpid, VAR_NAME, typeid, + spaceid, plistid)) < 0) ERR; + if (H5Dwrite(datasetid, typeid, spaceid, spaceid, + H5P_DEFAULT, data) < 0) ERR; + + /* Close up. */ + if (H5Dclose(datasetid) < 0) ERR; + if (H5Pclose(fapl_id) < 0) ERR; + if (H5Pclose(fcpl_id) < 0) ERR; + if (H5Pclose(plistid) < 0) ERR; + if (H5Tclose(typeid) < 0) ERR; + if (H5Gclose(grpid) < 0) ERR; + if (H5Fclose(fileid) < 0) ERR; + + /* Read the file with netCDF-4. */ +/* nc_set_log_level(6); */ +/* if (nc_open(FILE_NAME, NC_NOWRITE, &ncid)) ERR; */ +/* if (nc_inq(ncid, &ndims_in, &nvars_in, &natts_in, &unlimdim_in)) ERR; */ +/* if (ndims_in != 0 || nvars_in != 1 || natts_in != 0 || unlimdim_in != -1) ERR; */ +/* if (nc_inq_var(ncid, 0, name_in, &type_in, &ndims_in, NULL, &natts_in)) ERR; */ +/* if (strcmp(name_in, VAR_NAME) || type_in != NC_STRING || */ +/* ndims_in != 0 || natts_in != 0) ERR; */ +/* if (nc_get_var_string(ncid, 0, &data_in2)) ERR; */ +/* if (strcmp(data_in2, data)) ERR; */ +/* if (nc_free_string(size_in, &data_in2)) ERR; */ +/* if (nc_close(ncid)) ERR;*/ + } + SUMMARIZE_ERR; +/* printf("*** Checking a HDF5 file with scalar, fixed-length string dataset..."); */ +/* { */ +/* #define VAR_NAME "Gettysburg Address" */ +/* hid_t fapl_id, fcpl_id, fileid, grpid, spaceid, typeid, datasetid, plistid; */ +/* int ncid, nvars_in, ndims_in, natts_in, unlimdim_in, type_in; */ +/* size_t size_in; */ +/* char data[] = "Four score and seven years ago our fathers brought forth on " */ +/* "this continent, a new nation, conceived in Liberty, and dedicated to " */ +/* "the proposition that all men are created equal. Now we are engaged " */ +/* "in a great civil war, testing whether that nation, or any nation so " */ +/* "conceived and so dedicated, can long endure. We are met on a great " */ +/* "battle-field of that war. We have come to dedicate a portion of that " */ +/* "field, as a final resting place for those who here gave their lives " */ +/* "that that nation might live. It is altogether fitting and proper that " */ +/* "we should do this. But, in a larger sense, we can not dedicate -- we " */ +/* "can not consecrate -- we can not hallow -- this ground. The brave men, " */ +/* "living and dead, who struggled here, have consecrated it, far above our " */ +/* "poor power to add or detract. The world will little note, nor long " */ +/* "remember what we say here, but it can never forget what they did here. " */ +/* "It is for us the living, rather, to be dedicated here to the unfinished " */ +/* "work which they who fought here have thus far so nobly advanced. It is " */ +/* "rather for us to be here dedicated to the great task remaining before " */ +/* "us -- that from these honored dead we take increased devotion to that " */ +/* "cause for which they gave the last full measure of devotion -- that we " */ +/* "here highly resolve that these dead shall not have died in vain -- that " */ +/* "this nation, under God, shall have a new birth of freedom -- and that " */ +/* "government of the people, by the people, for the people, shall not " */ +/* "perish from the earth."; */ +/* char *empty = ""; */ +/* char *data_in2, name_in[NC_MAX_NAME + 1]; */ + +/* /\* Create file access and create property lists. *\/ */ +/* if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) ERR; */ +/* if ((fcpl_id = H5Pcreate(H5P_FILE_CREATE)) < 0) ERR; */ + +/* /\* Set latest_format in access propertly list. This ensures that */ +/* * the latest, greatest, HDF5 versions are used in the file. *\/ */ +/* if (H5Pset_libver_bounds(fapl_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) ERR; */ + +/* /\* Set H5P_CRT_ORDER_TRACKED in the creation property list. This */ +/* * turns on HDF5 creation ordering in the file. *\/ */ +/* if (H5Pset_link_creation_order(fcpl_id, (H5P_CRT_ORDER_TRACKED | */ +/* H5P_CRT_ORDER_INDEXED)) < 0) ERR; */ +/* if (H5Pset_attr_creation_order(fcpl_id, (H5P_CRT_ORDER_TRACKED | */ +/* H5P_CRT_ORDER_INDEXED)) < 0) ERR; */ + +/* /\* Create the file, open root group. *\/ */ +/* if ((fileid = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, fcpl_id, fapl_id)) < 0) ERR; */ +/* if ((grpid = H5Gopen2(fileid, "/", H5P_DEFAULT)) < 0) ERR; */ + +/* /\* Create string type. *\/ */ +/* if ((typeid = H5Tcopy(H5T_C_S1)) < 0) ERR; */ +/* if (H5Tset_size(typeid, strlen(data) + 1) < 0) ERR; */ + +/* /\* Create a scalar space. *\/ */ +/* if ((spaceid = H5Screate(H5S_SCALAR)) < 0) ERR; */ + +/* /\* Write an scalar dataset of this type. *\/ */ +/* if ((plistid = H5Pcreate(H5P_DATASET_CREATE)) < 0) ERR; */ +/* if (H5Pset_fill_value(plistid, typeid, &empty) < 0) ERR; */ +/* if ((datasetid = H5Dcreate1(grpid, VAR_NAME, typeid, */ +/* spaceid, plistid)) < 0) ERR; */ +/* if (H5Dwrite(datasetid, typeid, spaceid, spaceid, */ +/* H5P_DEFAULT, data) < 0) ERR; */ + +/* /\* Close up. *\/ */ +/* if (H5Dclose(datasetid) < 0) ERR; */ +/* if (H5Pclose(fapl_id) < 0) ERR; */ +/* if (H5Pclose(fcpl_id) < 0) ERR; */ +/* if (H5Pclose(plistid) < 0) ERR; */ +/* if (H5Tclose(typeid) < 0) ERR; */ +/* if (H5Gclose(grpid) < 0) ERR; */ +/* if (H5Fclose(fileid) < 0) ERR; */ + +/* /\* Read the file with netCDF-4. *\/ */ +/* if (nc_open(FILE_NAME, NC_NOWRITE, &ncid)) ERR; */ +/* if (nc_inq(ncid, &ndims_in, &nvars_in, &natts_in, &unlimdim_in)) ERR; */ +/* if (ndims_in != 0 || nvars_in != 1 || natts_in != 0 || unlimdim_in != -1) ERR; */ +/* if (nc_inq_var(ncid, 0, name_in, &type_in, &ndims_in, NULL, &natts_in)) ERR; */ +/* if (strcmp(name_in, VAR_NAME) || type_in != NC_STRING || */ +/* ndims_in != 0 || natts_in != 0) ERR; */ +/* if (nc_get_var_string(ncid, 0, &data_in2)) ERR; */ +/* if (strcmp(data_in2, data)) ERR; */ +/* if (nc_free_string(size_in, &data_in2)) ERR; */ +/* if (nc_close(ncid)) ERR; */ +/* } */ +/* SUMMARIZE_ERR; */ + FINAL_RESULTS; +} +