Back to index

lightning-sunbird  0.9+nobinonly
DocStream.c
Go to the documentation of this file.
00001 /* DocStream.c: Display complete HTML document using IFRAME */
00002 
00003 #include <stdio.h>
00004 #include <stdlib.h>
00005 
00006 int main(void)
00007 {
00008   char ch;
00009   char* cookie;
00010 
00011   cookie = getenv("LTERM_COOKIE");  /* Get security cookie */
00012   if (cookie == NULL)
00013     cookie = "";
00014 
00015   /* XMLTerm escape sequence signalling start of a HTML document */
00016   printf("\033{1S%s\n", cookie);
00017 
00018   printf(" <HTML><BODY> \
00019 <FORM> \
00020 <IMG align=center src='chrome://navigator/skin/animthrob_single.gif'> \
00021    <B>Please click a button</B> <BR> \
00022 <INPUT ID='button-b#' TYPE=button VALUE='Bold' \
00023   onClick=\"return HandleEvent(event, 'click', 'sendln','#','b')\"> \
00024 <INPUT ID='button-e#' TYPE=button VALUE='Emphasis' \
00025   onClick=\"return HandleEvent(event, 'click', 'sendln','#','e')\"> \
00026 <INPUT ID='button-q#' TYPE=button VALUE='Quit' \
00027   onClick=\"return HandleEvent(event, 'click', 'sendln','#','q')\"> \
00028 <BR></FORM> \
00029 </BODY></HTML>");
00030 
00031   /* XMLTerm escape sequence signalling end of stream */
00032   printf("%c", '\0');
00033 
00034   while((ch = getchar())){ /* Poll for data generated by button click events */
00035     switch (ch) {
00036     case 'b':
00037       printf("\033{S%s\n<B>Hello World!</B><BR> %c", cookie, '\0');
00038       break;
00039     case 'e':
00040       printf("\033{S%s\n<EM>Hello World!</EM><BR> %c", cookie, '\0');
00041       break;
00042     case 'q':
00043       return 0;
00044       break;
00045     default:
00046       break;
00047     }
00048   }
00049 
00050   return 0;
00051 }