void StrBufPrintf(StrBuf *Buf, const char *format, ...) __attribute__((__format__(__printf__,2,3)));
void StrBufCutLeft(StrBuf *Buf, int nChars);
void StrBufCutRight(StrBuf *Buf, int nChars);
+void StrBufTrim(StrBuf *Buf);
void StrBufUpCase(StrBuf *Buf);
void StrBufEUid_unescapize(StrBuf *target, const StrBuf *source);
void StrBufEUid_escapize(StrBuf *target, const StrBuf *source);
}
+/*
+ * Strip leading and trailing spaces from a string; with premeasured and adjusted length.
+ * buf - the string to modify
+ * len - length of the string.
+ */
+void StrBufTrim(StrBuf *Buf)
+{
+ int delta = 0;
+ if ((Buf == NULL) || (Buf->BufUsed == 0)) return;
+
+ while ((Buf->BufUsed > delta) && (isspace(Buf->buf[delta]))){
+ delta ++;
+ }
+ if (delta > 0) StrBufCutLeft(Buf, delta);
+
+ if (Buf->BufUsed == 0) return;
+ while (isspace(Buf->buf[Buf->BufUsed - 1])){
+ Buf->BufUsed --;
+ }
+ Buf->buf[Buf->BufUsed] = '\0';
+}
+
+
void StrBufUpCase(StrBuf *Buf)
{
char *pch, *pche;