/* Create a chunk from an allocated buffer ** --------------------------------------- */ PUBLIC HTChunk * HTChunk_fromBuffer (char * buf, int buflen, int size, int grow) { HTChunk * ch; ch = HTChunk_new(grow); if (buf) { ch->data = buf; ch->size = ch->allocated = buflen; if (size < buflen) HTChunk_setSize(ch, size); /* This ensures the end is 0-filled */ } return ch; }
PRIVATE int SendCommand (HTRequest *request, news_info *news, char *token, char *pars) { HTStream * input = HTRequest_inputStream(request); int len = strlen(token) + (pars ? strlen(pars)+1:0) + 2; HTChunk_setSize(news->cmd, len); if (pars && *pars) sprintf(HTChunk_data(news->cmd), "%s %s%c%c", token, pars, CR, LF); else sprintf(HTChunk_data(news->cmd), "%s%c%c", token, CR, LF); HTTRACE(PROT_TRACE, "News Tx..... %s" _ HTChunk_data(news->cmd)); return (*input->isa->put_block)(input, HTChunk_data(news->cmd), len); }