StrBufExtract_tokenFromStr: add wrapper around StrBufExtract_token() which takes...
authorWilfried Goesgens <dothebart@citadel.org>
Sun, 10 Jun 2012 08:33:10 +0000 (10:33 +0200)
committerWilfried Goesgens <dothebart@citadel.org>
Sun, 10 Jun 2012 08:33:10 +0000 (10:33 +0200)
libcitadel/lib/libcitadel.h
libcitadel/lib/stringbuf.c

index 5fb0058f9a315fe4ed92bc1bb4e0a960ddc34c0e..3eee3728f998e274ea8bc3142b3f7ffa001ac34f 100644 (file)
@@ -278,6 +278,7 @@ long IOBufferStrLength(IOBuffer *FB);
 
 int StrBufSipLine(StrBuf *LineBuf, const StrBuf *Buf, const char **Ptr);
 int StrBufReplaceToken(StrBuf *Buf, long where, long HowLong, const char *Repl, long ReplLen);
+int StrBufExtract_tokenFromStr(StrBuf *dest, const char *Source, long SourceLen, int parmnum, char separator);
 int StrBufExtract_token(StrBuf *dest, const StrBuf *Source, int parmnum, char separator);
 int StrBufSub(StrBuf *dest, const StrBuf *Source, unsigned long Offset, size_t nChars);
 
index 0d88f7ca14f9c2e9925b744300194791c3334f7f..359538d9611584c957bd032062ff9840be85607e 100644 (file)
@@ -1345,6 +1345,23 @@ int StrBufRemove_token(StrBuf *Source, int parmnum, char separator)
        return ReducedBy;
 }
 
+int StrBufExtract_tokenFromStr(StrBuf *dest, const char *Source, long SourceLen, int parmnum, char separator)
+{
+       const StrBuf Temp = {
+               (char*)Source,
+               SourceLen,
+               SourceLen,
+               1
+#ifdef SIZE_DEBUG
+               ,
+               0,
+               "",
+               ""
+#endif
+       };
+
+       return StrBufExtract_token(dest, &Temp, parmnum, separator);
+}
 
 /**
  * @ingroup StrBuf_Tokenizer
@@ -3892,7 +3909,6 @@ void FDIOBufferDelete(FDIOBuffer *FDB)
 
 int FileSendChunked(FDIOBuffer *FDB, const char **Err)
 {
-
 #ifdef LINUX_SPLICE
        ssize_t sent;
        sent = sendfile(FDB->IOB->fd, FDB->OtherFD, &FDB->TotalSentAlready, FDB->ChunkSendRemain);
@@ -3941,19 +3957,26 @@ int FileRecvChunked(FDIOBuffer *FDB, const char **Err)
 
 #ifdef LINUX_SPLICE
 
-       pipesize = splice(FDB->IOB->fd, NULL, 
-                         FDB->SplicePipe[1], NULL, 
+       pipesize = splice(FDB->IOB->fd,
+                         NULL, 
+                         FDB->SplicePipe[1],
+                         NULL, 
                          FDB->ChunkSendRemain, 
                          SPLICE_F_MORE | SPLICE_F_MOVE|SPLICE_F_NONBLOCK);
+
        if (pipesize == -1)
        {
                *Err = strerror(errno);
                return pipesize;
        }
        
-       sent = splice(FDB->SplicePipe[0], NULL, 
-                     FDB->OtherFD, &FDB->TotalSentAlready, 
-                     pipesize, SPLICE_F_MORE | SPLICE_F_MOVE);
+       sent = splice(FDB->SplicePipe[0],
+                     NULL, 
+                     FDB->OtherFD,
+                     &FDB->TotalSentAlready, 
+                     pipesize,
+                     SPLICE_F_MORE | SPLICE_F_MOVE);
+
        if (sent == -1)
        {
                *Err = strerror(errno);