****************************************************************** *** WEBGET BASIC API FOR GUI-SCREENIO *** *** *** This api A simple request to a web server and recieves *** *** the reply. It makes no attempt to intrepret the content *** *** or follow links or anything else. That's up to you, to *** *** do using multiple calls and repetitive fetches. We do not *** *** intend this to be a web browser, just a simple document *** *** fetch. *** *** Included in the sent request will be a minimum of headers *** *** and in addition, the USER-AGENT: header will specifying *** *** your GUI-ScreenIO serial number. NORCOM does not want *** *** to receive Denial Of Service complaints due to use of this*** *** software. *** *** *** ****************************************************************** * To use: * * COPY WIN32API. * COPY WEBGET. * 01 MY-WEB-PAGE-BUFFER PIC X(32000). * 01 DUMMY PIC X. * . * . * . * ------------------------: Load the data specifying the request. * : Note the sample text below is not * : complete and serves as only one * : possible way of loading the data. * MOVE 'www.screenio.com' TO WEBGET-HOST-NAME * : Usefull to identify your request in * : Server logs. Will be appended to * : "GUI ScreenIO" * MOVE 'My Application Name' TO WEBGET-USER-AGENT * MOVE '/index.html' TO WEBGET-PAGE-NAME * MOVE LENGTH OF MY-BUFFER TO WEBGET-BUFFER-SIZE * MOVE LOW-VALUES TO MY-WEB-PAGE-BUFFER * * ------------------------: Call the API to GET the page * * SET FUNC-GETWEBPAGE TO TRUE. * CALL 'GSWINAPI' USING WIN32API-PARMS * WEBGET-PARMS * MY-WEB-PAGE-BUFFER * DUMMY * DUMMY * DUMMY * DUMMY. * * ------------------------: If function failed, * : display a textual error message. * * IF WIN32API-FAILED * MOVE WIN32API-ERROR-TEXT TO my-error-message * do whatever to display my-error-message. * * * : If function succeeded, the data will * : appear in MY-WEB-PAGE-BUFFER * : Note that data from web servers is * : preceeded by some information from * : the server, and your actual content * : will appear following the occurance * : of two consecutive CRLF pairs. * : X'0D0A0D0A'. Info from the server * : varies from one server to the next. * : Some return a Content-Length header * : others don't. ****************************************************************** 01 WEBGET-PARMS. * : Server Name or IP 05 WEBGET-HOST-NAME PIC X(50) VALUE SPACE. * * : What you want appended to User Agent * : Form: any text string. * : Embedded, but not trailing space * : are allowed. 05 WEBGET-USER-AGENT PIC X(20) VALUE SPACE. * : Set this to the size of your * : data buffer (my-web-page-buffer in * : example above). Any additional * : data will be flushed. You should * : initialize the buffer to low-values. * --> : NOTE: upon return this will be set * : to the number of bytes actually * : returned. 05 WEBGET-BUFFER-SIZE PIC S9(9) COMP-5 VALUE ZERO. * : Change this only if web server is on * : a nonstandard port. 1-65535. 05 WEBGET-PORT-NUMBER-X. 10 WEBGET-PORT-NUMBER PIC 9(9) COMP-5 VALUE 80. * * : The name of the page starting at the * : web root. Case sensitive. * : Embedded, but not trailing space * : are allowed. 05 WEBGET-PAGE-NAME PIC X(1000) VALUE SPACE.