Changed XMLterm escape sequence string terminator from ^G to CRLF to allow use with buffered STDOUT.
This commit is contained in:
svn%xmlterm.org 2000-04-21 13:10:44 +00:00
Родитель f66d59919f
Коммит b0e7263a58
7 изменённых файлов: 54 добавлений и 27 удалений

Просмотреть файл

@ -1017,11 +1017,13 @@ static int ltermProcessXTERMSequence(struct lterms *lts, const UNICHAR *buf,
/** Processes XMLTerm sequence (a special case of Escape sequence processing)
* XMLterm escape sequences are of the form
* ESC { Pm C Pt BEL
* ESC { Pm C Pt LF
* where Pm denotes multiple numeric arguments separated by semicolons,
* character C is a not a digit and not a semicolon, and
* text parameter Pt may be a null string.
* character C is a not a digit and not a semicolon,
* text parameter Pt may be a null string, and
* LF is the linefeed character.
* Omitted numeric parameters are assumed to be zero.
* Any carriage return character preceding the terminating LF is discarded.
* @return 0 on success and -1 on error.
*/
static int ltermProcessXMLTermSequence(struct lterms *lts, const UNICHAR *buf,
@ -1104,7 +1106,7 @@ static int ltermProcessXMLTermSequence(struct lterms *lts, const UNICHAR *buf,
/* Process string parameter */
strLength = 0;
while ((offset < count) && (buf[offset] != U_BEL)) {
while ((offset < count) && (buf[offset] != U_LINEFEED)) {
if (strLength < MAXSTRINGPARAM) {
paramCString[strLength] = buf[offset];
paramString[strLength++] = buf[offset];
@ -1122,6 +1124,10 @@ static int ltermProcessXMLTermSequence(struct lterms *lts, const UNICHAR *buf,
return 1;
}
/* Discard any CR character preceding the terminating LF character */
if ((strLength > 0) && (paramString[strLength-1] == U_CRETURN))
strLength--;
/* Insert terminating NULL character in string */
paramCString[strLength] = U_NUL;
paramString[strLength] = U_NUL;
@ -1139,6 +1145,20 @@ static int ltermProcessXMLTermSequence(struct lterms *lts, const UNICHAR *buf,
switch (termChar) {
int streamOpcodes;
case U_A_CHAR: /* Send XMLterm device attributes */
LTERM_LOG(ltermProcessXMLTermSequence,52,("Sending device attributes\n"));
if (ltermSendChar(lts, "\033{?", 3) != 0)
return -1;
if (strlen(lts->cookie) > 0) {
if (ltermSendChar(lts, lts->cookie, strlen(lts->cookie)) != 0)
return -1;
}
if (ltermSendChar(lts, "\n", 1) != 0)
return -1;
return 0;
case U_D_CHAR: /* Set debugging messageLevel/search-string */
LTERM_LOG(ltermProcessXMLTermSequence,52,("Setting message level etc.\n"));
if (strLength == 0) {

Просмотреть файл

@ -88,7 +88,7 @@ foreach my $url (@ARGV) { # for each argument
($extension eq ".jpg")) {
## print STDERR "Image file\n";
print "\e{S$cookie\a"; # HTML stream escape sequence
print "\e{S$cookie\n"; # HTML stream escape sequence
print "<IMG SRC='$scheme://${host}$pathname'>";
print "\000"; # Terminate HTML stream
@ -130,7 +130,7 @@ foreach my $url (@ARGV) { # for each argument
my $clickcmd =
qq%onClick="return HandleEvent(event,'click','textlink',-\#,'$urlstr')"%;
print "\e{S$cookie\a"; # HTML stream escape sequence
print "\e{S$cookie\n"; # HTML stream escape sequence
if ($nurl >= 2) {
print "<img src='$urlvals[1]' $clickcmd><br>";
}
@ -142,7 +142,7 @@ foreach my $url (@ARGV) { # for each argument
(($scheme eq "file") && (($extension eq ".htm") ||
($extension eq ".html")) ) ) {
## print STDERR "IFRAME\n";
print "\e{S$cookie\a"; # HTML stream escape sequence
print "\e{S$cookie\n"; # HTML stream escape sequence
print "<iframe frameborder=0 width='100%' height='$height' src='$scheme://${host}$pathname'></iframe>";
print "<div class='beginner'>";
print "Use shift-key + Home/End/PageUp/PageDown to scroll nested IFrame.";
@ -153,7 +153,7 @@ foreach my $url (@ARGV) { # for each argument
## print STDERR "Text file\n";
open INFILE, $pathname or next;
print "\e{S$cookie\a"; # HTML stream escape sequence
print "\e{S$cookie\n"; # HTML stream escape sequence
print "<pre>";
while (<INFILE>) {

Просмотреть файл

@ -43,7 +43,7 @@ if (@ARGV) {
}
my $cookie = $ENV{LTERM_COOKIE}; # XMLTerm cookie
print "\e{S$cookie\a"; # HTML stream escape sequence
print "\e{S$cookie\012"; # HTML stream escape sequence
print "<TABLE FRAME=none BORDER=0>";
print "<COLGROUP COLSPAN=$ncols WIDTH=1*>";

Просмотреть файл

@ -13,7 +13,7 @@ int main(void)
cookie = "";
/* XMLTerm escape sequence signalling start of a HTML document */
printf("\033{1S%s\007", cookie);
printf("\033{1S%s\n", cookie);
printf(" <HTML><BODY> \
<FORM> \
@ -34,10 +34,10 @@ int main(void)
while((ch = getchar())){ /* Poll for data generated by button click events */
switch (ch) {
case 'b':
printf("\033{S%s\007<B>Hello World!</B><BR> %c", cookie, '\0');
printf("\033{S%s\n<B>Hello World!</B><BR> %c", cookie, '\0');
break;
case 'e':
printf("\033{S%s\007<EM>Hello World!</EM><BR> %c", cookie, '\0');
printf("\033{S%s\n<EM>Hello World!</EM><BR> %c", cookie, '\0');
break;
case 'q':
return 0;

Просмотреть файл

@ -12,7 +12,7 @@ int main(void)
if (cookie == NULL)
cookie = "";
printf("\033{S%s\007", cookie); /* Escape sequence for start of HTML frag */
printf("\033{S%s\n", cookie); /* Escape sequence for start of HTML frag */
printf("<FORM> \
<IMG align=center src='chrome://navigator/skin/animthrob_single.gif'> \
@ -30,10 +30,10 @@ int main(void)
while((ch = getchar())){ /* Poll for data generated by button click events */
switch (ch) {
case 'b':
printf("\033{S%s\007<B>Hello World!</B><BR> %c", cookie, '\0');
printf("\033{S%s\n<B>Hello World!</B><BR> %c", cookie, '\0');
break;
case 'e':
printf("\033{S%s\007<EM>Hello World!</EM><BR> %c", cookie, '\0');
printf("\033{S%s\n<EM>Hello World!</EM><BR> %c", cookie, '\0');
break;
case 'q':
return 0;
@ -43,7 +43,7 @@ int main(void)
}
}
printf("\033{1E\007"); /* Enable input echo */
printf("\033{1E\n"); /* Enable input echo */
return 0;
}

Просмотреть файл

@ -39,17 +39,17 @@ int main(int argc, char *argv[])
}
if (nparam == 0) {
fprintf(stderr, "ESC{%s%sBEL\n", code, sparam);
fprintf(stdout, "\033{%s%s\007", code, sparam);
fprintf(stderr, "ESC{%s%s\\n\n", code, sparam);
fprintf(stdout, "\033{%s%s\n", code, sparam);
} else if (nparam == 1) {
fprintf(stderr, "ESC{%s%s%sBEL\n", param1, code, sparam);
fprintf(stdout, "\033{%s%s%s\007", param1, code, sparam);
fprintf(stderr, "ESC{%s%s%s\\n\n", param1, code, sparam);
fprintf(stdout, "\033{%s%s%s\n", param1, code, sparam);
} else if (nparam == 2) {
fprintf(stderr, "ESC{%s;%s%s%sBEL\n", param1, param2, code, sparam);
fprintf(stdout, "\033{%s;%s%s%s\007", param1, param2, code, sparam);
fprintf(stderr, "ESC{%s;%s%s%s\\n\n", param1, param2, code, sparam);
fprintf(stdout, "\033{%s;%s%s%s\n", param1, param2, code, sparam);
} else {
fprintf(stderr, "ESC{%s;%s;%s%s%sBEL\n", param1, param2, param3, code, sparam);
fprintf(stdout, "\033{%s;%s;%s%s%s\007", param1, param2, param3, code, sparam);
fprintf(stderr, "ESC{%s;%s;%s%s%s\\n\n", param1, param2, param3, code, sparam);
fprintf(stdout, "\033{%s;%s;%s%s%s\n", param1, param2, param3, code, sparam);
}
return 0;

Просмотреть файл

@ -1,19 +1,26 @@
/* teststream.c: Test driver to generate escaped stream data */
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
char* cookie;
cookie = getenv("LTERM_COOKIE"); /* Get security cookie */
if (cookie == NULL)
cookie = "";
if (argc < 2) {
fprintf(stderr, "Usage: %s <data-string> [<terminator-string>]\n",argv[0]);
return 1;
}
if (argc > 2) {
/* fprintf(stderr, "{ESCS%sBEL%s%s", argv[2], argv[1], argv[2]); */
fprintf(stdout, "\033{S%s\007%s%s", argv[2], argv[1], argv[2]);
/* NOT IMPLEMENTED YET */
fprintf(stdout, "\033{T%s\n%s%s", argv[2], argv[1], argv[2]);
} else {
fprintf(stdout, "\033{S\007%s%c", argv[1], '\0');
fprintf(stdout, "\033{S%s\n%s%c", cookie, argv[1], '\0');
}
return 0;