Mercurial > audlegacy
annotate src/libid3tag/render.c @ 3465:0dd74d0da472 trunk
the less gdk calls, the better
author | Tomasz Mon <desowin@gmail.com> |
---|---|
date | Sun, 09 Sep 2007 12:50:57 +0200 |
parents | 1e6d2d719876 |
children |
rev | line source |
---|---|
2503
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
1 /* |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
2 * libid3tag - ID3 tag manipulation library |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
3 * Copyright (C) 2000-2004 Underbit Technologies, Inc. |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
4 * |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
5 * This program is free software; you can redistribute it and/or modify |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
6 * it under the terms of the GNU General Public License as published by |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
7 * the Free Software Foundation; either version 2 of the License, or |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
8 * (at your option) any later version. |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
9 * |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
10 * This program is distributed in the hope that it will be useful, |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
13 * GNU General Public License for more details. |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
14 * |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
16 * along with this program; if not, write to the Free Software |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
18 * |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
19 * $Id: render.c,v 1.11 2004/01/23 09:41:32 rob Exp $ |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
20 */ |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
21 |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
22 # ifdef HAVE_CONFIG_H |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
23 # include "config.h" |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
24 # endif |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
25 |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
26 # include "global.h" |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
27 |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
28 # include <string.h> |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
29 # include <stdlib.h> |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
30 |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
31 # ifdef HAVE_ASSERT_H |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
32 # include <assert.h> |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
33 # endif |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
34 |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
35 # include "id3tag.h" |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
36 # include "render.h" |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
37 # include "ucs4.h" |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
38 # include "latin1.h" |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
39 # include "utf16.h" |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
40 # include "utf8.h" |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
41 |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
42 id3_length_t id3_render_immediate(id3_byte_t **ptr, |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
43 char const *value, unsigned int bytes) |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
44 { |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
45 assert(value); |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
46 assert(bytes == 8 || bytes == 4 || bytes == 3); |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
47 |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
48 if (ptr) { |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
49 switch (bytes) { |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
50 case 8: *(*ptr)++ = *value++; |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
51 *(*ptr)++ = *value++; |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
52 *(*ptr)++ = *value++; |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
53 *(*ptr)++ = *value++; |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
54 case 4: *(*ptr)++ = *value++; |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
55 case 3: *(*ptr)++ = *value++; |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
56 *(*ptr)++ = *value++; |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
57 *(*ptr)++ = *value++; |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
58 } |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
59 } |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
60 |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
61 return bytes; |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
62 } |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
63 |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
64 id3_length_t id3_render_syncsafe(id3_byte_t **ptr, |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
65 unsigned long num, unsigned int bytes) |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
66 { |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
67 assert(bytes == 4 || bytes == 5); |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
68 |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
69 if (ptr) { |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
70 switch (bytes) { |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
71 case 5: *(*ptr)++ = (num >> 28) & 0x0f; |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
72 case 4: *(*ptr)++ = (num >> 21) & 0x7f; |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
73 *(*ptr)++ = (num >> 14) & 0x7f; |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
74 *(*ptr)++ = (num >> 7) & 0x7f; |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
75 *(*ptr)++ = (num >> 0) & 0x7f; |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
76 } |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
77 } |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
78 |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
79 return bytes; |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
80 } |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
81 |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
82 id3_length_t id3_render_int(id3_byte_t **ptr, |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
83 signed long num, unsigned int bytes) |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
84 { |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
85 assert(bytes >= 1 && bytes <= 4); |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
86 |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
87 if (ptr) { |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
88 switch (bytes) { |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
89 case 4: *(*ptr)++ = num >> 24; |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
90 case 3: *(*ptr)++ = num >> 16; |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
91 case 2: *(*ptr)++ = num >> 8; |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
92 case 1: *(*ptr)++ = num >> 0; |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
93 } |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
94 } |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
95 |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
96 return bytes; |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
97 } |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
98 |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
99 id3_length_t id3_render_binary(id3_byte_t **ptr, |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
100 id3_byte_t const *data, id3_length_t length) |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
101 { |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
102 if (data == 0) |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
103 return 0; |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
104 |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
105 if (ptr) { |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
106 memcpy(*ptr, data, length); |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
107 *ptr += length; |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
108 } |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
109 |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
110 return length; |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
111 } |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
112 |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
113 id3_length_t id3_render_latin1(id3_byte_t **ptr, |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
114 id3_latin1_t const *latin1, int terminate) |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
115 { |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
116 id3_length_t size; |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
117 |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
118 if (latin1 == 0) |
2513 | 119 latin1 = (id3_latin1_t *)""; |
2503
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
120 |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
121 size = id3_latin1_size(latin1); |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
122 if (!terminate) |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
123 --size; |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
124 |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
125 if (ptr) { |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
126 memcpy(*ptr, latin1, size); |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
127 *ptr += size; |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
128 } |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
129 |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
130 return size; |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
131 } |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
132 |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
133 id3_length_t id3_render_string(id3_byte_t **ptr, id3_ucs4_t const *ucs4, |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
134 enum id3_field_textencoding encoding, |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
135 int terminate) |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
136 { |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
137 enum id3_utf16_byteorder byteorder = ID3_UTF16_BYTEORDER_ANY; |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
138 |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
139 if (ucs4 == 0) |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
140 ucs4 = id3_ucs4_empty; |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
141 |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
142 switch (encoding) { |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
143 case ID3_FIELD_TEXTENCODING_ISO_8859_1: |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
144 return id3_latin1_serialize(ptr, ucs4, terminate); |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
145 |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
146 case ID3_FIELD_TEXTENCODING_UTF_16BE: |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
147 byteorder = ID3_UTF16_BYTEORDER_BE; |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
148 case ID3_FIELD_TEXTENCODING_UTF_16: |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
149 return id3_utf16_serialize(ptr, ucs4, byteorder, terminate); |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
150 |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
151 case ID3_FIELD_TEXTENCODING_UTF_8: |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
152 return id3_utf8_serialize(ptr, ucs4, terminate); |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
153 } |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
154 |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
155 return 0; |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
156 } |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
157 |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
158 id3_length_t id3_render_padding(id3_byte_t **ptr, id3_byte_t value, |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
159 id3_length_t length) |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
160 { |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
161 if (ptr) { |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
162 memset(*ptr, value, length); |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
163 *ptr += length; |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
164 } |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
165 |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
166 return length; |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
167 } |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
168 |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
169 /* |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
170 * NAME: render->paddedstring() |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
171 * DESCRIPTION: render a space-padded string using latin1 encoding |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
172 */ |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
173 id3_length_t id3_render_paddedstring(id3_byte_t **ptr, id3_ucs4_t const *ucs4, |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
174 id3_length_t length) |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
175 { |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
176 id3_ucs4_t padded[31], *data, *end; |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
177 |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
178 /* latin1 encoding only (this is used for ID3v1 fields) */ |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
179 |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
180 assert(length <= 30); |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
181 |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
182 data = padded; |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
183 end = data + length; |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
184 |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
185 if (ucs4) { |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
186 while (*ucs4 && end - data > 0) { |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
187 *data++ = *ucs4++; |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
188 |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
189 if (data[-1] == '\n') |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
190 data[-1] = ' '; |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
191 } |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
192 } |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
193 |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
194 while (end - data > 0) |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
195 *data++ = ' '; |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
196 |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
197 *data = 0; |
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
198 |
2513 | 199 return id3_latin1_serialize(ptr, padded, 0); |
2503
10692383c103
[svn] first try for libid3tag integration. this improved libid3tag supports vfs operations and is capable of adding id3v2 tag to files which doesn't have id3v2 tag ever.
yaz
parents:
diff
changeset
|
200 } |