view Gui/skin/cut.c @ 9913:88fe89b46786

Add suffix support to the object list type. So now -vf-clr destroy the list -vf-add filer1=blah,filter append these 2 filters, -vf-pre ... will 'prepend' them. Finnaly -vf-del 2,3,-1 will delete the filters at at given indexs It start from 0, negative number start from the end of the list (so -1 is the last one).
author albeu
date Sat, 12 Apr 2003 13:45:43 +0000
parents 58dd326fcc4a
children
line wrap: on
line source


#include <string.h>
#include <stdlib.h>

void cutItem( char * in,char * out,char sep,int num )
{
 int i,n,c;
 for ( c=0,n=0,i=0;i<strlen( in );i++ )
  {
   if ( in[i] == sep ) n++;
   if ( n >= num && in[i] != sep ) out[c++]=in[i];
   if ( n >= num && in[i+1] == sep ) { out[c]=0; return; }
  }
 out[c]=0;
}

int cutItemToInt( char * in,char sep,int num )
{
 char tmp[512];
 cutItem( in,tmp,sep,num ); 
 return atoi( tmp );
}

float cutItemToFloat( char * in,char sep,int num )
{
 char tmp[512];
 cutItem( in,tmp,sep,num ); 
 return atof( tmp );
}

void cutChunk( char * in,char * s1 )
{
 cutItem( in,s1,'=',0 );
 memmove( in,strchr( in,'=' )+1,strlen( in ) - strlen( s1 ) );
}