33046
|
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 <stdlib.h>
|
|
20 #include <string.h>
|
|
21
|
|
22 #include "cut.h"
|
|
23
|
|
24 void cutItemString(char *in, char *out, char sep, int num, size_t maxout)
|
|
25 {
|
|
26 int n;
|
|
27 unsigned int i, c;
|
|
28
|
|
29 for (c = 0, n = 0, i = 0; in[i]; i++) {
|
|
30 if (in[i] == sep)
|
|
31 n++;
|
|
32 if (n >= num && in[i] != sep && c + 1 < maxout)
|
|
33 out[c++] = in[i];
|
|
34 if (n >= num && in[i + 1] == sep)
|
|
35 break;
|
|
36 }
|
|
37
|
|
38 if (c < maxout)
|
|
39 out[c] = 0;
|
|
40 }
|
|
41
|
|
42 int cutItemToInt(char *in, char sep, int num)
|
|
43 {
|
|
44 char tmp[64];
|
|
45
|
|
46 cutItem(in, tmp, sep, num);
|
33053
|
47
|
33046
|
48 return atoi(tmp);
|
|
49 }
|