#ifndef _w3a_h_
#define _w3a_h_

/*
 * Include file for the W3A (World-Wide Web Applets) API.
 *
 * Version: 0.0
 * Date: 21 July 1994
 * Author: Bert Bos <bert@let.rug.nl>
 */

#include <sys/types.h>
#ifndef NO_X11					/* W3A for X uses Widgets */
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#define W3AWindow Widget
#else
#define W3AWindow void*
#endif

/*
 * Booleans. Some functions return TRUE or FALSE to indicate
 * succes/failure
 */

#ifndef Bool
#define Bool int
#endif
#ifndef TRUE
#define TRUE (1)
#endif
#ifndef FALSE
#define FALSE (0)
#endif

/*
 * Extra values for errno
 */

#define EURL 2001				/* Syntax error in URL */
#define EMETHOD 2002				/* Illegal method */
#define ENYI 2003				/* Not yet implemented */
#define ETYPE 2004				/* No applet for this type */
#define EFORMAT 2005				/* Error in data */
#define EUSER 2006				/* Interrupted by user */

/*
 * The following constants define the four methods that are used in
 * HTTP requests. Other protocols usually support methods that can be
 * mapped to one or more of these. E.g., Gopher supports only GET,
 * while NNTP supports GET, DELETE and POST.
 */

#define GET_METHOD 0
#define PUT_METHOD 1
#define POST_METHOD 2
#define DELETE_METHOD 3
#define HEAD_METHOD 4

/*
 * Experimental event types. Only code 1 is described in the W3A draft
 * standard. Code 5000 is even more experimental. Currently is is used
 * in my HTML-3.0, GIF and XPM viewers.
 *
 *    1 = W3Aprocess succeeded; argument: pointer to W3ADocumentInfo struct
 * 5000 = user clicked on image; argument pointer to struct {int x, y;}
 */

#define NEW_DOCUMENT 1
#define POINT_SELECT 5000
 
/*
 * W3ADocumentInfo is a struct that can be used to describe a
 * document. The applet functions info*() should allocate the strings
 * on the heap.
 */

typedef struct {
    char *url;
    char *mime_type;
    char *mime_params;
    char *title;
    char *referer;
    char *status;
    char *location;				/* If status = "302..." */
    long size;
} W3ADocumentInfo;

/*
 * W3ABrowserInfo is a struct that describes the browser and the
 * formats that it can handle. Each format has an associated
 * preference value between 0.0 and 1.0. HTTP servers that can serve
 * multiple formats of the same document use this information to
 * decide which format to send.
 */

typedef struct {
    char *version;				/* Name and version */
    int nformats;				/* # of accepted formats */
    char **formats;				/* List of MIME types */
    float *preferences;				/* Each in <0,1] */
} W3ABrowserInfo;

/*
 * Each browser should implement the following functions:
 */

Bool W3Aprocess(W3ADocumentInfo *, int, const char *, size_t);
long W3Asubprocess(W3ADocumentInfo *, int, const char *, size_t, W3AWindow);
int W3AopenDoc(const char *, int method, int, const char *);
Bool W3AinfoDoc(int, W3ADocumentInfo *);
int W3AreadDoc(int, char *, size_t);
int W3AwriteDoc(int, const char *, size_t);
Bool W3AcloseDoc(int);
long W3AopenView(const W3ADocumentInfo, W3AWindow);
int W3AwriteView(long, const char *, size_t);
Bool W3AcloseView(long);
int W3AresolveURN(const char *, char ***);
void W3AbrowserInfo(W3ABrowserInfo *);
void W3Aevent(long id, long eventtype, void *param);
W3AWindow W3Atoplevel(void);

/*
 * Types in terms of which the initXXX functions for
 * user-functions are defined. IconArray3 represents
 * an array of three icons, each icon being an array
 * of strings, as defined by XPM.
 */
typedef char **RawIconData;			/* A single XPM pixmap */
typedef RawIconData ThreeIcons[3];		/* Array of 3 XPM pixmaps */


#endif /* _w3a_h_ */
