Mercurial > hg > xmms-sid
annotate src/xs_support.c @ 412:7f694e5a1493
Updated GNU GPL (new FSF address) and some cleanups.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 14 Aug 2006 00:49:02 +0000 |
parents | 933b9ea5923e |
children | d2e6682d3ef8 |
rev | line source |
---|---|
4 | 1 /* |
2 XMMS-SID - SIDPlay input plugin for X MultiMedia System (XMMS) | |
3 | |
4 Miscellaneous support functions | |
5 | |
324 | 6 Programmed and designed by Matti 'ccr' Hamalainen <ccr@tnsp.org> |
7 (C) Copyright 1999-2005 Tecnic Software productions (TNSP) | |
4 | 8 |
9 This program is free software; you can redistribute it and/or modify | |
10 it under the terms of the GNU General Public License as published by | |
11 the Free Software Foundation; either version 2 of the License, or | |
12 (at your option) any later version. | |
13 | |
14 This program is distributed in the hope that it will be useful, | |
15 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 GNU General Public License for more details. | |
18 | |
412
7f694e5a1493
Updated GNU GPL (new FSF address) and some cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
398
diff
changeset
|
19 You should have received a copy of the GNU General Public License along |
7f694e5a1493
Updated GNU GPL (new FSF address) and some cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
398
diff
changeset
|
20 with this program; if not, write to the Free Software Foundation, Inc., |
7f694e5a1493
Updated GNU GPL (new FSF address) and some cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
398
diff
changeset
|
21 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
4 | 22 */ |
214 | 23 #include "xmms-sid.h" |
49
3518ca5c8b0f
Support for compile-time big/little-endian optimizations in audio output
Matti Hamalainen <ccr@tnsp.org>
parents:
40
diff
changeset
|
24 #include "xs_support.h" |
224
df4cb5115322
Removed duplicate function, more portability cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
218
diff
changeset
|
25 #include <ctype.h> |
202 | 26 |
226
858c09f59011
Moved some functions from xs_length.c here.
Matti Hamalainen <ccr@tnsp.org>
parents:
224
diff
changeset
|
27 |
858c09f59011
Moved some functions from xs_length.c here.
Matti Hamalainen <ccr@tnsp.org>
parents:
224
diff
changeset
|
28 /* Bigendian file reading functions |
858c09f59011
Moved some functions from xs_length.c here.
Matti Hamalainen <ccr@tnsp.org>
parents:
224
diff
changeset
|
29 */ |
398 | 30 guint16 xs_rd_be16(FILE *f) |
226
858c09f59011
Moved some functions from xs_length.c here.
Matti Hamalainen <ccr@tnsp.org>
parents:
224
diff
changeset
|
31 { |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
32 return (((guint16) fgetc(f)) << 8) | ((guint16) fgetc(f)); |
226
858c09f59011
Moved some functions from xs_length.c here.
Matti Hamalainen <ccr@tnsp.org>
parents:
224
diff
changeset
|
33 } |
858c09f59011
Moved some functions from xs_length.c here.
Matti Hamalainen <ccr@tnsp.org>
parents:
224
diff
changeset
|
34 |
858c09f59011
Moved some functions from xs_length.c here.
Matti Hamalainen <ccr@tnsp.org>
parents:
224
diff
changeset
|
35 |
398 | 36 guint32 xs_rd_be32(FILE *f) |
226
858c09f59011
Moved some functions from xs_length.c here.
Matti Hamalainen <ccr@tnsp.org>
parents:
224
diff
changeset
|
37 { |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
38 return (((guint32) fgetc(f)) << 24) | |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
39 (((guint32) fgetc(f)) << 16) | (((guint32) fgetc(f)) << 8) | ((guint32) fgetc(f)); |
226
858c09f59011
Moved some functions from xs_length.c here.
Matti Hamalainen <ccr@tnsp.org>
parents:
224
diff
changeset
|
40 } |
858c09f59011
Moved some functions from xs_length.c here.
Matti Hamalainen <ccr@tnsp.org>
parents:
224
diff
changeset
|
41 |
858c09f59011
Moved some functions from xs_length.c here.
Matti Hamalainen <ccr@tnsp.org>
parents:
224
diff
changeset
|
42 |
398 | 43 size_t xs_rd_str(FILE *f, gchar *s, size_t l) |
226
858c09f59011
Moved some functions from xs_length.c here.
Matti Hamalainen <ccr@tnsp.org>
parents:
224
diff
changeset
|
44 { |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
45 return fread(s, sizeof(gchar), l, f); |
226
858c09f59011
Moved some functions from xs_length.c here.
Matti Hamalainen <ccr@tnsp.org>
parents:
224
diff
changeset
|
46 } |
858c09f59011
Moved some functions from xs_length.c here.
Matti Hamalainen <ccr@tnsp.org>
parents:
224
diff
changeset
|
47 |
858c09f59011
Moved some functions from xs_length.c here.
Matti Hamalainen <ccr@tnsp.org>
parents:
224
diff
changeset
|
48 |
206
8b896d461fdb
Trivial fixes and added strncpy replacement.
Matti Hamalainen <ccr@tnsp.org>
parents:
202
diff
changeset
|
49 /* Copy a string |
4 | 50 */ |
398 | 51 gchar *xs_strncpy(gchar *pDest, gchar *pSource, size_t n) |
4 | 52 { |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
53 gchar *s, *d; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
54 size_t i; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
55 |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
56 /* Check the string pointers */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
57 if (!pSource || !pDest) |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
58 return pDest; |
4 | 59 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
60 /* Copy to the destination */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
61 i = n; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
62 s = pSource; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
63 d = pDest; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
64 while (*s && (i > 0)) { |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
65 *(d++) = *(s++); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
66 i--; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
67 } |
206
8b896d461fdb
Trivial fixes and added strncpy replacement.
Matti Hamalainen <ccr@tnsp.org>
parents:
202
diff
changeset
|
68 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
69 /* Fill rest of space with zeros */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
70 while (i > 0) { |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
71 *(d++) = 0; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
72 i--; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
73 } |
206
8b896d461fdb
Trivial fixes and added strncpy replacement.
Matti Hamalainen <ccr@tnsp.org>
parents:
202
diff
changeset
|
74 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
75 /* Ensure that last is always zero */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
76 pDest[n - 1] = 0; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
77 |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
78 return pDest; |
206
8b896d461fdb
Trivial fixes and added strncpy replacement.
Matti Hamalainen <ccr@tnsp.org>
parents:
202
diff
changeset
|
79 } |
8b896d461fdb
Trivial fixes and added strncpy replacement.
Matti Hamalainen <ccr@tnsp.org>
parents:
202
diff
changeset
|
80 |
8b896d461fdb
Trivial fixes and added strncpy replacement.
Matti Hamalainen <ccr@tnsp.org>
parents:
202
diff
changeset
|
81 |
8b896d461fdb
Trivial fixes and added strncpy replacement.
Matti Hamalainen <ccr@tnsp.org>
parents:
202
diff
changeset
|
82 /* Copy a given string over in *ppResult. |
8b896d461fdb
Trivial fixes and added strncpy replacement.
Matti Hamalainen <ccr@tnsp.org>
parents:
202
diff
changeset
|
83 */ |
398 | 84 gint xs_pstrcpy(gchar **ppResult, const gchar *pStr) |
206
8b896d461fdb
Trivial fixes and added strncpy replacement.
Matti Hamalainen <ccr@tnsp.org>
parents:
202
diff
changeset
|
85 { |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
86 /* Check the string pointers */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
87 if (!ppResult || !pStr) |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
88 return -1; |
206
8b896d461fdb
Trivial fixes and added strncpy replacement.
Matti Hamalainen <ccr@tnsp.org>
parents:
202
diff
changeset
|
89 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
90 /* Allocate memory for destination */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
91 if (*ppResult) |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
92 g_free(*ppResult); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
93 *ppResult = (gchar *) g_malloc(strlen(pStr) + 1); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
94 if (!*ppResult) |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
95 return -2; |
206
8b896d461fdb
Trivial fixes and added strncpy replacement.
Matti Hamalainen <ccr@tnsp.org>
parents:
202
diff
changeset
|
96 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
97 /* Copy to the destination */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
98 strcpy(*ppResult, pStr); |
4 | 99 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
100 return 0; |
4 | 101 } |
102 | |
103 | |
206
8b896d461fdb
Trivial fixes and added strncpy replacement.
Matti Hamalainen <ccr@tnsp.org>
parents:
202
diff
changeset
|
104 /* Concatenates a given string into string pointed by *ppResult. |
8b896d461fdb
Trivial fixes and added strncpy replacement.
Matti Hamalainen <ccr@tnsp.org>
parents:
202
diff
changeset
|
105 */ |
398 | 106 gint xs_pstrcat(gchar **ppResult, const gchar *pStr) |
4 | 107 { |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
108 /* Check the string pointers */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
109 if (!ppResult || !pStr) |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
110 return -1; |
206
8b896d461fdb
Trivial fixes and added strncpy replacement.
Matti Hamalainen <ccr@tnsp.org>
parents:
202
diff
changeset
|
111 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
112 if (*ppResult != NULL) { |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
113 *ppResult = (gchar *) g_realloc(*ppResult, strlen(*ppResult) + strlen(pStr) + 1); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
114 if (*ppResult == NULL) |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
115 return -1; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
116 strcat(*ppResult, pStr); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
117 } else { |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
118 *ppResult = (gchar *) g_malloc(strlen(pStr) + 1); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
119 if (*ppResult == NULL) |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
120 return -1; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
121 strcpy(*ppResult, pStr); |
206
8b896d461fdb
Trivial fixes and added strncpy replacement.
Matti Hamalainen <ccr@tnsp.org>
parents:
202
diff
changeset
|
122 } |
4 | 123 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
124 return 0; |
4 | 125 } |
126 | |
127 | |
239
7833df935239
Added xs_pnstrcat() to ease forming of limited size strings.
Matti Hamalainen <ccr@tnsp.org>
parents:
230
diff
changeset
|
128 /* Concatenate a given string up to given dest size or \n. |
7833df935239
Added xs_pnstrcat() to ease forming of limited size strings.
Matti Hamalainen <ccr@tnsp.org>
parents:
230
diff
changeset
|
129 * If size max is reached, change the end to "..." |
7833df935239
Added xs_pnstrcat() to ease forming of limited size strings.
Matti Hamalainen <ccr@tnsp.org>
parents:
230
diff
changeset
|
130 */ |
398 | 131 void xs_pnstrcat(gchar *pDest, size_t iSize, gchar *pStr) |
239
7833df935239
Added xs_pnstrcat() to ease forming of limited size strings.
Matti Hamalainen <ccr@tnsp.org>
parents:
230
diff
changeset
|
132 { |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
133 size_t i, n; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
134 gchar *s, *d; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
135 |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
136 d = pDest; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
137 i = 0; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
138 while (*d && (i < iSize)) { |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
139 i++; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
140 d++; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
141 } |
239
7833df935239
Added xs_pnstrcat() to ease forming of limited size strings.
Matti Hamalainen <ccr@tnsp.org>
parents:
230
diff
changeset
|
142 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
143 s = pStr; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
144 while (*s && (*s != '\n') && (i < iSize)) { |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
145 *d = *s; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
146 d++; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
147 s++; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
148 i++; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
149 } |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
150 |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
151 *d = 0; |
239
7833df935239
Added xs_pnstrcat() to ease forming of limited size strings.
Matti Hamalainen <ccr@tnsp.org>
parents:
230
diff
changeset
|
152 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
153 if (i >= iSize) { |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
154 i--; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
155 d--; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
156 n = 3; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
157 while ((i > 0) && (n > 0)) { |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
158 *d = '.'; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
159 d--; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
160 i--; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
161 n--; |
239
7833df935239
Added xs_pnstrcat() to ease forming of limited size strings.
Matti Hamalainen <ccr@tnsp.org>
parents:
230
diff
changeset
|
162 } |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
163 } |
239
7833df935239
Added xs_pnstrcat() to ease forming of limited size strings.
Matti Hamalainen <ccr@tnsp.org>
parents:
230
diff
changeset
|
164 } |
7833df935239
Added xs_pnstrcat() to ease forming of limited size strings.
Matti Hamalainen <ccr@tnsp.org>
parents:
230
diff
changeset
|
165 |
7833df935239
Added xs_pnstrcat() to ease forming of limited size strings.
Matti Hamalainen <ccr@tnsp.org>
parents:
230
diff
changeset
|
166 |
206
8b896d461fdb
Trivial fixes and added strncpy replacement.
Matti Hamalainen <ccr@tnsp.org>
parents:
202
diff
changeset
|
167 /* Locate character in string |
8b896d461fdb
Trivial fixes and added strncpy replacement.
Matti Hamalainen <ccr@tnsp.org>
parents:
202
diff
changeset
|
168 */ |
398 | 169 gchar *xs_strrchr(gchar *pcStr, gchar ch) |
56
6a3ce7260ae1
Changed some standard functions to glib ones
Matti Hamalainen <ccr@tnsp.org>
parents:
49
diff
changeset
|
170 { |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
171 gchar *lastPos = NULL; |
56
6a3ce7260ae1
Changed some standard functions to glib ones
Matti Hamalainen <ccr@tnsp.org>
parents:
49
diff
changeset
|
172 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
173 while (*pcStr) { |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
174 if (*pcStr == ch) |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
175 lastPos = pcStr; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
176 pcStr++; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
177 } |
56
6a3ce7260ae1
Changed some standard functions to glib ones
Matti Hamalainen <ccr@tnsp.org>
parents:
49
diff
changeset
|
178 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
179 return lastPos; |
56
6a3ce7260ae1
Changed some standard functions to glib ones
Matti Hamalainen <ccr@tnsp.org>
parents:
49
diff
changeset
|
180 } |
6a3ce7260ae1
Changed some standard functions to glib ones
Matti Hamalainen <ccr@tnsp.org>
parents:
49
diff
changeset
|
181 |
6a3ce7260ae1
Changed some standard functions to glib ones
Matti Hamalainen <ccr@tnsp.org>
parents:
49
diff
changeset
|
182 |
398 | 183 void xs_findnext(gchar *pcStr, guint *piPos) |
4 | 184 { |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
185 while (pcStr[*piPos] && isspace(pcStr[*piPos])) |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
186 (*piPos)++; |
4 | 187 } |
188 | |
189 | |
398 | 190 void xs_findeol(gchar *pcStr, guint *piPos) |
4 | 191 { |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
192 while (pcStr[*piPos] && (pcStr[*piPos] != '\n') && (pcStr[*piPos] != '\r')) |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
193 (*piPos)++; |
4 | 194 } |
195 | |
196 | |
398 | 197 void xs_findnum(gchar *pcStr, guint *piPos) |
109
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
198 { |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
199 while (pcStr[*piPos] && isdigit(pcStr[*piPos])) |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
200 (*piPos)++; |
109
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
201 } |
214 | 202 |
203 | |
204 #ifndef HAVE_MEMSET | |
205 void *xs_memset(void *p, int c, size_t n) | |
206 { | |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
207 gchar *dp; |
214 | 208 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
209 dp = (gchar *) p; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
210 while (n--) { |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
211 *dp = (gchar) c; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
212 n--; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
213 } |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
214 |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
215 return p; |
214 | 216 } |
217 #endif |