return -1;
if (DestSize > 0)
- while (NewSize <= DestSize)
+ while ((NewSize <= DestSize) && (NewSize != 0))
NewSize *= 2;
+ if (NewSize == 0)
+ return -1;
+
NewBuf= (char*) malloc(NewSize);
if (NewBuf == NULL)
return -1;
else
CopySize = nChars;
- while (Siz <= CopySize)
+ while ((Siz <= CopySize) && (Siz != 0))
Siz *= 2;
+ if (Siz == 0)
+ {
+ return NULL;
+ }
+
NewBuf->buf = (char*) malloc(Siz);
if (NewBuf->buf == NULL)
{
else
CopySize = nChars;
- while (Siz <= CopySize)
+ while ((Siz <= CopySize) && (Siz != 0))
Siz *= 2;
+ if (Siz == 0) {
+ FlushStrBuf(Buf);
+ return -1;
+ }
+
if (Siz != Buf->BufSize)
IncreaseBuf(Buf, 0, Siz);
memcpy(Buf->buf, ptr, CopySize);
va_end(apl);
newused = Offset + nWritten;
if (newused >= Buf->BufSize) {
- IncreaseBuf(Buf, 1, newused);
+ if (IncreaseBuf(Buf, 1, newused) == -1)
+ return; /* TODO: error handling? */
newused = Buf->BufSize + 1;
}
else {
va_end(arg_ptr);
newused = Buf->BufUsed + nWritten;
if (newused >= Buf->BufSize) {
- IncreaseBuf(Buf, 1, newused);
+ if (IncreaseBuf(Buf, 1, newused) == -1)
+ return; /* TODO: error handling? */
newused = Buf->BufSize + 1;
}
else {
nWritten = vsnprintf(Buf->buf, Buf->BufSize, format, arg_ptr);
va_end(arg_ptr);
if (nWritten >= Buf->BufSize) {
- IncreaseBuf(Buf, 0, 0);
+ if (IncreaseBuf(Buf, 0, 0) == -1)
+ return; /* TODO: error handling? */
nWritten = Buf->BufSize + 1;
continue;
}
//cit_backtrace();
//lprintf (CTDL_DEBUG, "test >: n: %d sep: %c source: %s \n willi \n", parmnum, separator, source);
- while ((s<e) && !IsEmptyStr(s)) {
+ while ((s < e) && !IsEmptyStr(s)) {
if (*s == separator) {
++current_token;
}
//cit_backtrace();
//lprintf (CTDL_DEBUG, "test >: n: %d sep: %c source: %s \n willi \n", parmnum, separator, source);
- while ((s<EndBuffer) && !IsEmptyStr(s)) {
+ while ((s < EndBuffer) && !IsEmptyStr(s)) {
if (*s == separator) {
++current_token;
}
{
if (*Url != NULL) {
FreeStrBuf(&(*Url)->URL);
+ FreeStrBuf(&(*Url)->UrlWithoutCred);
+ FreeStrBuf(&(*Url)->CurlCreds);
if ((*Url)->Next != NULL)
FreeURL(&(*Url)->Next);
free(*Url);
*Url = url;
return 1;
}
+
+void CurlPrepareURL(ParsedURL *Url)
+{
+ if (!strcmp(ChrPtr(Url->URL), "http"))
+ Url->UrlWithoutCred = NewStrBufPlain(ChrPtr(Url->URL), -1);
+ else
+ Url->UrlWithoutCred = NewStrBufPlain(HKEY("http://"));
+ StrBufAppendBufPlain(Url->UrlWithoutCred, Url->Host, -1, 0);
+ StrBufAppendBufPlain(Url->UrlWithoutCred, HKEY(":"), 0);
+
+ StrBufAppendPrintf(Url->UrlWithoutCred, "%u", Url->Port);
+ StrBufAppendBufPlain(Url->UrlWithoutCred, HKEY("/"), 0);
+ if (Url->LocalPart)
+ StrBufAppendBufPlain(Url->UrlWithoutCred, Url->LocalPart, -1, 0);
+ if (Url->User != NULL)
+ {
+ Url->CurlCreds = NewStrBufPlain(Url->User, -1);
+ StrBufAppendBufPlain(Url->CurlCreds, HKEY(":"), 0);
+ if (Url->Pass != NULL)
+ StrBufAppendBufPlain(Url->CurlCreds, Url->Pass, -1, 0);
+ }
+}