Back to index

lightning-sunbird  0.9+nobinonly
HelloWorld.c
Go to the documentation of this file.
00001 /* HelloWorld.c: Simple demo program for "pagelets" */
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   printf("\033{S%s\n", cookie);  /* Escape sequence for start of HTML frag */
00016 
00017   printf("<FORM> \
00018 <IMG align=center src='chrome://navigator/skin/animthrob_single.gif'> \
00019    <B>Please click a button</B> <BR> \
00020 <INPUT ID='button-b#' TYPE=button VALUE='Bold' \
00021   onClick=\"return HandleEvent(event, 'click', 'sendln','#','b')\"> \
00022 <INPUT ID='button-e#' TYPE=button VALUE='Emphasis' \
00023   onClick=\"return HandleEvent(event, 'click', 'sendln','#','e')\"> \
00024 <INPUT ID='button-q#' TYPE=button VALUE='Quit' \
00025   onClick=\"return HandleEvent(event, 'click', 'sendln','#','q')\"> \
00026 <BR></FORM>");
00027 
00028   printf("%c", '\0');              /* Escape sequence signalling end of HTML */
00029 
00030   while((ch = getchar())){ /* Poll for data generated by button click events */
00031     switch (ch) {
00032     case 'b':
00033       printf("\033{S%s\n<B>Hello World!</B><BR> %c", cookie, '\0');
00034       break;
00035     case 'e':
00036       printf("\033{S%s\n<EM>Hello World!</EM><BR> %c", cookie, '\0');
00037       break;
00038     case 'q':
00039       return 0;
00040       break;
00041     default:
00042       break;
00043     }
00044   }
00045 
00046   printf("\033{1E\n");       /* Enable input echo */
00047 
00048   return 0;
00049 }