Home Projects Redmine Issues

interos gitweb

Initial commit
[interos.git] / c / main_interos.com_ssl.c
1 /*************************************************/
2 /*  interos Standard Document Header - CGI in C  */
3 /*************************************************/
4 /*         URIs:  https://interos.com/           */
5 /*                https://interos.com/main       */
6 /*                https://www.interos.com/       */
7 /*                https://www.interos.com/main   */
8 /*       Source:  main.c                         */
9 /*  Description:  FastCGI for interos main       */
10 /*       Author:  Brent Angeline                 */
11 /*          CGI:  FastCGI in ISO/ANSI C          */
12 /*************************************************/
14 /* PREPROCESSOR DIRECTIVES */
15 #include "fcgi_stdio.h"     /*  FCGI_Accept(), fclose(), fgetc(), fopen(), printf()                                 */
16 #include "interos.h"        /*  DIRECTORY, INT, MAX_PASSWORD_SIZE, MENU_ITEM, PASSWORD_FILE_NAME, SYSTEM_DIRECTORY  */
17 #include <stdlib.h>         /*  free(), getenv(), malloc()                                                          */
18 #include <string.h>         /*  strcat(), strcmp(), strcpy(), strlen()                                              */
19 #include <unistd.h>         /*  F_OK, access()                                                                      */
21 #ifndef INTEROS_H
23   /* TYPE DEFINITION */
24   typedef struct {
25     char *name;
26     char *link;
27     char *icon;
28     struct MENU_ITEM *next;
29   } MENU_ITEM;
31 #endif
33 /* FUNCTION PROTOTYPE DECLARATIONS */
34 static void RedirectToLoginPanel(void);
35 static void OutputGUI(const char *variableName, char *variableValue);
36 static void OutputNewMenu(void);
37 static void OutputOpenMenu(char *open);
38 static void OutputNextMenu(char *next);
39 static void OutputSettingsMenu(char *settings);
40 static void BeginXHTMLOutput(void);
41 static void FinishXHTMLOutput(void);
43 /* BEGIN MAIN PROGRAM */
44 int main(void) {
46   /* BEGIN FASTCGI */
47   while (FCGI_Accept() >= 0) {
49     /* IF COOKIE DATA DOESN'T EXIST OR IS TOO LONG... */
50     if (!getenv("HTTP_COOKIE") || (sizeof(strlen(getenv("HTTP_COOKIE"))) > sizeof(INT))) {
51       /** ERROR | COOKIE DATA DOES NOT EXIST OR IS TOO LONG > REDIRECT TO LOGIN PANEL **/
52       RedirectToLoginPanel();
54     /* OTHERWISE, IF COOKIE DATA DOES EXIST AND IS OF ACCEPTABLE LENGTH... */
55     } else {
57       /* ATTEMPT TO ALLOCATE MEMORY FOR COOKIE VARIABLES */
58       char *cookie;
59       INT cookieLength = strlen(getenv("HTTP_COOKIE"));
60       if ((cookieLength < 1) || !(cookie = malloc(cookieLength + 1))) {
61         /** ERROR | CRUCIAL MEMORY ALLOCATION ERROR FOR COOKIE DATA! > REDIRECT TO LOGIN PANEL **/
62         RedirectToLoginPanel();
63       } else {
64         char *variableName;
65         if (!(variableName = malloc(cookieLength + 1))) {
66           /** ERROR | CANNOT ALLOCATE MEMORY FOR COOKIE VARIABLE NAME > REDIRECT TO LOGIN PANEL **/
67           RedirectToLoginPanel();
68         } else {
69           char *variableValue;
70           if (!(variableValue = malloc(cookieLength + 1))) {
71             /** ERROR | CANNOT ALLOCATE MEMORY FOR COOKIE VARIABLE VALUE > REDIRECT TO LOGIN PANEL **/
72             RedirectToLoginPanel();
74           /* IF SUFFICIENT MEMORY FOR COOKIE VARIABLES... */
75           } else {
77             /* PROCESS COOKIE DATA */
78             char *login, *password;
79             INT c, i;
80             login = password = NULL;
81             c = 0;
82             strcpy(cookie, getenv("HTTP_COOKIE"));
83             while ((c < cookieLength) && (cookie[c] != '\0')) {
84               i = 0;
85               while ((c < cookieLength) && (cookie[c] != '=') && (cookie[c] != '\0')) {
86                 variableName[i] = cookie[c];
87                 ++c;
88                 ++i;
89               }
90               variableName[i] = '\0';
91               ++c;
92               i = 0;
93               while ((c < cookieLength) && (cookie[c] != ';') && (cookie[c] != '\0')) {
94                 variableValue[i] = cookie[c];
95                 ++c;
96                 ++i;
97               }
98               variableValue[i] = '\0';
99               ++c;
100               while ((c < cookieLength) && (cookie[c] == ' ')) {
101                 ++c;
102               }
103               if (!login && !strcmp(variableName, "login")) {
104                 if ((login = malloc(strlen(variableValue) + 1)) != 0) {
105                   strcpy(login, variableValue);
106                 }
107               } else if (!password && !strcmp(variableName, "password")) {
108                 if ((password = malloc(strlen(variableValue) + 1)) != 0) {
109                   strcpy(password, variableValue);
110                 }
111               }
112             }
114             /* IF LOGIN VALUE IS MISSING... */
115             if (!login) {
116               /** ERROR | LOGIN VALUE IS MISSING > REDIRECT TO LOGIN PANEL **/
117               RedirectToLoginPanel();
119             /* OTHERWISE, IF LOGIN VALUE EXISTS... */
120             } else {
122               /* VERIFY LOGIN AND PASSWORD */
123               char *directory;
124               if (!(directory = malloc(strlen(login) + strlen(DIRECTORY) + 1))) {
125                 /** ERROR | CANNOT ALLOCATE MEMORY FOR DIRECTORY NAME > REDIRECT TO LOGIN PANEL **/
126                 RedirectToLoginPanel();
127               } else {
128                 char *systemDirectory;
129                 if (!(systemDirectory = malloc(strlen(login) + strlen(SYSTEM_DIRECTORY) + 1))) {
130                   /** ERROR | CANNOT ALLOCATE MEMORY FOR SYSTEM DIRECTORY NAME > REDIRECT TO LOGIN PANEL **/
131                   RedirectToLoginPanel();
132                 } else {
133                   strcpy(directory, DIRECTORY);
134                   strcat(directory, login);
135                   strcpy(systemDirectory, SYSTEM_DIRECTORY);
136                   strcat(systemDirectory, login);
138                   /* IF DIRECTORY CAN'T BE ACCESSED... */
139                   if (access(directory, F_OK) || access(systemDirectory, F_OK)) {
140                     /** ERROR | CANNOT ACCESS DIRECTORY > REDIRECT TO LOGIN PANEL **/
141                     RedirectToLoginPanel();
143                   /* OTHERWISE, IF DIRECTORY CAN BE ACCESSED... */
144                   } else {
146                     /* ATTEMPT TO ACCESS PASSWORD FILE */
147                     char *passwordFileName;
148                     if (!(passwordFileName = malloc(strlen(systemDirectory) + strlen(PASSWORD_FILE_NAME) + 1))) {
149                       /** ERROR | CANNOT ALLOCATE MEMORY FOR FILE NAME > REDIRECT TO LOGIN PANEL **/
150                       RedirectToLoginPanel();
151                     } else {
152                       strcpy(passwordFileName, systemDirectory);
153                       strcat(passwordFileName, PASSWORD_FILE_NAME);
155                       /* IF PASSWORD FILE CAN'T BE ACCESSED... */
156                       if (access(passwordFileName, F_OK)) {
157                         /** ERROR | CANNOT ACCESS FILE > REDIRECT TO LOGIN PANEL **/
158                         RedirectToLoginPanel();
160                       /* OTHERWISE, IF PASSWORD FILE CAN BE ACCESSED... */
161                       } else {
163                         /* ATTEMPT TO OPEN PASSWORD FILE FOR READING */
164                         FILE *passwordFile;
166                         /* IF PASSWORD FILE CAN'T BE OPENED FOR READING... */
167                         if (!(passwordFile = fopen(passwordFileName, "r"))) {
168                           /** ERROR | CANNOT READ FILE > REDIRECT TO LOGIN PANEL **/
169                           RedirectToLoginPanel();
171                         /* OTHERWISE, IF PASSWORD FILE CAN BE OPENED FOR READING... */
172                         } else {
173                           char *filePassword;
174                           if (!(filePassword = malloc(MAX_PASSWORD_SIZE + 1))) {
175                             /** ERROR | CANNOT ALLOCATE MEMORY FOR PASSWORD FROM FILE > REDIRECT TO LOGIN PANEL **/
176                             RedirectToLoginPanel();
177                           } else {
178                             char c;
179                             i = 0;
181                             /* READ PASSWORD FROM PASSWORD FILE */
182                             while (((c = fgetc(passwordFile)) != '\n') && (i < MAX_PASSWORD_SIZE)) {
183                               filePassword[i] = c;
184                               ++i;
185                             }
186                             filePassword[i] = '\0';
187                             fclose(passwordFile);
189                             /* IF PASSWORD FAILS COMPARISON... */
190                             if (strcmp(filePassword, password)) {
191                               /** ERROR | PASSWORD FAILED > REDIRECT TO LOGIN PANEL **/
192                               RedirectToLoginPanel();
194                             /* OTHERWISE, IF PASSWORD PASSES COMPARISON... */
195                             } else {
197                               /* LOAD SETTINGS VALUES FROM FILE(S) */
199                               /* LOAD MENU ITEMS FROM FILES */
201                               /* READ NEW MENU FILE */
203                               /* READ OPEN MENU FILE */
205                               /* READ NEXT MENU FILE */
207                               /* READ SETTINGS MENU FILE */
209                               /* DECLARE AND INITIALIZE QUERY VARIABLES */
210                               char *menu, *new, *open, *next, *settings, *text_file, *status;
211                               menu = new = open = next = settings = text_file = status = NULL;
213                               /* IF QUERY DATA EXISTS AND IS OF ACCEPTABLE LENGTH... */
214                               if (getenv("QUERY_STRING") && (sizeof(strlen(getenv("QUERY_STRING"))) <= sizeof(INT))) {
215                                 char *query;
216                                 INT queryLength = strlen(getenv("QUERY_STRING"));
217                                 if ((queryLength < 1) || !(query = malloc(queryLength + 1))) {
218                                   /** ERROR | CRUCIAL MEMORY ALLOCATION ERROR FOR QUERY DATA! > CONTINUE WITHOUT QUERY **/
219                                 } else {
220                                   free(variableName);
221                                   strcpy(query, getenv("QUERY_STRING"));
222                                   if (!(variableName = malloc(queryLength + 1))) {
223                                     /** ERROR | CANNOT ALLOCATE MEMORY FOR VARIABLE NAME > CONTINUE WITHOUT QUERY **/
224                                   } else {
225                                     free(variableValue);
226                                     if (!(variableValue = malloc(queryLength + 1))) {
227                                       /** ERROR | CANNOT ALLOCATE MEMORY FOR VARIABLE VALUE > CONTINUE WITHOUT QUERY **/
229                                     /* IF SUFFICIENT MEMORY FOR QUERY VARIABLES... */
230                                     } else {
232                                       /* PROCESS QUERY DATA */
233                                       INT q = 0;
234                                       i = 0;
235                                       while ((q < queryLength) && (query[q] != '\0')) {
236                                         while ((q < queryLength) && (query[q] != '=') && (query[q] != '\0')) {
237                                           variableName[i] = query[q];
238                                           ++q;
239                                           ++i;
240                                         }
241                                         variableName[i] = '\0';
242                                         ++q;
243                                         i = 0;
244                                         while ((query[q] != '&') && (query[q] != '\0')) {
245                                           variableValue[i] = query[q];
246                                           ++q;
247                                           ++i;
248                                         }
249                                         variableValue[i] = '\0';
250                                         if (query[q] != '\0') {
251                                           ++q;
252                                         }
253                                         if (!menu && !strcmp(variableName, "menu")) {
254                                           if ((menu = malloc(strlen(variableValue) + 1)) != 0) {
255                                             strcpy(menu, variableValue);
256                                           }
257                                         } else if (!new && !strcmp(variableName, "new")) {
258                                           if ((new = malloc(strlen(variableValue) + 1)) != 0) {
259                                             strcpy(new, variableValue);
260                                           }
261                                         } else if (!open && !strcmp(variableName, "open")) {
262                                           if ((open = malloc(strlen(variableValue) + 1)) != 0) {
263                                             strcpy(open, variableValue);
264                                           }
265                                         } else if (!next && !strcmp(variableName, "next")) {
266                                           if ((next = malloc(strlen(variableValue) + 1)) != 0) {
267                                             strcpy(next, variableValue);
268                                           }
269                                         } else if (!settings && !strcmp(variableName, "settings")) {
270                                           if ((settings = malloc(strlen(variableValue) + 1)) != 0) {
271                                             strcpy(settings, variableValue);
272                                           }
273                                         } else if (!text_file && !strcmp(variableName, "text_file")) {
274                                           if ((text_file = malloc(strlen(variableValue) + 1)) != 0) {
275                                             strcpy(text_file, variableValue);
276                                           }
277                                         } else if (!status && !strcmp(variableName, "says")) {
278                                           if ((status = malloc(strlen(variableValue) + 1)) != 0) {
279                                             strcpy(status, variableValue);
280                                           }
281                                         }
282                                       }
283                                       free(variableValue);
284                                       variableValue = NULL;
285                                     }
286                                     free(variableName);
287                                     variableName = NULL;
288                                   }
289                                   free(query);
290                                 }
291                               }
293                               /* IF THIS IS A CONTINUED SESSION... */
295                                 /* LOAD SESSION FROM FILE */
297                               /* OUTPUT GUI COMPONENT(S) BASED ON VARIABLES */
298                               if (settings) {
299                                 OutputSettingsMenu(settings);
300                               } else if (new) {
301                                 if (!strcmp(new, "text_file")) {
302                                   OutputGUI("new", new);
303                                 } else {
304                                   OutputNewMenu();
305                                 }
306                               } else if (open) {
307                                 OutputOpenMenu(open);
308                               } else if (next) {
309                                 if (!strcmp(next, "save_as")) {
311                                 } else if (!strcmp(next, "save")) {
313                                 } else if (!strcmp(next, "close")) {
315                                 } else if (!strcmp(next, "bookmark")) {
317                                 } else if (!strcmp(next, "logout")) {
319                                   /* SET COOKIES */
320                                   printf("Set-Cookie: login=; path=/; secure\r\n");
321                                   printf("Set-Cookie: password=; path=/; secure\r\n");
323                                   /* REDIRECT TO LOGIN PANEL */
324                                   printf("Location: login\r\n\r\n");
325                                 } else if (status) {
326                                   OutputGUI("status", status);
327                                 } else {
328                                   OutputGUI(NULL, NULL);
329                                 }
330                               } else if (menu) {
331                                 if (!strcmp(menu, "settings")) {
332                                   OutputSettingsMenu(settings);
333                                 } else if (!strcmp(menu, "new")) {
334                                   OutputNewMenu();
335                                 } else if (!strcmp(menu, "open")) {
336                                   OutputOpenMenu(open);
337                                 } else if (!strcmp(menu, "next")) {
338                                   OutputNextMenu(next);
339                                 } else if (status) {
340                                   OutputGUI("status", status);
341                                 } else {
342                                   OutputGUI(NULL, NULL);
343                                 }
344                               } else if (text_file) {
345                                 OutputGUI("text_file", text_file);
346                               } else {
347                                 if (status) {
348                                   OutputGUI("status", status);
349                                 } else {
350                                   OutputGUI(NULL, NULL);
351                                 }
352                               }
353                               free(status);
354                               free(text_file);
355                               free(settings);
356                               free(next);
357                               free(open);
358                               free(new);
359                               free(menu);
360                             }
361                             free(filePassword);
362                           }
363                         }
364                       }
365                       free(passwordFileName);
366                     }
367                   }
368                   free(systemDirectory);
369                 }
370                 free(directory);
371               }
372               free(login);
373             }
374             free(password);
375             free(variableValue);
376           }
377           free(variableName);
378         }
379         free(cookie);
380       }
381     }
382   }
383   return 0;
386 /* FUNCTION | REDIRECT TO LOGIN PANEL */
387 static void RedirectToLoginPanel(void) {
388   printf("Location: login\r\n\r\n");
391 /* FUNCTION | OUTPUT XHTML FOR interos GRAPHICAL USER INTERFACE */
392 static void OutputGUI(const char *variableName, char *variableValue) {
393   BeginXHTMLOutput();
394   printf("<?xml-stylesheet type=\"text/css\" href=\"/style/main.css\"?>\n");
395   printf("<!DOCTYPE html SYSTEM \"http://interos.org/dtd/xhtml1-borderless-frameset.dtd\">\n");
396   printf("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en-US\" lang=\"en-US\">\n");
397   printf("  <!--========================================================-->\n");
398   printf("  <!--       interos Standard Document Header - Markup        -->\n");
399   printf("  <!--========================================================-->\n");
400   printf("  <!--    URIs:  https://interos.com/                         -->\n");
401   printf("  <!--           https://interos.com/main                     -->\n");
402   printf("  <!--           https://www.interos.com/                     -->\n");
403   printf("  <!--           https://www.interos.com/main                 -->\n");
404   printf("  <!--   Title:  interos                                      -->\n");
405   printf("  <!--  Author:  Brent Angeline                               -->\n");
406   printf("  <!--  Markup:  WDG-Validated XHTML 1.0 Borderless Frameset  -->\n");
407   printf("  <!--========================================================-->\n");
408   printf("  <head>\n");
409   printf("    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n");
410   printf("    <meta name=\"title\" content=\"interos\" />\n");
411   printf("    <meta name=\"description\" content=\"internet operating system\" />\n");
412   printf("    <meta name=\"author\" content=\"Brent Angeline\" />\n");
413   printf("    <meta name=\"copyright\" \n");
414   printf("          content=\"Copyright &copy; 2001-2010 Brent Angeline and interos LLC\" />\n");
415   printf("    <meta name=\"robots\" content=\"noindex, nofollow, noarchive\" />\n");
416   printf("    <title>interos</title>\n");
417   printf("    <link rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/favicon.ico\" />\n");
418   printf("    <link rel=\"icon\" type=\"image/gif\" href=\"/images/favicon.gif\" />\n");
419   printf("    <link rel=\"stylesheet\" type=\"text/css\" href=\"/style/main.css\" \n");
420   printf("          media=\"screen, projection\" />\n");
421   printf("    <script type=\"text/javascript\" src=\"/js/interos.js\"></script>\n");
422   printf("  </head>\n");
423   printf("  <frameset rows=\"72,*,72\" border=\"0\" frameborder=\"0\" framespacing=\"0\">\n");
424   printf("    <frame name=\"top\" src=\"/top\" \n");
425   printf("           frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" \n");
426   printf("           noresize=\"noresize\" scrolling=\"auto\" />\n");
427   if (variableName && variableValue) {
428     printf("    <frame name=\"content\" src=\"/content?%s=%s\" \n", variableName, variableValue);
429     printf("           frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" \n");
430     printf("           noresize=\"noresize\" scrolling=\"auto\" />\n");
431   } else {
432     printf("    <frame name=\"content\" src=\"/content\" \n");
433     printf("           frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" \n");
434     printf("           noresize=\"noresize\" scrolling=\"auto\" />\n");
435   }
436   printf("    <frame name=\"bottom\" src=\"/bottom\" \n");
437   printf("           frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" \n");
438   printf("           noresize=\"noresize\" scrolling=\"auto\" />\n");
439   printf("    <noframes>\n");
440   printf("      <body id=\"body\">\n");
441   printf("        <h3>\n");
442   printf("          menu\n");
443   printf("        </h3>\n");
444   printf("        <p>\n");
445   printf("          <a id=\"newLink\" href=\"/main?menu=new\">new</a>\n");
446   printf("        </p>\n");
447   printf("        <p>\n");
448   printf("          <a id=\"openLink\" href=\"/main?menu=open\">open</a>\n");
449   printf("        </p>\n");
450   printf("        <p>\n");
451   printf("          <a id=\"nextLink\" href=\"/main?menu=next\">next</a>\n");
452   printf("        </p>\n");
453   printf("        <p>\n");
454   printf("          <a id=\"settingsLink\" href=\"/main?menu=settings\">settings</a>");
455   printf("        </p>\n");
456   printf("      </body>\n");
457   printf("    </noframes>\n");
458   printf("  </frameset>\n");
459   FinishXHTMLOutput();
462 /* FUNCTION | OUTPUT XHTML FOR NEW MENU */
463 static void OutputNewMenu(void) {
464   BeginXHTMLOutput();
465   printf("<?xml-stylesheet type=\"text/css\" href=\"/style/main.css\"?>\n");
466   printf("<!DOCTYPE html SYSTEM \"http://interos.org/dtd/xhtml1-borderless-frameset.dtd\">\n");
467   printf("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en-US\" lang=\"en-US\">\n");
468   printf("  <!--========================================================-->\n");
469   printf("  <!--       interos Standard Document Header - Markup        -->\n");
470   printf("  <!--========================================================-->\n");
471   printf("  <!--    URIs:  https://interos.com/main?menu=new            -->\n");
472   printf("  <!--           https://interos.com/interos?menu=new         -->\n");
473   printf("  <!--           https://www.interos.com/main?menu=new        -->\n");
474   printf("  <!--           https://www.interos.com/interos?menu=new     -->\n");
475   printf("  <!--   Title:  interos new                                  -->\n");
476   printf("  <!--  Author:  Brent Angeline                               -->\n");
477   printf("  <!--  Markup:  WDG-Validated XHTML 1.0 Borderless Frameset  -->\n");
478   printf("  <!--========================================================-->\n");
479   printf("  <head>\n");
480   printf("    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n");
481   printf("    <meta name=\"title\" content=\"interos new\" />\n");
482   printf("    <meta name=\"description\" content=\"new menu for interos\" />\n");
483   printf("    <meta name=\"author\" content=\"Brent Angeline\" />\n");
484   printf("    <meta name=\"copyright\" \n");
485   printf("          content=\"Copyright &copy; 2001-2010 Brent Angeline and interos LLC\" />\n");
486   printf("    <meta name=\"robots\" content=\"noindex, nofollow, noarchive\" />\n");
487   printf("    <title>interos new</title>\n");
488   printf("    <link rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/favicon.ico\" />\n");
489   printf("    <link rel=\"icon\" type=\"image/gif\" href=\"/images/favicon.gif\" />\n");
490   printf("    <link rel=\"stylesheet\" type=\"text/css\" href=\"/style/main.css\" \n");
491   printf("          media=\"screen, projection\" />\n");
492   printf("    <script type=\"text/javascript\" src=\"/js/interos_new.js\"></script>\n");
493   printf("  </head>\n");
494   printf("  <frameset rows=\"*,72\" border=\"0\" frameborder=\"0\" framespacing=\"0\">\n");
495   printf("    <frame name=\"menu\" src=\"/menu?name=new\" \n");
496   printf("           frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" \n");
497   printf("           noresize=\"noresize\" scrolling=\"auto\" />\n");
498   printf("    <frame name=\"button\" src=\"/bottom?button=new\" \n");
499   printf("           frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" \n");
500   printf("           noresize=\"noresize\" scrolling=\"auto\" />\n");
501   printf("    <noframes>\n");
502   printf("      <body id=\"body\">\n");
503   printf("        <div id=\"newEntries\">\n");
504   printf("          <p>\n");
505   printf("            <a href=\"/main?new=text_file\">text file</a>\n");
506   printf("          </p>\n");
507   printf("        </div>\n");
508   printf("        <div id=\"newLink\"><a href=\"/main\">new</a></div>\n");
509   printf("      </body>\n");
510   printf("    </noframes>\n");
511   printf("  </frameset>\n");
512   FinishXHTMLOutput();
515 /* FUNCTION | OUTPUT XHTML FOR OPEN MENU */
516 static void OutputOpenMenu(char *open) {
517   BeginXHTMLOutput();
518   printf("<?xml-stylesheet type=\"text/css\" href=\"/style/main.css\"?>\n");
519   printf("<!DOCTYPE html SYSTEM \"http://interos.org/dtd/xhtml1-borderless-frameset.dtd\">\n");
520   printf("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en-US\" lang=\"en-US\">\n");
521   printf("  <!--========================================================-->\n");
522   printf("  <!--       interos Standard Document Header - Markup        -->\n");
523   printf("  <!--========================================================-->\n");
524   printf("  <!--    URIs:  https://interos.com/main?menu=open           -->\n");
525   printf("  <!--           https://interos.com/interos?menu=open        -->\n");
526   printf("  <!--           https://www.interos.com/main?menu=open       -->\n");
527   printf("  <!--           https://www.interos.com/interos?menu=open    -->\n");
528   printf("  <!--   Title:  interos open                                 -->\n");
529   printf("  <!--  Author:  Brent Angeline                               -->\n");
530   printf("  <!--  Markup:  WDG-Validated XHTML 1.0 Borderless Frameset  -->\n");
531   printf("  <!--========================================================-->\n");
532   printf("  <head>\n");
533   printf("    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n");
534   printf("    <meta name=\"title\" content=\"interos open\" />\n");
535   printf("    <meta name=\"description\" content=\"open menu for interos\" />\n");
536   printf("    <meta name=\"author\" content=\"Brent Angeline\" />\n");
537   printf("    <meta name=\"copyright\" \n");
538   printf("          content=\"Copyright &copy; 2001-2010 Brent Angeline and interos LLC\" />\n");
539   printf("    <meta name=\"robots\" content=\"noindex, nofollow, noarchive\" />\n");
540   printf("    <title>interos open</title>\n");
541   printf("    <link rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/favicon.ico\" />\n");
542   printf("    <link rel=\"icon\" type=\"image/gif\" href=\"/images/favicon.gif\" />\n");
543   printf("    <link rel=\"stylesheet\" type=\"text/css\" href=\"/style/main.css\" \n");
544   printf("          media=\"screen, projection\" />\n");
545   printf("    <script type=\"text/javascript\" src=\"/js/interos_open.js\"></script>\n");
546   printf("  </head>\n");
547   printf("  <frameset rows=\"72,*\" border=\"0\" frameborder=\"0\" framespacing=\"0\">\n");
548   printf("    <frame name=\"button\" src=\"/top?button=open\" \n");
549   printf("           frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" \n");
550   printf("           noresize=\"noresize\" scrolling=\"auto\" />\n");
551   if (open) {
552     if (!strcmp(open, "text_file")) {
553       printf("    <frame name=\"menu\" src=\"/menu?open=text_file\" \n");
554       printf("           frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" \n");
555       printf("           noresize=\"noresize\" scrolling=\"auto\" />\n");
556     } else {
557       printf("    <frame name=\"menu\" src=\"/menu?name=open\" \n");
558       printf("           frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" \n");
559       printf("           noresize=\"noresize\" scrolling=\"auto\" />\n");
560     }
561   } else {
562     printf("    <frame name=\"menu\" src=\"/menu?name=open\" \n");
563     printf("           frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" \n");
564     printf("           noresize=\"noresize\" scrolling=\"auto\" />\n");
565   }
566   printf("    <noframes>\n");
567   printf("      <body id=\"body\">\n");
568   printf("        <div id=\"openLink\"><a href=\"/main\">open</a></div>\n");
569   printf("        <div id=\"openEntries\">\n");
570   printf("          <p><a href=\"/main?open=text_file\">text file</a></p>\n");
571   printf("        </div>\n");
572   printf("      </body>\n");
573   printf("    </noframes>\n");
574   printf("  </frameset>\n");
575   FinishXHTMLOutput();
578 /* FUNCTION | OUTPUT XHTML FOR NEXT MENU */
579 static void OutputNextMenu(char *next) {
580   BeginXHTMLOutput();
581   printf("<?xml-stylesheet type=\"text/css\" href=\"/style/main.css\"?>\n");
582   printf("<!DOCTYPE html SYSTEM \"http://interos.org/dtd/xhtml1-borderless-frameset.dtd\">\n");
583   printf("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en-US\" lang=\"en-US\">\n");
584   printf("  <!--========================================================-->\n");
585   printf("  <!--       interos Standard Document Header - Markup        -->\n");
586   printf("  <!--========================================================-->\n");
587   printf("  <!--    URIs:  https://interos.com/main?menu=next           -->\n");
588   printf("  <!--           https://interos.com/interos?menu=next        -->\n");
589   printf("  <!--           https://www.interos.com/main?menu=next       -->\n");
590   printf("  <!--           https://www.interos.com/interos?menu=next    -->\n");
591   printf("  <!--   Title:  interos next                                 -->\n");
592   printf("  <!--  Author:  Brent Angeline                               -->\n");
593   printf("  <!--  Markup:  WDG-Validated XHTML 1.0 Borderless Frameset  -->\n");
594   printf("  <!--========================================================-->\n");
595   printf("  <head>\n");
596   printf("    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n");
597   printf("    <meta name=\"title\" content=\"interos next\" />\n");
598   printf("    <meta name=\"description\" content=\"next menu for interos\" />\n");
599   printf("    <meta name=\"author\" content=\"Brent Angeline\" />\n");
600   printf("    <meta name=\"copyright\" \n");
601   printf("          content=\"Copyright &copy; 2001-2010 Brent Angeline and interos LLC\" />\n");
602   printf("    <meta name=\"robots\" content=\"noindex, nofollow, noarchive\" />\n");
603   printf("    <title>interos next</title>\n");
604   printf("    <link rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/favicon.ico\" />\n");
605   printf("    <link rel=\"icon\" type=\"image/gif\" href=\"/images/favicon.gif\" />\n");
606   printf("    <link rel=\"stylesheet\" type=\"text/css\" href=\"/style/main.css\" \n");
607   printf("          media=\"screen, projection\" />\n");
608   printf("    <script type=\"text/javascript\" src=\"/js/interos_next.js\"></script>\n");
609   printf("  </head>\n");
610   printf("  <frameset rows=\"72,*\" border=\"0\" frameborder=\"0\" framespacing=\"0\">\n");
611   printf("    <frame name=\"button\" src=\"/top?button=next\" \n");
612   printf("           frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" \n");
613   printf("           noresize=\"noresize\" scrolling=\"auto\" />\n");
614   printf("    <frame name=\"menu\" src=\"/menu?name=next\" \n");
615   printf("           frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" \n");
616   printf("           noresize=\"noresize\" scrolling=\"auto\" />\n");
617   printf("    <noframes>\n");
618   printf("      <body id=\"body\">\n");
619   printf("        <div id=\"nextLink\"><a href=\"/main\">next</a></div>\n");
620   printf("        <div id=\"nextEntries\">\n");
621   printf("          <p><a href=\"/logout\">logout</a></p>\n");
622   printf("        </div>\n");
623   printf("      </body>\n");
624   printf("    </noframes>\n");
625   printf("  </frameset>\n");
626   FinishXHTMLOutput();
629 /* FUNCTION | OUTPUT XHTML FOR SETTINGS MENU */
630 void OutputSettingsMenu(char *settings) {
631   BeginXHTMLOutput();
632   printf("<?xml-stylesheet type=\"text/css\" href=\"/style/main.css\"?>\n");
633   printf("<!DOCTYPE html SYSTEM \"http://interos.org/dtd/xhtml1-borderless-frameset.dtd\">\n");
634   printf("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en-US\" lang=\"en-US\">\n");
635   printf("  <!--==========================================================-->\n");
636   printf("  <!--        interos Standard Document Header - Markup         -->\n");
637   printf("  <!--==========================================================-->\n");
638   printf("  <!--    URIs:  https://interos.com/main?menu=settings         -->\n");
639   printf("  <!--           https://interos.com/interos?menu=settings      -->\n");
640   printf("  <!--           https://www.interos.com/menu?menu=settings     -->\n");
641   printf("  <!--           https://www.interos.com/interos?menu=settings  -->\n");
642   printf("  <!--   Title:  interos settings                               -->\n");
643   printf("  <!--  Author:  Brent Angeline                                 -->\n");
644   printf("  <!--  Markup:  WDG-Validated XHTML 1.0 Borderless Frameset    -->\n");
645   printf("  <!--==========================================================-->\n");
646   printf("  <head>\n");
647   printf("    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n");
648   printf("    <meta name=\"title\" content=\"interos - settings\" />\n");
649   printf("    <meta name=\"description\" content=\"interos settings menu\" />\n");
650   printf("    <meta name=\"author\" content=\"Brent Angeline\" />\n");
651   printf("    <meta name=\"copyright\" \n");
652   printf("          content=\"Copyright &copy; 2001-2010 Brent Angeline and interos LLC\" />\n");
653   printf("    <meta name=\"robots\" content=\"noindex, nofollow, noarchive\" />\n");
654   printf("    <title>interos settings</title>\n");
655   printf("    <link rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/favicon.ico\" />\n");
656   printf("    <link rel=\"icon\" type=\"image/gif\" href=\"/images/favicon.gif\" />\n");
657   printf("    <link rel=\"stylesheet\" type=\"text/css\" href=\"/style/main.css\" \n");
658   printf("          media=\"screen, projection\" />\n");
659   printf("    <script type=\"text/javascript\" src=\"/js/interos_settings.js\"></script>\n");
660   printf("  </head>\n");
661   printf("  <frameset rows=\"*,72\" border=\"0\" frameborder=\"0\" framespacing=\"0\">\n");
662   printf("    <frame name=\"menu\" src=\"/menu?name=settings\" \n");
663   printf("           frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" \n");
664   printf("           noresize=\"noresize\" scrolling=\"auto\" />\n");
665   printf("    <frame name=\"button\" src=\"/bottom?button=settings\" \n");
666   printf("           frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" \n");
667   printf("           noresize=\"noresize\" scrolling=\"auto\" />\n");
668   printf("    <noframes>\n");
669   printf("      <body id=\"body\">\n");
670   printf("        <div id=\"settingsEntries\">\n");
671   printf("          <p><a href=\"/main?settings=button_size\">button size</a></p>\n");
672   printf("        </div>\n");
673   printf("        <div id=\"settingsLink\"><a href=\"/main\">settings</a></div>\n");
674   printf("      </body>\n");
675   printf("    </noframes>\n");
676   printf("  </frameset>\n");
677   FinishXHTMLOutput();
680 static void BeginXHTMLOutput(void) {
681   printf("Content-Type: text/html; charset=utf-8\r\n\r\n");
682   printf("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
685 static void FinishXHTMLOutput(void) {
686   printf("  <!--=====================================================================-->\n");
687   printf("  <!--                  Copyright and Trademark Statement                  -->\n");
688   printf("  <!--=====================================================================-->\n");
689   printf("  <!--                                                                     -->\n");
690   printf("  <!--          All original textual and graphical site content:           -->\n");
691   printf("  <!--                                                                     -->\n");
692   printf("  <!--  Copyright 2001-2010 Brent Angeline and interos LLC.  All rights    -->\n");
693   printf("  <!--  reserved.  Reproduction in whole or in part without written        -->\n");
694   printf("  <!--  permission is prohibited.  interos and the interos logos are       -->\n");
695   printf("  <!--  trademarks of Brent Angeline and interos LLC.  All other company,  -->\n");
696   printf("  <!--  product, and service names mentioned herein may be the properties  -->\n");
697   printf("  <!--  of their respective owners.  Comments in the interos.org forums    -->\n");
698   printf("  <!--  are the properties of their respective authors.  All software      -->\n");
699   printf("  <!--  developed in the forums is open source and belongs to everyone.    -->\n");
700   printf("  <!--                                                                     -->\n");
701   printf("  <!--=====================================================================-->\n");
702   printf("  <!--                      e-mail: info@interos.com                       -->\n");
703   printf("  <!--=====================================================================-->\n");
704   printf("</html>");
707 /***********************************************************************/
708 /*                  Copyright and Trademark Statement                  */
709 /***********************************************************************/
710 /*                                                                     */
711 /*          All original textual and graphical site content:           */
712 /*                                                                     */
713 /*  Copyright 2001-2010 Brent Angeline and interos LLC.  All rights    */
714 /*  reserved.  Reproduction in whole or in part without written        */
715 /*  permission is prohibited.  interos and the interos logos are       */
716 /*  trademarks of Brent Angeline and interos LLC.  All other company,  */
717 /*  product, and service names mentioned herein may be the properties  */
718 /*  of their respective owners.  Comments in the interos.org forums    */
719 /*  are the properties of their respective authors.  All software      */
720 /*  developed in the forums is open source and belongs to everyone.    */
721 /*                                                                     */
722 /***********************************************************************/
723 /*                      e-mail: info@interos.com                       */
724 /***********************************************************************/