| 1 |
function SetUpServer() { |
| 2 |
TopHeader = "<HTML><title>Remote Configuration</title>" |
| 3 |
TopDoc = "<BODY>\ |
| 4 |
<h2>Please choose one of the following actions:</h2>\ |
| 5 |
<UL>\ |
| 6 |
<LI><A HREF=" MyPrefix "/AboutServer>About this server</A></LI>\ |
| 7 |
<LI><A HREF=" MyPrefix "/ReadConfig>Read Configuration</A></LI>\ |
| 8 |
<LI><A HREF=" MyPrefix "/CheckConfig>Check Configuration</A></LI>\ |
| 9 |
<LI><A HREF=" MyPrefix "/ChangeConfig>Change Configuration</A></LI>\ |
| 10 |
<LI><A HREF=" MyPrefix "/SaveConfig>Save Configuration</A></LI>\ |
| 11 |
</UL>" |
| 12 |
TopFooter = "</BODY></HTML>" |
| 13 |
if (ConfigFile == "") ConfigFile = "config.asc" |
| 14 |
} |
| 15 |
function HandleGET() { |
| 16 |
if (MENU[2] == "AboutServer") { |
| 17 |
Document = "This is a GUI for remote configuration of an\ |
| 18 |
embedded system. It is is implemented as one GAWK script." |
| 19 |
} else if (MENU[2] == "ReadConfig") { |
| 20 |
RS = "\n" |
| 21 |
while ((getline < ConfigFile) > 0) |
| 22 |
config[$1] = $2; |
| 23 |
close(ConfigFile) |
| 24 |
RS = "\r\n" |
| 25 |
Document = "Configuration has been read." |
| 26 |
} else if (MENU[2] == "CheckConfig") { |
| 27 |
Document = "<TABLE BORDER=1 CELLPADDING=5>" |
| 28 |
for (i in config) |
| 29 |
Document = Document "<TR><TD>" i "</TD>" \ |
| 30 |
"<TD>" config[i] "</TD></TR>" |
| 31 |
Document = Document "</TABLE>" |
| 32 |
} else if (MENU[2] == "ChangeConfig") { |
| 33 |
if ("Param" in GETARG) { # any parameter to set? |
| 34 |
if (GETARG["Param"] in config) { # is parameter valid? |
| 35 |
config[GETARG["Param"]] = GETARG["Value"] |
| 36 |
Document = (GETARG["Param"] " = " GETARG["Value"] ".") |
| 37 |
} else { |
| 38 |
Document = "Parameter <b>" GETARG["Param"] "</b> is invalid." |
| 39 |
} |
| 40 |
} else { |
| 41 |
Document = "<FORM method=GET><h4>Change one parameter</h4>\ |
| 42 |
<TABLE BORDER CELLPADDING=5>\ |
| 43 |
<TR><TD>Parameter</TD><TD>Value</TD></TR>\ |
| 44 |
<TR><TD><input type=text name=Param value=\"\" size=20></TD>\ |
| 45 |
<TD><input type=text name=Value value=\"\" size=40></TD>\ |
| 46 |
</TR></TABLE><input type=submit value=\"Set\"></FORM>" |
| 47 |
} |
| 48 |
} else if (MENU[2] == "SaveConfig") { |
| 49 |
for (i in config) |
| 50 |
printf("%s %s\n", i, config[i]) > ConfigFile |
| 51 |
close(ConfigFile) |
| 52 |
Document = "Configuration has been saved." |
| 53 |
} |
| 54 |
} |