33048
|
1 /*
|
|
2 * This file is part of MPlayer.
|
|
3 *
|
|
4 * MPlayer is free software; you can redistribute it and/or modify
|
|
5 * it under the terms of the GNU General Public License as published by
|
|
6 * the Free Software Foundation; either version 2 of the License, or
|
|
7 * (at your option) any later version.
|
|
8 *
|
|
9 * MPlayer is distributed in the hope that it will be useful,
|
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12 * GNU General Public License for more details.
|
|
13 *
|
|
14 * You should have received a copy of the GNU General Public License along
|
|
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
|
|
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
17 */
|
|
18
|
|
19 #include <stddef.h>
|
|
20 #include <string.h>
|
|
21
|
|
22 #include "string.h"
|
|
23
|
|
24 char *strswap(char *in, char from, char to)
|
|
25 {
|
33049
|
26 char *p = in;
|
33048
|
27
|
33049
|
28 while (*p) {
|
|
29 if (*p == from)
|
|
30 *p = to;
|
33048
|
31
|
33049
|
32 p++;
|
|
33 }
|
33048
|
34
|
|
35 return in;
|
|
36 }
|
|
37
|
|
38 char *trim(char *in)
|
|
39 {
|
|
40 int c = 0, id = 0, i;
|
|
41
|
|
42 if (!*in)
|
|
43 return NULL;
|
|
44
|
|
45 while (c != (int)strlen(in)) {
|
|
46 if (in[c] == '"')
|
|
47 id = !id;
|
|
48
|
|
49 if ((in[c] == ' ') && (!id)) {
|
|
50 for (i = 0; i < (int)strlen(in) - c; i++)
|
|
51 in[c + i] = in[c + i + 1];
|
|
52 continue;
|
|
53 }
|
|
54
|
|
55 c++;
|
|
56 }
|
|
57
|
|
58 return in;
|
|
59 }
|