This commit is contained in:
Shahram Najm 2015-12-31 11:51:57 +00:00
parent 024f54a5cd
commit 4ab4ce2a9d
5 changed files with 50 additions and 52 deletions

View File

@ -239,7 +239,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t *len)
return GRIB_SUCCESS;
}
static char* months[] = {
static const char* months[] = {
"jan","feb","mar","apr",
"may","jun","jul","aug",
"sep","oct","nov","dec",

View File

@ -15,28 +15,25 @@
***************************************************************************/
#include "grib_api_internal.h"
/* #if GRIB_PTHREADS */
#if 0
static pthread_once_t once = PTHREAD_ONCE_INIT;
static pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t mutex2 = PTHREAD_MUTEX_INITIALIZER;
static void init() {
/* #if GRIB_PTHREADS */
static pthread_once_t once = PTHREAD_ONCE_INIT;
static pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t mutex2 = PTHREAD_MUTEX_INITIALIZER;
static void init() {
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
pthread_mutexattr_settype(&attr,PTHREAD_MUTEX_RECURSIVE);
pthread_mutex_init(&mutex1,&attr);
pthread_mutex_init(&mutex2,&attr);
pthread_mutexattr_destroy(&attr);
}
/* #elif GRIB_OMP_THREADS */
static int once = 0;
static omp_nest_lock_t mutex1;
static omp_nest_lock_t mutex2;
static void init()
{
}
/* #elif GRIB_OMP_THREADS */
static int once = 0;
static omp_nest_lock_t mutex1;
static omp_nest_lock_t mutex2;
static void init()
{
GRIB_OMP_CRITICAL(lock_grib_handle_c)
{
if (once == 0)
@ -46,10 +43,9 @@ static void init()
once = 1;
}
}
}
}
#endif
static grib_handle* grib_handle_new_from_file_no_multi ( grib_context* c, FILE* f,int headers_only,int *error );
static grib_handle* grib_handle_new_from_file_multi ( grib_context* c, FILE* f,int *error );
static int grib2_get_next_section ( unsigned char* msgbegin,size_t msglen,unsigned char** secbegin,size_t* seclen,int* secnum,int* err );
@ -129,7 +125,6 @@ void grib_empty_section ( grib_context *c,grib_section* b )
current = next;
}
b->block->first = b->block->last = 0;
}
void grib_section_delete ( grib_context *c, grib_section* b )
@ -396,8 +391,6 @@ grib_handle* grib_handle_new_from_message ( grib_context* c,void* data, size_t b
return h;
}
grib_handle* grib_handle_new_from_multi_message ( grib_context* c,void** data,
size_t *buflen,int* error )
{
@ -1157,15 +1150,16 @@ 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 ( grib_handle* h,off_t* offset )
{
if (h) *offset=h->offset;
else return GRIB_INTERNAL_ERROR;
return 0;
}
int grib_get_message_size ( grib_handle* h,size_t* size ) {
int grib_get_message_size ( grib_handle* h,size_t* size )
{
long totalLength=0;
int ret=0;
*size = h->buffer->ulength;
@ -1297,7 +1291,6 @@ int grib_handle_prepare_action ( grib_handle* h,grib_action* a )
static int grib2_get_next_section ( unsigned char* msgbegin,size_t msglen,unsigned char** secbegin,size_t* seclen,int* secnum,int* err )
{
if ( !grib2_has_next_section ( msgbegin,msglen,*secbegin,*seclen,err ) )
return 0;

View File

@ -31,7 +31,8 @@
#endif
#endif
static void set_total_length(unsigned char* buffer,long *section_length,long *section_offset,int edition,size_t totalLength) {
static void set_total_length(unsigned char* buffer,long *section_length,long *section_offset,int edition,size_t totalLength)
{
long off;
switch (edition) {
case 1:
@ -55,10 +56,10 @@ static void set_total_length(unsigned char* buffer,long *section_length,long *se
grib_encode_unsigned_long(buffer, (unsigned long)totalLength , &off, 64);
break;
}
}
static grib_handle* grib_sections_copy_internal(grib_handle* hfrom,grib_handle* hto,int sections[],int *err) {
static grib_handle* grib_sections_copy_internal(grib_handle* hfrom,grib_handle* hto,int sections[],int *err)
{
int i;
size_t totalLength=0;
unsigned char* buffer;
@ -180,7 +181,8 @@ static grib_handle* grib_sections_copy_internal(grib_handle* hfrom,grib_handle*
return h;
}
grib_handle* grib_util_sections_copy(grib_handle* hfrom,grib_handle* hto,int what,int *err) {
grib_handle* grib_util_sections_copy(grib_handle* hfrom,grib_handle* hto,int what,int *err)
{
long edition_from=0;
long edition_to=0;
long localDefinitionNumber=-1;
@ -265,24 +267,26 @@ grib_handle* grib_util_sections_copy(grib_handle* hfrom,grib_handle* hto,int wha
}
return grib_sections_copy_internal(hfrom,hto,sections_to_copy,err);
}
static grib_trie* init_list(const char* name);
static grib_trie* param_id_list = NULL;
static grib_trie* mars_param_list = NULL;
/* TODO thread safe */
grib_string_list* grib_util_get_param_id(const char* mars_param) {
grib_string_list* grib_util_get_param_id(const char* mars_param)
{
if (!mars_param_list && (mars_param_list=init_list("mars_param.table"))==NULL) return NULL;
return (grib_string_list*)grib_trie_get(mars_param_list,mars_param);
}
grib_string_list* grib_util_get_mars_param(const char* param_id) {
grib_string_list* grib_util_get_mars_param(const char* param_id)
{
if (!param_id_list && (param_id_list=init_list("param_id.table"))==NULL) return NULL;
return (grib_string_list*)grib_trie_get(param_id_list,param_id);
}
static grib_trie* init_list(const char* name) {
static grib_trie* init_list(const char* name)
{
char *full_path=0;
FILE* fh;
char s[101];
@ -1288,7 +1292,8 @@ grib_handle* grib_util_set_spec2(grib_handle* h,
return NULL;
}
int grib_moments(grib_handle* h,double east,double north,double west,double south,int order,double* moments,long *count) {
int grib_moments(grib_handle* h,double east,double north,double west,double south,int order,double* moments,long *count)
{
grib_iterator* iter=NULL;
int ret=0,i,j,l;
size_t n=0,numberOfPoints=0;

View File

@ -153,7 +153,6 @@ int grib_copy_namespace(grib_handle* dest, const char* name, grib_handle* src)
grib_key_err* first=NULL;
int todo=1,count=0;
grib_keys_iterator* iter=NULL;
if (!dest || !src) return GRIB_NULL_HANDLE;
@ -480,7 +479,8 @@ int grib_clear(grib_handle* h, const char* name)
return GRIB_NOT_FOUND;
}
int grib_set_missing_internal(grib_handle* h, const char* name) {
int grib_set_missing_internal(grib_handle* h, const char* name)
{
int ret=0;
grib_accessor* a =NULL;
@ -814,7 +814,8 @@ int grib_is_in_dump(grib_handle* h, const char* name)
return 0;
}
int grib_attributes_count(grib_accessor* a, size_t* size) {
int grib_attributes_count(grib_accessor* a, size_t* size)
{
if (a) {
*size=0;
while (a->attributes[*size]!=NULL) {(*size)++;}
@ -824,7 +825,6 @@ int grib_attributes_count(grib_accessor* a, size_t* size) {
return GRIB_NOT_FOUND;
}
int grib_get_long(grib_handle* h, const char* name, long* val)
{
size_t length = 1;
@ -922,7 +922,6 @@ int grib_get_double_elements(grib_handle* h, const char* name, int* i, long len,
int j=0;
grib_accessor* act =NULL;
act= grib_find_accessor(h, name);
ret=_grib_get_size(h,act,&size);
@ -961,7 +960,6 @@ int grib_get_string_internal(grib_handle* h, const char* name, char* val, size_t
return ret;
}
int grib_get_string(grib_handle* h, const char* name, char* val, size_t *length)
{
grib_accessor* a = NULL;
@ -981,7 +979,6 @@ int grib_get_string(grib_handle* h, const char* name, char* val, size_t *length)
}
}
int grib_get_bytes_internal(grib_handle* h, const char* name, unsigned char* val, size_t *length)
{
int ret = grib_get_bytes(h,name,val,length);
@ -1173,7 +1170,6 @@ 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)
{
grib_accessor* act = grib_find_accessor(h, key);
@ -1285,8 +1281,8 @@ int grib_get_long_array(grib_handle* h, const char* name, long* val, size_t *len
return ret;
}
static void grib_clean_key_value(grib_context* c,grib_key_value_list* kv) {
static void grib_clean_key_value(grib_context* c,grib_key_value_list* kv)
{
if (kv->long_value) grib_context_free(c,kv->long_value);
kv->long_value=NULL;
if (kv->double_value) grib_context_free(c,kv->double_value);
@ -1300,7 +1296,8 @@ static void grib_clean_key_value(grib_context* c,grib_key_value_list* kv) {
kv->size=0;
}
static int grib_get_key_value(grib_handle* h,grib_key_value_list* kv) {
static int grib_get_key_value(grib_handle* h,grib_key_value_list* kv)
{
int ret=0;
size_t size=0;
grib_keys_iterator* iter=NULL;
@ -1361,7 +1358,8 @@ static int grib_get_key_value(grib_handle* h,grib_key_value_list* kv) {
return ret;
}
grib_key_value_list* grib_key_value_list_clone(grib_context* c,grib_key_value_list* list) {
grib_key_value_list* grib_key_value_list_clone(grib_context* c,grib_key_value_list* list)
{
grib_key_value_list* next=list;
grib_key_value_list* the_clone=(grib_key_value_list*)grib_context_malloc_clear(c,sizeof(grib_key_value_list));
grib_key_value_list* p=the_clone;
@ -1374,7 +1372,8 @@ grib_key_value_list* grib_key_value_list_clone(grib_context* c,grib_key_value_li
return the_clone;
}
void grib_key_value_list_delete(grib_context* c,grib_key_value_list* kvl) {
void grib_key_value_list_delete(grib_context* c,grib_key_value_list* kvl)
{
grib_key_value_list* next=kvl;
grib_key_value_list* p=NULL;
while (next) {
@ -1388,7 +1387,8 @@ void grib_key_value_list_delete(grib_context* c,grib_key_value_list* kvl) {
}
}
int grib_get_key_value_list(grib_handle* h,grib_key_value_list* list) {
int grib_get_key_value_list(grib_handle* h,grib_key_value_list* list)
{
int ret=0;
grib_key_value_list* kvl=list;
while (kvl) {
@ -1398,7 +1398,8 @@ int grib_get_key_value_list(grib_handle* h,grib_key_value_list* list) {
return ret;
}
int grib_get_values(grib_handle* h,grib_values* args,size_t count) {
int grib_get_values(grib_handle* h,grib_values* args,size_t count)
{
int ret=0;
int i=0;
@ -1500,7 +1501,6 @@ int grib_set_values(grib_handle* h,grib_values* args,size_t count)
}
}
h->values[stack] = NULL;
h->values_count[stack] = 0;

View File

@ -119,7 +119,6 @@ int grib_tool_init(grib_runtime_options* options)
options->latlon_mask=strdup(p);
}
}
}
if (options->latlon && options->latlon_mask) {
@ -391,7 +390,8 @@ int grib_tool_finalise_action(grib_runtime_options* options)
return 0;
}
int grib_no_handle_action(int err) {
int grib_no_handle_action(int err)
{
fprintf(dump_file,"\t\t\"ERROR: unreadable message\"\n");
return 0;
}