/* *processingofamessageincludingescapecharacters, *returnsnumberofcharacterswrittentotheoutputsccb *("processed"meansthatisnotguaranteedthatthecharacterhavealready *beensenttotheSCLPbutthatitwillbedoneatleastnexttimetheSCLP *isnotbusy)
*/ int
sclp_write(struct sclp_buffer *buffer, constunsignedchar *msg, int count)
{ int spaces, i_msg; int rc;
/* *parsemsgforescapesequences(\t,\v...)andputformated *msgintoanmto(createdbysclp_initialize_mto). * *Wehavetodothisworkourselfsbecausethereisnosupportfor *thesecharactersonthenativemachineandonlypartialsupport *underVM(WhydoesVMinterpret\nbutthenativemachinedoesn't?) * *Dependingoni/o-controlsettingthemessageisalwayswritten *immediatelyorwewaitforafinalnewlinemaybecomingwiththe *nextmessage.Besidesweavoidabufferoverrunbywritingits *content. * *RESTRICTIONS: * *\rand\bworkwithinonelinebecausewearenotabletomodify *previousoutputthathavealreadybeenacceptedbytheSCLP. * *\tcombinedwithfollowing\risnotcorrectlyrepresentedbecause *\tisexpandedtosomespacesbut\rdoesnotknowabouta *previous\tanddecreasesthecurrentpositionbyonecolumn. *Thisisinordertoaslimandquickimplementation.
*/ for (i_msg = 0; i_msg < count; i_msg++) { switch (msg[i_msg]) { case'\n': /* new line, line feed (ASCII) */ /* check if new mto needs to be created */ if (buffer->current_line == NULL) {
rc = sclp_initialize_mto(buffer, 0); if (rc) return i_msg;
}
sclp_finalize_mto(buffer); break; case'\a': /* bell, one for several times */ /* set SCLP sound alarm bit in General Object */ if (buffer->current_line == NULL) {
rc = sclp_initialize_mto(buffer,
buffer->columns); if (rc) return i_msg;
}
buffer->current_msg->mdb.go.general_msg_flags |=
GNRLMSGFLGS_SNDALRM; break; case'\t': /* horizontal tabulator */ /* check if new mto needs to be created */ if (buffer->current_line == NULL) {
rc = sclp_initialize_mto(buffer,
buffer->columns); if (rc) return i_msg;
} /* "go to (next htab-boundary + 1, same line)" */ do { if (buffer->current_length >= buffer->columns) break; /* ok, add a blank */
*buffer->current_line++ = 0x40;
buffer->current_length++;
} while (buffer->current_length % buffer->htab); break; case'\f': /* form feed */ case'\v': /* vertical tabulator */ /* "go to (actual column, actual line + 1)" */ /* = new line, leading spaces */ if (buffer->current_line != NULL) {
spaces = buffer->current_length;
sclp_finalize_mto(buffer);
rc = sclp_initialize_mto(buffer,
buffer->columns); if (rc) return i_msg;
memset(buffer->current_line, 0x40, spaces);
buffer->current_line += spaces;
buffer->current_length = spaces;
} else { /* one an empty line this is the same as \n */
rc = sclp_initialize_mto(buffer,
buffer->columns); if (rc) return i_msg;
sclp_finalize_mto(buffer);
} break; case'\b': /* backspace */ /* "go to (actual column - 1, actual line)" */ /* decrement counter indicating position, */ /* do not remove last character */ if (buffer->current_line != NULL &&
buffer->current_length > 0) {
buffer->current_length--;
buffer->current_line--;
} break; case0x00: /* end of string */ /* transfer current line to SCCB */ if (buffer->current_line != NULL)
sclp_finalize_mto(buffer); /* skip the rest of the message including the 0 byte */
i_msg = count - 1; break; default: /* no escape character */ /* do not output unprintable characters */ if (!isprint(msg[i_msg])) break; /* check if new mto needs to be created */ if (buffer->current_line == NULL) {
rc = sclp_initialize_mto(buffer,
buffer->columns); if (rc) return i_msg;
}
*buffer->current_line++ = sclp_ascebc(msg[i_msg]);
buffer->current_length++; break;
} /* check if current mto is full */ if (buffer->current_line != NULL &&
buffer->current_length >= buffer->columns)
sclp_finalize_mto(buffer);
}
/* return number of processed characters */ return i_msg;
}
/* *Returnthenumberoffreebytesinthesccb
*/ int
sclp_buffer_space(struct sclp_buffer *buffer)
{ struct sccb_header *sccb; int count;
/* *Setuptherequeststructureinthestructsclp_buffertodoSCLPWrite *EventDataandpasstherequesttothecoreSCLPloop.Returnzeroon *success,non-zerootherwise.
*/ int
sclp_emit_buffer(struct sclp_buffer *buffer, void (*callback)(struct sclp_buffer *, int))
{ /* add current line if there is one */ if (buffer->current_line != NULL)
sclp_finalize_mto(buffer);
/* Are there messages in the output buffer ? */ if (buffer->messages == 0) return -EIO;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.