void ErrorHandler::operator() (const char* fmt, int n1, int n2) { if (StartMessage()) { sprintf(addBuff, fmt, n1, n2); Add(addBuff); EndMessage(); } }
void ErrorHandler::operator() (const char* fmt, const char* msg, int n) { if (StartMessage()) { sprintf(addBuff, fmt, msg, n); Add(addBuff); EndMessage(); } }
void RangeCheck(int lower, int value, int upper, char *errormessage) { if ((value < lower) | (value > upper)) { StartMessage(); printf("RangeCheck fails: %d <= %d <= %d: ",lower,value,upper); EndMessage(); oops(errormessage); } }
status_t LinkSender::StartMessage(int32 code, size_t minSize) { // end previous message if (EndMessage() < B_OK) CancelMessage(); if (minSize > kMaxBufferSize - sizeof(message_header)) { // we will handle this case in Attach, using an area minSize = sizeof(area_id); } minSize += sizeof(message_header); // Eventually flush buffer to make space for the new message. // Note, we do not take the actual buffer size into account to not // delay the time between buffer flushes too much. if (fBufferSize > 0 && (minSize > SpaceLeft() || fCurrentStart >= kWatermark)) { status_t status = Flush(); if (status < B_OK) return status; } if (minSize > fBufferSize) { if (AdjustBuffer(minSize) != B_OK) return fCurrentStatus = B_NO_MEMORY; } message_header *header = (message_header *)(fBuffer + fCurrentStart); header->size = 0; // will be set later header->code = code; header->flags = 0; STRACE(("info: LinkSender buffered header %ld (%lx) [%lu %lu %lu].\n", code, code, header->size, header->code, header->flags)); fCurrentEnd += sizeof(message_header); return B_OK; }
status_t LinkSender::Flush(bigtime_t timeout, bool needsReply) { if (fCurrentStatus < B_OK) return fCurrentStatus; EndMessage(needsReply); if (fCurrentStart == 0) return B_OK; STRACE(("info: LinkSender Flush() waiting to send messages of %ld bytes on port %ld.\n", fCurrentEnd, fPort)); status_t err; if (timeout != B_INFINITE_TIMEOUT) { do { err = write_port_etc(fPort, kLinkCode, fBuffer, fCurrentEnd, B_RELATIVE_TIMEOUT, timeout); } while (err == B_INTERRUPTED); } else { do { err = write_port(fPort, kLinkCode, fBuffer, fCurrentEnd); } while (err == B_INTERRUPTED); } if (err < B_OK) { STRACE(("error info: LinkSender Flush() failed for %ld bytes (%s) on port %ld.\n", fCurrentEnd, strerror(err), fPort)); return err; } STRACE(("info: LinkSender Flush() messages total of %ld bytes on port %ld.\n", fCurrentEnd, fPort)); fCurrentEnd = 0; fCurrentStart = 0; return B_OK; }
void ClangCodeModelServerProxy::end() { writeMessageBlock.write(EndMessage()); }
void ErrorHandler::operator() (const char* msg) { if (StartMessage()) { Add(msg); EndMessage(); } }
void ErrorHandler::operator() (const char* fmt, int n1, int n2) { if (StartMessage()) { fprintf(stderr, fmt, n1, n2); EndMessage(); } }
void ErrorHandler::operator() (const char* fmt, const char* msg, int n) { if (StartMessage()) { fprintf(stderr, fmt, msg, n); EndMessage(); } }
void ErrorHandler::operator() (const char* msg) { if (StartMessage()) { fputs(msg, stderr); EndMessage(); } }