DEFINITION HTTPDocs0; (* portable *)

 IMPORT Objects, Texts, HyperDocs, Oberon, Attributes, Documents;

 CONST
  DefPort = 80;

 TYPE
  ObjList = POINTER TO ObjListDesc;
  ObjListDesc = RECORD
   obj: Objects.Object;
   next: ObjList
  END;

  Context = POINTER TO ContextDesc;
  ContextDesc = RECORD ( HyperDocs.ContextDesc ) 
   query: Texts.Text;
   method: ARRAY 8 OF CHAR;
   user, passwd: ARRAY 64 OF CHAR
  END;

  Entry = POINTER TO EntryDesc;
  Worker = POINTER TO WorkerDesc;
  EntryDesc = RECORD
   basekey, key, pos: LONGINT;
   attrs: Attributes.Attr;
   text: Texts.Text;
   ol: ObjList;
   obj: Objects.Object;
   next, same: Entry;
   doc: Documents.Document;
   working: Worker
  END;

  WorkerDesc = RECORD ( Oberon.TaskDesc ) 
   entry: Entry;
   state: INTEGER;
   local: BOOLEAN
  END;

  Proxy = POINTER TO ProxyDesc;
  ProxyDesc = RECORD
   host: ARRAY 64 OF CHAR;
   port: INTEGER
  END;

 VAR 
  entries: Entry;
  ImgHandle: Objects.Handler;
  curNode: HyperDocs.Node;
  httpProxy: Proxy;
  requestDoc: PROCEDURE (D: Documents.Document; proxy: Proxy; VAR key: LONGINT; method: ARRAY OF CHAR; main: BOOLEAN; E: Entry; query: Texts.Text);
 PROCEDURE StripLoc (key: LONGINT): LONGINT;

(* Register a new http url. *)
 PROCEDURE RegisterHTTPAdr (VAR host, path, label: ARRAY OF CHAR; VAR port: INTEGER): LONGINT;

(* Parsing of an http url. *)
 PROCEDURE SplitHTTPAdr (VAR url, host, path, label: ARRAY OF CHAR; VAR port: INTEGER): LONGINT;
 PROCEDURE StopDoc (D: Documents.Document);
 PROCEDURE Wait ();
 PROCEDURE InsertDoc (me: Worker);

(* Requests the document ientified by key. *)
 PROCEDURE RequestDoc (D: Documents.Document; proxy: Proxy; VAR key: LONGINT; method: ARRAY OF CHAR; 
  main: BOOLEAN; E: Entry; query: Texts.Text);

END HTTPDocs0.