* pqGetInt * read a 2 or 4 byte integer and convert from network byte order * to local byte order */
| 221 | * to local byte order |
| 222 | */ |
| 223 | int |
| 224 | pqGetInt(int *result, size_t bytes, PGconn *conn) |
| 225 | { |
| 226 | uint16 tmp2; |
| 227 | uint32 tmp4; |
| 228 | |
| 229 | switch (bytes) |
| 230 | { |
| 231 | case 2: |
| 232 | if (conn->inCursor + 2 > conn->inEnd) |
| 233 | return EOF; |
| 234 | memcpy(&tmp2, conn->inBuffer + conn->inCursor, 2); |
| 235 | conn->inCursor += 2; |
| 236 | *result = (int) pg_ntoh16(tmp2); |
| 237 | break; |
| 238 | case 4: |
| 239 | if (conn->inCursor + 4 > conn->inEnd) |
| 240 | return EOF; |
| 241 | memcpy(&tmp4, conn->inBuffer + conn->inCursor, 4); |
| 242 | conn->inCursor += 4; |
| 243 | *result = (int) pg_ntoh32(tmp4); |
| 244 | break; |
| 245 | default: |
| 246 | pqInternalNotice(&conn->noticeHooks, |
| 247 | "integer of size %lu not supported by pqGetInt", |
| 248 | (unsigned long) bytes); |
| 249 | return EOF; |
| 250 | } |
| 251 | |
| 252 | return 0; |
| 253 | } |
| 254 | |
| 255 | int64 |
| 256 | pqGetInt64(int64 *result, PGconn *conn) |
no test coverage detected