Palm OS Web Application Developer's Guide: Developing and Delivering PQAs with Web Clipping

Sticking to the age-old tradition, we will start with a program that will fetch a hello.txt file from a Web server. The source code for the program (see Figure 11.1) is available on the CD that accompanies this book. Project files for CodeWarrior and Falch.Net DevStudio are also provided on the CD. If you prefer using the GNU Compiler Collection (GCC) from a command-line environment, ignore the project files and directly compile the Hello_World.c file instead. Create a file named hello.txt in your Web directory and update the URL given in the source code, then make sure that the URL is correct using a desktop browser like Internet Explorer. If you prefer to use the precompiled Palm resource (PRC) file given, you may do so, provided that the URL given in the listing is accessible from your desktop.
#include#include #include #include "Hello_World_res.h"#define MAX_RESPONSE_SIZE 4096#define HandleError(err) ErrFatalDisplayIf(err != 0, "Error!")// Replace this line with the URL of your hello.htm file#define SERVER_URL "http://www.unwiredwidgets.com/hello.txt"INetConfigNameType cfgName = { inetCfgNameCTPDefault };UInt32 PilotMain(UInt16 cmd, void *cmdPBP, UInt16 launchFlags){ Err error; UInt16 cfgIndex, libRefNum; // Reference # INet lib. MemHandle inetHan, inetSockH; Char *responsePtr; UInt32 totalBytes, bytesRead, reqestedBytes, offset = 0; UInt32 ...