Exemplo n.º 1
0
static PDX_DATA*
_get_pdx(MDX_DATA* mdx, char* mdxpath)
{
  char *a = NULL;
  char buf[PATH_BUF_SIZE];
  PDX_DATA* pdx = NULL;

  mdx->pdx_enable = FLAG_FALSE;
  if ( mdx->haspdx == FLAG_FALSE ) goto no_pdx_file;

  /* current directory */
  memset(buf, 0, PATH_BUF_SIZE);
  if (getcwd(buf, PATH_BUF_SIZE-1-strlen(mdx->pdx_name)-1)!=NULL) {
    strcat(buf, "/");
    strcat( buf, mdx->pdx_name );
    if ( (pdx=_open_pdx( buf )) != NULL ) goto get_pdx_file;
  }
  
  /* mdx file path directory */
  if ( strlen(mdxpath)+strlen(mdx->pdx_name) > PATH_BUF_SIZE ) goto next0;
  memset(buf, 0, PATH_BUF_SIZE);
  strncpy( buf, mdxpath, PATH_BUF_SIZE-1 );
  if ( (a=strrchr( buf, '/' )) != NULL ) {
    *(a+1)='\0';
    strcat( buf, mdx->pdx_name );
    if ( (pdx=_open_pdx( buf )) != NULL ) goto get_pdx_file;
  }

next0:
  /* specified directory : option "--pdx_path" */
  memset(buf, 0, PATH_BUF_SIZE);
  if ( pdx_pathname == NULL ) goto next;
  if ( strlen(pdx_pathname)+strlen(mdx->pdx_name) > PATH_BUF_SIZE ) goto next;
  snprintf( buf, PATH_BUF_SIZE, "%s/%s", pdx_pathname, mdx->pdx_name );
  if ( (pdx=_open_pdx( buf )) != NULL ) goto get_pdx_file;
    
next:
  /* specified directory : env "PDX_PATH" */
  memset(buf, 0, PATH_BUF_SIZE);
  a = getenv( MDX_PDX_PATH_ENV_NAME );
  if ( a==NULL ) goto next2;
  if ( strlen(a)+strlen(mdx->pdx_name) > PATH_BUF_SIZE ) goto next2;
  snprintf( buf, PATH_BUF_SIZE, "%s/%s", a, mdx->pdx_name );
  if ( (pdx=_open_pdx( buf )) != NULL ) goto get_pdx_file;
    
next2:
  //fprintf(stderr,_("%s: No pdx file : %s\n"), command_name, mdx->pdx_name );
no_pdx_file:
  goto unget_pdx_file;
    
unget_pdx_file:
  mdx->haspdx = FLAG_FALSE;
  mdx->tracks = 9;
  mdx->pdx_enable = FLAG_TRUE;
  return NULL;

get_pdx_file:
  mdx->pdx_enable = FLAG_TRUE;
  return pdx;
}
Exemplo n.º 2
0
static PDX_DATA*
_get_pdx(MDX_DATA* mdx, char* mdxpath)
{
  char *a = NULL;
  char buf[PATH_BUF_SIZE];
  PDX_DATA* pdx = NULL;

  mdx->pdx_enable = FLAG_FALSE;
  if ( mdx->haspdx == FLAG_FALSE ) goto no_pdx_file;

   
  /* mdx file path directory */
  
  memset(buf, 0, PATH_BUF_SIZE);
  strncpy( buf, mdxpath, PATH_BUF_SIZE-1 );
  if ( (a=strrchr( buf, '/' )) != NULL ) 
  {
    *(a+1)='\0';
  }
  else
    buf[0] = 0;
  
  strcat( buf, mdx->pdx_name );
  if ( (pdx=_open_pdx( buf )) == NULL ) 
  {
    // specified pdx directory
	strcpy( buf, mdx->pdx_dir );
	int len = (int)strlen( buf );
	
	if (len > 0 && buf [ len - 1 ] != '/' )
			strcat( buf, "/" );
	
	strcat( buf, mdx->pdx_name );
	if ((pdx=_open_pdx( buf )) != NULL )
		goto get_pdx_file;
  }
  else
    goto get_pdx_file;
  

no_pdx_file:
  goto unget_pdx_file;
    
unget_pdx_file:
// tempo could be changed in a pcm track
  mdx->haspdx = FLAG_FALSE;
  mdx->pdx_enable = FLAG_TRUE;
  return NULL;

get_pdx_file:
  mdx->pdx_enable = FLAG_TRUE;
  return pdx;
}