Example #1
0
int process_metadata (WavpackContext *wpc, WavpackMetadata *wpmd)
{
    WavpackStream *wps = &wpc->stream;

    switch (wpmd->id) {
        case ID_DUMMY:
            return TRUE;

        case ID_DECORR_TERMS:
            return read_decorr_terms (wps, wpmd);

        case ID_DECORR_WEIGHTS:
            return read_decorr_weights (wps, wpmd);

        case ID_DECORR_SAMPLES:
            return read_decorr_samples (wps, wpmd);

        case ID_ENTROPY_VARS:
            return read_entropy_vars (wps, wpmd);

        case ID_HYBRID_PROFILE:
            return read_hybrid_profile (wps, wpmd);

        case ID_FLOAT_INFO:
            return read_float_info (wps, wpmd);

        case ID_INT32_INFO:
            return read_int32_info (wps, wpmd);

        case ID_CHANNEL_INFO:
            return read_channel_info (wpc, wpmd);

        case ID_SAMPLE_RATE:
            return read_sample_rate (wpc, wpmd);

        case ID_CONFIG_BLOCK:
            return read_config_info (wpc, wpmd);

        case ID_WV_BITSTREAM:
            return init_wv_bitstream (wpc, wpmd);

        case ID_SHAPING_WEIGHTS:
        case ID_WVC_BITSTREAM:
        case ID_WVX_BITSTREAM:
            return TRUE;

        default:
            return (wpmd->id & ID_OPTIONAL_DATA) ? TRUE : FALSE;
    }
}
Example #2
0
int main(int argc, char** argv)
{
  FFDB_DBT key, res;
  FFDB_DB	*dbp;
  FFDB_HASHINFO ctl;
  ffdb_cursor_t* cur;
  int	stat, i, numkey, numpairs;
  char *dbase;
  unsigned char userdata[4096];
  unsigned int len = 4096;
  ffdb_all_config_info_t acf;
  char *mykey[MAXWORDS], *mydata[MAXWORDS], tmp1[MAX_LEN], tmp2[MAX_LEN];
  FILE *fd;

  if (argc < 4) {
    fprintf (stderr, "Usage: %s cachesize dbase stringfiles\n", argv[0]);
    exit (1);
  }

  fd = fopen (argv[3], "r");
  if (!fd) {
    fprintf (stderr, "Cannot open string file %s\n", argv[3]);
    return -1;
  }

  i = 0;
  while (fscanf (fd, "%s", tmp1) >= 1 &&
	 fscanf (fd, "%s", tmp2) >= 1 && i < MAXWORDS) {
    mykey[i] = (char *)malloc(strlen(tmp1) + 1);
    strcpy (mykey[i], tmp1);
    mydata[i] = (char *)malloc(strlen(tmp2) + 1);
    strcpy (mydata[i], tmp2);
    i++;
  }
  numpairs = i;
  fclose (fd);


  i = 0;
  argv++;
  ctl.nbuckets = INITIAL;
  ctl.hash = NULL;
  ctl.cmp = NULL;
  ctl.bsize = 64;
  ctl.cachesize = atoi(*argv++);
  ctl.rearrangepages = 0;
  dbase = *argv++;
  fprintf (stderr, "dbase = %s\n", dbase);
  if (!(dbp = ffdb_dbopen(dbase, O_RDONLY, 0600, &ctl))) {
    /* create table */
    fprintf(stderr, "cannot open: hash table\n" );
    exit(1);
  }

  /* Read user and configuration information */
  read_user_info (dbp, userdata, &len);

  read_config_info (dbp, &acf);

  /* create a new cursor */
  stat = dbp->cursor (dbp, &cur, FFDB_KEY_CURSOR);
  if (stat != 0) {
    fprintf (stderr, "Cannot open a cursor\n");
    (dbp->close)(dbp);
    return -1;
  }

#if 0
  key.data = 0;
  key.size = 0;
  res.data = 0;
  res.size = 0;
#endif
  key.data = tmp1;
  key.size = MAX_LEN;
  res.data = tmp2;
  res.size = MAX_LEN;

  numkey = 0;
  while ((stat = cur->get (cur, &key, &res, FFDB_NEXT)) == FFDB_SUCCESS) {
#if 0
    fprintf (stderr, "Key len %d = %s\n", strlen((char *)(key.data)),(char *)(key.data));
    fprintf (stderr, "Data %s\n", (char *)(res.data));
#endif
    numkey++;

    /* Look for the key in the string table */
    for (i = 0; i < numpairs; i++) {
      if (strcmp (mykey[i], (char *)(key.data)) == 0) {
	if (strcmp (mydata[i], (char *)(res.data)) != 0) {
	    fprintf (stderr, "Data mismatch.\n");
	    return -1;
	}
      }
      break;
    }
    if (i >= numpairs) {
      fprintf (stderr, "Cannot match any keys\n");
      return -1;
    }

#if 0	  
    free (key.data);
    free (res.data);

    key.data = 0;
    key.size = 0;
    res.data = 0;
    res.size = 0;
#endif

    key.data = tmp1;
    key.size = MAX_LEN;
    res.data = tmp2;
    res.size = MAX_LEN;
  }

  cur->close (cur);

  (dbp->close)(dbp);

  fprintf (stderr, "Number of pairs found = %d\n", numkey);

  for (i = 0; i < numpairs; i++) {
    free (mykey[i]);
    free (mydata[i]);
  }

  return 0;
}
Example #3
0
/*ARGSUSED*/
void
main( int argc, char **argv)
{
    errdesc = 1;
    debug = 0;

  if ( argc == 2 ) {
    conf_file = *(argv+1);
  } /* if */
    /*
     * setup network connections
     */
    setup_connections();

    if ( batch ) {
      /*
       * check authentication
       */

      authenticate_client();

      read_config_info ();

    } else {
      strcpy ( uniq_str, "kxct-compatible" );
    } /* if */
    for (;;) {
      /*
       * read argument list for command
       */
      read_arglist();
      /*
       * check configuration
       */
      check_config();

      if ( start_batch ) {
        start_batch = 0;
        continue;
      } /* if */
      if ( end_batch ) {
        break;
      } /* if */
      /*
       * receive data file
       */
      if (tempslot != 0)
          receive_data();

    /*
     * execute command
     */
    run_command();
    /*
     * transmit data file
     */
    if (tempslot != 0)
        transmit_data();

    /*
     * transmit the exit status
     */
    transmit_status();
    if ( ! batch ) {
      break;
    } /* if */
}
    /*
     * that is all
     */
    if ( made_temp_dir )
      (void) rmdir(tempdir);
    /* if */
    exit(0);
}
Example #4
0
int process_metadata (WavpackContext *wpc, WavpackMetadata *wpmd)
{
    WavpackStream *wps = wpc->streams [wpc->current_stream];

    switch (wpmd->id) {
	case ID_DUMMY:
	    return TRUE;

	case ID_DECORR_TERMS:
	    return read_decorr_terms (wps, wpmd);

	case ID_DECORR_WEIGHTS:
	    return read_decorr_weights (wps, wpmd);

	case ID_DECORR_SAMPLES:
	    return read_decorr_samples (wps, wpmd);

	case ID_ENTROPY_VARS:
	    return read_entropy_vars (wps, wpmd);

	case ID_HYBRID_PROFILE:
	    return read_hybrid_profile (wps, wpmd);

	case ID_SHAPING_WEIGHTS:
	    return read_shaping_info (wps, wpmd);

	case ID_FLOAT_INFO:
	    return read_float_info (wps, wpmd);

	case ID_INT32_INFO:
	    return read_int32_info (wps, wpmd);

	case ID_CHANNEL_INFO:
	    return read_channel_info (wpc, wpmd);

	case ID_CONFIG_BLOCK:
	    return read_config_info (wpc, wpmd);

	case ID_WV_BITSTREAM:
	    return init_wv_bitstream (wps, wpmd);

	case ID_WVC_BITSTREAM:
	    return init_wvc_bitstream (wps, wpmd);

	case ID_WVX_BITSTREAM:
	    return init_wvx_bitstream (wps, wpmd);

	case ID_RIFF_HEADER: case ID_RIFF_TRAILER:
	    return read_wrapper_data (wpc, wpmd);

	case ID_MD5_CHECKSUM:
	    if (wpmd->byte_length == 16) {
		memcpy (wpc->config.md5_checksum, wpmd->data, 16);
		wpc->config.flags |= CONFIG_MD5_CHECKSUM;
		wpc->config.md5_read = 1;
	    }

	    return TRUE;

	default:
	    return (wpmd->id & ID_OPTIONAL_DATA) ? TRUE : FALSE;
    }
}