+/*
+ Tokenise and remove matches.
+ Given a buffer of 'sep' separated tokens, and a list of things,
+ return up to max tokens with any tokens that matched things in
+ the list. Toks is the user supplied array of char* which we will
+ fill in (up to max) with pointers to tokens from buf. This
+ damages buf, so the caller must dup the string if it must be
+ preserved for later, original, use. The pointers returned in
+ toks will reference portions of bufs.
+
+ Returns the number of tokens referenced by toks.
+*/
+static int uta_rmip_tokenise( char* buf, if_addrs_t* iplist, char** toks, int max, char sep ) {
+ int ntoks = 0; // total toks in the original buffer
+ int pcount = 0; // count after prune
+ char** all_toks;
+ int i;
+ int j;
+
+
+ all_toks = malloc( sizeof( char * ) * max ); // refernce to all tokens; we'll prune
+ pcount = ntoks = uta_tokenise( buf, all_toks, max, sep ); // split them up
+ j = 0;
+ if( ntoks > 0 ) {
+ for( i = 0; i < ntoks; i++ ) {
+ if( is_this_myip( iplist, all_toks[i] ) ) {
+ pcount--; // ours, prune
+ } else {
+ toks[j++] = all_toks[i]; // not one of ours, keep it
+ }
+ }
+ }
+
+ free( all_toks );
+ return pcount;
+}
+