MINOR: ist: Add `istshift(struct ist*)`

istshift() returns the first character and advances the ist by 1.
This commit is contained in:
Tim Duesterhus 2021-04-05 17:53:55 +02:00 committed by Willy Tarreau
parent 551eeaec91
commit 90aa8c7f02
1 changed files with 15 additions and 0 deletions

View File

@ -240,6 +240,21 @@ static inline struct ist istnext(const struct ist ist)
return ret;
}
/* Returns the first character of the <ist> and advances the <ist> by 1.
* If the <ist> is empty the result is undefined.
*/
static inline char istshift(struct ist *ist)
{
if (ist->len) {
char c = *ist->ptr;
*ist = istnext(*ist);
return c;
}
return 0;
}
/* copies the contents from string <ist> to buffer <buf> and adds a trailing
* zero. The caller must ensure <buf> is large enough.
*/