Mercurial > hg > xmms-sid
annotate src/xs_support.c @ 763:61a527ac3baa
Cleanups, remove useless function.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 05 Nov 2012 22:39:12 +0200 |
parents | 55eea3fa8868 |
children | 469b341734b2 |
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> |
723 | 7 (C) Copyright 1999-2009 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 */ |
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" |
224
df4cb5115322
Removed duplicate function, more portability cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
218
diff
changeset
|
24 #include <ctype.h> |
202 | 25 |
226
858c09f59011
Moved some functions from xs_length.c here.
Matti Hamalainen <ccr@tnsp.org>
parents:
224
diff
changeset
|
26 |
751 | 27 guint16 xs_fread_be16(XSFile *f) |
516
c192468eb8ce
Audacious VFS support functions finished.
Matti Hamalainen <ccr@tnsp.org>
parents:
506
diff
changeset
|
28 { |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
29 return (((guint16) xs_fgetc(f)) << 8) | ((guint16) xs_fgetc(f)); |
516
c192468eb8ce
Audacious VFS support functions finished.
Matti Hamalainen <ccr@tnsp.org>
parents:
506
diff
changeset
|
30 } |
c192468eb8ce
Audacious VFS support functions finished.
Matti Hamalainen <ccr@tnsp.org>
parents:
506
diff
changeset
|
31 |
c192468eb8ce
Audacious VFS support functions finished.
Matti Hamalainen <ccr@tnsp.org>
parents:
506
diff
changeset
|
32 |
751 | 33 guint32 xs_fread_be32(XSFile *f) |
516
c192468eb8ce
Audacious VFS support functions finished.
Matti Hamalainen <ccr@tnsp.org>
parents:
506
diff
changeset
|
34 { |
763
61a527ac3baa
Cleanups, remove useless function.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
35 return |
61a527ac3baa
Cleanups, remove useless function.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
36 (((guint32) xs_fgetc(f)) << 24) | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
37 (((guint32) xs_fgetc(f)) << 16) | |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
38 (((guint32) xs_fgetc(f)) << 8) | |
763
61a527ac3baa
Cleanups, remove useless function.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
39 ((guint32) xs_fgetc(f)); |
516
c192468eb8ce
Audacious VFS support functions finished.
Matti Hamalainen <ccr@tnsp.org>
parents:
506
diff
changeset
|
40 } |
c192468eb8ce
Audacious VFS support functions finished.
Matti Hamalainen <ccr@tnsp.org>
parents:
506
diff
changeset
|
41 |
c192468eb8ce
Audacious VFS support functions finished.
Matti Hamalainen <ccr@tnsp.org>
parents:
506
diff
changeset
|
42 |
527
fe8b41abd923
Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
516
diff
changeset
|
43 /* Load a file to a buffer, return 0 on success, negative value on error |
fe8b41abd923
Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
516
diff
changeset
|
44 */ |
657
acaba070cf49
Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents:
634
diff
changeset
|
45 gint xs_fload_buffer(const gchar *filename, guint8 **buf, size_t *bufSize) |
527
fe8b41abd923
Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
516
diff
changeset
|
46 { |
751 | 47 XSFile *f; |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
48 glong seekPos; |
763
61a527ac3baa
Cleanups, remove useless function.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
49 |
61a527ac3baa
Cleanups, remove useless function.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
50 if (filename == NULL) |
61a527ac3baa
Cleanups, remove useless function.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
51 return -15; |
61a527ac3baa
Cleanups, remove useless function.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
52 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
53 if ((f = xs_fopen(filename, "rb")) == NULL) |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
54 return -1; |
527
fe8b41abd923
Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
516
diff
changeset
|
55 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
56 xs_fseek(f, 0, SEEK_END); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
57 seekPos = xs_ftell(f); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
58 |
763
61a527ac3baa
Cleanups, remove useless function.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
59 if (seekPos > 0) |
61a527ac3baa
Cleanups, remove useless function.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
60 { |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
61 size_t readSize = seekPos; |
763
61a527ac3baa
Cleanups, remove useless function.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
62 if (readSize >= *bufSize || *buf == NULL) |
61a527ac3baa
Cleanups, remove useless function.
Matti Hamalainen <ccr@tnsp.org>
parents:
751
diff
changeset
|
63 { |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
64 /* Only re-allocate if the required size > current */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
65 if (*buf != NULL) { |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
66 g_free(*buf); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
67 *buf = NULL; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
68 } |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
69 |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
70 *bufSize = seekPos; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
71 |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
72 *buf = (guint8 *) g_malloc(*bufSize * sizeof(guint8)); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
73 if (*buf == NULL) { |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
74 xs_fclose(f); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
75 return -2; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
76 } |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
77 } |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
78 |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
79 /* Read data */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
80 xs_fseek(f, 0, SEEK_SET); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
81 readSize = xs_fread(*buf, sizeof(guint8), *bufSize, f); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
82 xs_fclose(f); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
83 |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
84 if (readSize != *bufSize) |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
85 return -3; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
86 else |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
87 return 0; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
88 } else { |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
89 xs_fclose(f); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
90 return -4; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
91 } |
527
fe8b41abd923
Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
516
diff
changeset
|
92 } |
fe8b41abd923
Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
516
diff
changeset
|
93 |
fe8b41abd923
Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
516
diff
changeset
|
94 |
663
180d7a0250d8
More cosmetic variable name changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
660
diff
changeset
|
95 /* Copy a given string over in *result. |
206
8b896d461fdb
Trivial fixes and added strncpy replacement.
Matti Hamalainen <ccr@tnsp.org>
parents:
202
diff
changeset
|
96 */ |
663
180d7a0250d8
More cosmetic variable name changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
660
diff
changeset
|
97 gint xs_pstrcpy(gchar **result, const gchar *str) |
206
8b896d461fdb
Trivial fixes and added strncpy replacement.
Matti Hamalainen <ccr@tnsp.org>
parents:
202
diff
changeset
|
98 { |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
99 /* Check the string pointers */ |
663
180d7a0250d8
More cosmetic variable name changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
660
diff
changeset
|
100 if (!result || !str) |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
101 return -1; |
206
8b896d461fdb
Trivial fixes and added strncpy replacement.
Matti Hamalainen <ccr@tnsp.org>
parents:
202
diff
changeset
|
102 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
103 /* Allocate memory for destination */ |
663
180d7a0250d8
More cosmetic variable name changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
660
diff
changeset
|
104 if (*result) |
180d7a0250d8
More cosmetic variable name changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
660
diff
changeset
|
105 g_free(*result); |
180d7a0250d8
More cosmetic variable name changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
660
diff
changeset
|
106 *result = (gchar *) g_malloc(strlen(str) + 1); |
180d7a0250d8
More cosmetic variable name changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
660
diff
changeset
|
107 if (!*result) |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
108 return -2; |
206
8b896d461fdb
Trivial fixes and added strncpy replacement.
Matti Hamalainen <ccr@tnsp.org>
parents:
202
diff
changeset
|
109 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
110 /* Copy to the destination */ |
663
180d7a0250d8
More cosmetic variable name changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
660
diff
changeset
|
111 strcpy(*result, str); |
4 | 112 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
113 return 0; |
4 | 114 } |
115 | |
116 | |
663
180d7a0250d8
More cosmetic variable name changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
660
diff
changeset
|
117 /* Concatenates a given string into string pointed by *result. |
206
8b896d461fdb
Trivial fixes and added strncpy replacement.
Matti Hamalainen <ccr@tnsp.org>
parents:
202
diff
changeset
|
118 */ |
663
180d7a0250d8
More cosmetic variable name changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
660
diff
changeset
|
119 gint xs_pstrcat(gchar **result, const gchar *str) |
4 | 120 { |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
121 /* Check the string pointers */ |
663
180d7a0250d8
More cosmetic variable name changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
660
diff
changeset
|
122 if (!result || !str) |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
123 return -1; |
206
8b896d461fdb
Trivial fixes and added strncpy replacement.
Matti Hamalainen <ccr@tnsp.org>
parents:
202
diff
changeset
|
124 |
663
180d7a0250d8
More cosmetic variable name changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
660
diff
changeset
|
125 if (*result != NULL) { |
180d7a0250d8
More cosmetic variable name changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
660
diff
changeset
|
126 *result = (gchar *) g_realloc(*result, strlen(*result) + strlen(str) + 1); |
180d7a0250d8
More cosmetic variable name changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
660
diff
changeset
|
127 if (*result == NULL) |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
128 return -1; |
663
180d7a0250d8
More cosmetic variable name changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
660
diff
changeset
|
129 strcat(*result, str); |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
130 } else { |
663
180d7a0250d8
More cosmetic variable name changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
660
diff
changeset
|
131 *result = (gchar *) g_malloc(strlen(str) + 1); |
180d7a0250d8
More cosmetic variable name changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
660
diff
changeset
|
132 if (*result == NULL) |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
133 return -1; |
663
180d7a0250d8
More cosmetic variable name changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
660
diff
changeset
|
134 strcpy(*result, str); |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
135 } |
4 | 136 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
137 return 0; |
4 | 138 } |
139 | |
140 | |
239
7833df935239
Added xs_pnstrcat() to ease forming of limited size strings.
Matti Hamalainen <ccr@tnsp.org>
parents:
230
diff
changeset
|
141 /* 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
|
142 * 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
|
143 */ |
663
180d7a0250d8
More cosmetic variable name changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
660
diff
changeset
|
144 void xs_pnstrcat(gchar *dest, size_t iSize, const gchar *str) |
239
7833df935239
Added xs_pnstrcat() to ease forming of limited size strings.
Matti Hamalainen <ccr@tnsp.org>
parents:
230
diff
changeset
|
145 { |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
146 size_t i, n; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
147 const gchar *s; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
148 gchar *d; |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
149 |
663
180d7a0250d8
More cosmetic variable name changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
660
diff
changeset
|
150 d = dest; |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
151 i = 0; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
152 while (*d && (i < iSize)) { |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
153 i++; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
154 d++; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
155 } |
239
7833df935239
Added xs_pnstrcat() to ease forming of limited size strings.
Matti Hamalainen <ccr@tnsp.org>
parents:
230
diff
changeset
|
156 |
663
180d7a0250d8
More cosmetic variable name changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
660
diff
changeset
|
157 s = str; |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
158 while (*s && (*s != '\n') && (i < iSize)) { |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
159 *d = *s; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
160 d++; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
161 s++; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
162 i++; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
163 } |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
324
diff
changeset
|
164 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
165 *d = 0; |
239
7833df935239
Added xs_pnstrcat() to ease forming of limited size strings.
Matti Hamalainen <ccr@tnsp.org>
parents:
230
diff
changeset
|
166 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
167 if (i >= iSize) { |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
168 i--; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
169 d--; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
170 n = 3; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
171 while ((i > 0) && (n > 0)) { |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
172 *d = '.'; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
173 d--; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
174 i--; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
175 n--; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
176 } |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
177 } |
239
7833df935239
Added xs_pnstrcat() to ease forming of limited size strings.
Matti Hamalainen <ccr@tnsp.org>
parents:
230
diff
changeset
|
178 } |
7833df935239
Added xs_pnstrcat() to ease forming of limited size strings.
Matti Hamalainen <ccr@tnsp.org>
parents:
230
diff
changeset
|
179 |
7833df935239
Added xs_pnstrcat() to ease forming of limited size strings.
Matti Hamalainen <ccr@tnsp.org>
parents:
230
diff
changeset
|
180 |
206
8b896d461fdb
Trivial fixes and added strncpy replacement.
Matti Hamalainen <ccr@tnsp.org>
parents:
202
diff
changeset
|
181 /* Locate character in string |
8b896d461fdb
Trivial fixes and added strncpy replacement.
Matti Hamalainen <ccr@tnsp.org>
parents:
202
diff
changeset
|
182 */ |
663
180d7a0250d8
More cosmetic variable name changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
660
diff
changeset
|
183 void xs_findnext(const gchar *str, size_t *pos) |
4 | 184 { |
663
180d7a0250d8
More cosmetic variable name changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
660
diff
changeset
|
185 while (str[*pos] && isspace(str[*pos])) |
180d7a0250d8
More cosmetic variable name changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
660
diff
changeset
|
186 (*pos)++; |
4 | 187 } |
188 | |
189 | |
663
180d7a0250d8
More cosmetic variable name changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
660
diff
changeset
|
190 void xs_findeol(const gchar *str, size_t *pos) |
4 | 191 { |
663
180d7a0250d8
More cosmetic variable name changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
660
diff
changeset
|
192 while (str[*pos] && (str[*pos] != '\n') && (str[*pos] != '\r')) |
180d7a0250d8
More cosmetic variable name changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
660
diff
changeset
|
193 (*pos)++; |
4 | 194 } |
195 | |
196 | |
663
180d7a0250d8
More cosmetic variable name changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
660
diff
changeset
|
197 void xs_findnum(const gchar *str, size_t *pos) |
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 { |
663
180d7a0250d8
More cosmetic variable name changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
660
diff
changeset
|
199 while (str[*pos] && isdigit(str[*pos])) |
180d7a0250d8
More cosmetic variable name changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
660
diff
changeset
|
200 (*pos)++; |
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 } |