Remove trailing whitespace from most files
[mplayer/glamo.git] / gui / skin / cut.c
blobf101b67f946c0d63308a2e906825a810a9a6ebb1
1 /*
2 * This file is part of MPlayer.
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.
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.
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.
19 #include <string.h>
20 #include <stdlib.h>
22 void cutItem( char * in,char * out,char sep,int num )
24 int i,n,c;
25 for ( c=0,n=0,i=0;i<strlen( in );i++ )
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; }
31 out[c]=0;
34 int cutItemToInt( char * in,char sep,int num )
36 char tmp[512];
37 cutItem( in,tmp,sep,num );
38 return atoi( tmp );
41 float cutItemToFloat( char * in,char sep,int num )
43 char tmp[512];
44 cutItem( in,tmp,sep,num );
45 return atof( tmp );
48 void cutChunk( char * in,char * s1 )
50 cutItem( in,s1,'=',0 );
51 memmove( in,strchr( in,'=' )+1,strlen( in ) - strlen( s1 ) );