| 4548 | */ |
| 4549 | |
| 4550 | ipp_state_t /* O - Current state */ |
| 4551 | ippWriteIO(void *dst, /* I - Destination */ |
| 4552 | ipp_iocb_t cb, /* I - Write callback function */ |
| 4553 | int blocking, /* I - Use blocking IO? */ |
| 4554 | ipp_t *parent, /* I - Parent IPP message */ |
| 4555 | ipp_t *ipp) /* I - IPP data */ |
| 4556 | { |
| 4557 | int i; /* Looping var */ |
| 4558 | int n; /* Length of data */ |
| 4559 | unsigned char *buffer, /* Data buffer */ |
| 4560 | *bufptr; /* Pointer into buffer */ |
| 4561 | ipp_attribute_t *attr; /* Current attribute */ |
| 4562 | _ipp_value_t *value; /* Current value */ |
| 4563 | |
| 4564 | |
| 4565 | DEBUG_printf(("ippWriteIO(dst=%p, cb=%p, blocking=%d, parent=%p, ipp=%p)", (void *)dst, (void *)cb, blocking, (void *)parent, (void *)ipp)); |
| 4566 | |
| 4567 | if (!dst || !ipp) |
| 4568 | return (IPP_STATE_ERROR); |
| 4569 | |
| 4570 | if ((buffer = (unsigned char *)_cupsBufferGet(IPP_BUF_SIZE)) == NULL) |
| 4571 | { |
| 4572 | DEBUG_puts("1ippWriteIO: Unable to get write buffer"); |
| 4573 | return (IPP_STATE_ERROR); |
| 4574 | } |
| 4575 | |
| 4576 | switch (ipp->state) |
| 4577 | { |
| 4578 | case IPP_STATE_IDLE : |
| 4579 | ipp->state ++; /* Avoid common problem... */ |
| 4580 | |
| 4581 | case IPP_STATE_HEADER : |
| 4582 | if (parent == NULL) |
| 4583 | { |
| 4584 | /* |
| 4585 | * Send the request header: |
| 4586 | * |
| 4587 | * Version = 2 bytes |
| 4588 | * Operation/Status Code = 2 bytes |
| 4589 | * Request ID = 4 bytes |
| 4590 | * Total = 8 bytes |
| 4591 | */ |
| 4592 | |
| 4593 | bufptr = buffer; |
| 4594 | |
| 4595 | *bufptr++ = ipp->request.any.version[0]; |
| 4596 | *bufptr++ = ipp->request.any.version[1]; |
| 4597 | *bufptr++ = (ipp_uchar_t)(ipp->request.any.op_status >> 8); |
| 4598 | *bufptr++ = (ipp_uchar_t)ipp->request.any.op_status; |
| 4599 | *bufptr++ = (ipp_uchar_t)(ipp->request.any.request_id >> 24); |
| 4600 | *bufptr++ = (ipp_uchar_t)(ipp->request.any.request_id >> 16); |
| 4601 | *bufptr++ = (ipp_uchar_t)(ipp->request.any.request_id >> 8); |
| 4602 | *bufptr++ = (ipp_uchar_t)ipp->request.any.request_id; |
| 4603 | |
| 4604 | DEBUG_printf(("2ippWriteIO: version=%d.%d", buffer[0], buffer[1])); |
| 4605 | DEBUG_printf(("2ippWriteIO: op_status=%04x", |
| 4606 | ipp->request.any.op_status)); |
| 4607 | DEBUG_printf(("2ippWriteIO: request_id=%d", |