Mercurial > hg > xmms-sid
annotate src/xs_support.c @ 49:3518ca5c8b0f
Support for compile-time big/little-endian optimizations in audio output
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 21 Jun 2003 20:51:01 +0000 |
parents | 1788f4ce6a44 |
children | 6a3ce7260ae1 |
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 <stdlib.h> |
25 #include <string.h> | |
26 #include <ctype.h> | |
27 | |
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 | |
38 | 63 int xs_strpcat(gchar **ppcResult, gint *j, const gchar *pcStr) |
4 | 64 { |
38 | 65 int iLen; |
4 | 66 |
38 | 67 assert(ppcResult); |
68 assert(pcStr); | |
69 assert(j); | |
70 | |
71 /* Get length of the pcString to be catted */ | |
72 iLen = strlen(pcStr); | |
73 (*j) += iLen; | |
4 | 74 |
38 | 75 /* Re-allocate memory for destination */ |
76 *ppcResult = (gchar *) g_realloc(*ppcResult, strlen(*ppcResult) + iLen + 1); | |
77 if (*ppcResult == NULL) return -1; | |
4 | 78 |
38 | 79 /* Cat to the destination */ |
80 strcat(*ppcResult, pcStr); | |
4 | 81 |
38 | 82 return 0; |
4 | 83 } |
84 | |
85 | |
86 inline void xs_findnext(gchar *pcStr, gint *piPos) | |
87 { | |
88 /* Terminating NULL-character is not whitespace! */ | |
89 while (isspace(pcStr[*piPos])) (*piPos)++; | |
90 } | |
91 | |
92 | |
93 inline void xs_findnum(gchar *pcStr, gint *piPos) | |
94 { | |
95 /* Terminating NULL-character is not digit! */ | |
96 while (isdigit(pcStr[*piPos])) (*piPos)++; | |
97 } | |
98 | |
99 |