1Reading GET vars
This example will show reading GET vars.
Bitty HTTP stores GET vars in a block of RAM as the headers are processed. This means it needs to know the names of all the GET vars before the page is requested. This is done by filling in the struct WSPageProp.Gets variable when the page properties are requested.
The Gets property is an array of pointers to strings with the last one being set to NULL to mark the end of the list. This list is scanned when the page is requested and the value of any vars in this list are added to a RAM array.
You then call WS_GET() to get the value that was saved (or NULL if it wasn't found).
Using things this way means a low memory foot print as we only remember vars that we are going to pull out later.
The file server is changed to provide a form on the root page and a new page to display the values from the form.
We add a list of GET vars that we may want to read when processing a page later. We end the list with NULL to mark the end of the list. The code will loop though this list looking for a NULL entry to stop at.
When a match is made the value of the var will be copied to an internal RAM buffer.
A new page has been added called /Display.html that will display what the user has typed into the form from the root page. This includes a pointer to the GetArgs as the 4'th argument.
This now just outputs a basic form with a get method asking the user for their name and going to /Display.html.
File_Display() uses WS_GET() to read out the get vars from internal RAM. You call it with the name of the GET var to read. This name also has to be in the GetArgs array as well.
If WS_GET() does not find the var (because it wasn't passed in) it returns NULL.
It WS_GET() does find the var then it returns a string pointer to the value that was read.