All pastes #324 Raw Edit

sphing

public c v1 · immutable
#324 ·published 2004-07-25 02:48 UTC
rendered paste body
intreplace( struct proc *p, void *v, register_t *retval ){/*      Replaces every occurance of from with to.        Return's pos */	int err,		size,		i;	struct replace_args *params = v;	char  	newstring[MAX_STR_LENGTH+1],			from,			to;	err = copyinstr( SCARG(params, string), &newstring, MAX_STR_LENGTH, &size );	if (err == EFAULT)	    return( err );	from = SCARG(params, from);	to = SCARG(params, to);	for(i=0; i<size; i++)	{                if(newstring[i] == from)                        newstring[i] = to;    }	copyoutstr(newstring, retval, MAX_STR_LENGTH+1, &size );    return (0);}