Mercurial > mplayer.hg
annotate gui/util/string.c @ 33976:b2d3a97cab66
Add doxygen comments to mem.h.
author | ib |
---|---|
date | Tue, 06 Sep 2011 08:52:01 +0000 |
parents | 0d3d8db05a59 |
children | d7527ee45784 |
rev | line source |
---|---|
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 | |
33740
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33737
diff
changeset
|
19 #include <stdio.h> |
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33737
diff
changeset
|
20 #include <stdlib.h> |
33737 | 21 #include <string.h> |
22 | |
33048 | 23 #include "string.h" |
24 | |
33052 | 25 char *strlower(char *in) |
26 { | |
27 char *p = in; | |
28 | |
29 while (*p) { | |
30 if (*p >= 'A' && *p <= 'Z') | |
31 *p += 'a' - 'A'; | |
32 | |
33 p++; | |
34 } | |
35 | |
36 return in; | |
37 } | |
38 | |
33048 | 39 char *strswap(char *in, char from, char to) |
40 { | |
33049 | 41 char *p = in; |
33048 | 42 |
33049 | 43 while (*p) { |
44 if (*p == from) | |
45 *p = to; | |
33048 | 46 |
33049 | 47 p++; |
48 } | |
33048 | 49 |
50 return in; | |
51 } | |
52 | |
53 char *trim(char *in) | |
54 { | |
33051 | 55 char *src, *dest; |
56 int freeze = 0; | |
33048 | 57 |
33051 | 58 src = dest = in; |
33048 | 59 |
33051 | 60 while (*src) { |
61 if (*src == '"') | |
62 freeze = !freeze; | |
33048 | 63 |
33051 | 64 if (freeze || (*src != ' ')) |
65 *dest++ = *src; | |
66 | |
67 src++; | |
33048 | 68 } |
69 | |
33051 | 70 *dest = 0; |
71 | |
33048 | 72 return in; |
73 } | |
33073 | 74 |
75 char *decomment(char *in) | |
76 { | |
77 char *p; | |
78 int nap = 0; | |
79 | |
80 p = in; | |
81 | |
33080 | 82 if (*p == '#') |
83 *p = 0; | |
84 | |
33073 | 85 while (*p) { |
86 if (*p == '"') | |
87 nap = !nap; | |
88 | |
89 if ((*p == ';') && !nap) { | |
90 *p = 0; | |
91 break; | |
92 } | |
93 | |
94 p++; | |
95 } | |
96 | |
97 return in; | |
98 } | |
33737 | 99 |
100 char *gstrchr(const char *str, int c) | |
101 { | |
102 if (!str) | |
103 return NULL; | |
104 | |
105 return strchr(str, c); | |
106 } | |
107 | |
108 int gstrcmp(const char *a, const char *b) | |
109 { | |
110 if (!a && !b) | |
111 return 0; | |
112 if (!a || !b) | |
113 return -1; | |
114 | |
115 return strcmp(a, b); | |
116 } | |
117 | |
33786 | 118 int gstrcasecmp(const char *a, const char *b) |
119 { | |
120 if (!a && !b) | |
121 return 0; | |
122 if (!a || !b) | |
123 return -1; | |
124 | |
125 return strcasecmp(a, b); | |
126 } | |
127 | |
33737 | 128 int gstrncmp(const char *a, const char *b, int n) |
129 { | |
130 if (!a && !b) | |
131 return 0; | |
132 if (!a || !b) | |
133 return -1; | |
134 | |
135 return strncmp(a, b, n); | |
136 } | |
137 | |
138 char *gstrdup(const char *str) | |
139 { | |
140 if (!str) | |
141 return NULL; | |
142 | |
143 return strdup(str); | |
144 } | |
33740
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33737
diff
changeset
|
145 |
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33737
diff
changeset
|
146 void setdup(char **old, const char *str) |
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33737
diff
changeset
|
147 { |
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33737
diff
changeset
|
148 free(*old); |
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33737
diff
changeset
|
149 *old = gstrdup(str); |
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33737
diff
changeset
|
150 } |
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33737
diff
changeset
|
151 |
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33737
diff
changeset
|
152 void setddup(char **old, const char *dir, const char *name) |
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33737
diff
changeset
|
153 { |
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33737
diff
changeset
|
154 free(*old); |
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33737
diff
changeset
|
155 *old = malloc(strlen(dir) + strlen(name) + 2); |
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33737
diff
changeset
|
156 if (*old) |
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33737
diff
changeset
|
157 sprintf(*old, "%s/%s", dir, name); |
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33737
diff
changeset
|
158 } |