ECC-995: C API: Review const-ness of arguments (part 1)

This commit is contained in:
Shahram Najm 2019-10-02 14:51:14 +01:00
parent 0057dc4719
commit 4d5abcb7db
13 changed files with 106 additions and 95 deletions

View File

@ -155,7 +155,7 @@ void codes_index_delete(grib_index* index)
/* Create handle */
/******************************************************************************/
int codes_write_message(grib_handle* h,const char* file,const char* mode)
int codes_write_message(const grib_handle* h,const char* file,const char* mode)
{
return grib_write_message(h,file,mode);
}
@ -171,7 +171,7 @@ grib_handle* codes_grib_handle_new_from_samples(grib_context* c, const char* sam
{
return grib_handle_new_from_samples(c, sample_name);
}
grib_handle* codes_handle_clone(grib_handle* h)
grib_handle* codes_handle_clone(const grib_handle* h)
{
return grib_handle_clone(h);
}
@ -187,11 +187,11 @@ grib_handle* codes_handle_new_from_partial_message(grib_context* c, const void*
{
return grib_handle_new_from_partial_message(c,data,buflen);
}
int codes_get_message(grib_handle* h ,const void** message, size_t *message_length )
int codes_get_message(const grib_handle* h ,const void** message, size_t *message_length )
{
return grib_get_message(h,message,message_length);
}
int codes_get_message_copy(grib_handle* h, void* message,size_t *message_length )
int codes_get_message_copy(const grib_handle* h, void* message,size_t *message_length )
{
return grib_get_message_copy(h,message,message_length);
}
@ -255,11 +255,11 @@ int codes_grib_multi_handle_write(grib_multi_handle* mh,FILE* f)
/* Lat/Lon iterator and nearest (GRIB specific) */
/******************************************************************************/
grib_iterator* codes_grib_iterator_new(grib_handle* h, unsigned long flags,int* error)
grib_iterator* codes_grib_iterator_new(const grib_handle* h, unsigned long flags,int* error)
{
return grib_iterator_new(h,flags,error);
}
int codes_grib_get_data(grib_handle *h, double *lats, double *lons, double *values)
int codes_grib_get_data(const grib_handle *h, double *lats, double *lons, double *values)
{
return grib_get_data(h,lats,lons,values);
}
@ -284,17 +284,17 @@ int codes_grib_iterator_delete(grib_iterator *i)
return grib_iterator_delete(i);
}
grib_nearest* codes_grib_nearest_new(grib_handle* h, int* error)
grib_nearest* codes_grib_nearest_new(const grib_handle* h, int* error)
{
return grib_nearest_new(h,error);
}
int codes_grib_nearest_find(grib_nearest *nearest,grib_handle* h,double inlat,double inlon,
int codes_grib_nearest_find(grib_nearest *nearest, const grib_handle* h,double inlat,double inlon,
unsigned long flags,double* outlats,double* outlons,
double* values,double* distances,int* indexes,size_t *len)
{
return grib_nearest_find(nearest, h, inlat, inlon, flags, outlats, outlons, values, distances, indexes, len);
}
int codes_grib_nearest_find_multiple(grib_handle* h,int is_lsm,
int codes_grib_nearest_find_multiple(const grib_handle* h,int is_lsm,
double* inlats,double* inlons,long npoints,
double* outlats,double* outlons,
double* values,double* distances, int* indexes)
@ -321,11 +321,11 @@ int codes_set_missing(grib_handle* h, const char* key)
{
return grib_set_missing(h,key);
}
int codes_get_size(grib_handle* h, const char* key,size_t *size)
int codes_get_size(const grib_handle* h, const char* key,size_t *size)
{
return grib_get_size(h,key,size);
}
int codes_get_length(grib_handle* h, const char* key,size_t *length)
int codes_get_length(const grib_handle* h, const char* key,size_t *length)
{
return grib_get_length(h,key,length);
}
@ -407,15 +407,15 @@ int codes_set_values(grib_handle* h,grib_values* grib_values , size_t arg_count
{
return grib_set_values(h,grib_values,arg_count);
}
int codes_get_message_offset ( grib_handle* h,off_t* offset )
int codes_get_message_offset(const grib_handle* h,off_t* offset)
{
return grib_get_message_offset (h,offset);
}
int codes_get_message_size ( grib_handle* h,size_t* size )
int codes_get_message_size(const grib_handle* h,size_t* size)
{
return grib_get_message_size (h,size);
}
void codes_dump_content(grib_handle* h,FILE* out,const char* mode, unsigned long option_flags,void* arg)
void codes_dump_content(const grib_handle* h,FILE* out,const char* mode, unsigned long option_flags,void* arg)
{
grib_dump_content(h, out, mode, option_flags, arg);
}

View File

@ -415,7 +415,7 @@ codes_handle* codes_bufr_handle_new_from_file(codes_context* c, FILE* f, int* er
* @param mode : mode
* @return 0 if OK, integer value on error
*/
int codes_write_message(codes_handle* h, const char* file, const char* mode);
int codes_write_message(const codes_handle* h, const char* file, const char* mode);
codes_handle* codes_grib_util_sections_copy(codes_handle* hfrom, codes_handle* hto, int what, int *err);
codes_string_list* codes_grib_util_get_param_id(const char* mars_param);
@ -485,7 +485,7 @@ codes_handle* codes_bufr_handle_new_from_samples(codes_context* c, const char* s
* @param h : The handle to be cloned
* @return the new handle, NULL if the message is invalid or a problem is encountered
*/
codes_handle* codes_handle_clone(codes_handle* h);
codes_handle* codes_handle_clone(const codes_handle* h);
/**
* Frees a handle, also frees the message if it is not a user message
@ -552,7 +552,7 @@ int codes_grib_multi_handle_write(codes_multi_handle* mh, FILE* f);
* @param message_length : On exit, the message size in number of bytes
* @return 0 if OK, integer value on error
*/
int codes_get_message(codes_handle* h, const void** message, size_t *message_length);
int codes_get_message(const codes_handle* h, const void** message, size_t *message_length);
/**
@ -564,7 +564,7 @@ int codes_get_message(codes_handle* h, const void** message, size_t *message_len
* On exit, the actual message length in number of bytes
* @return 0 if OK, integer value on error
*/
int codes_get_message_copy(codes_handle* h, void* message, size_t *message_length);
int codes_get_message_copy(const codes_handle* h, void* message, size_t *message_length);
/*! @} */
/*! \defgroup iterators Iterating on latitude/longitude/values */
@ -578,7 +578,7 @@ int codes_get_message_copy(codes_handle* h, void* message, size_t *message_lengt
* \param error : error code
* \return the new iterator, NULL if no iterator can be created
*/
codes_iterator* codes_grib_iterator_new(codes_handle* h, unsigned long flags, int* error);
codes_iterator* codes_grib_iterator_new(const codes_handle* h, unsigned long flags, int* error);
/**
* Get latitude/longitude and data values.
@ -591,7 +591,7 @@ codes_iterator* codes_grib_iterator_new(codes_handle* h, unsigned long flags, in
* @param values : returned array of data values
* @return 0 if OK, integer value on error
*/
int codes_grib_get_data(codes_handle *h, double *lats, double *lons, double *values);
int codes_grib_get_data(const codes_handle *h, double *lats, double *lons, double *values);
/**
* Get the next value from an iterator.
@ -646,7 +646,7 @@ int codes_grib_iterator_delete(codes_iterator *i);
* \param error : error code
* \return the new nearest, NULL if no nearest can be created
*/
codes_nearest* codes_grib_nearest_new(codes_handle* h, int* error);
codes_nearest* codes_grib_nearest_new(const codes_handle* h, int* error);
/**
* Find the 4 nearest points of a latitude longitude point.
@ -669,7 +669,7 @@ codes_nearest* codes_grib_nearest_new(codes_handle* h, int* error);
* @param len : size of the arrays
* @return 0 if OK, integer value on error
*/
int codes_grib_nearest_find(codes_nearest *nearest, codes_handle* h, double inlat, double inlon,
int codes_grib_nearest_find(codes_nearest *nearest, const codes_handle* h, double inlat, double inlon,
unsigned long flags, double* outlats, double* outlons,
double* values, double* distances, int* indexes, size_t *len);
@ -705,7 +705,7 @@ int codes_grib_nearest_delete(codes_nearest *nearest);
* @param indexes : returned array of indexes of the nearest points
* @return 0 if OK, integer value on error
*/
int codes_grib_nearest_find_multiple(codes_handle* h, int is_lsm,
int codes_grib_nearest_find_multiple(const codes_handle* h, int is_lsm,
double* inlats, double* inlons, long npoints,
double* outlats, double* outlons,
double* values, double* distances, int* indexes);
@ -723,7 +723,7 @@ int codes_grib_nearest_find_multiple(codes_handle* h, int is_lsm,
* @param offset : the address of a size_t where the offset will be set
* @return 0 if OK, integer value on error
*/
int codes_get_offset(codes_handle* h, const char* key, size_t* offset);
int codes_get_offset(const codes_handle* h, const char* key, size_t* offset);
/**
* Get the number of coded value from a key, if several keys of the same name are present, the total sum is returned
@ -733,7 +733,7 @@ int codes_get_offset(codes_handle* h, const char* key, size_t* offset);
* @param size : the address of a size_t where the size will be set
* @return 0 if OK, integer value on error
*/
int codes_get_size(codes_handle* h, const char* key, size_t *size);
int codes_get_size(const codes_handle* h, const char* key, size_t *size);
/**
* Get the length of the string representation of the key, if several keys of the same name are present, the maximum length is returned
@ -743,7 +743,7 @@ int codes_get_size(codes_handle* h, const char* key, size_t *size);
* @param length : the address of a size_t where the length will be set
* @return 0 if OK, integer value on error
*/
int codes_get_length(codes_handle* h, const char* key, size_t *length);
int codes_get_length(const codes_handle* h, const char* key, size_t *length);
/**
* Get a long value from a key, if several keys of the same name are present, the last one is returned
@ -963,7 +963,7 @@ int codes_set_string_array(codes_handle *h, const char *key, const char **vals,
* @param option_flags : all the CODES_DUMP_FLAG_x flags can be used
* @param arg : used to provide a format to output data (experimental)
*/
void codes_dump_content(codes_handle* h, FILE* out, const char* mode, unsigned long option_flags, void* arg);
void codes_dump_content(const codes_handle* h, FILE* out, const char* mode, unsigned long option_flags, void* arg);
/**
* Print all keys from the parsed definition files available in a context
@ -1215,9 +1215,9 @@ void codes_get_reduced_row_p(long pl, double lon_first, double lon_last, long *n
/* read products */
int codes_get_message_offset(codes_handle* h, off_t* offset);
int codes_get_message_size(codes_handle* h, size_t* size);
int codes_get_product_kind(codes_handle* h, ProductKind* product_kind);
int codes_get_message_offset(const codes_handle* h, off_t* offset);
int codes_get_message_size(const codes_handle* h, size_t* size);
int codes_get_product_kind(const codes_handle* h, ProductKind* product_kind);
int codes_check_message_header(const void* bytes, size_t length, ProductKind product);
int codes_check_message_footer(const void* bytes, size_t length, ProductKind product);

View File

@ -144,8 +144,9 @@ static void dump(grib_accessor* a,grib_dumper* dumper)
grib_dump_label(dumper,a,NULL);
}
grib_iterator* grib_iterator_new(grib_handle* h,unsigned long flags,int* error)
{
grib_iterator* grib_iterator_new(const grib_handle* ch, unsigned long flags, int* error)
{
grib_handle* h = (grib_handle*)ch;
grib_accessor* a = NULL;
grib_accessor_iterator* ita =NULL;
grib_iterator* iter =NULL;

View File

@ -140,8 +140,9 @@ static void dump(grib_accessor* a,grib_dumper* dumper)
grib_dump_label(dumper,a,NULL);
}
grib_nearest* grib_nearest_new(grib_handle* h,int* error)
grib_nearest* grib_nearest_new(const grib_handle* ch, int* error)
{
grib_handle* h = (grib_handle*)ch;
grib_accessor* a = NULL;
grib_accessor_nearest* na =NULL;
grib_nearest* n =NULL;

View File

@ -433,7 +433,7 @@ grib_handle* grib_handle_new_from_file(grib_context* c, FILE* f, int* error);
* @param mode : mode
* @return 0 if OK, integer value on error
*/
int grib_write_message(grib_handle* h,const char* file,const char* mode);
int grib_write_message(const grib_handle* h,const char* file,const char* mode);
typedef struct grib_string_list grib_string_list;
struct grib_string_list {
@ -502,7 +502,7 @@ grib_handle* grib_handle_new_from_samples (grib_context* c, const char* sample_n
* @param h : The handle to be cloned
* @return the new handle, NULL if the message is invalid or a problem is encountered
*/
grib_handle* grib_handle_clone(grib_handle* h) ;
grib_handle* grib_handle_clone(const grib_handle* h) ;
/**
* Frees a handle, also frees the message if it is not a user message
@ -565,7 +565,7 @@ int grib_multi_handle_write(grib_multi_handle* mh,FILE* f);
* @param message_length : On exit, the message size in number of bytes
* @return 0 if OK, integer value on error
*/
int grib_get_message(grib_handle* h ,const void** message, size_t *message_length);
int grib_get_message(const grib_handle* h ,const void** message, size_t *message_length);
/**
@ -577,7 +577,7 @@ int grib_get_message(grib_handle* h ,const void** message, size_t *message_lengt
* On exit, the actual message length in number of bytes
* @return 0 if OK, integer value on error
*/
int grib_get_message_copy(grib_handle* h , void* message,size_t *message_length);
int grib_get_message_copy(const grib_handle* h, void* message,size_t *message_length);
/*! @} */
/*! \defgroup iterators Iterating on latitude/longitude/values */
@ -591,7 +591,7 @@ int grib_get_message_copy(grib_handle* h , void* message,size_t *message_length
* \param error : error code
* \return the new iterator, NULL if no iterator can be created
*/
grib_iterator* grib_iterator_new(grib_handle* h, unsigned long flags,int* error);
grib_iterator* grib_iterator_new(const grib_handle* h, unsigned long flags, int* error);
/**
* Get latitude/longitude and data values.
@ -604,7 +604,7 @@ grib_iterator* grib_iterator_new(grib_handle* h, unsigned long flags,int* erro
* @param values : returned array of data values
* @return 0 if OK, integer value on error
*/
int grib_get_data(grib_handle *h, double *lats, double *lons, double *values);
int grib_get_data(const grib_handle *h, double *lats, double *lons, double *values);
/**
* Get the next value from an iterator.
@ -659,7 +659,7 @@ int grib_iterator_delete(grib_iterator *i);
* \param error : error code
* \return the new nearest, NULL if no nearest can be created
*/
grib_nearest* grib_nearest_new(grib_handle* h, int* error);
grib_nearest* grib_nearest_new(const grib_handle* h, int* error);
/**
* Find the 4 nearest points of a latitude longitude point.
@ -682,7 +682,7 @@ grib_nearest* grib_nearest_new(grib_handle* h, int* error);
* @param len : size of the arrays
* @return 0 if OK, integer value on error
*/
int grib_nearest_find(grib_nearest *nearest,grib_handle* h,double inlat,double inlon,
int grib_nearest_find(grib_nearest *nearest, const grib_handle* h,double inlat,double inlon,
unsigned long flags,double* outlats,double* outlons,
double* values,double* distances,int* indexes,size_t *len);
@ -718,7 +718,7 @@ int grib_nearest_delete(grib_nearest *nearest);
* @param indexes : returned array of indexes of the nearest points
* @return 0 if OK, integer value on error
*/
int grib_nearest_find_multiple(grib_handle* h,int is_lsm,
int grib_nearest_find_multiple(const grib_handle* h,int is_lsm,
double* inlats,double* inlons,long npoints,
double* outlats,double* outlons,
double* values,double* distances, int* indexes);
@ -736,7 +736,7 @@ int grib_nearest_find_multiple(grib_handle* h,int is_lsm,
* @param offset : the address of a size_t where the offset will be set
* @return 0 if OK, integer value on error
*/
int grib_get_offset(grib_handle* h, const char* key, size_t* offset);
int grib_get_offset(const grib_handle* h, const char* key, size_t* offset);
/**
* Get the number of coded value from a key, if several keys of the same name are present, the total sum is returned
@ -746,7 +746,7 @@ int grib_get_offset(grib_handle* h, const char* key, size_t* offset);
* @param size : the address of a size_t where the size will be set
* @return 0 if OK, integer value on error
*/
int grib_get_size(grib_handle* h, const char* key,size_t *size);
int grib_get_size(const grib_handle* h, const char* key,size_t *size);
/**
* Get the length of the string representation of the key, if several keys of the same name are present, the maximum length is returned
@ -756,7 +756,7 @@ int grib_get_size(grib_handle* h, const char* key,size_t *size);
* @param length : the address of a size_t where the length will be set
* @return 0 if OK, integer value on error
*/
int grib_get_length(grib_handle* h, const char* key,size_t *length);
int grib_get_length(const grib_handle* h, const char* key,size_t *length);
/**
* Get a long value from a key, if several keys of the same name are present, the last one is returned
@ -975,7 +975,7 @@ int grib_set_string_array(grib_handle* h, const char *key, const char **vals, si
* @param option_flags : all the GRIB_DUMP_FLAG_x flags can be used
* @param arg : used to provide a format to output data (experimental)
*/
void grib_dump_content(grib_handle* h,FILE* out,const char* mode, unsigned long option_flags,void* arg);
void grib_dump_content(const grib_handle* h,FILE* out,const char* mode, unsigned long option_flags,void* arg);
/**
* Print all keys from the parsed definition files available in a context
@ -1365,8 +1365,8 @@ void *wmo_read_bufr_from_file_malloc(FILE* f,int headers_only,size_t *size,off_t
void *wmo_read_grib_from_file_malloc(FILE* f,int headers_only,size_t *size,off_t *offset,int* err);
int grib_read_any_from_file(grib_context *ctx, FILE *f, void *buffer, size_t *len);
int grib_get_message_offset ( grib_handle* h,off_t* offset);
int grib_get_message_size ( grib_handle* h,size_t* size);
int grib_get_message_offset(const grib_handle* h,off_t* offset);
int grib_get_message_size(const grib_handle* h,size_t* size);
struct grib_points {
grib_context* context;

View File

@ -519,12 +519,12 @@ void accessor_constant_set_type(grib_accessor *a, int type);
void accessor_constant_set_dval(grib_accessor *a, double dval);
/* grib_accessor_class_iterator.c */
grib_iterator *grib_iterator_new(grib_handle *h, unsigned long flags, int *error);
grib_iterator *grib_iterator_new(const grib_handle *h, unsigned long flags, int *error);
/* grib_accessor_class_message.c */
/* grib_accessor_class_nearest.c */
grib_nearest *grib_nearest_new(grib_handle *h, int *error);
grib_nearest *grib_nearest_new(const grib_handle *h, int *error);
/* grib_accessor_class_box.c */
grib_box *grib_box_new(grib_handle *h, int *error);
@ -916,8 +916,8 @@ void grib_dump_bytes(grib_dumper *d, grib_accessor *a, const char *comment);
void grib_dump_bits(grib_dumper *d, grib_accessor *a, const char *comment);
void grib_dump_section(grib_dumper *d, grib_accessor *a, grib_block_of_accessors *block);
void grib_dump_values(grib_dumper *d, grib_accessor *a);
void grib_dump_header(grib_dumper *d, grib_handle *h);
void grib_dump_footer(grib_dumper *d, grib_handle *h);
void grib_dump_header(grib_dumper *d, const grib_handle *h);
void grib_dump_footer(grib_dumper *d, const grib_handle *h);
/* grib_dumper_class_serialize.c */
@ -952,11 +952,11 @@ void grib_dump_footer(grib_dumper *d, grib_handle *h);
/* grib_dumper_class_wmo.c */
/* grib_dumper_class.c */
grib_dumper *grib_dumper_factory(const char *op, grib_handle *h, FILE *out, unsigned long option_flags, void *arg);
grib_dumper *grib_dumper_factory(const char *op, const grib_handle *h, FILE *out, unsigned long option_flags, void *arg);
void grib_dump_accessors_block(grib_dumper *dumper, grib_block_of_accessors *block);
void grib_dump_accessors_list(grib_dumper *dumper, grib_accessors_list *al);
int grib_print(grib_handle *h, const char *name, grib_dumper *d);
void grib_dump_content(grib_handle *h, FILE *f, const char *mode, unsigned long flags, void *data);
void grib_dump_content(const grib_handle *h, FILE *f, const char *mode, unsigned long flags, void *data);
void grib_dump_keys(grib_handle* h, FILE* f, const char* mode, unsigned long flags, void *data, const char **keys, size_t num_keys);
grib_dumper *grib_dump_content_with_dumper(grib_handle *h, grib_dumper *dumper, FILE *f, const char *mode, unsigned long flags, void *data);
void codes_dump_bufr_flat(grib_accessors_list *al, grib_handle *h, FILE *f, const char *mode, unsigned long flags, void *data);
@ -1070,8 +1070,8 @@ int grib_handle_delete(grib_handle *h);
grib_handle *grib_new_handle(grib_context *c);
grib_handle *grib_handle_new_from_samples(grib_context *c, const char *name);
grib_handle *codes_bufr_handle_new_from_samples(grib_context *c, const char *name);
int grib_write_message(grib_handle *h, const char *file, const char *mode);
grib_handle *grib_handle_clone(grib_handle *h);
int grib_write_message(const grib_handle *h, const char *file, const char *mode);
grib_handle *grib_handle_clone(const grib_handle *h);
grib_handle *codes_handle_new_from_file(grib_context *c, FILE *f, ProductKind product, int *error);
grib_handle *codes_grib_handle_new_from_file(grib_context *c, FILE *f, int *error);
grib_handle *codes_bufr_handle_new_from_file(grib_context *c, FILE *f, int *error);
@ -1095,13 +1095,13 @@ int grib_multi_handle_append(grib_handle *h, int start_section, grib_multi_handl
int grib_multi_handle_write(grib_multi_handle *h, FILE *f);
int grib_get_partial_message(grib_handle *h, const void **msg, size_t *len, int start_section);
int grib_get_partial_message_copy(grib_handle *h, void *message, size_t *len, int start_section);
int grib_get_message_copy(grib_handle *h, void *message, size_t *len);
int grib_get_message_offset(grib_handle *h, off_t *offset);
int codes_get_product_kind(grib_handle *h, ProductKind *product_kind);
int grib_get_message_copy(const grib_handle *h, void *message, size_t *len);
int grib_get_message_offset(const grib_handle *h, off_t *offset);
int codes_get_product_kind(const grib_handle *h, ProductKind *product_kind);
int codes_check_message_header(const void *bytes, size_t length, ProductKind product);
int codes_check_message_footer(const void *bytes, size_t length, ProductKind product);
int grib_get_message_size(grib_handle *h, size_t *size);
int grib_get_message(grib_handle *h, const void **msg, size_t *size);
int grib_get_message_size(const grib_handle *h, size_t *size);
int grib_get_message(const grib_handle *h, const void **msg, size_t *size);
int grib_get_message_headers(grib_handle *h, const void **msg, size_t *size);
grib_handle *grib_handle_new(grib_context *c);
grib_action *grib_action_from_filter(const char *filter);
@ -1219,9 +1219,9 @@ grib_action *grib_parse_file(grib_context *gc, const char *filename);
int grib_type_to_int(char id);
/* grib_query.c */
grib_accessors_list *grib_find_accessors_list(grib_handle *h, const char *name);
grib_accessors_list *grib_find_accessors_list(const grib_handle *h, const char *name);
char *grib_split_name_attribute(grib_context *c, const char *name, char *attribute_name);
grib_accessor *grib_find_accessor(grib_handle *h, const char *name);
grib_accessor *grib_find_accessor(const grib_handle *h, const char *name);
grib_accessor *grib_find_attribute(grib_handle *h, const char *name, const char *attr_name, int *err);
grib_accessor *grib_find_accessor_fast(grib_handle *h, const char *name);
@ -1295,12 +1295,12 @@ int _grib_get_double_array_internal(grib_handle *h, grib_accessor *a, double *va
int grib_get_double_array_internal(grib_handle *h, const char *name, double *val, size_t *length);
int grib_get_double_array(grib_handle *h, const char *name, double *val, size_t *length);
int _grib_get_string_length(grib_accessor *a, size_t *size);
int grib_get_string_length(grib_handle *h, const char *name, size_t *size);
int _grib_get_size(grib_handle *h, grib_accessor *a, size_t *size);
int grib_get_size(grib_handle *h, const char *name, size_t *size);
int grib_get_length(grib_handle *h, const char *name, size_t *length);
int grib_get_string_length(const grib_handle *h, const char *name, size_t *size);
int _grib_get_size(const grib_handle *h, grib_accessor *a, size_t *size);
int grib_get_size(const grib_handle *h, const char *name, size_t *size);
int grib_get_length(const grib_handle *h, const char *name, size_t *length);
int grib_get_count(grib_handle *h, const char *name, size_t *size);
int grib_get_offset(grib_handle *h, const char *key, size_t *val);
int grib_get_offset(const grib_handle *h, const char *key, size_t *val);
int _grib_get_string_array_internal(grib_handle *h, grib_accessor *a, char **val, size_t buffer_len, size_t *decoded_length);
int grib_get_string_array(grib_handle *h, const char *name, char **val, size_t *length);
int _grib_get_long_array_internal(grib_handle *h, grib_accessor *a, long *val, size_t buffer_len, size_t *decoded_length);
@ -1386,12 +1386,12 @@ grib_box *grib_box_factory(grib_handle *h, grib_arguments *args);
/* grib_box_class_reduced_gaussian.c */
/* grib_nearest.c */
int grib_nearest_find(grib_nearest *nearest, grib_handle *h, double inlat, double inlon, unsigned long flags, double *outlats, double *outlons, double *values, double *distances, int *indexes, size_t *len);
int grib_nearest_find(grib_nearest *nearest, const grib_handle *h, double inlat, double inlon, unsigned long flags, double *outlats, double *outlons, double *values, double *distances, int *indexes, size_t *len);
int grib_nearest_init(grib_nearest *i, grib_handle *h, grib_arguments *args);
int grib_nearest_delete(grib_nearest *i);
void grib_binary_search(double xx[], const unsigned long n, double x, int *ju, int *jl);
double grib_nearest_distance(double radius, double lon1, double lat1, double lon2, double lat2);
int grib_nearest_find_multiple(grib_handle *h, int is_lsm, double *inlats, double *inlons, long npoints, double *outlats, double *outlons, double *values, double *distances, int *indexes);
int grib_nearest_find_multiple(const grib_handle *h, int is_lsm, double *inlats, double *inlons, long npoints, double *outlats, double *outlons, double *values, double *distances, int *indexes);
/* grib_nearest_class.c */
grib_nearest *grib_nearest_factory(grib_handle *h, grib_arguments *args);
@ -1417,7 +1417,7 @@ grib_nearest *grib_nearest_factory(grib_handle *h, grib_arguments *args);
/* grib_iterator_class_lambert_conformal.c */
/* grib_iterator.c */
int grib_get_data(grib_handle *h, double *lats, double *lons, double *values);
int grib_get_data(const grib_handle *h, double *lats, double *lons, double *values);
int grib_iterator_next(grib_iterator *i, double *lat, double *lon, double *value);
int grib_iterator_has_next(grib_iterator *i);
int grib_iterator_previous(grib_iterator *i, double *lat, double *lon, double *value);

View File

@ -211,8 +211,9 @@ void grib_dump_values(grib_dumper* d,grib_accessor* a)
Assert(0);
}
void grib_dump_header(grib_dumper* d,grib_handle* h)
void grib_dump_header(grib_dumper* d, const grib_handle* ch)
{
grib_handle* h = (grib_handle*)ch;
grib_dumper_class *c = d->cclass;
while(c)
{
@ -225,8 +226,9 @@ void grib_dump_header(grib_dumper* d,grib_handle* h)
}
}
void grib_dump_footer(grib_dumper* d,grib_handle* h)
void grib_dump_footer(grib_dumper* d, const grib_handle* ch)
{
grib_handle* h = (grib_handle*)ch;
grib_dumper_class *c = d->cclass;
while(c)
{

View File

@ -29,7 +29,7 @@ static struct table_entry table[] =
#define NUMBER(x) (sizeof(x)/sizeof(x[0]))
grib_dumper* grib_dumper_factory(const char* op, grib_handle* h, FILE* out, unsigned long option_flags,void* arg)
grib_dumper* grib_dumper_factory(const char* op, const grib_handle* h, FILE* out, unsigned long option_flags,void* arg)
{
int i;
for(i = 0; i < NUMBER(table) ; i++)
@ -38,7 +38,7 @@ grib_dumper* grib_dumper_factory(const char* op, grib_handle* h, FILE* out, unsi
grib_dumper_class* c = *(table[i].cclass);
grib_dumper* d = (grib_dumper*) grib_context_malloc_clear(h->context,c->size);
d->depth = 0;
d->handle = h;
d->handle = (grib_handle*)h;
d->cclass = c;
d->option_flags = option_flags;
d->arg = arg;
@ -80,7 +80,7 @@ int grib_print(grib_handle* h, const char* name, grib_dumper *d ){
return GRIB_NOT_FOUND;
}
void grib_dump_content(grib_handle* h, FILE* f,const char* mode,unsigned long flags,void *data)
void grib_dump_content(const grib_handle* h, FILE* f,const char* mode,unsigned long flags,void *data)
{
grib_dumper *dumper;
dumper = grib_dumper_factory(mode?mode:"serialize", h, f, flags, data);

View File

@ -295,7 +295,7 @@ grib_handle* codes_bufr_handle_new_from_samples ( grib_context* c, const char* n
return g;
}
int grib_write_message(grib_handle* h,const char* file,const char* mode)
int grib_write_message(const grib_handle* h,const char* file,const char* mode)
{
FILE* fh=0;
int err;
@ -324,9 +324,9 @@ int grib_write_message(grib_handle* h,const char* file,const char* mode)
return 0;
}
grib_handle* grib_handle_clone ( grib_handle* h )
grib_handle* grib_handle_clone(const grib_handle* h)
{
grib_handle* result = grib_handle_new_from_message_copy ( h->context, h->buffer->data, h->buffer->ulength );
grib_handle* result = grib_handle_new_from_message_copy(h->context, h->buffer->data, h->buffer->ulength );
result->product_kind = h->product_kind;
return result;
}
@ -1264,7 +1264,7 @@ int grib_get_partial_message_copy ( grib_handle* h , void* message,size_t *len,
return GRIB_SUCCESS;
}
int grib_get_message_copy ( grib_handle* h , void* message,size_t *len )
int grib_get_message_copy(const grib_handle* h, void* message,size_t *len)
{
if ( !h )
return GRIB_NOT_FOUND;
@ -1278,7 +1278,7 @@ int grib_get_message_copy ( grib_handle* h , void* message,size_t *len )
return GRIB_SUCCESS;
}
int grib_get_message_offset ( grib_handle* h,off_t* offset )
int grib_get_message_offset(const grib_handle* h,off_t* offset)
{
if (h) *offset=h->offset;
else return GRIB_INTERNAL_ERROR;
@ -1286,7 +1286,7 @@ int grib_get_message_offset ( grib_handle* h,off_t* offset )
return 0;
}
int codes_get_product_kind(grib_handle* h, ProductKind* product_kind)
int codes_get_product_kind(const grib_handle* h, ProductKind* product_kind)
{
if (h) {
*product_kind = h->product_kind;
@ -1327,20 +1327,22 @@ int codes_check_message_footer(const void* bytes, size_t length, ProductKind pro
return GRIB_SUCCESS;
}
int grib_get_message_size ( grib_handle* h,size_t* size )
int grib_get_message_size(const grib_handle* ch,size_t* size)
{
long totalLength=0;
int ret=0;
grib_handle* h = (grib_handle*)ch;
*size = h->buffer->ulength;
ret=grib_get_long(h,"totalLength",&totalLength);
if (!ret) *size=totalLength;
return ret;
}
int grib_get_message ( grib_handle* h,const void** msg,size_t* size )
int grib_get_message(const grib_handle* ch, const void** msg, size_t* size)
{
long totalLength=0;
int ret=0;
grib_handle* h = (grib_handle*)ch;
*msg = h->buffer->data;
*size = h->buffer->ulength;

View File

@ -44,7 +44,7 @@ static void init_mutex()
#endif
int grib_get_data(grib_handle* h,double* lats, double* lons,double* values)
int grib_get_data(const grib_handle* h,double* lats, double* lons,double* values)
{
int err=0;
grib_iterator* iter=NULL;

View File

@ -17,12 +17,13 @@
#include "grib_api_internal.h"
int grib_nearest_find(
grib_nearest *nearest, grib_handle* h,
grib_nearest *nearest, const grib_handle* ch,
double inlat, double inlon,
unsigned long flags,
double* outlats,double* outlons,
double* values, double* distances, int* indexes, size_t *len)
{
grib_handle* h = (grib_handle*)ch;
grib_nearest_class *c = NULL;
if (!nearest) return GRIB_INVALID_ARGUMENT;
c = nearest->cclass;
@ -128,7 +129,7 @@ double grib_nearest_distance(double radius,double lon1, double lat1, double lon2
return radius*acos(a);
}
int grib_nearest_find_multiple(grib_handle* h,int is_lsm,
int grib_nearest_find_multiple(const grib_handle* h,int is_lsm,
double* inlats,double* inlons,long npoints,
double* outlats,double* outlons,
double* values,double* distances, int* indexes)

View File

@ -421,12 +421,13 @@ static void grib_find_same_and_push(grib_accessors_list* al,grib_accessor* a)
}
}
grib_accessors_list* grib_find_accessors_list(grib_handle* h,const char* name)
grib_accessors_list* grib_find_accessors_list(const grib_handle* ch,const char* name)
{
char* str=NULL;
grib_accessors_list* al=NULL;
codes_condition* condition=NULL;
grib_accessor* a=NULL;
grib_handle* h = (grib_handle*)ch;
if (name[0]=='/') {
condition=(codes_condition*)grib_context_malloc_clear(h->context,sizeof(codes_condition));
@ -475,8 +476,9 @@ static grib_accessor* search_and_cache(grib_handle* h, const char* name,const ch
return a;
}
static grib_accessor* _grib_find_accessor(grib_handle* h, const char* name)
static grib_accessor* _grib_find_accessor(const grib_handle* ch, const char* name)
{
grib_handle* h = (grib_handle*)ch;
grib_accessor* a = NULL;
char* p = NULL;
DebugAssert(name);
@ -523,7 +525,7 @@ char* grib_split_name_attribute(grib_context* c,const char* name,char* attribute
return accessor_name;
}
grib_accessor* grib_find_accessor(grib_handle* h, const char* name)
grib_accessor* grib_find_accessor(const grib_handle* h, const char* name)
{
grib_accessor* aret = NULL;
Assert(h);

View File

@ -1156,7 +1156,7 @@ int _grib_get_string_length(grib_accessor* a, size_t* size)
return GRIB_SUCCESS;
}
int grib_get_string_length(grib_handle* h, const char* name,size_t* size)
int grib_get_string_length(const grib_handle* h, const char* name,size_t* size)
{
grib_accessor* a = NULL;
grib_accessors_list* al=NULL;
@ -1175,7 +1175,7 @@ int grib_get_string_length(grib_handle* h, const char* name,size_t* size)
}
}
int _grib_get_size(grib_handle* h, grib_accessor* a,size_t* size)
int _grib_get_size(const grib_handle* h, grib_accessor* a,size_t* size)
{
long count=0;
int err=0;
@ -1195,8 +1195,9 @@ int _grib_get_size(grib_handle* h, grib_accessor* a,size_t* size)
return GRIB_SUCCESS;
}
int grib_get_size(grib_handle* h, const char* name,size_t* size)
int grib_get_size(const grib_handle* ch, const char* name,size_t* size)
{
grib_handle* h = (grib_handle*)ch;
grib_accessor* a =NULL;
grib_accessors_list* al=NULL;
int ret=0;
@ -1220,7 +1221,7 @@ int grib_get_size(grib_handle* h, const char* name,size_t* size)
}
}
int grib_get_length(grib_handle* h, const char* name, size_t* length)
int grib_get_length(const grib_handle* h, const char* name, size_t* length)
{
return grib_get_string_length(h, name, length);
}
@ -1238,8 +1239,9 @@ int grib_get_count(grib_handle* h, const char* name,size_t* size)
return GRIB_SUCCESS;
}
int grib_get_offset(grib_handle* h, const char* key,size_t* val)
int grib_get_offset(const grib_handle* ch, const char* key,size_t* val)
{
grib_handle* h = (grib_handle*)ch;
grib_accessor* act = grib_find_accessor(h, key);
if(act) {
*val = (size_t)grib_byte_offset(act);