* pqPutMsgStart: begin construction of a message to the server * * msg_type is the message type byte, or 0 for a message without type byte * (only startup messages have no type byte) * * Returns 0 on success, EOF on error * * The idea here is that we construct the message in conn->outBuffer, * beginning just past any data already in outBuffer (ie, at * outBuffer+outCount). We enlarge the
| 499 | * the data collected so far. |
| 500 | */ |
| 501 | int |
| 502 | pqPutMsgStart(char msg_type, PGconn *conn) |
| 503 | { |
| 504 | int lenPos; |
| 505 | int endPos; |
| 506 | |
| 507 | /* allow room for message type byte */ |
| 508 | if (msg_type) |
| 509 | endPos = conn->outCount + 1; |
| 510 | else |
| 511 | endPos = conn->outCount; |
| 512 | |
| 513 | /* do we want a length word? */ |
| 514 | lenPos = endPos; |
| 515 | /* allow room for message length */ |
| 516 | endPos += 4; |
| 517 | |
| 518 | /* make sure there is room for message header */ |
| 519 | if (pqCheckOutBufferSpace(endPos, conn)) |
| 520 | return EOF; |
| 521 | /* okay, save the message type byte if any */ |
| 522 | if (msg_type) |
| 523 | conn->outBuffer[conn->outCount] = msg_type; |
| 524 | /* set up the message pointers */ |
| 525 | conn->outMsgStart = lenPos; |
| 526 | conn->outMsgEnd = endPos; |
| 527 | /* length word, if needed, will be filled in by pqPutMsgEnd */ |
| 528 | |
| 529 | return 0; |
| 530 | } |
| 531 | |
| 532 | /* |
| 533 | * pqPutMsgBytes: add bytes to a partially-constructed message |
no test coverage detected