annotate src/xs_support.c @ 527:fe8b41abd923

Now everything necessary should be using the VFS functions.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 20 Feb 2007 18:09:04 +0000
parents c192468eb8ce
children 3e4901a89f3d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 /*
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2 XMMS-SID - SIDPlay input plugin for X MultiMedia System (XMMS)
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
4 Miscellaneous support functions
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5
324
dd201740a720 Changed copyright text.
Matti Hamalainen <ccr@tnsp.org>
parents: 288
diff changeset
6 Programmed and designed by Matti 'ccr' Hamalainen <ccr@tnsp.org>
422
d2e6682d3ef8 Copyright year update
Matti Hamalainen <ccr@tnsp.org>
parents: 412
diff changeset
7 (C) Copyright 1999-2007 Tecnic Software productions (TNSP)
4
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9 This program is free software; you can redistribute it and/or modify
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10 it under the terms of the GNU General Public License as published by
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11 the Free Software Foundation; either version 2 of the License, or
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
12 (at your option) any later version.
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
13
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
14 This program is distributed in the hope that it will be useful,
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17 GNU General Public License for more details.
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
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
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
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
fe684a2ccdc7 Reworking code.
Matti Hamalainen <ccr@tnsp.org>
parents: 109
diff changeset
25
226
858c09f59011 Moved some functions from xs_length.c here.
Matti Hamalainen <ccr@tnsp.org>
parents: 224
diff changeset
26
516
c192468eb8ce Audacious VFS support functions finished.
Matti Hamalainen <ccr@tnsp.org>
parents: 506
diff changeset
27 #ifndef __AUDACIOUS_NEWVFS__
452
aec9f4beb401 New file reading functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 428
diff changeset
28 /* File handling
226
858c09f59011 Moved some functions from xs_length.c here.
Matti Hamalainen <ccr@tnsp.org>
parents: 224
diff changeset
29 */
466
00a32ab5887d Moved some things from xmms-sid.h to xs_support.h; File handling functions
Matti Hamalainen <ccr@tnsp.org>
parents: 452
diff changeset
30 t_xs_file *xs_fopen(const gchar *path, const gchar *mode)
452
aec9f4beb401 New file reading functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 428
diff changeset
31 {
aec9f4beb401 New file reading functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 428
diff changeset
32 return fopen(path, mode);
aec9f4beb401 New file reading functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 428
diff changeset
33 }
aec9f4beb401 New file reading functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 428
diff changeset
34
aec9f4beb401 New file reading functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 428
diff changeset
35
aec9f4beb401 New file reading functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 428
diff changeset
36 gint xs_fclose(t_xs_file *f)
aec9f4beb401 New file reading functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 428
diff changeset
37 {
aec9f4beb401 New file reading functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 428
diff changeset
38 return fclose(f);
aec9f4beb401 New file reading functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 428
diff changeset
39 }
aec9f4beb401 New file reading functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 428
diff changeset
40
aec9f4beb401 New file reading functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 428
diff changeset
41
aec9f4beb401 New file reading functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 428
diff changeset
42 gint xs_fgetc(t_xs_file *f)
aec9f4beb401 New file reading functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 428
diff changeset
43 {
aec9f4beb401 New file reading functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 428
diff changeset
44 return fgetc(f);
aec9f4beb401 New file reading functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 428
diff changeset
45 }
aec9f4beb401 New file reading functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 428
diff changeset
46
aec9f4beb401 New file reading functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 428
diff changeset
47
aec9f4beb401 New file reading functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 428
diff changeset
48 size_t xs_fread(void *p, size_t s, size_t n, t_xs_file *f)
226
858c09f59011 Moved some functions from xs_length.c here.
Matti Hamalainen <ccr@tnsp.org>
parents: 224
diff changeset
49 {
452
aec9f4beb401 New file reading functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 428
diff changeset
50 return fread(p, s, n, f);
aec9f4beb401 New file reading functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 428
diff changeset
51 }
aec9f4beb401 New file reading functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 428
diff changeset
52
aec9f4beb401 New file reading functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 428
diff changeset
53
466
00a32ab5887d Moved some things from xmms-sid.h to xs_support.h; File handling functions
Matti Hamalainen <ccr@tnsp.org>
parents: 452
diff changeset
54 gint xs_feof(t_xs_file *f)
452
aec9f4beb401 New file reading functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 428
diff changeset
55 {
466
00a32ab5887d Moved some things from xmms-sid.h to xs_support.h; File handling functions
Matti Hamalainen <ccr@tnsp.org>
parents: 452
diff changeset
56 return feof(f);
00a32ab5887d Moved some things from xmms-sid.h to xs_support.h; File handling functions
Matti Hamalainen <ccr@tnsp.org>
parents: 452
diff changeset
57 }
00a32ab5887d Moved some things from xmms-sid.h to xs_support.h; File handling functions
Matti Hamalainen <ccr@tnsp.org>
parents: 452
diff changeset
58
00a32ab5887d Moved some things from xmms-sid.h to xs_support.h; File handling functions
Matti Hamalainen <ccr@tnsp.org>
parents: 452
diff changeset
59
00a32ab5887d Moved some things from xmms-sid.h to xs_support.h; File handling functions
Matti Hamalainen <ccr@tnsp.org>
parents: 452
diff changeset
60 gint xs_ferror(t_xs_file *f)
00a32ab5887d Moved some things from xmms-sid.h to xs_support.h; File handling functions
Matti Hamalainen <ccr@tnsp.org>
parents: 452
diff changeset
61 {
00a32ab5887d Moved some things from xmms-sid.h to xs_support.h; File handling functions
Matti Hamalainen <ccr@tnsp.org>
parents: 452
diff changeset
62 return ferror(f);
226
858c09f59011 Moved some functions from xs_length.c here.
Matti Hamalainen <ccr@tnsp.org>
parents: 224
diff changeset
63 }
858c09f59011 Moved some functions from xs_length.c here.
Matti Hamalainen <ccr@tnsp.org>
parents: 224
diff changeset
64
858c09f59011 Moved some functions from xs_length.c here.
Matti Hamalainen <ccr@tnsp.org>
parents: 224
diff changeset
65
516
c192468eb8ce Audacious VFS support functions finished.
Matti Hamalainen <ccr@tnsp.org>
parents: 506
diff changeset
66 glong xs_ftell(t_xs_file *f)
c192468eb8ce Audacious VFS support functions finished.
Matti Hamalainen <ccr@tnsp.org>
parents: 506
diff changeset
67 {
c192468eb8ce Audacious VFS support functions finished.
Matti Hamalainen <ccr@tnsp.org>
parents: 506
diff changeset
68 return ftell(f);
c192468eb8ce Audacious VFS support functions finished.
Matti Hamalainen <ccr@tnsp.org>
parents: 506
diff changeset
69 }
527
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
70
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
71
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
72 gint xs_fseek(t_xs_file *f, glong o, gint w)
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
73 {
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
74 return fseek(f, o, w);
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
75 }
516
c192468eb8ce Audacious VFS support functions finished.
Matti Hamalainen <ccr@tnsp.org>
parents: 506
diff changeset
76 #endif
c192468eb8ce Audacious VFS support functions finished.
Matti Hamalainen <ccr@tnsp.org>
parents: 506
diff changeset
77
c192468eb8ce Audacious VFS support functions finished.
Matti Hamalainen <ccr@tnsp.org>
parents: 506
diff changeset
78
c192468eb8ce Audacious VFS support functions finished.
Matti Hamalainen <ccr@tnsp.org>
parents: 506
diff changeset
79 guint16 xs_fread_be16(t_xs_file *f)
c192468eb8ce Audacious VFS support functions finished.
Matti Hamalainen <ccr@tnsp.org>
parents: 506
diff changeset
80 {
c192468eb8ce Audacious VFS support functions finished.
Matti Hamalainen <ccr@tnsp.org>
parents: 506
diff changeset
81 return (((guint16) xs_fgetc(f)) << 8) | ((guint16) xs_fgetc(f));
c192468eb8ce Audacious VFS support functions finished.
Matti Hamalainen <ccr@tnsp.org>
parents: 506
diff changeset
82 }
c192468eb8ce Audacious VFS support functions finished.
Matti Hamalainen <ccr@tnsp.org>
parents: 506
diff changeset
83
c192468eb8ce Audacious VFS support functions finished.
Matti Hamalainen <ccr@tnsp.org>
parents: 506
diff changeset
84
c192468eb8ce Audacious VFS support functions finished.
Matti Hamalainen <ccr@tnsp.org>
parents: 506
diff changeset
85 guint32 xs_fread_be32(t_xs_file *f)
c192468eb8ce Audacious VFS support functions finished.
Matti Hamalainen <ccr@tnsp.org>
parents: 506
diff changeset
86 {
c192468eb8ce Audacious VFS support functions finished.
Matti Hamalainen <ccr@tnsp.org>
parents: 506
diff changeset
87 return (((guint32) xs_fgetc(f)) << 24) |
c192468eb8ce Audacious VFS support functions finished.
Matti Hamalainen <ccr@tnsp.org>
parents: 506
diff changeset
88 (((guint32) xs_fgetc(f)) << 16) |
c192468eb8ce Audacious VFS support functions finished.
Matti Hamalainen <ccr@tnsp.org>
parents: 506
diff changeset
89 (((guint32) xs_fgetc(f)) << 8) |
c192468eb8ce Audacious VFS support functions finished.
Matti Hamalainen <ccr@tnsp.org>
parents: 506
diff changeset
90 ((guint32) xs_fgetc(f));
c192468eb8ce Audacious VFS support functions finished.
Matti Hamalainen <ccr@tnsp.org>
parents: 506
diff changeset
91 }
c192468eb8ce Audacious VFS support functions finished.
Matti Hamalainen <ccr@tnsp.org>
parents: 506
diff changeset
92
c192468eb8ce Audacious VFS support functions finished.
Matti Hamalainen <ccr@tnsp.org>
parents: 506
diff changeset
93
527
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
94 /* 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
95 */
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
96 gint xs_fload_buffer(gchar *pcFilename, guint8 **buf, size_t *bufSize)
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
97 {
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
98 t_xs_file *f;
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
99 glong seekPos;
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
100
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
101 /* Open file, get file size */
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
102 if ((f = xs_fopen(pcFilename, "rb")) == NULL)
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
103 return -1;
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
104
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
105 xs_fseek(f, 0, SEEK_END);
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
106 seekPos = xs_ftell(f);
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
107
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
108 if (seekPos > 0) {
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
109 size_t readSize = seekPos;
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
110 if (readSize >= *bufSize || *buf == NULL) {
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
111 /* Only re-allocate if the required size > current */
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
112 if (*buf != NULL) {
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
113 g_free(*buf);
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
114 *buf = NULL;
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
115 }
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
116
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
117 *bufSize = seekPos;
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
118
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
119 *buf = (guint8 *) g_malloc(*bufSize * sizeof(guint8));
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
120 if (*buf == NULL) {
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
121 xs_fclose(f);
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
122 return -2;
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
123 }
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
124 }
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
125
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
126 /* Read data */
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
127 xs_fseek(f, 0, SEEK_SET);
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
128 readSize = xs_fread(*buf, sizeof(guint8), *bufSize, f);
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
129 xs_fclose(f);
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
130
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
131 if (readSize != *bufSize)
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
132 return -3;
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
133 else
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
134 return 0;
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
135 } else {
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
136 xs_fclose(f);
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
137 return -4;
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
138 }
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
139 }
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
140
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
141
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
142
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
143
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
144
206
8b896d461fdb Trivial fixes and added strncpy replacement.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
145 /* Copy a string
4
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
146 */
398
933b9ea5923e Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
147 gchar *xs_strncpy(gchar *pDest, gchar *pSource, size_t n)
4
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
148 {
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
149 gchar *s, *d;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
150 size_t i;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
151
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
152 /* Check the string pointers */
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
153 if (!pSource || !pDest)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
154 return pDest;
4
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
155
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
156 /* Copy to the destination */
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
157 i = n;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
158 s = pSource;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
159 d = pDest;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
160 while (*s && (i > 0)) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
161 *(d++) = *(s++);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
162 i--;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
163 }
206
8b896d461fdb Trivial fixes and added strncpy replacement.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
164
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
165 /* Fill rest of space with zeros */
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
166 while (i > 0) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
167 *(d++) = 0;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
168 i--;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
169 }
206
8b896d461fdb Trivial fixes and added strncpy replacement.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
170
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
171 /* Ensure that last is always zero */
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
172 pDest[n - 1] = 0;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
173
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
174 return pDest;
206
8b896d461fdb Trivial fixes and added strncpy replacement.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
175 }
8b896d461fdb Trivial fixes and added strncpy replacement.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
176
8b896d461fdb Trivial fixes and added strncpy replacement.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
177
8b896d461fdb Trivial fixes and added strncpy replacement.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
178 /* Copy a given string over in *ppResult.
8b896d461fdb Trivial fixes and added strncpy replacement.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
179 */
398
933b9ea5923e Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
180 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
181 {
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
182 /* Check the string pointers */
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
183 if (!ppResult || !pStr)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
184 return -1;
206
8b896d461fdb Trivial fixes and added strncpy replacement.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
185
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
186 /* Allocate memory for destination */
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
187 if (*ppResult)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
188 g_free(*ppResult);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
189 *ppResult = (gchar *) g_malloc(strlen(pStr) + 1);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
190 if (!*ppResult)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
191 return -2;
206
8b896d461fdb Trivial fixes and added strncpy replacement.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
192
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
193 /* Copy to the destination */
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
194 strcpy(*ppResult, pStr);
4
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
195
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
196 return 0;
4
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
197 }
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
198
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
199
206
8b896d461fdb Trivial fixes and added strncpy replacement.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
200 /* 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
201 */
398
933b9ea5923e Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
202 gint xs_pstrcat(gchar **ppResult, const gchar *pStr)
4
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
203 {
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
204 /* Check the string pointers */
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
205 if (!ppResult || !pStr)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
206 return -1;
206
8b896d461fdb Trivial fixes and added strncpy replacement.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
207
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
208 if (*ppResult != NULL) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
209 *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
210 if (*ppResult == NULL)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
211 return -1;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
212 strcat(*ppResult, pStr);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
213 } else {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
214 *ppResult = (gchar *) g_malloc(strlen(pStr) + 1);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
215 if (*ppResult == NULL)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
216 return -1;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
217 strcpy(*ppResult, pStr);
206
8b896d461fdb Trivial fixes and added strncpy replacement.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
218 }
4
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
219
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
220 return 0;
4
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
221 }
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
222
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
223
239
7833df935239 Added xs_pnstrcat() to ease forming of limited size strings.
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
224 /* 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
225 * 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
226 */
398
933b9ea5923e Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
227 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
228 {
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
229 size_t i, n;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
230 gchar *s, *d;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
231
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
232 d = pDest;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
233 i = 0;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
234 while (*d && (i < iSize)) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
235 i++;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
236 d++;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
237 }
239
7833df935239 Added xs_pnstrcat() to ease forming of limited size strings.
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
238
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
239 s = pStr;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
240 while (*s && (*s != '\n') && (i < iSize)) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
241 *d = *s;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
242 d++;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
243 s++;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
244 i++;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
245 }
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
246
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
247 *d = 0;
239
7833df935239 Added xs_pnstrcat() to ease forming of limited size strings.
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
248
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
249 if (i >= iSize) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
250 i--;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
251 d--;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
252 n = 3;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
253 while ((i > 0) && (n > 0)) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
254 *d = '.';
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
255 d--;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
256 i--;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
257 n--;
239
7833df935239 Added xs_pnstrcat() to ease forming of limited size strings.
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
258 }
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
259 }
239
7833df935239 Added xs_pnstrcat() to ease forming of limited size strings.
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
260 }
7833df935239 Added xs_pnstrcat() to ease forming of limited size strings.
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
261
7833df935239 Added xs_pnstrcat() to ease forming of limited size strings.
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
262
206
8b896d461fdb Trivial fixes and added strncpy replacement.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
263 /* Locate character in string
8b896d461fdb Trivial fixes and added strncpy replacement.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
264 */
398
933b9ea5923e Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
265 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
266 {
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
267 gchar *lastPos = NULL;
56
6a3ce7260ae1 Changed some standard functions to glib ones
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
268
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
269 while (*pcStr) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
270 if (*pcStr == ch)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
271 lastPos = pcStr;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
272 pcStr++;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
273 }
56
6a3ce7260ae1 Changed some standard functions to glib ones
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
274
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
275 return lastPos;
56
6a3ce7260ae1 Changed some standard functions to glib ones
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
276 }
6a3ce7260ae1 Changed some standard functions to glib ones
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
277
6a3ce7260ae1 Changed some standard functions to glib ones
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
278
506
d87ac4d5dc52 guint -> size_t
Matti Hamalainen <ccr@tnsp.org>
parents: 466
diff changeset
279 void xs_findnext(gchar *pcStr, size_t *piPos)
4
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
280 {
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
281 while (pcStr[*piPos] && isspace(pcStr[*piPos]))
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
282 (*piPos)++;
4
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
283 }
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
284
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
285
506
d87ac4d5dc52 guint -> size_t
Matti Hamalainen <ccr@tnsp.org>
parents: 466
diff changeset
286 void xs_findeol(gchar *pcStr, size_t *piPos)
4
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
287 {
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
288 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
289 (*piPos)++;
4
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
290 }
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
291
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
292
506
d87ac4d5dc52 guint -> size_t
Matti Hamalainen <ccr@tnsp.org>
parents: 466
diff changeset
293 void xs_findnum(gchar *pcStr, size_t *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
294 {
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
295 while (pcStr[*piPos] && isdigit(pcStr[*piPos]))
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
296 (*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
297 }
214
575686094eb1 Portability fixes
Matti Hamalainen <ccr@tnsp.org>
parents: 206
diff changeset
298
575686094eb1 Portability fixes
Matti Hamalainen <ccr@tnsp.org>
parents: 206
diff changeset
299
575686094eb1 Portability fixes
Matti Hamalainen <ccr@tnsp.org>
parents: 206
diff changeset
300 #ifndef HAVE_MEMSET
575686094eb1 Portability fixes
Matti Hamalainen <ccr@tnsp.org>
parents: 206
diff changeset
301 void *xs_memset(void *p, int c, size_t n)
575686094eb1 Portability fixes
Matti Hamalainen <ccr@tnsp.org>
parents: 206
diff changeset
302 {
428
33c3bb80d2a5 Urgh, xs_memset() was buggy :P
Matti Hamalainen <ccr@tnsp.org>
parents: 422
diff changeset
303 guint8 *dp;
214
575686094eb1 Portability fixes
Matti Hamalainen <ccr@tnsp.org>
parents: 206
diff changeset
304
428
33c3bb80d2a5 Urgh, xs_memset() was buggy :P
Matti Hamalainen <ccr@tnsp.org>
parents: 422
diff changeset
305 dp = (guint8 *) p;
33c3bb80d2a5 Urgh, xs_memset() was buggy :P
Matti Hamalainen <ccr@tnsp.org>
parents: 422
diff changeset
306 while (n--)
33c3bb80d2a5 Urgh, xs_memset() was buggy :P
Matti Hamalainen <ccr@tnsp.org>
parents: 422
diff changeset
307 *dp = c;
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
308
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
309 return p;
214
575686094eb1 Portability fixes
Matti Hamalainen <ccr@tnsp.org>
parents: 206
diff changeset
310 }
575686094eb1 Portability fixes
Matti Hamalainen <ccr@tnsp.org>
parents: 206
diff changeset
311 #endif