Example #1
0
void
mp_free_list(id3_tag_list *list)
{
	if(!list) return;
	
	/* free tag */
	if(list->tag) mp_free_tag(list->tag);

	/* free next element */
	if(list->next) mp_free_list(list->next);

	/* free this element */
	xfree(list); 
}
Example #2
0
void
do_expr(char *dir, char *file) 
{
  id3_tag_list *list, *fstlist;
  id3_tag *tag;
  mpeg_header *head;

  printf("Checking tag of file %s\n", file);

  res->checked++;
  head = mp_get_mpeg_header_from_file(file);
  if(!head) {
      printf("W A R N I N G: Cannot get mpeg header for file %s\n", file);
  }
  // TODO

  xfree(head);

  /* Get tag list */
  if((fstlist = list = mp_get_tag_list_from_file(file)))
  {
      id3_content* cont;
      id3_text_content* tcont;
      id3_comment_content* ccont;
      do {
	  char* curver = (list->tag->version == 2 ? "v2" : "v1");
	  tag = list->tag;
	  if(!tag) {
	      printf("%s: empty tag as list element\n");
	  }
	  cont = mp_get_content(tag, MP_ARTIST);
	  if(cont) {
	      tcont = mp_parse_artist(cont);
	      if(!tcont)
		  printf("%s: artist text content is null", file);
	      else
		  if(!tcont->text)
		      printf("%s: artist string provided with value null", file);
		  else
		      printf("artist %s: %s\n", curver, tcont->text);
	      
	      mp_free_text_content(tcont);
	      mp_free_content(cont);
	  }

	  /* Beware! C&P code */

	  cont = mp_get_content(tag, MP_TITLE);
	  if(cont) {
	      tcont = mp_parse_title(cont);
	      if(!tcont)
		  printf("E R R O R: title text content is null", file);
	      else
		  if(!tcont->text)
		      printf("E R R O R: artist string provided with value null", file);
		  else
		      printf("title %s: %s\n", curver, tcont->text);
	      
	      mp_free_text_content(tcont);
	      mp_free_content(cont);
	  }

	  cont = mp_get_content(tag, MP_ALBUM);
	  if(cont) {
	      tcont = mp_parse_album(cont);
	      if(!tcont)
		  printf("E R R O R: album text content is null", file);
	      else
		  if(!tcont->text)
		      printf("E R R O R: album string provided with value null", file);
		  else
		      printf("album %s: %s\n", curver, tcont->text);
	      
	      mp_free_text_content(tcont);
	      mp_free_content(cont);
	  }

	  cont = mp_get_content(tag, MP_YEAR);
	  if(cont) {
	      tcont = mp_parse_year(cont);
	      if(!tcont)
		  printf("E R R O R: year text content is null", file);
	      else
		  if(!tcont->text)
		      printf("E R R O R: year string provided with value null", file);
		  else
		      printf("year %s: %s\n", curver, tcont->text);
	      
	      mp_free_text_content(tcont);
	      mp_free_content(cont);
	  }

	  cont = mp_get_content(tag, MP_TRACK);
	  if(cont) {
	      tcont = mp_parse_track(cont);
	      if(!tcont)
		  printf("E R R O R: track text content is null", file);
	      else
		  if(!tcont->text)
		      printf("E R R O R: track string provided with value null", file);
		  else
		      printf("track %s: %s\n", curver, tcont->text);
	      
	      mp_free_text_content(tcont);
	      mp_free_content(cont);
	  }

	  cont = mp_get_content(tag, MP_GENRE);
	  if(cont) {
	      tcont = mp_parse_genre(cont);
	      if(!tcont)
		  printf("E R R O R: genre text content is null", file);
	      else
		  if(!tcont->text)
		      printf("E R R O R: genre string provided with value null", file);
		  else
		      printf("genre %s: %s\n", curver, tcont->text);
	      
	      mp_free_text_content(tcont);
	      mp_free_content(cont);
	  }

	  cont = mp_get_content(tag, MP_COMMENT);
	  if(cont) {
	      ccont = mp_parse_comment(cont);
	      if(!ccont)
		  printf("E R R O R: comment text content is null", file);
	      else
		  if(!ccont->text)
		      printf("E R R O R: comment string provided with value null", file);
		  else
		      printf("comment %s: %s\n", curver, ccont->text);
	      
	      mp_free_comment_content(ccont);
	      mp_free_content(cont);
	  }

	  
      } while((list = list->next));

      mp_free_list(fstlist);
  }
  else
  {
      puts("No tags found");
  }
}