26458
|
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 */
|
23077
|
18
|
|
19 #include <string.h>
|
|
20 #include <stdlib.h>
|
|
21
|
|
22 void cutItem( char * in,char * out,char sep,int num )
|
|
23 {
|
|
24 int i,n,c;
|
|
25 for ( c=0,n=0,i=0;i<strlen( in );i++ )
|
|
26 {
|
|
27 if ( in[i] == sep ) n++;
|
|
28 if ( n >= num && in[i] != sep ) out[c++]=in[i];
|
|
29 if ( n >= num && in[i+1] == sep ) { out[c]=0; return; }
|
|
30 }
|
|
31 out[c]=0;
|
|
32 }
|
|
33
|
|
34 int cutItemToInt( char * in,char sep,int num )
|
|
35 {
|
|
36 char tmp[512];
|
|
37 cutItem( in,tmp,sep,num );
|
|
38 return atoi( tmp );
|
|
39 }
|
|
40
|
|
41 float cutItemToFloat( char * in,char sep,int num )
|
|
42 {
|
|
43 char tmp[512];
|
|
44 cutItem( in,tmp,sep,num );
|
|
45 return atof( tmp );
|
|
46 }
|
|
47
|
|
48 void cutChunk( char * in,char * s1 )
|
|
49 {
|
|
50 cutItem( in,s1,'=',0 );
|
|
51 memmove( in,strchr( in,'=' )+1,strlen( in ) - strlen( s1 ) );
|
|
52 }
|
|
53
|