* pqPacketSend() -- convenience routine to send a message to server. * * pack_type: the single-byte message type code. (Pass zero for startup * packets, which have no message type code.) * * buf, buf_len: contents of message. The given length includes only what * is in buf; the message type and message length fields are added here. * * RETURNS: STATUS_ERROR if the write fails, STATUS_OK
| 4812 | * SIDE_EFFECTS: may block. |
| 4813 | */ |
| 4814 | int |
| 4815 | pqPacketSend(PGconn *conn, char pack_type, |
| 4816 | const void *buf, size_t buf_len) |
| 4817 | { |
| 4818 | /* Start the message. */ |
| 4819 | if (pqPutMsgStart(pack_type, conn)) |
| 4820 | return STATUS_ERROR; |
| 4821 | |
| 4822 | /* Send the message body. */ |
| 4823 | if (pqPutnchar(buf, buf_len, conn)) |
| 4824 | return STATUS_ERROR; |
| 4825 | |
| 4826 | /* Finish the message. */ |
| 4827 | if (pqPutMsgEnd(conn)) |
| 4828 | return STATUS_ERROR; |
| 4829 | |
| 4830 | /* Flush to ensure backend gets it. */ |
| 4831 | if (pqFlush(conn)) |
| 4832 | return STATUS_ERROR; |
| 4833 | |
| 4834 | return STATUS_OK; |
| 4835 | } |
| 4836 | |
| 4837 | #ifdef USE_LDAP |
| 4838 |
no test coverage detected