static void dump(grib_accessor* a,grib_dumper* dumper)
{
  grib_accessor_lookup* self = (grib_accessor_lookup*)a;
  unsigned char bytes[1024] = {0,};
  char msg[1024]= {0,};
  char buf[1024];
  int i;
  unsigned long v = 0;

  size_t llen = self->llength;
  grib_unpack_bytes(a, bytes, &llen); /* TODO: Unpack byte unpack the wrong offset */

  bytes[llen] = 0;
  for(i = 0; i < llen; i++)
  {
    msg[i] = isprint(bytes[i]) ? bytes[i] : '?';
    v <<= 8;
    v |= bytes[i];
  }

  msg[llen] = 0;

  sprintf(buf,"%s %ld %ld-%ld",msg,v,(long)a->offset+self->loffset,(long)self->llength);

  grib_dump_long(dumper,a,buf);

}
static void dump(grib_accessor* a, grib_dumper* dumper)
{
    long rlen = 0;
    grib_value_count(a,&rlen);
    if(rlen == 1)
        grib_dump_long(dumper,a,NULL);
    else
        grib_dump_values(dumper,a);
}
static void dump(grib_accessor* a, grib_dumper* dumper)
{
    switch (get_native_type(a)) {
    case GRIB_TYPE_STRING:
        grib_dump_string(dumper,a,NULL);
        break;
    case GRIB_TYPE_LONG:
        grib_dump_long(dumper,a,NULL);
        break;
    case GRIB_TYPE_DOUBLE:
        grib_dump_double(dumper,a,NULL);
        break;
    }
}
Пример #4
0
static void dump(grib_accessor* a, grib_dumper* dumper)
{
	grib_dump_long(dumper,a,NULL);
}
static void dump(grib_accessor* a, grib_dumper* dumper) {
  grib_accessor_codetable* self  = (grib_accessor_codetable*)a;
  char comment[2048];
  grib_codetable* table;

  size_t llen = 1;
  long value;

  if(!self->table) self->table = load_table(self);
  table=self->table;

  grib_unpack_long(a, &value,&llen);

  if(value == GRIB_MISSING_LONG)
  {
    if(a->length < 4)
    {
      value = (1L << a->length) - 1;
    }
  }

  if(table && value >= 0 && value < table->size)
  {
    if(table->entries[value].abbreviation)
    {
      int b = atol(table->entries[value].abbreviation);
      if(b == value)
        strcpy(comment,table->entries[value].title);
      else
        sprintf(comment,"%s", table->entries[value].title);

      if (table->entries[value].units!=NULL && strcmp(table->entries[value].units,"unknown")) {
        strcat(comment," (");
        strcat(comment,table->entries[value].units);
        strcat(comment,") ");
      }
    }
    else
    {
      strcpy(comment,"Unknown code table entry");
    }

  }
  else
  {
    strcpy(comment,"Unknown code table entry");
  }

  strcat(comment," (");
  if (table) {
    strcat(comment,table->recomposed_name[0]);
    if (table->recomposed_name[1]!=NULL) {
      strcat(comment," , ");
      strcat(comment,table->recomposed_name[1]);
    }
  }
  strcat(comment,") ");

  grib_dump_long(dumper,a,comment);

}