<commit_before>#include "itunesdb.h"

#include <stdlib.h>
#include <stdio.h>

void usage (void) {
  printf("Usgae:\n");
  printf(" db_list <database>\n");

  exit(1);
}

char *str_type(int file_type) {
  switch (file_type) {
  case IPOD_TITLE:
    return "Title";
  case IPOD_PATH:
    return "Path";
  case IPOD_ALBUM:
    return "Album";
  case IPOD_ARTIST:
    return "Artist";
  case IPOD_GENRE:
    return "Genre";
  case IPOD_TYPE:
    return "Type";
  case IPOD_COMMENT:
    return "Comment";
  case IPOD_EQ:
    return "Equilizer";
  default:
    return "Unknown";
  }
}

int main (int argc, char *argv[]) {
  GList *songs, *tmp;
  GList *playlists;

  tihm_t *tihm;
  pyhm_t *pyhm;
  char buffer[1024];
  int i, ret;

  itunesdb_t itunesdb;
  int fd, result;

  if (argc != 2)
    usage();

  if (db_load (&itunesdb, argv[1]) < 0) {
    close (fd);
    exit(1);
  }

  printf ("Checking the sanity of the database...\n");

  ret = db_sanity_check(itunesdb);

  if (ret <= -20) {
    printf ("There is somthing wrong with the loaded database!\n");
    db_free (&itunesdb);
    exit(1);
  } else if (ret < 0) {
    printf ("The database has small problems, continuing anyway. :: %i\n", ret);
  } else
    printf ("The database check out.\n");

  /* get song lists */
  songs = db_song_list (&itunesdb);

  if (songs == NULL)
    printf("Could not get song list\n");

  /* get playlists */
  playlists = db_playlist_list (&itunesdb);

  if (playlists == NULL) {
    printf("Could not get playlist list\n");
    db_free(&itunesdb);
    close (fd);
    exit(1);
  }

  /* dump songlist contents */
  for (tmp = songs ; tmp ; tmp = tmp->next) {
    tihm = tmp->data;

    printf("%04i |\n", tihm->num, buffer);
    
    printf(" encoding: %d\n", tihm->bitrate);
    printf(" type    : %d\n", tihm->type);
    printf(" num dohm: %d\n", tihm->num_dohm);
    printf(" samplert: %d\n", tihm->samplerate);
    printf(" stars   : %d\n", tihm->stars);
    printf(" played  : %d\n", tihm->times_played);

    for (i = 0 ; i < tihm->num_dohm ; i++) {
      memset(buffer, 0, 1024);
      unicode_to_char (buffer, tihm->dohms[i].data, tihm->dohms[i].size);
      if (tihm->dohms[i].type == IPOD_EQ)
	printf (" %10s : %i\n", str_type(tihm->dohms[i].type), buffer[5]);
      else
	printf (" %10s : %s\n", str_type(tihm->dohms[i].type), buffer);
    }

    printf("\n");
  }

  /* free the song list */
  db_song_list_free (songs);

  /* dump playlist contents */
  for (tmp = playlists ; tmp ; tmp = tmp->next) {
    int num_ref;
    int *list = NULL;

    pyhm = (pyhm_t *)tmp->data;
    /* P(laylist) M(aster) */
    printf ("playlist name: %s(%s) len=%i\n", pyhm->name, (pyhm->num)?"P":"M", pyhm->name_len);

    num_ref = db_playlist_list_songs (&itunesdb, pyhm->num, &list);

    for (i = 0 ; i < num_ref ; i++)
      printf ("%i ", list[i]);

    printf ("\n");
    free(list);
  }

  db_free(&itunesdb);
  db_song_list_free (songs);
  db_playlist_list_free (playlists);
  close(fd);

  return 0;
}<commit_msg>Removed a extra free.<commit_after>#include "itunesdb.h"

#include <stdlib.h>
#include <stdio.h>

void usage (void) {
  printf("Usgae:\n");
  printf(" db_list <database>\n");

  exit(1);
}

char *str_type(int file_type) {
  switch (file_type) {
  case IPOD_TITLE:
    return "Title";
  case IPOD_PATH:
    return "Path";
  case IPOD_ALBUM:
    return "Album";
  case IPOD_ARTIST:
    return "Artist";
  case IPOD_GENRE:
    return "Genre";
  case IPOD_TYPE:
    return "Type";
  case IPOD_COMMENT:
    return "Comment";
  case IPOD_EQ:
    return "Equilizer";
  default:
    return "Unknown";
  }
}

int main (int argc, char *argv[]) {
  GList *songs, *tmp;
  GList *playlists;

  tihm_t *tihm;
  pyhm_t *pyhm;
  char buffer[1024];
  int i, ret;

  itunesdb_t itunesdb;
  int fd, result;

  if (argc != 2)
    usage();

  if (db_load (&itunesdb, argv[1]) < 0) {
    close (fd);
    exit(1);
  }

  printf ("Checking the sanity of the database...\n");

  ret = db_sanity_check(itunesdb);

  if (ret <= -20) {
    printf ("There is somthing wrong with the loaded database!\n");
    db_free (&itunesdb);
    exit(1);
  } else if (ret < 0) {
    printf ("The database has small problems, continuing anyway. :: %i\n", ret);
  } else
    printf ("The database check out.\n");

  /* get song lists */
  songs = db_song_list (&itunesdb);

  if (songs == NULL)
    printf("Could not get song list\n");

  /* get playlists */
  playlists = db_playlist_list (&itunesdb);

  if (playlists == NULL) {
    printf("Could not get playlist list\n");
    db_free(&itunesdb);
    close (fd);
    exit(1);
  }

  /* dump songlist contents */
  for (tmp = songs ; tmp ; tmp = tmp->next) {
    tihm = tmp->data;

    printf("%04i |\n", tihm->num, buffer);
    
    printf(" encoding: %d\n", tihm->bitrate);
    printf(" type    : %d\n", tihm->type);
    printf(" num dohm: %d\n", tihm->num_dohm);
    printf(" samplert: %d\n", tihm->samplerate);
    printf(" stars   : %d\n", tihm->stars);
    printf(" played  : %d\n", tihm->times_played);

    for (i = 0 ; i < tihm->num_dohm ; i++) {
      memset(buffer, 0, 1024);
      unicode_to_char (buffer, tihm->dohms[i].data, tihm->dohms[i].size);
      if (tihm->dohms[i].type == IPOD_EQ)
	printf (" %10s : %i\n", str_type(tihm->dohms[i].type), buffer[5]);
      else
	printf (" %10s : %s\n", str_type(tihm->dohms[i].type), buffer);
    }

    printf("\n");
  }
  
  /* free the song list */
  db_song_list_free (songs);
  songs = NULL;
  
  /* dump playlist contents */
  
  for (tmp = playlists ; tmp ; tmp = tmp->next) {
    int num_ref;
    int *list = NULL;
    
    pyhm = (pyhm_t *)tmp->data;
    /* P(laylist) M(aster) */
    printf ("playlist name: %s(%s) len=%i\n", pyhm->name, (pyhm->num)?"P":"M", pyhm->name_len);
    
    num_ref = db_playlist_list_songs (&itunesdb, pyhm->num, &list);
    
    for (i = 0 ; i < num_ref ; i++)
      printf ("%i ", list[i]);
    
    printf ("\n");
    free(list);
  }
  
  db_playlist_list_free (playlists);
  db_free(&itunesdb);

  close(fd);

  return 0;
}
{'fraction_non_alphanumeric': 0.17928748964374483, 'fraction_numerical': 0.009610604805302403, 'mean_word_length': 2.8396946564885495, 'pattern_counts': {'":': 2, '<': 19, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1136843', 'n_tokens_mistral': 2495, 'n_tokens_neox': 2393, 'n_words': 587}