* pqPutInt * write an integer of 2 or 4 bytes, converting from host byte order * to network byte order. */
| 294 | * to network byte order. |
| 295 | */ |
| 296 | int |
| 297 | pqPutInt(int value, size_t bytes, PGconn *conn) |
| 298 | { |
| 299 | uint16 tmp2; |
| 300 | uint32 tmp4; |
| 301 | |
| 302 | switch (bytes) |
| 303 | { |
| 304 | case 2: |
| 305 | tmp2 = pg_hton16((uint16) value); |
| 306 | if (pqPutMsgBytes((const char *) &tmp2, 2, conn)) |
| 307 | return EOF; |
| 308 | break; |
| 309 | case 4: |
| 310 | tmp4 = pg_hton32((uint32) value); |
| 311 | if (pqPutMsgBytes((const char *) &tmp4, 4, conn)) |
| 312 | return EOF; |
| 313 | break; |
| 314 | default: |
| 315 | pqInternalNotice(&conn->noticeHooks, |
| 316 | "integer of size %lu not supported by pqPutInt", |
| 317 | (unsigned long) bytes); |
| 318 | return EOF; |
| 319 | } |
| 320 | |
| 321 | return 0; |
| 322 | } |
| 323 | |
| 324 | /* |
| 325 | * Make sure conn's output buffer can hold bytes_needed bytes (caller must |
no test coverage detected