home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / lib / libnet / mkgeturl.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  4.6 KB  |  131 lines

  1. /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. #ifndef MKGETURL_H
  20. #define MKGETURL_H
  21.  
  22. #include "mkutils.h"
  23. #include "xp.h"
  24. #include "mktcp.h"
  25. #include "nslocks.h"
  26.  
  27.  
  28. /* fix Mac warnings about missing prototypes */
  29. MODULE_PRIVATE int PR_CALLBACK 
  30. NET_PrefChangedFunc(const char *pref, void *data);
  31.  
  32. /* Debugging routine prints an URL (and string "header")
  33.  */
  34. XP_BEGIN_PROTOS
  35. #ifdef DEBUG
  36. extern void TraceURL (URL_Struct *url, char *header);
  37. #else
  38. #define TraceURL(U,M)
  39. #endif /* DEBUG */
  40. XP_END_PROTOS
  41.  
  42. /* forward declared; see below */
  43. typedef struct _NET_ProtoImpl NET_ProtoImpl;
  44.  
  45. /* structure for maintaining multiple active data transfers
  46.  */
  47. typedef struct _ActiveEntry {
  48.     URL_Struct    *URL_s;           /* the URL data */
  49.     int            status;          /* current status */
  50.     int32          bytes_received;  /* number of bytes received so far */
  51.     PRFileDesc    *socket;          /* data sock */
  52.     PRFileDesc    *con_sock;        /* socket waiting for connection */
  53.     Bool           local_file;      /* are we reading a local file */
  54.     Bool           memory_file;     /* are we reading from memory? */
  55.     int            protocol;        /* protocol used for transfer */
  56.     NET_ProtoImpl *proto_impl;        /* handle to protocol implemenation */
  57.     void          *con_data;        /* data about the transfer connection and status */
  58.                                     /* routine to call when finished */
  59.     Net_GetUrlExitFunc *exit_routine;
  60.     MWContext  * window_id;         /* a unique window id */
  61.     FO_Present_Types format_out;    /* the output format */
  62.  
  63.     NET_StreamClass    * save_stream; /* used for cacheing of partial docs
  64.                                     * The file code opens this stream
  65.                                     * and writes part of the file down it.
  66.                                     * Then the stream is saved
  67.                                     * and the rest is loaded from the
  68.                                     * network
  69.                                     */
  70.     Bool      busy;
  71.  
  72.     char *    proxy_conf;    /* Proxy autoconfig string */
  73.     char *    proxy_addr;    /* Proxy address in host:port format */
  74.     u_long    socks_host;    /* SOCKS host IP address */
  75.     short     socks_port;    /* SOCKS port number */
  76.  
  77. } ActiveEntry;
  78.  
  79. /* typedefs of protocol implementation functions
  80.  *
  81.  * All these currently take an ActiveEntry Struct but
  82.  * should probably be abstracted out considerably more
  83.  */
  84. typedef int32 NET_ProtoInitFunc(ActiveEntry *ce);
  85. typedef int32 NET_ProtoProcessFunc(ActiveEntry *ce);
  86. typedef int32 NET_ProtoInterruptFunc(ActiveEntry *ce);
  87. typedef int32 NET_ProtoCleanupFunc(void);
  88.  
  89. /* a structure to hold the registered implementation of
  90.  * a protocol converter
  91.  */
  92. struct _NET_ProtoImpl {
  93.     int32 (*init) (ActiveEntry *ce);
  94.     int32 (*process)   (ActiveEntry *ce);
  95.     int32 (*interrupt) (ActiveEntry *ce);
  96.     void  (*cleanup)   (void);   /* note that cleanup can be called more 
  97.                                     * than once, when we need to shut down 
  98.                                     * connections or free up memory
  99.                                     */
  100. };
  101.  
  102. XP_BEGIN_PROTOS
  103. extern int NET_TotalNumberOfOpenConnections;
  104. extern int NET_MaxNumberOfOpenConnections;
  105. extern CacheUseEnum NET_CacheUseMethod;
  106. extern time_t NET_StartupTime;  /* time we began the program */
  107. extern XP_Bool NET_ProxyAcLoaded;
  108. /*
  109.  * Silently Interrupts all transfers in progress that have the same
  110.  * window id as the one passed in.
  111.  */
  112. extern int NET_SilentInterruptWindow(MWContext * window_id);
  113. /* cause prefs to be read or updated */
  114. extern void NET_SetupPrefs(const char * prefChanged);
  115.  
  116. extern NET_ProxyStyle NET_GetProxyStyle(void);
  117. extern const char * net_GetPACUrl(void);
  118. extern void net_SetPACUrl(char *u);
  119.  
  120. /* return a proxy server host and port to the caller or NULL
  121.  */
  122. extern char * NET_FindProxyHostForUrl(int urltype, char *urladdress);
  123.  
  124. /* registers a protocol impelementation for a particular url_type
  125.  * see NET_URL_Type() for types
  126.  */
  127. extern void NET_RegisterProtocolImplementation(NET_ProtoImpl *impl, int for_url_type);
  128.  
  129. XP_END_PROTOS
  130. #endif /* not MKGetURL_H */
  131.