~ubuntu-branches/ubuntu/hardy/gnomad2/hardy

« back to all changes in this revision

Viewing changes to src/id3read.c

  • Committer: Bazaar Package Importer
  • Author(s): Shaun Jackman
  • Date: 2005-08-19 16:09:28 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050819160928-l2glu227nh0algdc
Tags: 2.8.0-2
Add a versioned dependency for libnjb-dev (>> 2.2). Closes: #324036.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
{
36
36
  id3_utf8_t *tmp;
37
37
  
38
 
  tmp = g_convert(str,-1,"UTF-8","ISO-8859-1",NULL,NULL,NULL);
 
38
  tmp = (id3_utf8_t *) g_convert((gchar *) str,-1,"UTF-8","ISO-8859-1",NULL,NULL,NULL);
39
39
  return (id3_utf8_t *) tmp;
40
40
}
41
41
 
43
43
{
44
44
  id3_latin1_t *tmp;
45
45
 
46
 
  tmp = g_convert(str,-1,"ISO-8859-1","UTF-8",NULL,NULL,NULL);
 
46
  tmp = (id3_latin1_t *) g_convert((gchar *) str,-1,"ISO-8859-1","UTF-8",NULL,NULL,NULL);
47
47
  return (id3_latin1_t *) tmp;
48
48
}
49
49
 
321
321
       whatever coding system they are using into it, so we use
322
322
       charset_to_utf8() to convert to utf8 */
323
323
    id3_latin1_t *raw = id3_ucs4_latin1duplicate(string);
324
 
    utf8 = charset_to_utf8(raw);
 
324
    utf8 = (gchar *) charset_to_utf8(raw);
325
325
    g_free (raw);
326
326
  } else {
327
327
    /* Standard unicode is being used -- we won't have to worry
328
328
       about charsets then. */
329
329
    // g_print("This frame is a Unicode frame!\n");
330
 
    utf8 = id3_ucs4_utf8duplicate (string);
 
330
    utf8 = (gchar *) id3_ucs4_utf8duplicate (string);
331
331
  }
332
332
  // g_print("Found tag: %s, value: %s\n", frame_name, utf8);
333
333
  return utf8;
399
399
    if (index != -1) {
400
400
      /* valid genre -- simply store the genre number */
401
401
      gchar *tmp = g_strdup_printf("%d", index);
402
 
      ucs4 = id3_latin1_ucs4duplicate (tmp);
 
402
      ucs4 = id3_latin1_ucs4duplicate ((id3_latin1_t *) tmp);
403
403
      g_free (tmp);
404
404
    } else {
405
405
      /* oups -- not a valid genre -- save the entire genre string */
406
406
      if (encoding == ID3_FIELD_TEXTENCODING_ISO_8859_1) {
407
407
        /* we read 'ISO_8859_1' to stand for 'any locale
408
408
           charset' -- most programs seem to work that way */
409
 
        id3_latin1_t *raw = charset_from_utf8(data);
 
409
        id3_latin1_t *raw = charset_from_utf8((id3_utf8_t *) data);
410
410
        ucs4 = id3_latin1_ucs4duplicate (raw);
411
411
        g_free (raw);
412
412
      } else {
421
421
    if (encoding == ID3_FIELD_TEXTENCODING_ISO_8859_1) {
422
422
      /* we read 'ISO_8859_1' to stand for 'any locale charset'
423
423
         -- most programs seem to work that way */
424
 
      id3_latin1_t *raw = charset_from_utf8(data);
 
424
      id3_latin1_t *raw = charset_from_utf8((id3_utf8_t *) data);
425
425
      ucs4 = id3_latin1_ucs4duplicate (raw);
426
426
      g_free (raw);
427
427
    } else {
698
698
        tag[0] == 'I' &&
699
699
        tag[1] == 'D' &&
700
700
        tag[2] == '3') {
701
 
      // g_print("Found ID3v2 tag header...\n");
 
701
      // g_print("Found ID3v2 tag header...");
702
702
      // Get tag length from the tag
703
703
      header_taglength = (tag[6] << 24) + (tag[7] << 16) + (tag[8] << 8) + tag[9];
704
704
      // This needs some heuristics... first scan until only zeroes are found.
705
 
      // while ()
 
705
      // g_print(" given size %d (%08x)\n", header_taglength, header_taglength);
706
706
      n = read(f1,buffer,bufsiz);
707
707
      if (n > 4) {
708
708
        guint m = 0;
723
723
          }
724
724
          m += 8;
725
725
        }
726
 
        // g_print("Found zeros\n");
 
726
        if (foundzeros == TRUE) {
 
727
          // g_print("Found zeros\n");
 
728
        }
727
729
 
728
730
        // Then look for first non-zero
729
731
        while (!founddata && (m < n)) {
745
747
        if (founddata) {
746
748
          // g_print("Found data\n");
747
749
          if (header_taglength != m) {
748
 
            g_print("Bad header tag! Given length: %d, detected length: %d\n", header_taglength, m);
 
750
            g_print("remove_tag_from_mp3file(): Bad header tag! Given length: %d, detected length: %d\n", header_taglength, m);
749
751
          }
750
752
          // Adjust header taglength
751
753
          header_taglength = m;
882
884
 
883
885
  /* g_print("Getting tag info for %s...\n", path); */
884
886
  fh = id3_file_open(tmppath, ID3_FILE_MODE_READONLY);
 
887
  if (fh == 0) {
 
888
    g_print("get_tag_for_mp3file(), file could not be opened: %s\n", tmppath);
 
889
    g_print("This may be caused by bad locale settings.\n");
 
890
    return;
 
891
  }
885
892
  g_free(tmppath);
886
893
  tag = id3_file_tag(fh);
887
894