summaryrefslogtreecommitdiffstats
path: root/tests/itdb_main.c
blob: e7723bbb033e9279998b1e93680c8a0e23bab838 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
|   Copyright (C) 2002-2003 Jorg Schuler <jcsjcs at users.sourceforge.net>
|   Part of the gtkpod project.
|
|   URL: http://gtkpod.sourceforge.net/
|
|   This program is free software; you can redistribute it and/or modify
|   it under the terms of the GNU General Public License as published by
|   the Free Software Foundation; either version 2 of the License, or
|   (at your option) any later version.
|
|   This program is distributed in the hope that it will be useful,
|   but WITHOUT ANY WARRANTY; without even the implied warranty of
|   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
|   GNU General Public License for more details.
|
|   You should have received a copy of the GNU General Public License
|   along with this program; if not, write to the Free Software
|   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|  iTunes and iPod are trademarks of Apple
|
|  This product is not supported/written/published by Apple!
|
|  $Id$
*/
/*
 * Initial main.c file generated by Glade. Edit as required.
 * Glade will not overwrite this file.
 */

#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

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

#include "itdb.h"

int
main (int argc, char *argv[])
{
  GError *error=NULL;
  Itdb_iTunesDB *itdb;
  gchar *infile = NULL;
  gchar *outfile = NULL;

  if (argc >= 2)
      infile = argv[1];
  if (argc >= 3)
      outfile = argv[2];

  if (infile == 0)
  {
      printf ("Usage: %s <infile> [<outfile>]\n",  g_basename(argv[0]));
      exit (0);
  }

  itdb = itdb_parse_file (infile, &error);
  printf ("%p\n", itdb);

  if (error)
  {
      if (error->message)
	  puts (error->message);
      g_error_free (error);
      error = NULL;
  }

  if (itdb)
  {
      printf ("tracks: %d\n", g_list_length (itdb->tracks));
      printf ("playlists: %d\n", g_list_length (itdb->playlists));

      if (outfile)
	  itdb_write_file (itdb, outfile, &error);
      if (error)
      {
	  if (error->message)
	      puts (error->message);
	  g_error_free (error);
	  error = NULL;
      }
  }

  itdb_free (itdb);

  return 0;
}