Lines Matching refs:buffer

35  * Setup a sclp write buffer. Gets a page as input (4K) and returns
37 * end of the input page. This reduces the buffer space by a few
43 struct sclp_buffer *buffer;
51 buffer = ((struct sclp_buffer *) ((addr_t) sccb + PAGE_SIZE)) - 1;
52 buffer->sccb = sccb;
53 buffer->retry_count = 0;
54 buffer->messages = 0;
55 buffer->char_sum = 0;
56 buffer->current_line = NULL;
57 buffer->current_length = 0;
58 buffer->columns = columns;
59 buffer->htab = htab;
65 return buffer;
70 * the buffer.
73 sclp_unmake_buffer(struct sclp_buffer *buffer)
75 return buffer->sccb;
79 * Initialize a new message the end of the provided buffer with
83 sclp_initialize_mto(struct sclp_buffer *buffer, int max_len)
95 /* check if current buffer sccb can contain the mto */
96 sccb = buffer->sccb;
121 buffer->current_msg = msg;
122 buffer->current_line = (char *) (mto + 1);
123 buffer->current_length = 0;
130 * updating the sizes of MTO, enclosing MDB, event buffer and SCCB.
133 sclp_finalize_mto(struct sclp_buffer *buffer)
142 sccb = buffer->sccb;
143 msg = buffer->current_msg;
144 msg->header.length += buffer->current_length;
145 msg->mdb.header.length += buffer->current_length;
146 msg->mdb.mto.length += buffer->current_length;
154 buffer->messages++;
155 buffer->char_sum += buffer->current_length;
157 buffer->current_line = NULL;
158 buffer->current_length = 0;
159 buffer->current_msg = NULL;
170 sclp_write(struct sclp_buffer *buffer, const unsigned char *msg, int count)
185 * next message. Besides we avoid a buffer overrun by writing its
202 if (buffer->current_line == NULL) {
203 rc = sclp_initialize_mto(buffer, 0);
207 sclp_finalize_mto(buffer);
211 if (buffer->current_line == NULL) {
212 rc = sclp_initialize_mto(buffer,
213 buffer->columns);
217 buffer->current_msg->mdb.go.general_msg_flags |=
222 if (buffer->current_line == NULL) {
223 rc = sclp_initialize_mto(buffer,
224 buffer->columns);
230 if (buffer->current_length >= buffer->columns)
233 *buffer->current_line++ = 0x40;
234 buffer->current_length++;
235 } while (buffer->current_length % buffer->htab);
241 if (buffer->current_line != NULL) {
242 spaces = buffer->current_length;
243 sclp_finalize_mto(buffer);
244 rc = sclp_initialize_mto(buffer,
245 buffer->columns);
248 memset(buffer->current_line, 0x40, spaces);
249 buffer->current_line += spaces;
250 buffer->current_length = spaces;
253 rc = sclp_initialize_mto(buffer,
254 buffer->columns);
257 sclp_finalize_mto(buffer);
264 if (buffer->current_line != NULL &&
265 buffer->current_length > 0) {
266 buffer->current_length--;
267 buffer->current_line--;
272 if (buffer->current_line != NULL)
273 sclp_finalize_mto(buffer);
282 if (buffer->current_line == NULL) {
283 rc = sclp_initialize_mto(buffer,
284 buffer->columns);
288 *buffer->current_line++ = sclp_ascebc(msg[i_msg]);
289 buffer->current_length++;
293 if (buffer->current_line != NULL &&
294 buffer->current_length >= buffer->columns)
295 sclp_finalize_mto(buffer);
306 sclp_buffer_space(struct sclp_buffer *buffer)
311 sccb = buffer->sccb;
313 if (buffer->current_line != NULL)
314 count -= sizeof(struct msg_buf) + buffer->current_length;
319 * Return number of characters in buffer
322 sclp_chars_in_buffer(struct sclp_buffer *buffer)
326 count = buffer->char_sum;
327 if (buffer->current_line != NULL)
328 count += buffer->current_length;
360 struct sclp_buffer *buffer;
363 buffer = (struct sclp_buffer *) data;
364 sccb = buffer->sccb;
367 if (buffer->callback != NULL)
368 buffer->callback(buffer, -EIO);
374 /* Normal completion, buffer processed, message(s) sent */
379 if (++buffer->retry_count > SCLP_BUFFER_MAX_RETRY) {
387 buffer->request.status = SCLP_REQ_FILLED;
397 if (++buffer->retry_count > SCLP_BUFFER_MAX_RETRY) {
403 buffer->request.status = SCLP_REQ_FILLED;
415 if (buffer->callback != NULL)
416 buffer->callback(buffer, rc);
425 sclp_emit_buffer(struct sclp_buffer *buffer,
429 if (buffer->current_line != NULL)
430 sclp_finalize_mto(buffer);
432 /* Are there messages in the output buffer ? */
433 if (buffer->messages == 0)
436 buffer->request.command = SCLP_CMDW_WRITE_EVENT_DATA;
437 buffer->request.status = SCLP_REQ_FILLED;
438 buffer->request.callback = sclp_writedata_callback;
439 buffer->request.callback_data = buffer;
440 buffer->request.sccb = buffer->sccb;
441 buffer->callback = callback;
442 return sclp_add_request(&buffer->request);