--- libelwix/src/str.c 2024/10/28 09:58:51 1.11 +++ libelwix/src/str.c 2026/07/27 21:11:07 1.12 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: str.c,v 1.11 2024/10/28 09:58:51 misho Exp $ +* $Id: str.c,v 1.12 2026/07/27 21:11:07 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -12,7 +12,7 @@ terms: All of the documentation and software included in the ELWIX and AITNET Releases is copyrighted by ELWIX - Sofia/Bulgaria -Copyright 2004 - 2024 +Copyright 2004 - 2026 by Michael Pounov . All rights reserved. Redistribution and use in source and binary forms, with or without @@ -322,6 +322,36 @@ str_Dig2Hex2(u_char * __restrict digz, int diglen) } return str; +} + +/* + * str_makeup() - Makeup the string, delete character or replace it + * + * @str = String for makeup + * @ch = Find character + * @replace = Replace found character with this one if it !=0 + * return: how many replaces are done or -1 error + */ +int +str_makeup(char * __restrict str, char ch, char replace) +{ + int ret = 0; + char *p, *c; + + if (!str) + return -1; + + for (p = c = str; *c; c++) + if (*c != ch) + *p++ = *c; + else { + if (replace) + *p++ = replace; + ret++; + } + *p = 0; + + return ret; } /*