static void
img_clicked_9_cb(void *data, Evas_Object *obj, void *event_info)
{
	Evas_Object *entry = data;

	if(confirm_flag == READY_TO_CONFIRM)
	{
		/*if(inout_flag == INCOME)
			elm_entry_text_style_user_push(entry, "DEFAULT='font_size=40 color=#4cffba align=center'");
		else if(inout_flag == OUTGO)
			elm_entry_text_style_user_push(entry, "DEFAULT='font_size=40 color=#ffffff align=center'");*/

		elm_entry_text_style_user_push(entry, "DEFAULT='font_size=40 color=#ffffff align=center'");

		confirm_flag = DEFAULT;

		return;
	}

	if( strlen( strdup( elm_entry_entry_get(entry) ) ) < 8)
	{
		elm_entry_entry_append(entry, "9");
		adjust_string(entry);
	}
}
Exemplo n.º 2
0
/*!
  \fn int climat_parse_x01 ( struct climat_chunks *c, struct bufr2tac_subset_state *s )
  \brief Parse a expanded descriptor with X = 01
  \param c pointer to a struct \ref climat_chunks where to set the results
  \param s pointer to a struct \ref bufr2tac_subset_state where is stored needed information in sequential analysis

  It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway
*/
int climat_parse_x01 ( struct climat_chunks *c, struct bufr2tac_subset_state *s )
{
  char aux[80];

  if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
    return 0;

  switch ( s->a->desc.y )
    {

    case 1: // 0 01 001 . WMO block number
      sprintf ( c->s0.II, "%02d", s->ival );
      break;

    case 2: // 0 01 002 . WMO station number
      sprintf ( c->s0.iii, "%03d", s->ival );
      break;

    case 3: // 0 01 003 . WMO Region
      if ( s->ival == 1 )
        strcpy ( c->s0.Reg, "I" );
      else if ( s->ival == 2 )
        strcpy ( c->s0.Reg, "II" );
      else if ( s->ival == 3 )
        strcpy ( c->s0.Reg, "III" );
      else if ( s->ival == 4 )
        strcpy ( c->s0.Reg, "IV" );
      else if ( s->ival == 5 )
        strcpy ( c->s0.Reg, "V" );
      else if ( s->ival == 6 )
        strcpy ( c->s0.Reg, "VI" );
      break;

    case 15: // 0 01 015 . Station or site name
    case 18: // 0 01 018 . Short station or site name
    case 19: // 0 01 019 . Long station or site name
      if ( strlen ( s->a->cval ) <= 80 )
        {
          strcpy ( aux, s->a->cval );
          adjust_string ( aux );
          strcpy ( s->name, aux );
          s->mask |= SUBSET_MASK_HAVE_NAME;
        }
      break;


    default:
      break;
    }
  return 0;
}
Exemplo n.º 3
0
static int get_samp(struct module_data *m, int size, HIO_HANDLE *f, void *parm)
{
    struct xmp_module *mod = &m->mod;
    struct local_data *data = (struct local_data *)parm;
    int i, j;
    int looplen;

    /* Should be always 36 */
    mod->ins = size / 32;	/* sizeof(struct okt_instrument_header); */
    mod->smp = mod->ins;

    if (instrument_init(mod) < 0)
        return -1;

    for (j = i = 0; i < mod->ins; i++) {
        struct xmp_instrument *xxi = &mod->xxi[i];
        struct xmp_sample *xxs = &mod->xxs[j];
        struct xmp_subinstrument *sub;

        if (subinstrument_alloc(mod, i, 1) < 0)
            return -1;

        sub = &xxi->sub[0];

        hio_read(xxi->name, 1, 20, f);
        adjust_string((char *)xxi->name);

        /* Sample size is always rounded down */
        xxs->len = hio_read32b(f) & ~1;
        xxs->lps = hio_read16b(f);
        looplen = hio_read16b(f);
        xxs->lpe = xxs->lps + looplen;
        xxs->flg = looplen > 2 ? XMP_SAMPLE_LOOP : 0;

        sub->vol = hio_read16b(f);
        data->mode[i] = hio_read16b(f);

        sub->pan = 0x80;
        sub->sid = j;

        data->idx[j] = i;

        if (xxs->len > 0) {
            xxi->nsm = 1;
            j++;
        }
    }

    return 0;
}
Exemplo n.º 4
0
static int get_inst(struct module_data *m, int size, HIO_HANDLE *f, void *parm)
{
	struct xmp_module *mod = &m->mod;
	struct local_data *data = (struct local_data *)parm;
	int i, j;
	int srate, finetune, flags;
	int val, vwf, vra, vde, vsw, fade;
	uint8 buf[30];

	hio_read8(f);		/* 00 */
	i = hio_read8(f);		/* instrument number */

	hio_read(&mod->xxi[i].name, 1, 28, f);
	adjust_string((char *)mod->xxi[i].name);

	mod->xxi[i].nsm = hio_read8(f);

	for (j = 0; j < 108; j++) {
		mod->xxi[i].map[j].ins = hio_read8(f);
	}

	hio_seek(f, 11, SEEK_CUR);		/* unknown */
	vwf = hio_read8(f);			/* vibrato waveform */
	vsw = hio_read8(f);			/* vibrato sweep */
	hio_read8(f);			/* unknown */
	hio_read8(f);			/* unknown */
	vde = hio_read8(f);		/* vibrato depth */
	vra = hio_read16l(f) / 16;		/* vibrato speed */
	hio_read8(f);			/* unknown */

	val = hio_read8(f);			/* PV envelopes flags */
	if (LSN(val) & 0x01)
		mod->xxi[i].aei.flg |= XMP_ENVELOPE_ON;
	if (LSN(val) & 0x02)
		mod->xxi[i].aei.flg |= XMP_ENVELOPE_SUS;
	if (LSN(val) & 0x04)
		mod->xxi[i].aei.flg |= XMP_ENVELOPE_LOOP;
	if (MSN(val) & 0x01)
		mod->xxi[i].pei.flg |= XMP_ENVELOPE_ON;
	if (MSN(val) & 0x02)
		mod->xxi[i].pei.flg |= XMP_ENVELOPE_SUS;
	if (MSN(val) & 0x04)
		mod->xxi[i].pei.flg |= XMP_ENVELOPE_LOOP;

	val = hio_read8(f);			/* PV envelopes points */
	mod->xxi[i].aei.npt = LSN(val) + 1;
	mod->xxi[i].pei.npt = MSN(val) + 1;

	val = hio_read8(f);			/* PV envelopes sustain point */
	mod->xxi[i].aei.sus = LSN(val);
	mod->xxi[i].pei.sus = MSN(val);

	val = hio_read8(f);			/* PV envelopes loop start */
	mod->xxi[i].aei.lps = LSN(val);
	mod->xxi[i].pei.lps = MSN(val);

	hio_read8(f);			/* PV envelopes loop end */
	mod->xxi[i].aei.lpe = LSN(val);
	mod->xxi[i].pei.lpe = MSN(val);

	if (mod->xxi[i].aei.npt <= 0 || mod->xxi[i].aei.npt >= XMP_MAX_ENV_POINTS)
		mod->xxi[i].aei.flg &= ~XMP_ENVELOPE_ON;

	if (mod->xxi[i].pei.npt <= 0 || mod->xxi[i].pei.npt >= XMP_MAX_ENV_POINTS)
		mod->xxi[i].pei.flg &= ~XMP_ENVELOPE_ON;

	hio_read(buf, 1, 30, f);		/* volume envelope points */;
	for (j = 0; j < mod->xxi[i].aei.npt; j++) {
		mod->xxi[i].aei.data[j * 2] = readmem16l(buf + j * 3) / 16;
		mod->xxi[i].aei.data[j * 2 + 1] = buf[j * 3 + 2];
	}

	hio_read(buf, 1, 30, f);		/* pan envelope points */;
	for (j = 0; j < mod->xxi[i].pei.npt; j++) {
		mod->xxi[i].pei.data[j * 2] = readmem16l(buf + j * 3) / 16;
		mod->xxi[i].pei.data[j * 2 + 1] = buf[j * 3 + 2];
	}

	fade = hio_read8(f);		/* fadeout - 0x80->0x02 0x310->0x0c */
	hio_read8(f);			/* unknown */

	D_(D_INFO "[%2X] %-28.28s  %2d ", i, mod->xxi[i].name, mod->xxi[i].nsm);

	if (mod->xxi[i].nsm == 0)
		return 0;

	if (subinstrument_alloc(mod, i, mod->xxi[i].nsm) < 0)
		return -1;

	for (j = 0; j < mod->xxi[i].nsm; j++, data->snum++) {
		hio_read32b(f);	/* SAMP */
		hio_read32b(f);	/* size */
	
		hio_read(&mod->xxs[data->snum].name, 1, 28, f);
		adjust_string((char *)mod->xxs[data->snum].name);
	
		mod->xxi[i].sub[j].pan = hio_read8(f) * 4;
		if (mod->xxi[i].sub[j].pan == 0)	/* not sure about this */
			mod->xxi[i].sub[j].pan = 0x80;
		
		mod->xxi[i].sub[j].vol = hio_read8(f);
		flags = hio_read8(f);
		hio_read8(f);	/* unknown - 0x80 */

		mod->xxi[i].sub[j].vwf = vwf;
		mod->xxi[i].sub[j].vde = vde;
		mod->xxi[i].sub[j].vra = vra;
		mod->xxi[i].sub[j].vsw = vsw;
		mod->xxi[i].sub[j].sid = data->snum;
	
		mod->xxs[data->snum].len = hio_read32l(f);
		mod->xxs[data->snum].lps = hio_read32l(f);
		mod->xxs[data->snum].lpe = hio_read32l(f);
	
		mod->xxs[data->snum].flg = 0;
		if (flags & 0x04)
			mod->xxs[data->snum].flg |= XMP_SAMPLE_16BIT;
		if (flags & 0x08)
			mod->xxs[data->snum].flg |= XMP_SAMPLE_LOOP;
		if (flags & 0x10)
			mod->xxs[data->snum].flg |= XMP_SAMPLE_LOOP_BIDIR;
		/* if (flags & 0x80)
			mod->xxs[data->snum].flg |= ? */
	
		srate = hio_read32l(f);
		finetune = 0;
		c2spd_to_note(srate, &mod->xxi[i].sub[j].xpo, &mod->xxi[i].sub[j].fin);
		mod->xxi[i].sub[j].fin += finetune;
	
		hio_read32l(f);			/* 0x00000000 */
		hio_read32l(f);			/* unknown */
	
		D_(D_INFO "  %X: %05x%c%05x %05x %c V%02x P%02x %5d",
			j, mod->xxs[data->snum].len,
			mod->xxs[data->snum].flg & XMP_SAMPLE_16BIT ? '+' : ' ',
			mod->xxs[data->snum].lps,
			mod->xxs[data->snum].lpe,
			mod->xxs[data->snum].flg & XMP_SAMPLE_LOOP_BIDIR ? 'B' : 
			mod->xxs[data->snum].flg & XMP_SAMPLE_LOOP ? 'L' : ' ',
			mod->xxi[i].sub[j].vol,
			mod->xxi[i].sub[j].pan,
			srate);
	
		if (mod->xxs[data->snum].len > 1) {
			int snum = data->snum;
			if (load_sample(m, f, 0, &mod->xxs[snum], NULL) < 0)
				return -1;
		}
	}

	return 0;
}
Exemplo n.º 5
0
static int get_inst(struct module_data *m, int size, HIO_HANDLE *f, void *parm)
{
	struct xmp_module *mod = &m->mod;
	int i, srate, finetune, flags;
	int has_unsigned_sample;

	hio_read32b(f);		/* 42 01 00 00 */
	hio_read8(f);		/* 00 */
	i = hio_read8(f);		/* instrument number */
	
	hio_read(&mod->xxi[i].name, 1, 28, f);
	adjust_string((char *)mod->xxi[i].name);

	hio_seek(f, 290, SEEK_CUR);	/* Sample/note map, envelopes */
	mod->xxi[i].nsm = hio_read16l(f);

	D_(D_INFO "[%2X] %-28.28s  %2d ", i, mod->xxi[i].name, mod->xxi[i].nsm);

	if (mod->xxi[i].nsm == 0)
		return 0;

	if (subinstrument_alloc(mod, i, mod->xxi[i].nsm) < 0)
		return -1;

	/* FIXME: Currently reading only the first sample */

	hio_read32b(f);	/* RIFF */
	hio_read32b(f);	/* size */
	hio_read32b(f);	/* AS   */
	hio_read32b(f);	/* SAMP */
	hio_read32b(f);	/* size */
	hio_read32b(f);	/* unknown - usually 0x40000000 */

	hio_read(&mod->xxs[i].name, 1, 28, f);
	adjust_string((char *)mod->xxs[i].name);

	hio_read32b(f);	/* unknown - 0x0000 */
	hio_read8(f);	/* unknown - 0x00 */

	mod->xxi[i].sub[0].sid = i;
	mod->xxi[i].vol = hio_read8(f);
	mod->xxi[i].sub[0].pan = 0x80;
	mod->xxi[i].sub[0].vol = (hio_read16l(f) + 1) / 512;
	flags = hio_read16l(f);
	hio_read16l(f);			/* unknown - 0x0080 */
	mod->xxs[i].len = hio_read32l(f);
	mod->xxs[i].lps = hio_read32l(f);
	mod->xxs[i].lpe = hio_read32l(f);

	mod->xxs[i].flg = 0;
	has_unsigned_sample = 0;
	if (flags & 0x04)
		mod->xxs[i].flg |= XMP_SAMPLE_16BIT;
	if (flags & 0x08)
		mod->xxs[i].flg |= XMP_SAMPLE_LOOP;
	if (flags & 0x10)
		mod->xxs[i].flg |= XMP_SAMPLE_LOOP | XMP_SAMPLE_LOOP_BIDIR;
	if (~flags & 0x80)
		has_unsigned_sample = 1;

	srate = hio_read32l(f);
	finetune = 0;
	c2spd_to_note(srate, &mod->xxi[i].sub[0].xpo, &mod->xxi[i].sub[0].fin);
	mod->xxi[i].sub[0].fin += finetune;

	hio_read32l(f);			/* 0x00000000 */
	hio_read32l(f);			/* unknown */

	D_(D_INFO "  %x: %05x%c%05x %05x %c V%02x %04x %5d",
		0, mod->xxs[i].len,
		mod->xxs[i].flg & XMP_SAMPLE_16BIT ? '+' : ' ',
		mod->xxs[i].lps,
		mod->xxs[i].lpe,
		mod->xxs[i].flg & XMP_SAMPLE_LOOP_BIDIR ? 'B' : 
			mod->xxs[i].flg & XMP_SAMPLE_LOOP ? 'L' : ' ',
		mod->xxi[i].sub[0].vol, flags, srate);

	if (mod->xxs[i].len > 1) {
		if (load_sample(m, f, has_unsigned_sample ?
				SAMPLE_FLAG_UNS : 0, &mod->xxs[i], NULL) < 0)
			return -1;
	}

	return 0;
}
Exemplo n.º 6
0
/*!
  \fn int syn_parse_x01 ( struct synop_chunks *syn, struct bufr2tac_subset_state *s )
  \brief Parse a expanded descriptor with X = 01
  \param syn pointer to a struct \ref synop_chunks where to set the results
  \param s pointer to a struct \ref bufr2tac_subset_state where is stored needed information in sequential analysis

  It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway
*/
int syn_parse_x01 ( struct synop_chunks *syn, struct bufr2tac_subset_state *s )
{
  char aux[80];

  if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
    return 0;

  switch ( s->a->desc.y )
    {
    case 1: // 0 01 001 . WMO block number
      sprintf ( syn->s0.II, "%02d", s->ival );
      break;
    case 2: // 0 01 002 . WMO station number
      sprintf ( syn->s0.iii, "%03d", s->ival );
      break;
    case 3: // 0 01 003 . WMO Region
      sprintf ( syn->s0.A1, "%d", s->ival );
      if ( strcmp ( syn->s0.A1, "1" ) == 0 )
        strcpy ( syn->s0.Reg, "I" );
      else if ( strcmp ( syn->s0.A1, "2" ) == 0 )
        strcpy ( syn->s0.Reg, "II" );
      else if ( strcmp ( syn->s0.A1, "3" ) == 0 )
        strcpy ( syn->s0.Reg, "III" );
      else if ( strcmp ( syn->s0.A1, "4" ) == 0 )
        strcpy ( syn->s0.Reg, "IV" );
      else if ( strcmp ( syn->s0.A1, "5" ) == 0 )
        strcpy ( syn->s0.Reg, "V" );
      else if ( strcmp ( syn->s0.A1, "6" ) == 0 )
        strcpy ( syn->s0.Reg, "VI" );
      break;
    case 4: // 0 01 004 . WMO Subarea
    case 20: // 0 01 020 . WMO region subarea
      sprintf ( syn->s0.bw, "%d", s->ival );
      break;
    case 11: // 0 01 011. Ship or mobile land station index
      if ( strlen ( s->a->cval ) < 16 )
        {
          strcpy ( aux, s->a->cval );
          adjust_string ( aux );
          if ( aux[0] == '\xff' )
            break;
          if ( strlen ( aux ) < 10 )
            strcpy ( syn->s0.D_D, aux );
        }
      break;
    case 15: // 0 01 015 . Station or site name
    case 18: // 0 01 018 . Short station or site name
    case 19: // 0 01 019 . Long station or site name
      if ( strlen ( s->a->cval ) <= 80 )
        {
          strcpy ( aux, s->a->cval );
          adjust_string ( aux );
          strcpy ( s->name, aux );
          s->mask |= SUBSET_MASK_HAVE_NAME;
        }
      break;
    case 101: // 0 01 101 . State identifier
      if ( strlen ( s->a->ctable ) <= 256 )
        {
          strcpy ( aux, s->a->ctable );
          adjust_string ( aux );
          strcpy ( s->country, aux );
          s->mask |= SUBSET_MASK_HAVE_COUNTRY;
        }
      break;
    default:
      break;
    }

  //set WMO region if we know II and iii and still no set A1
  if ( ( syn->s0.A1[0] == 0 ) && syn->s0.II[0] && syn->s0.iii[0] )
    {
      guess_WMO_region ( syn->s0.A1, syn->s0.Reg, syn->s0.II, syn->s0.iii );
    }
  return 0;
}
Exemplo n.º 7
0
/*!
  \fn int temp_parse_x01 ( struct temp_chunks *t, struct bufr2tac_subset_state *s )
  \brief Parse a expanded descriptor with X = 01
  \param t pointer to a struct \ref temp_chunks where to set the results
  \param s pointer to a struct \ref bufr2tac_subset_state where is stored needed information in sequential analysis

  It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway
*/
int temp_parse_x01 ( struct temp_chunks *t, struct bufr2tac_subset_state *s )
{
  char aux[80];

  if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
    return 0;

  switch ( s->a->desc.y )
    {
    case 1: // 0 01 001 . WMO block number
      sprintf ( t->a.s1.II, "%02d", s->ival );
      sprintf ( t->b.s1.II, "%02d", s->ival );
      sprintf ( t->c.s1.II, "%02d", s->ival );
      sprintf ( t->d.s1.II, "%02d", s->ival );
      break;
    case 2: // 0 01 002 . WMO station number
      sprintf ( t->a.s1.iii, "%03d", s->ival );
      sprintf ( t->b.s1.iii, "%03d", s->ival );
      sprintf ( t->c.s1.iii, "%03d", s->ival );
      sprintf ( t->d.s1.iii, "%03d", s->ival );
      break;
    case 3: // 0 01 003 . WMO Region
      sprintf ( t->a.s1.A1, "%d", s->ival );
      sprintf ( t->b.s1.A1, "%d", s->ival );
      sprintf ( t->c.s1.A1, "%d", s->ival );
      sprintf ( t->d.s1.A1, "%d", s->ival );
      if ( strcmp ( t->a.s1.A1, "1" ) == 0 )
        {
          strcpy ( t->a.s1.Reg, "I" );
          strcpy ( t->b.s1.Reg, "I" );
          strcpy ( t->c.s1.Reg, "I" );
          strcpy ( t->d.s1.Reg, "I" );
        }
      else if ( strcmp ( t->a.s1.A1, "2" ) == 0 )
        {
          strcpy ( t->a.s1.Reg, "II" );
          strcpy ( t->b.s1.Reg, "II" );
          strcpy ( t->c.s1.Reg, "II" );
          strcpy ( t->d.s1.Reg, "II" );
        }
      else if ( strcmp ( t->a.s1.A1, "3" ) == 0 )
        {
          strcpy ( t->a.s1.Reg, "III" );
          strcpy ( t->b.s1.Reg, "III" );
          strcpy ( t->c.s1.Reg, "III" );
          strcpy ( t->d.s1.Reg, "III" );
        }
      else if ( strcmp ( t->a.s1.A1, "4" ) == 0 )
        {
          strcpy ( t->a.s1.Reg, "IV" );
          strcpy ( t->b.s1.Reg, "IV" );
          strcpy ( t->c.s1.Reg, "IV" );
          strcpy ( t->d.s1.Reg, "IV" );
        }
      else if ( strcmp ( t->a.s1.A1, "5" ) == 0 )
        {
          strcpy ( t->a.s1.Reg, "V" );
          strcpy ( t->b.s1.Reg, "V" );
          strcpy ( t->c.s1.Reg, "V" );
          strcpy ( t->d.s1.Reg, "V" );
        }
      else if ( strcmp ( t->a.s1.A1, "6" ) == 0 )
        {
          strcpy ( t->a.s1.Reg, "VI" );
          strcpy ( t->b.s1.Reg, "VI" );
          strcpy ( t->c.s1.Reg, "VI" );
          strcpy ( t->d.s1.Reg, "VI" );
        }
      break;
    case 4: // 0 01 004 . WMO Subarea
    case 20: // 0 01 020 . WMO region subarea
      sprintf ( t->a.s1.bw, "%d", s->ival );
      sprintf ( t->b.s1.bw, "%d", s->ival );
      sprintf ( t->c.s1.bw, "%d", s->ival );
      sprintf ( t->d.s1.bw, "%d", s->ival );
      break;
    case 11: // 0 01 011. Ship or mobile land station index
      if ( strlen ( s->a->cval ) < 16 )
        {
          strcpy ( aux, s->a->cval );
          adjust_string ( aux );
          if ( aux[0] == '\xff' )
            break;

          if ( strlen ( aux ) < 10 )
            {
              strcpy ( t->a.s1.D_D, aux );
              strcpy ( t->b.s1.D_D, aux );
              strcpy ( t->c.s1.D_D, aux );
              strcpy ( t->d.s1.D_D, aux );
            }
        }
      break;
    case 15: // 0 01 015 . Station or site name
    case 18: // 0 01 018 . Short station or site name
    case 19: // 0 01 019 . Long station or site name
      if ( strlen ( s->a->cval ) <= 80 )
        {
          strcpy ( aux, s->a->cval );
          adjust_string ( aux );
          strcpy ( s->name, aux );
          s->mask |= SUBSET_MASK_HAVE_NAME;
        }
      break;
    case 101: // 0 01 101 . State identifier
      if ( strlen ( s->a->ctable ) <= 256 )
        {
          strcpy ( aux, s->a->ctable );
          adjust_string ( aux );
          strcpy ( s->country, aux );
          s->mask |= SUBSET_MASK_HAVE_COUNTRY;
        }
      break;
    default:
      break;
    }
  return 0;
}
Exemplo n.º 8
0
/*!
  \fn int buoy_parse_x01 ( struct buoy_chunks *b, struct bufr2tac_subset_state *s )
  \brief Parse a expanded descriptor with X = 01
  \param b pointer to a struct \ref synop_chunks where to set the results
  \param s pointer to a struct \ref bufr2tac_subset_state where is stored needed information in sequential analysis

  It returns 0 if success, 1 if problems when processing. If a descriptor is not processed returns 0 anyway
*/
int buoy_parse_x01 ( struct buoy_chunks *b, struct bufr2tac_subset_state *s )
{
  char aux[80];

  if ( s->a->mask & DESCRIPTOR_VALUE_MISSING )
    return 0;

  switch ( s->a->desc.y )
    {
    case 3: // 0 01 003
      if ( s->ival > 0 )
        sprintf ( b->s0.A1, "%d", s->ival );
      else if ( s->ival == 0 )
        sprintf ( b->s0.A1, "7" );
      break;

    case 4: // 0 01 004
    case 20: // 0 01 004
      sprintf ( b->s0.bw, "%d", s->ival );
      break;
    case 5: // 0 01 005
      if ( s->ival < 1000 )
        sprintf ( b->s0.nbnbnb, "%03d", s->ival );
      else
        sprintf ( b->s0.nbnbnb, "%05d", s->ival ); // note this is a nnnnn extension
      break;
    case 15: // 0 01 015
      if ( strlen ( s->a->cval ) <= 80 )
        {
          strcpy ( aux, s->a->cval );
          adjust_string ( aux );
          strcpy ( s->name, aux );
          s->mask |= SUBSET_MASK_HAVE_NAME;
        }
      break;
    case 87: // 0 01 087. WMO marine observing platform extended identifier
      if ( s->a->val < 100000000 )
        {
          sprintf ( aux, "%07.0lf", s->a->val );
          b->s0.A1[0] = aux[0];
          b->s0.A1[1] = 0;
          b->s0.bw[0] = aux[1];
          b->s0.bw[1] = 0;
          if ( ( ( int ) ( s->a->val ) % 100000 ) < 1000 )
            strcpy ( b->s0.nbnbnb , & aux[4] );
          else
            strcpy ( b->s0.nbnbnb , & aux[2] );
        }
      break;
    case 101: // 0 01 101
      if ( strlen ( s->a->ctable ) <= 80 )
        {
          strcpy ( aux, s->a->ctable );
          adjust_string ( aux );
          strcpy ( s->name, aux );
          s->mask |= SUBSET_MASK_HAVE_COUNTRY;
        }
      break;
    default:
      break;
    }
  return 0;
}
Exemplo n.º 9
0
Arquivo: load.c Projeto: Nlcke/gideros
static int load_module(xmp_context opaque, HIO_HANDLE *h)
{
	struct context_data *ctx = (struct context_data *)opaque;
	struct module_data *m = &ctx->m;
	struct xmp_module *mod = &m->mod;
	int i, j, ret;
	int test_result, load_result;

	load_prologue(ctx);

	D_(D_WARN "load");
	test_result = load_result = -1;
	for (i = 0; format_loader[i] != NULL; i++) {
		hio_seek(h, 0, SEEK_SET);
		D_(D_WARN "test %s", format_loader[i]->name);
		test_result = format_loader[i]->test(h, NULL, 0);
		if (test_result == 0) {
			hio_seek(h, 0, SEEK_SET);
			D_(D_WARN "load format: %s", format_loader[i]->name);
			load_result = format_loader[i]->loader(m, h, 0);
			break;
		}
	}

#ifndef LIBXMP_CORE_PLAYER
	if (test_result == 0 && load_result == 0)
		set_md5sum(h, m->md5);
#endif

	if (test_result < 0) {
		free(m->basename);
		free(m->dirname);
		return -XMP_ERROR_FORMAT;
	}

	if (load_result < 0) {
		goto err_load;
	}

	/* Sanity check */
	if (mod->chn > XMP_MAX_CHANNELS || mod->len > XMP_MAX_MOD_LENGTH) {
		goto err_load;
	}

	/* Sanity check */
	if (mod->xxp == NULL) {
		goto err_load;
	}
	for (i = 0; i < mod->pat; i++) {
		if (mod->xxp[i] == NULL) {
			goto err_load;
		}
		for (j = 0; j < mod->chn; j++) {
			int t = mod->xxp[i]->index[j];
			if (t < 0 || t >= mod->trk || mod->xxt[t] == NULL) {
				goto err_load;
			}
		}
	}

	adjust_string(mod->name);
	load_epilogue(ctx);

	ret = prepare_scan(ctx);
	if (ret < 0) {
		xmp_release_module(opaque);
		return ret;
	}

	scan_sequences(ctx);

	ctx->state = XMP_STATE_LOADED;

	return 0;

    err_load:
	xmp_release_module(opaque);
	return -XMP_ERROR_LOAD;
}