Mercurial > hg > xmms-sid
annotate src/xs_support.c @ 202:fe684a2ccdc7
Reworking code.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 16 Nov 2004 06:56:02 +0000 |
parents | 578b71b62eeb |
children | 8b896d461fdb |
rev | line source |
---|---|
4 | 1 /* |
2 XMMS-SID - SIDPlay input plugin for X MultiMedia System (XMMS) | |
3 | |
4 Miscellaneous support functions | |
5 | |
6 Written by Matti "ccr" Hamalainen <ccr@tnsp.org> | |
7 | |
8 This program is free software; you can redistribute it and/or modify | |
9 it under the terms of the GNU General Public License as published by | |
10 the Free Software Foundation; either version 2 of the License, or | |
11 (at your option) any later version. | |
12 | |
13 This program is distributed in the hope that it will be useful, | |
14 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 GNU General Public License for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
19 along with this program; if not, write to the Free Software | |
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
21 */ | |
22 | |
49
3518ca5c8b0f
Support for compile-time big/little-endian optimizations in audio output
Matti Hamalainen <ccr@tnsp.org>
parents:
40
diff
changeset
|
23 #include "xs_support.h" |
4 | 24 #include <string.h> |
25 #include <ctype.h> | |
26 | |
202 | 27 |
4 | 28 /* |
29 * Utility routines | |
30 */ | |
38 | 31 gint xs_strcalloc(gchar **ppcResult, const gchar *pcStr) |
4 | 32 { |
38 | 33 assert(ppcResult); |
34 assert(pcStr); | |
35 | |
36 /* Allocate memory for destination */ | |
37 *ppcResult = (gchar *) g_realloc(*ppcResult, strlen(pcStr) + 1); | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
38
diff
changeset
|
38 if (*ppcResult == NULL) return -1; |
4 | 39 |
38 | 40 /* Copy to the destination */ |
41 strcpy(*ppcResult, pcStr); | |
4 | 42 |
38 | 43 return 0; |
4 | 44 } |
45 | |
46 | |
47 int xs_strcat(gchar **ppcResult, const gchar *pcStr) | |
48 { | |
38 | 49 assert(ppcResult); |
50 assert(pcStr); | |
51 | |
52 /* Re-allocate memory for destination */ | |
53 *ppcResult = (gchar *) g_realloc(*ppcResult, strlen(*ppcResult) + strlen(pcStr) + 1); | |
54 if (*ppcResult == NULL) return -1; | |
4 | 55 |
38 | 56 /* Cat to the destination */ |
57 strcat(*ppcResult, pcStr); | |
4 | 58 |
38 | 59 return 0; |
4 | 60 } |
61 | |
62 | |
56
6a3ce7260ae1
Changed some standard functions to glib ones
Matti Hamalainen <ccr@tnsp.org>
parents:
49
diff
changeset
|
63 gchar *xs_strrchr(gchar *pcStr, gchar ch) |
6a3ce7260ae1
Changed some standard functions to glib ones
Matti Hamalainen <ccr@tnsp.org>
parents:
49
diff
changeset
|
64 { |
6a3ce7260ae1
Changed some standard functions to glib ones
Matti Hamalainen <ccr@tnsp.org>
parents:
49
diff
changeset
|
65 gchar *lastPos = NULL; |
6a3ce7260ae1
Changed some standard functions to glib ones
Matti Hamalainen <ccr@tnsp.org>
parents:
49
diff
changeset
|
66 |
6a3ce7260ae1
Changed some standard functions to glib ones
Matti Hamalainen <ccr@tnsp.org>
parents:
49
diff
changeset
|
67 while (*pcStr) |
6a3ce7260ae1
Changed some standard functions to glib ones
Matti Hamalainen <ccr@tnsp.org>
parents:
49
diff
changeset
|
68 { |
6a3ce7260ae1
Changed some standard functions to glib ones
Matti Hamalainen <ccr@tnsp.org>
parents:
49
diff
changeset
|
69 if (*pcStr == ch) lastPos = pcStr; |
6a3ce7260ae1
Changed some standard functions to glib ones
Matti Hamalainen <ccr@tnsp.org>
parents:
49
diff
changeset
|
70 pcStr++; |
6a3ce7260ae1
Changed some standard functions to glib ones
Matti Hamalainen <ccr@tnsp.org>
parents:
49
diff
changeset
|
71 } |
6a3ce7260ae1
Changed some standard functions to glib ones
Matti Hamalainen <ccr@tnsp.org>
parents:
49
diff
changeset
|
72 |
6a3ce7260ae1
Changed some standard functions to glib ones
Matti Hamalainen <ccr@tnsp.org>
parents:
49
diff
changeset
|
73 return lastPos; |
6a3ce7260ae1
Changed some standard functions to glib ones
Matti Hamalainen <ccr@tnsp.org>
parents:
49
diff
changeset
|
74 } |
6a3ce7260ae1
Changed some standard functions to glib ones
Matti Hamalainen <ccr@tnsp.org>
parents:
49
diff
changeset
|
75 |
6a3ce7260ae1
Changed some standard functions to glib ones
Matti Hamalainen <ccr@tnsp.org>
parents:
49
diff
changeset
|
76 |
109
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
77 inline void xs_findnext(gchar *pcStr, guint *piPos) |
4 | 78 { |
109
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
79 while (pcStr[*piPos] && isspace(pcStr[*piPos])) (*piPos)++; |
4 | 80 } |
81 | |
82 | |
109
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
83 inline void xs_findeol(gchar *pcStr, guint *piPos) |
4 | 84 { |
109
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
85 while (pcStr[*piPos] && (pcStr[*piPos] != '\n') && (pcStr[*piPos] != '\r')) (*piPos)++; |
4 | 86 } |
87 | |
88 | |
109
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
89 inline void xs_findnum(gchar *pcStr, guint *piPos) |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
90 { |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
91 while (pcStr[*piPos] && isdigit(pcStr[*piPos])) (*piPos)++; |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
92 } |