home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / include / net.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  74.2 KB  |  2,106 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. /*
  20.    This file should contain prototypes of all public functions for 
  21.    the network module in the client library.  Also all NET lib
  22.    related public data structures should be in here.
  23.  
  24.    This file will be included automatically when source includes "xp.h".
  25.    By the time this file is included, all global typedefs have been 
  26.    executed.
  27. */
  28.  
  29. /* make sure we only include this once */
  30. #ifndef _NET_PROTO_H_
  31. #define _NET_PROTO_H_
  32.  
  33. #include "xp_core.h"
  34. #include "ntypes.h"
  35. #include "shistele.h"
  36. #include "xp_list.h"
  37. #include "msgtypes.h"
  38.  
  39. #include "xp_error.h"
  40.  
  41. #ifdef XP_UNIX
  42. #include <sys/param.h> /* for MAXPATHLEN */
  43. #endif
  44.  
  45. /* larubbio */
  46. #include "mcom_db.h"
  47. /* #include "jri.h" */
  48.  
  49. /*
  50.     prototypes for external structures
  51. */
  52.  
  53. typedef struct _net_MemoryCacheObject net_MemoryCacheObject;
  54.  
  55. /* ------------------------------------------------------------------------ */
  56. /* ============= Typedefs for the network module structures =============== */ 
  57.  
  58. #define VIEW_SOURCE_URL_PREFIX    "view-source:"
  59. #define NETHELP_URL_PREFIX        "nethelp:"
  60.  
  61. /* spider begin */
  62. #define MARIMBA_URL_PREFIX        "castanet:"
  63. /* spider end */
  64.  
  65. /* Format out codes
  66.  *
  67.  * Notice that there is no wildcard for format out.
  68.  * you must register a wildcard format_in and
  69.  * regular format_out pair for every format_out
  70.  * listed or used in the application.  That way
  71.  * there can never be a mime pair that doesn't
  72.  * match.
  73.  */
  74. #define SET_PRESENT_BIT(X,B)    ((FO_Present_Types) ( (int)X | B ))
  75. #define CLEAR_PRESENT_BIT(X,B)  ((FO_Present_Types) ( (int)X & ~(B) ))
  76. #define CLEAR_CACHE_BIT(X)      CLEAR_PRESENT_BIT(X,FO_CACHE_ONLY)
  77.  
  78. /*  If you add a FO_TYPE below for the client, please tell a windows
  79.  *      front end person that is working on your product immediately.
  80.  *      GAB
  81.  */
  82. #define FO_PRESENT                1
  83. #define FO_INTERNAL_IMAGE        2
  84. #define FO_OUT_TO_PROXY_CLIENT    3
  85. #define FO_VIEW_SOURCE            4
  86. #define FO_SAVE_AS                5
  87. #define FO_SAVE_AS_TEXT            6
  88. #define FO_SAVE_AS_POSTSCRIPT    7
  89. #define FO_QUOTE_MESSAGE        8    /* very much like FO_SAVE_AS_TEXT */
  90. #define FO_MAIL_TO                9
  91. #define FO_OLE_NETWORK            10
  92. #define FO_MULTIPART_IMAGE        11
  93. #define FO_EMBED                12
  94. #define FO_PRINT                13
  95. #define FO_PLUGIN                14
  96. #define FO_APPEND_TO_FOLDER        15    /* used by the mail/news code */
  97. #define FO_DO_JAVA                16
  98. #define FO_BYTERANGE            17
  99. #define FO_EDT_SAVE_IMAGE        18
  100. #define FO_EDIT                    19
  101. #define FO_LOAD_HTML_HELP_MAP_FILE 20
  102. #define FO_SAVE_TO_NEWS_DB        21 /* used by off-line news for art. caching */
  103. #define FO_OPEN_DRAFT            22 /* used by the mail/news code */
  104. #define FO_PRESENT_INLINE       23 /* like FO_PRESENT, but doesn't blow away */
  105. #define FO_OBJECT                24 /* see layobj.c */
  106. #define FO_FONT                    25 /* Downloadable Fonts */
  107. #define FO_SOFTWARE_UPDATE        26 /* Software updates */
  108. #define FO_JAVASCRIPT_CONFIG    27
  109. #define FO_QUOTE_HTML_MESSAGE    28
  110. #define FO_CMDLINE_ATTACHMENTS  29 /* for initializing compose window with attachments via commandline */
  111. #define FO_MAIL_MESSAGE_TO        30    /* for S/MIME */
  112. #define FO_LOCATION_INDEPENDENCE 31 /* Location independence stuff */
  113. #define FO_RDF            32
  114. #define FO_CRAWL_PAGE            33 /* for crawling HTML pages */
  115. #define FO_CRAWL_RESOURCE        34 /* for crawling images and resources */
  116. #define FO_ROBOTS_TXT            35 /* web robots control */
  117. #define FO_XMLCSS               36 /* CSS for formatting XML */
  118. #define FO_XMLHTML               37 /* HTML inclusions in XML */
  119.  
  120. /* bitfield detectable CACHE FO's
  121.  */
  122. #define FO_CACHE_ONLY                    64
  123. #define FO_CACHE_AND_PRESENT            (FO_CACHE_ONLY | FO_PRESENT)
  124. #define FO_CACHE_AND_INTERNAL_IMAGE        (FO_CACHE_ONLY | FO_INTERNAL_IMAGE)
  125. #define FO_CACHE_AND_OUT_TO_PROXY_CLIENT (FO_CACHE_ONLY | \
  126.                                           FO_OUT_TO_PROXY_CLIENT)
  127. #define FO_CACHE_AND_VIEW_SOURCE        (FO_CACHE_ONLY | FO_VIEW_SOURCE)
  128. #define FO_CACHE_AND_SAVE_AS            (FO_CACHE_ONLY | FO_SAVE_AS)
  129. #define FO_CACHE_AND_SAVE_AS_TEXT        (FO_CACHE_ONLY | FO_SAVE_AS_TEXT)
  130. #define FO_CACHE_AND_SAVE_AS_POSTSCRIPT    (FO_CACHE_ONLY | FO_SAVE_AS_POSTSCRIPT)
  131. #define FO_CACHE_AND_QUOTE_MESSAGE        (FO_CACHE_ONLY | FO_QUOTE_MESSAGE)
  132. #define FO_CACHE_AND_MAIL_TO            (FO_CACHE_ONLY | FO_MAIL_TO)
  133. #define FO_CACHE_AND_MAIL_MESSAGE_TO    (FO_CACHE_ONLY | FO_MAIL_MESSAGE_TO)
  134. #define FO_CACHE_AND_OLE_NETWORK        (FO_CACHE_ONLY | FO_OLE_NETWORK)
  135. #define FO_CACHE_AND_MULTIPART_IMAGE    (FO_CACHE_ONLY | FO_MULTIPART_IMAGE)
  136. #define FO_CACHE_AND_EMBED                (FO_CACHE_ONLY | FO_EMBED)
  137. #define FO_CACHE_AND_PRINT                (FO_CACHE_ONLY | FO_PRINT)
  138. #define FO_CACHE_AND_PLUGIN                (FO_CACHE_ONLY | FO_PLUGIN)
  139. #define FO_CACHE_AND_APPEND_TO_FOLDER    (FO_CACHE_ONLY | FO_APPEND_TO_FOLDER)
  140. #define FO_CACHE_AND_DO_JAVA            (FO_CACHE_ONLY | FO_DO_JAVA)
  141. #define FO_CACHE_AND_BYTERANGE            (FO_CACHE_ONLY | FO_BYTERANGE)
  142. #define FO_CACHE_AND_EDIT                (FO_CACHE_ONLY | FO_EDIT)
  143. #define FO_CACHE_AND_LOAD_HTML_HELP_MAP_FILE    (FO_CACHE_ONLY | FO_LOAD_HTML_HELP_MAP_FILE)
  144. #define FO_CACHE_AND_PRESENT_INLINE     (FO_CACHE_ONLY | FO_PRESENT_INLINE)
  145. #define FO_CACHE_AND_OBJECT                (FO_CACHE_ONLY | FO_OBJECT)
  146. #define FO_CACHE_AND_FONT                (FO_CACHE_ONLY | FO_FONT)
  147. #define FO_CACHE_AND_JAVASCRIPT_CONFIG   (FO_CACHE_ONLY | FO_JAVASCRIPT_CONFIG)
  148. #define FO_CACHE_AND_SOFTUPDATE   (FO_CACHE_ONLY | FO_SOFTWARE_UPDATE)
  149. #define FO_CACHE_AND_RDF   (FO_CACHE_ONLY | FO_RDF)
  150. #define FO_CACHE_AND_XMLCSS   (FO_CACHE_ONLY | FO_XMLCSS)
  151. #define FO_CACHE_AND_XMLHTML   (FO_CACHE_ONLY | FO_XMLHTML)
  152. #define FO_CACHE_AND_CRAWL_PAGE            (FO_CACHE_ONLY | FO_CRAWL_PAGE)
  153. #define FO_CACHE_AND_CRAWL_RESOURCE        (FO_CACHE_ONLY | FO_CRAWL_RESOURCE)
  154. #define FO_CACHE_AND_ROBOTS_TXT            (FO_CACHE_ONLY | FO_ROBOTS_TXT)
  155.  
  156. /* bitfield detectable ONLY_FROM_CACHE FO's
  157.  */
  158. #define FO_ONLY_FROM_CACHE                        128
  159. #define FO_ONLY_FROM_CACHE_AND_PRESENT            (FO_ONLY_FROM_CACHE | \
  160.                                                  FO_PRESENT)
  161. #define FO_ONLY_FROM_CACHE_AND_INTERNAL_IMAGE    (FO_ONLY_FROM_CACHE | \
  162.                                                  FO_INTERNAL_IMAGE)
  163. #define FO_ONLY_FROM_CACHE_AND_OUT_TO_PROXY_CLIENT    (FO_ONLY_FROM_CACHE | \
  164.                                                      FO_OUT_TO_PROXY_CLIENT)
  165. #define FO_ONLY_FROM_CACHE_AND_VIEW_SOURCE        (FO_ONLY_FROM_CACHE | \
  166.                                                  FO_VIEW_SOURCE)
  167. #define FO_ONLY_FROM_CACHE_AND_SAVE_AS            (FO_ONLY_FROM_CACHE | \
  168.                                                  FO_SAVE_AS)
  169. #define FO_ONLY_FROM_CACHE_AND_SAVE_AS_TEXT        (FO_ONLY_FROM_CACHE | \
  170.                                                  FO_SAVE_AS_TEXT)
  171. #define FO_ONLY_FROM_CACHE_AND_SAVE_AS_POSTSCRIPT (FO_ONLY_FROM_CACHE | \
  172.                                                    FO_SAVE_AS_POSTSCRIPT)
  173. #define FO_ONLY_FROM_CACHE_AND_QUOTE_MESSAGE     (FO_ONLY_FROM_CACHE | \
  174.                                                   FO_QUOTE_MESSAGE)
  175. #define FO_ONLY_FROM_CACHE_AND_MAIL_TO            (FO_ONLY_FROM_CACHE | \
  176.                                                  FO_MAIL_TO)
  177. #define FO_ONLY_FROM_CACHE_AND_MAIL_MESSAGE_TO    (FO_ONLY_FROM_CACHE | \
  178.                                                  FO_MAIL_MESSAGE_TO)
  179. #define FO_ONLY_FROM_CACHE_AND_OLE_NETWORK        (FO_ONLY_FROM_CACHE | \
  180.                                                  FO_OLE_NETWORK)
  181. #define FO_ONLY_FROM_CACHE_AND_MULTIPART_IMAGE    (FO_ONLY_FROM_CACHE | \
  182.                                                  FO_MULTIPART_IMAGE)
  183. #define FO_ONLY_FROM_CACHE_AND_EMBED            (FO_ONLY_FROM_CACHE | FO_EMBED)
  184.  
  185. #define FO_ONLY_FROM_CACHE_AND_PRINT            (FO_ONLY_FROM_CACHE | FO_PRINT)
  186.  
  187. #define FO_ONLY_FROM_CACHE_AND_PLUGIN            (FO_ONLY_FROM_CACHE | FO_PLUGIN)
  188.  
  189. #define FO_ONLY_FROM_CACHE_AND_APPEND_TO_FOLDER    (FO_ONLY_FROM_CACHE | \
  190.                                                  FO_APPEND_TO_FOLDER)
  191. #define FO_ONLY_FROM_CACHE_AND_DO_JAVA            (FO_ONLY_FROM_CACHE | FO_DO_JAVA)
  192.  
  193. #define FO_ONLY_FROM_CACHE_AND_BYTERANGE        (FO_ONLY_FROM_CACHE | FO_BYTERANGE)
  194.  
  195. #define FO_ONLY_FROM_CACHE_AND_EDIT                (FO_ONLY_FROM_CACHE | FO_EDIT)
  196. #define FO_ONLY_FROM_CACHE_AND_LOAD_HTML_HELP_MAP_FILE        (FO_ONLY_FROM_CACHE | FO_LOAD_HTML_HELP_MAP_FILE)
  197. #define FO_ONLY_FROM_CACHE_AND_PRESENT_INLINE                (FO_ONLY_FROM_CACHE | FO_PRESENT_INLINE)
  198.  
  199. typedef void
  200. Net_GetUrlExitFunc (URL_Struct *URL_s, int status, MWContext *window_id);
  201.  
  202. typedef void
  203. Net_GetUrlProgressFunc (URL_Struct *URL_s, int status, MWContext *window_id);
  204.  
  205.  
  206. /* A structure to store all headers that can be passed into HTTPLOAD. 
  207.  * Used for supporting URLConnection object of Java
  208.  */
  209. typedef struct _NET_AllHeaders { 
  210.     char **key;                 /* The Key portion of each HTTP header */
  211.     char **value;               /* The value portion of each HTTP header */
  212.     uint32 empty_index;         /* pointer to the next free slot */
  213.     uint32 max_index;           /* maximum no of free slots allocated */
  214. } NET_AllHeaders;
  215.  
  216. /* Forward declaration to make compiler happy on OSF1 */
  217. #if defined (OSF1)
  218. #ifdef XP_CPLUSPLUS
  219. class MSG_Pane; 
  220. #endif
  221. #endif
  222.  
  223. /* larubbio */
  224. /* moved from mkextcac, this is used for 197 SAR caches, 
  225.  * and external cache
  226.  */
  227. typedef struct _ExtCacheDBInfo {
  228.     DB        *database;
  229.     char    *filename;
  230.     char    *path;
  231.     char    *name;
  232.     Bool    queried_this_session;
  233.     int        type;
  234.     uint32    DiskCacheSize; 
  235.     uint32    NumberInDiskCache;
  236.     uint32  MaxSize;
  237.     void    *logFile;
  238.  
  239. } ExtCacheDBInfo;
  240.  
  241. typedef enum {
  242.     Normal_priority,
  243.     Prefetch_priority,                /* passed in to prefetch a URL in the background */
  244.     CurrentlyPrefetching_priority   /* a prefetch url currently loading */
  245. } URLLoadPriority;
  246.  
  247. /* passing in structure 
  248.  *
  249.  * use this structure to pass a URL and associated data
  250.  * into the load_URL() routine
  251.  *
  252.  * This structure can then be used to look up associated
  253.  * data after the transfer has taken place
  254.  *
  255.  *    WARNING!!  If you ever change this structure, there is a good chance
  256.  *    you will have to also change History_entry, and the functions
  257.  *  SHIST_CreateHistoryEntry and SHIST_CreateURLStructFromHistoryEntry which
  258.  *  copy URLs to and from the history.  You may also need to change the
  259.  *  net_CacheObject structure in mkcache.c, and the code therein which copies
  260.  *  URLs to and from the memory and disk caches.
  261.  */
  262. struct URL_Struct_ {
  263.     URLLoadPriority priority;       /* load priority */
  264.     char *  address;            /* the URL part */
  265.  
  266.     char * username; /* Put username/password info into the URL struct without */
  267.     char * password; /* using the address field.  The problem was that the user's password
  268.                       * became visible on screen in a number of cases. Bug 35243, 39418 */
  269.  
  270.       char *  destination;        /* for copy and move methods */
  271.     char *  IPAddressString;    /* ASCII string of IP address.
  272.                                  * If this field exists, then NET_BeginConnect
  273.                                  * should use it rather than the hostname in
  274.                                  * the address.
  275.                                  * This is here for Java DNS security firedrill
  276.                                  *  see jar or jsw...
  277.                                  */
  278.     int     method;             /* post or get or ... */
  279.     char *  referer;            /* What document points to this url */
  280.     char *  post_data;          /* data to be posted */
  281.     int32   post_data_size;     /* size of post_data */
  282.     char *  range_header;       /* requested ranges (bytes usually) */
  283.     char *  post_headers;       /* Additional headers for the post. 
  284.                                  * Should end with \n */
  285.     NET_ReloadMethod
  286.             force_reload;       /* forced refresh? either NORMAL or SUPER */
  287.     char *  http_headers;       /* headers that can be passed into
  288.                                  * HTTPLoad.  Used to support
  289.                                  * proxying
  290.                                  */
  291.     char  * window_target;      /* named window support */
  292.     Chrome * window_chrome;     /* pointer to a Chrome structure that
  293.                                  * if non-null specifies the characteristics
  294.                                  * of the target window named in 
  295.                                  * the window_target variable
  296.                                  */
  297.  
  298.     /* attributes of the URL that are assembled
  299.      * during and after transfer of the data
  300.      */
  301.     int      server_status;               /* status code returned by server */
  302.     int32    content_length;              /* length of the incoming data */
  303.     int32    real_content_length;         /* real length of the partial file */
  304.     char   * content_type;                /* the content type of incoming 
  305.                                            * data 
  306.                                            */
  307.     char   * content_name;                /* passed in name for object */
  308.     char   * transfer_encoding;           /* first encoding of incoming data */
  309.     char   * content_encoding;            /* encoding of incoming data */
  310.  
  311.     char   *x_mac_creator, *x_mac_type;   /* If we somehow know the Mac-types
  312.                                              of this document, these are they.
  313.                                              This is only of interest on Macs,
  314.                                              and currently only happens with
  315.                                              mail/news attachments. */
  316.  
  317.     char   * charset;                     /* charset of the data */
  318.     char   * boundary;                    /* mixed multipart boundary */
  319.     char   * redirecting_url;             /* the Location: of the redirect */
  320.     char   * authenticate;                /* auth scheme */
  321.     char   * proxy_authenticate;          /* proxy auth scheme */
  322.     char   * protection_template;         /* name of server auth template */
  323.     uint32   refresh;                     /* refresh interval */
  324.     char   * refresh_url;                 /* url to refresh */
  325.     char   * wysiwyg_url;                 /* URL for WYSIWYG printing/saving */
  326.     time_t   expires;
  327.     time_t   last_modified;
  328.     time_t   server_date;                 /* Date: header returned by 
  329.                                            * HTTP servers
  330.                                            */
  331.     char   * cache_file;                  /* if non-NULL then it contains
  332.                                            * the filename of its local cache 
  333.                                            * file containing it's data
  334.                                            */
  335.     net_MemoryCacheObject * memory_copy;  /* if non-NULL then it contains 
  336.                                            * a structure with
  337.                                            * a pointer to a list of 
  338.                                            * memory segments
  339.                                            * containing it's data
  340.                                            */
  341.  
  342.     void   * fe_data;                       /* random front end data to be passed
  343.                                            * up the line
  344.                                            */
  345.  
  346. #if defined(XP_WIN) || defined(XP_OS2)
  347.     void *ncapi_data;    /* Window ncapi data structure
  348.                  * to track loads by URL and not context
  349.                  */
  350. #endif /* XP_WIN */
  351.  
  352.     int     history_num;                  /* == add this to history list 
  353.                                            * dflt TRUE 
  354.                                            */
  355.  
  356.     uint32   position;                    /* for plug-in streams */
  357.     uint32   low_range;                    
  358.     uint32   high_range;                  /* these range tags represent
  359.                                            * the byte offsets that
  360.                                            * this URL contains.
  361.                                            * if high_range is non-zero
  362.                                            * then this URL represents
  363.                                            * just a subset of the URL.
  364.                                            */
  365.  
  366.     int32   position_tag;                 /* tag number of last position */
  367.  
  368.     SHIST_SavedData savedData;              /* layout data */
  369.  
  370.     Net_GetUrlExitFunc *pre_exit_fn;      /* If set, called just before the
  371.                                              exit routine that was passed
  372.                                              in to NET_GetURL. */
  373.  
  374.     /* Security information */
  375.     int     security_on;                  /* is security on? */
  376.     char   *key_cipher;                      /* cipher being used */
  377.     int     key_size;                      /* size of the total key (in bits) */
  378.     int     key_secret_size;              /* secret portion (in bits) */
  379.     struct CERTCertificateStr *certificate;        /* server's certificate */
  380.     struct CERTCertificateStr *redirecting_cert;    /* redirecting server's certificate */
  381.     char   *key_issuer;                      /* XXX obsolete */
  382.     char   *key_subject;                    /* XXX obsolete */
  383.     void   *sec_private;                  /* private libsec info */
  384.  
  385.     char   *error_msg;                   /* what went wrong */
  386.  
  387.     char  **files_to_post;               /* zero terminated array
  388.                                           * of char * filenames
  389.                                           * that need to be posted
  390.                                           */
  391.     char **post_to;               /* Only meaningful if files_to_post is set.  If post_to is non-NULL, it is a NULL-terminated 
  392.                                             array of the URLs to post the files in files_to_post to.  If NULL, files_to_post along with 
  393.                                             address(a directory) will be used to decide where to post the files (like before). */
  394.   XP_Bool *add_crlf; /* Only meaningful if files_to_post is non-NULL.  If set, it specifies for each file in files_to_post,
  395.                         whether or not to make all line endings be crlf. */
  396.     uint32    auto_scroll;                  /* set this if you want
  397.                                            * the window to autoscroll
  398.                                            * to the bottom at all times
  399.                                            * The value represents
  400.                                            * the number of lines to
  401.                                            * buffer
  402.                                            */
  403.     PRPackedBool
  404.             dontAllowDiffHostRedirect,  /* Do we want to allow a redirect from host A to host B */        
  405.             post_data_is_file,            /* is the post_data field a filename? */
  406.             address_modified,            /* was the address modified? */
  407.             resize_reload,                /* persistent NET_RESIZE_RELOAD flag */
  408.             use_local_copy,                /* ignore force reload */
  409.             is_directory,                /* filled in upon return in to indicate
  410.                                          * the url points to a directory 
  411.                                          */
  412.             preset_content_type,         /* set this if you want to pass in
  413.                                           * a known content-type 
  414.                                           */
  415.             is_binary,                     /* should mailto and save-as be 
  416.                                           * wary of this object 
  417.                                           */
  418.             is_active,                   /* is it an active stream */
  419.             is_netsite,                  /* did it come from Netsite? */
  420.             intr_on_load,                /* set this to interrupt any
  421.                                           * existing transfers for the window
  422.                                           * when this URL begins to load
  423.                                           */
  424.             internal_url,                 /* set to true if this
  425.                                            * is a for internal use
  426.                                            * only url.  If it's not
  427.                                            * set for an internal
  428.                                            * URL the netlib will
  429.                                            * return an unrecognized url
  430.                                            * error
  431.                                            */
  432.             ext_cache_file,               /* the cache file referenced
  433.                                            * is from an external cache
  434.                                            */
  435.  
  436.              must_cache,                      /* overrides cache logic, used by plugins */
  437.  
  438.             dont_cache,                    /* This gets set by a mime
  439.                                            * header and tells us not
  440.                                            * to cache the document
  441.                                            */
  442.             can_reuse_connection,         /* set when the connetion is reusable
  443.                                            * as in HTTP/1.1 or NG.
  444.                                            */
  445.             server_can_do_byteranges,     /* can the server do byteranges */
  446.             server_can_do_restart,        /* can the (ftp) server do restarts? */
  447.    
  448.             load_background,              /* Load in the "background".
  449.                                              Suppress thermo, progress, etc. */
  450.             mailto_post;                  /* is this a mailto: post? */
  451. #ifdef XP_CPLUSPLUS
  452.     class MSG_Pane                *msg_pane; 
  453. #else
  454.     struct MSG_Pane               *msg_pane; 
  455. #endif
  456.  
  457.     NET_AllHeaders all_headers;           /* All headers that can be passed into
  458.                                            * HTTPLOAD. Used to support 
  459.                                            * URLConnection object of Java
  460.                                            */
  461.     int ref_count;            /* how many people have a pointer to me */
  462.     ExtCacheDBInfo *SARCache;                          /* a pointer to the structure telling
  463.                                            * us which cache this is in, if it's 
  464.                                            * NULL it's in the normal navigator
  465.                                            * cache
  466.                                            */ /* larubbio */
  467.     int         owner_id;                      /* unique ID for each library:
  468.                                                 NPL (plugins) => 0x0000BAC0; 
  469.                                            */
  470.     void    *owner_data;                  /* private data owned by whomever created the URL_Struct */            
  471.     char    *page_services_url;
  472.     char    *etag;                          /* HTTP/1.1 Etag */
  473.     char    *origin_url;                  /* original referrer of javascript: URL */
  474. };
  475.  
  476. /* macro's (methods) to access the URL Struct
  477.  */
  478. #define NET_URLStruct_Address(S)          S->address
  479. #define NET_URLStruct_AddressModified(S)  S->address_modified
  480. #define NET_URLStruct_PostData(S)         S->post_data
  481. #define NET_URLStruct_Method(S)           S->method
  482. #define NET_URLStruct_ContentLength(S)    S->content_length
  483. #define NET_URLStruct_ContentType(S)      S->content_type
  484.  
  485. /* stream functions
  486.  */
  487. typedef unsigned int
  488. (*MKStreamWriteReadyFunc) (NET_StreamClass *stream);
  489.  
  490. #define MAX_WRITE_READY (((unsigned) (~0) << 1) >> 1)   /* must be <= than MAXINT!!!!! */
  491.  
  492. typedef int 
  493. (*MKStreamWriteFunc) (NET_StreamClass *stream, const char *str, int32 len);
  494.  
  495. typedef void 
  496. (*MKStreamCompleteFunc) (NET_StreamClass *stream);
  497.  
  498. typedef void 
  499. (*MKStreamAbortFunc) (NET_StreamClass *stream, int status);
  500.  
  501. /* streamclass function
  502.  */
  503. struct _NET_StreamClass {
  504.  
  505.     char      * name;          /* Just for diagnostics */
  506.  
  507.     MWContext * window_id;     /* used for progress messages, etc. */
  508.  
  509.     void      * data_object;   /* a pointer to whatever
  510.                                 * structure you wish to have
  511.                                 * passed to the routines below
  512.                                 * during writes, etc...
  513.                                 * 
  514.                                 * this data object should hold
  515.                                 * the document, document
  516.                                 * structure or a pointer to the
  517.                                 * document.
  518.                                 */
  519.  
  520.     MKStreamWriteReadyFunc  is_write_ready;   /* checks to see if the stream is ready
  521.                                                * for writing.  Returns 0 if not ready
  522.                                                * or the number of bytes that it can
  523.                                                * accept for write
  524.                                                */
  525.     MKStreamWriteFunc       put_block;        /* writes a block of data to the stream */
  526.     MKStreamCompleteFunc    complete;           /* normal end */
  527.     MKStreamAbortFunc       abort;              /* abnormal end */
  528.  
  529.     Bool                    is_multipart;      /* is the stream part of a multipart sequence */
  530. };
  531.  
  532. /*DSR040197 - new and improved position for BEGIN_PROTOS*/
  533. XP_BEGIN_PROTOS
  534. /*
  535.  * this defines the prototype for
  536.  * stream converter routines.
  537.  */
  538. typedef NET_StreamClass * NET_Converter (FO_Present_Types rep_out,      /* the output format */
  539.                                          void * data_obj,     /* saved from registration */
  540.                                          URL_Struct * URL_s,  /* the URL info */
  541.                                          MWContext * context);/* window id */
  542.    
  543. /*
  544.  * The ContentInfo structure.
  545.  *
  546.  * Currently, we support the following attributes:
  547.  *
  548.  * 1. Type: This identifies what kind of data is in the file.
  549.  * 2. Encoding: Identifies any compression or otherwise content-independent
  550.  *    transformation which has been applied to the file (uuencode, etc.)
  551.  * 3. Language: Identifies the language a text document is in.
  552.  * 4. Description: A text string describing the file.
  553.  *
  554.  * Multiple items are separated with a comma, e.g.
  555.  * encoding="x-gzip, x-uuencode"
  556.  */
  557.  
  558. typedef struct {
  559.     char *type;
  560.     char *encoding;
  561.     char *language;
  562.     char *desc;
  563.     char *icon;
  564.     char *alt_text;
  565.     Bool  is_default; /* is it the default because a type couldn't be found? */
  566.     void *fe_data;   /* used by fe to save ext. viewer/save to disk options */
  567. } NET_cinfo;
  568.  
  569. /* this is a list item struct that holds extension lists and
  570.  * cinfo structs.
  571.  *
  572.  * call cinfo_MasterListPointer to return 
  573.  * the master list held by the net library
  574.  */
  575. typedef struct _cdata {
  576.     int            num_exts;
  577.     char         **exts;
  578.     NET_cinfo      ci;
  579.     Bool       is_external;  /* did this entry come from an external file? */
  580.     Bool       is_modified;  /* Is this entry modified externally; default = False */
  581.     Bool       is_local;    /* Is personal copy*/
  582.     Bool         is_new;    /* indicate if this is 
  583.                    added by user via helper */
  584.     char*       src_string;  /* For output use */
  585. } NET_cdataStruct;
  586.  
  587.  
  588. #ifdef XP_UNIX
  589. /* This is only used in UNIX */
  590.  
  591. typedef struct _mdata {
  592.     char *contenttype;
  593.     char *command;
  594.     char *testcommand;
  595.     char *label;
  596.     char *printcommand;
  597.     int32 stream_buffer_size;
  598.     Bool  test_succeed;
  599.     char* xmode;
  600.     char*   src_string;  /* For output use */
  601.     Bool  is_local;
  602.     Bool  is_modified;
  603. } NET_mdataStruct;
  604. #endif
  605.  
  606.  
  607.  
  608. /* Defines for various MIME content-types and encodings.
  609.    Whenever you type in a content-type, you should use one of these defines
  610.    instead, to help catch typos, and make central management of them easier.
  611.  */
  612.  
  613. #define AUDIO_WILDCARD                        "audio/*"
  614. #define IMAGE_WILDCARD                        "image/*"
  615.  
  616. #define APPLICATION_APPLEFILE                "application/applefile"
  617. #define APPLICATION_BINHEX                    "application/mac-binhex40"
  618. #define APPLICATION_MACBINARY                "application/x-macbinary"
  619. #define APPLICATION_COMPRESS                "application/x-compress"
  620. #define APPLICATION_COMPRESS2                "application/compress"
  621. #define APPLICATION_FORTEZZA_CKL            "application/x-fortezza-ckl"
  622. #define APPLICATION_FORTEZZA_KRL            "application/x-fortezza-krl"
  623. #define APPLICATION_GZIP                    "application/x-gzip"
  624. #define APPLICATION_GZIP2                    "application/gzip"
  625. #define APPLICATION_HTTP_INDEX                "application/http-index"
  626. #define APPLICATION_JAVASCRIPT                "application/x-javascript"
  627. #define APPLICATION_NETSCAPE_REVOCATION        "application/x-netscape-revocation"
  628. #define APPLICATION_NS_PROXY_AUTOCONFIG        "application/x-ns-proxy-autoconfig"
  629. #define APPLICATION_NS_JAVASCRIPT_AUTOCONFIG        "application/x-javascript-config"
  630. #define APPLICATION_OCTET_STREAM            "application/octet-stream"
  631. #define APPLICATION_PGP                        "application/pgp"
  632. #define APPLICATION_PGP2                    "application/x-pgp-message"
  633. #define APPLICATION_POSTSCRIPT                "application/postscript"
  634. #define APPLICATION_PRE_ENCRYPTED            "application/pre-encrypted"
  635. #define APPLICATION_UUENCODE                "application/x-uuencode"
  636. #define APPLICATION_UUENCODE2                "application/x-uue"
  637. #define APPLICATION_UUENCODE3                "application/uuencode"
  638. #define APPLICATION_UUENCODE4                "application/uue"
  639. #define APPLICATION_X509_CA_CERT            "application/x-x509-ca-cert"
  640. #define APPLICATION_X509_SERVER_CERT        "application/x-x509-server-cert"
  641. #define APPLICATION_X509_EMAIL_CERT            "application/x-x509-email-cert"
  642. #define APPLICATION_X509_USER_CERT            "application/x-x509-user-cert"
  643. #define APPLICATION_X509_CRL                "application/x-pkcs7-crl"
  644. #define APPLICATION_XPKCS7_MIME             "application/x-pkcs7-mime"
  645. #define APPLICATION_XPKCS7_SIGNATURE        "application/x-pkcs7-signature"
  646. #define APPLICATION_WWW_FORM_URLENCODED        "application/x-www-form-urlencoded"
  647. #define APPLICATION_OLEOBJECT                "application/oleobject"
  648. #define APPLICATION_OLEOBJECT2                "application/x-oleobject"
  649. #define APPLICATION_JAVAVM                    "application/java-vm"
  650. #define APPLICATION_JAVAARCHIVE                "application/java-archive"
  651. #define APPLICATION_MARIMBA                 "application/marimba"
  652. #define APPLICATION_XMARIMBA                 "application/x-marimba"
  653.  
  654. #define AUDIO_BASIC                            "audio/basic"
  655.  
  656. #define IMAGE_GIF                            "image/gif"
  657. #define IMAGE_JPG                            "image/jpeg"
  658. #define IMAGE_PJPG                            "image/pjpeg"
  659. #define IMAGE_PNG                            "image/png"
  660. #define IMAGE_PPM                            "image/x-portable-pixmap"
  661. #define IMAGE_XBM                            "image/x-xbitmap"
  662. #define IMAGE_XBM2                            "image/x-xbm"
  663. #define IMAGE_XBM3                            "image/xbm"
  664.  
  665. #define MESSAGE_EXTERNAL_BODY                "message/external-body"
  666. #define MESSAGE_NEWS                        "message/news"
  667. #define MESSAGE_RFC822                        "message/rfc822"
  668.  
  669. #define MULTIPART_ALTERNATIVE                "multipart/alternative"
  670. #define MULTIPART_APPLEDOUBLE                "multipart/appledouble"
  671. #define MULTIPART_DIGEST                    "multipart/digest"
  672. #define MULTIPART_HEADER_SET                "multipart/header-set"
  673. #define MULTIPART_MIXED                        "multipart/mixed"
  674. #define MULTIPART_PARALLEL                    "multipart/parallel"
  675. #define MULTIPART_SIGNED                    "multipart/signed"
  676. #define MULTIPART_RELATED                    "multipart/related"
  677. #define SUN_ATTACHMENT                        "x-sun-attachment"
  678.  
  679. #define TEXT_ENRICHED                        "text/enriched"
  680. #define TEXT_HTML                            "text/html"
  681. #define TEXT_MDL                            "text/mdl"
  682. #define TEXT_PLAIN                            "text/plain"
  683. #define TEXT_RICHTEXT                        "text/richtext"
  684. #define TEXT_VCARD                            "text/x-vcard"
  685. #define TEXT_CSS                            "text/css"
  686. #define TEXT_JSSS                            "text/jsss"
  687. #define TEXT_XML                            "text/xml"
  688.  
  689. #define VIDEO_MPEG                            "video/mpeg"
  690.  
  691. /* x-uuencode-apple-single. QuickMail made me do this. */
  692. #define UUENCODE_APPLE_SINGLE                "x-uuencode-apple-single"
  693.  
  694. /* The standard MIME message-content-encoding values:
  695.  */
  696. #define ENCODING_7BIT                        "7bit"
  697. #define ENCODING_8BIT                        "8bit"
  698. #define ENCODING_BINARY                        "binary"
  699. #define ENCODING_BASE64                        "base64"
  700. #define ENCODING_QUOTED_PRINTABLE            "quoted-printable"
  701.  
  702. /* Some nonstandard encodings.  Note that the names are TOTALLY RANDOM,
  703.    and code that looks for these in network-provided data must look for
  704.    all the possibilities.
  705.  */
  706. #define ENCODING_COMPRESS                    "x-compress"
  707. #define ENCODING_COMPRESS2                    "compress"
  708. #define ENCODING_ZLIB                        "x-zlib"
  709. #define ENCODING_ZLIB2                        "zlib"
  710. #define ENCODING_GZIP                        "x-gzip"
  711. #define ENCODING_GZIP2                        "gzip"
  712. #define ENCODING_UUENCODE                    "x-uuencode"
  713. #define ENCODING_UUENCODE2                    "x-uue"
  714. #define ENCODING_UUENCODE3                    "uuencode"
  715. #define ENCODING_UUENCODE4                    "uue"
  716.  
  717. /* Some names of parameters that various MIME headers include.
  718.  */
  719. #define PARAM_PROTOCOL                        "protocol"
  720. #define PARAM_MICALG                        "micalg"
  721. #define PARAM_MICALG_MD2                    "rsa-md2"
  722. #define PARAM_MICALG_MD5                    "rsa-md5"
  723. #define PARAM_MICALG_SHA1                    "sha1"
  724. #define PARAM_MICALG_SHA1_2                    "sha-1"
  725. #define PARAM_MICALG_SHA1_3                    "rsa-sha1"
  726. #define PARAM_MICALG_SHA1_4                    "rsa-sha-1"
  727. #define PARAM_MICALG_SHA1_5                    "rsa-sha"
  728. #define PARAM_X_MAC_CREATOR                    "x-mac-creator"
  729. #define PARAM_X_MAC_TYPE                    "x-mac-type"
  730.  
  731.  
  732. /* This is like text/html, but also implies that the charset is that of
  733.    the window.  This type should not escape to the outside world!
  734.  */
  735. #define INTERNAL_PARSER                        "internal/parser"
  736.  
  737. /* This type represents a document whose type was unknown.  Note that this
  738.    is not the same as "application/octet-stream".  UNKNOWN_CONTENT_TYPE is
  739.    an internal marker used to distinguish between documents *without* a
  740.    specified type, and documents which had their type explicitly specified
  741.    as octet_stream.
  742.  
  743.    This type should not be allowed to escape to the outside world -- if we
  744.    feed a content type to an external consumer, we must translate this type
  745.    to application/octet-stream first.
  746.  */
  747. #define UNKNOWN_CONTENT_TYPE               "application/x-unknown-content-type"
  748.  
  749. /* I have no idea what these are... */
  750. #define MAGNUS_INTERNAL_UNKNOWN                "magnus-internal/unknown"
  751. /* pre-encrypted file that has passed the cache */
  752. #define INTERNAL_PRE_ENCRYPTED              "internal/pre-encrypted"
  753. /* html file that needs to be pre-encrypted */
  754. #define INTERNAL_PRE_ENC_HTML               "internal/preenc-html"
  755.  
  756. #define NET_AUTH_FAILED_DONT_DISPLAY        1
  757. #define NET_AUTH_FAILED_DISPLAY_DOCUMENT    2
  758. #define NET_AUTH_SUCCEEDED                  3
  759. #define NET_RETRY_WITH_AUTH                 4
  760.  
  761. #ifdef  XP_UNIX
  762. #define NET_COMMAND_NETSCAPE        "internal"
  763. #define NET_COMMAND_PLUGIN        "plugin:"
  764. #define NET_COMMAND_SAVE_TO_DISK    "save"
  765. #define NET_COMMAND_SAVE_BY_NETSCAPE    "plugin-error"
  766. #define NET_COMMAND_UNKNOWN        "prompt"
  767. #define NET_COMMAND_DELETED        "deleted"
  768. #define NET_MOZILLA_FLAGS        "x-mozilla-flags"
  769. #endif
  770.  
  771. /* the entry file info structure contains information about
  772.  * an ftp directory entry broken down into components
  773.  */
  774. typedef struct _NET_FileEntryInfo {
  775.     char      *  filename;
  776.     NET_cinfo *  cinfo;
  777.     char      *     content_type;
  778.     int          special_type;
  779.     time_t       date;
  780.     int32        size;
  781.     Bool           display;    /* show this entry? */
  782.     int32          permissions;
  783. } NET_FileEntryInfo;
  784.  
  785. #define NET_FILE_TYPE         0
  786. #define NET_DIRECTORY           1
  787. #define NET_SYM_LINK           2
  788. #define NET_SYM_LINK_TO_DIR  3
  789. #define NET_SYM_LINK_TO_FILE 4
  790.  
  791. /* bit wise or'able permissions */
  792. #define NET_READ_PERMISSION        4
  793. #define NET_WRITE_PERMISSION    2
  794. #define NET_EXECUTE_PERMISSION  1
  795.  
  796. typedef struct _HTTPIndexParserData HTTPIndexParserData;
  797.  
  798. /* define HTML help mapping file parser */
  799. #define HTML_HELP_ID_FOUND 999
  800.  
  801. /* ====================================================================== */
  802. /* Prototypes for NetLib */
  803.  
  804. /* set this to see debug messages if compiled with -DDEBUG
  805.  */
  806. extern int MKLib_trace_flag;
  807.  
  808. /* load the HTML help mapping file and search for
  809.  * the id or text to load a specific document
  810.  */
  811. extern void
  812. NET_GetHTMLHelpFileFromMapFile(MWContext *context,
  813.                                char *map_file_url,
  814.                                char *id,
  815.                                char *search_text);
  816.  
  817. /* print a text string in place of the NET_FileEntryInfo special_type int */
  818. extern char * NET_PrintFileType(int special_type);
  819.  
  820. /* streamclass parser for application/http-index-format */
  821. extern NET_StreamClass *
  822. NET_HTTPIndexFormatToHTMLConverter(int         format_out,
  823.                                void       *data_object,
  824.                                URL_Struct *URL_s,
  825.                                MWContext  *window_id);
  826.  
  827. /* parser routines to parse application/http-index-format
  828.  */
  829. extern HTTPIndexParserData * NET_HTTPIndexParserInit(void);
  830.  
  831. extern void NET_HTTPIndexParserFree(HTTPIndexParserData *obj);
  832.  
  833. extern int
  834. NET_HTTPIndexParserPut(HTTPIndexParserData *obj, char *data, int32 len);
  835.  
  836. extern int
  837. NET_HTTPIndexParserSort(HTTPIndexParserData *data_obj, int sort_method);
  838.  
  839. extern int32 NET_HTTPIndexParserGetTotalFiles(HTTPIndexParserData *data_obj);
  840.  
  841. extern NET_FileEntryInfo *
  842. NET_HTTPIndexParserGetFileNum(HTTPIndexParserData *data_obj, int32 num);
  843.  
  844. extern char * NET_HTTPIndexParserGetTextMessage(HTTPIndexParserData *data_obj);
  845.  
  846. extern char * NET_HTTPIndexParserGetHTMLMessage(HTTPIndexParserData *data_obj);
  847.  
  848. extern char * NET_HTTPIndexParserGetBaseURL(HTTPIndexParserData *data_obj);
  849.  
  850. /* the view source converter.  Data_obj should be the
  851.  * content type of the object
  852.  */
  853. extern NET_StreamClass * 
  854. net_ColorHTMLStream (int         format_out,
  855.                      void       *data_obj,
  856.                      URL_Struct *URL_s,
  857.                      MWContext  *window_id);
  858.  
  859. /* socks support function
  860.  *
  861.  * if set to NULL socks is off.  If set to non null string the string will be
  862.  * used as the socks host and socks will be used for all connections.
  863.  *
  864.  * returns 0 on hostname error (gethostbyname returning bad)
  865.  * 1 otherwise
  866.  */
  867. extern int NET_SetSocksHost(char * host);
  868.  
  869. /* set the number of seconds for the tcp connect timeout
  870.  *
  871.  * this timeout is used to end connections that do not
  872.  * timeout on there own
  873.  */
  874. extern void NET_SetTCPConnectTimeout(uint32 seconds);
  875.  
  876. /* Is there a registered converter for the passed mime_type  */
  877. extern XP_Bool NET_HaveConverterForMimeType(char *content_type);
  878.  
  879. /* builds an outgoing stream and returns a stream class structure
  880.  * containing a stream function table
  881.  */
  882. extern NET_StreamClass * NET_StreamBuilder (
  883.         FO_Present_Types  format_out,
  884.         URL_Struct *      anchor,
  885.         MWContext *       window_id);
  886.  
  887.  
  888. /* bit flags for determining what we want to parse from the URL
  889.  */
  890. #define GET_ALL_PARTS              127
  891. #define GET_PASSWORD_PART            64
  892. #define GET_USERNAME_PART            32
  893. #define GET_PROTOCOL_PART          16
  894. #define GET_HOST_PART               8
  895. #define GET_PATH_PART               4
  896. #define GET_HASH_PART               2
  897. #define GET_SEARCH_PART             1
  898.  
  899.  
  900.  /* return codes used by NET_BeginConnection
  901.  * and MSG_BeginOpenFolder
  902.  */
  903. #define MK_WAITING_FOR_CONNECTION    100
  904. #define MK_CONNECTED                  101
  905.  
  906. /* This function assumes a url that includes the protocol.
  907.  * Parses and returns peices of URL as defined by the
  908.  * bit flags in "wanted" which are defined above.
  909.  *
  910.  * Note: GET_HOST_PART returns the port number if one exists.
  911.  * always mallocs a returned string that must be freed
  912.  */
  913. extern char * NET_ParseURL (const char *url, int wanted);
  914.  
  915. /* decode % escaped hex codes into character values,
  916.  * modifies the parameter, returns the same buffer
  917.  */
  918. extern char * NET_UnEscape (char * str);
  919.  
  920. /* decode % escaped hex codes into character values,
  921.  * modifies the parameter buffer, returns the length of the result
  922.  * (result may contain \0's).
  923.  */
  924. extern int NET_UnEscapeCnt (char * str);
  925.  
  926. /* Like UnEscapeCnt but uses len to bound str, does not assume NUL termination
  927.  */
  928. extern int32  NET_UnEscapeBytes (char * str, int32 len);
  929.  
  930. /* a converter for plain text
  931.  */
  932. PUBLIC NET_StreamClass *
  933. NET_PlainTextConverter   (FO_Present_Types format_out,
  934.                           void       *data_obj,
  935.                           URL_Struct *URL_s,
  936.                           MWContext  *window_id);
  937.  
  938.  
  939. MODULE_PRIVATE NET_StreamClass *
  940. NET_ProxyAutoConfig(int fmt, void *data_obj, URL_Struct *URL_s, MWContext *w);
  941.  
  942. /* set the host to be used as an SMTP relay
  943.  */
  944. extern void NET_SetMailRelayHost(char * host);
  945.  
  946. /* add coordinates to the URL address
  947.  * in the form url?x,y
  948.  *
  949.  * any # or ? data previously on the URL is stripped
  950.  */
  951. extern int NET_AddCoordinatesToURLStruct(URL_Struct * url_struct, int32 x_coord, int32 y_coord);
  952.  
  953.  
  954. /* take a Layout generated LO_FormSubmitData_struct
  955.  * and use it to add post data to the URL Structure
  956.  * generated by CreateURLStruct
  957.  *
  958.  * DOES NOT Generate the URL Struct, it must be created prior to
  959.  * calling this function
  960.  *
  961.  * returns 0 on failure and 1 on success
  962.  */
  963. extern int NET_AddLOSubmitDataToURLStruct(LO_FormSubmitData * sub_data, 
  964.                                           URL_Struct * url_struct);
  965.  
  966. typedef enum {
  967.     IdententifyViaUniqueID,
  968.     IdentintifyViaEmailAddress,
  969.     DoNotIdentifyMe
  970. } IdentifyMeEnum;
  971.  
  972. /* set the method that the user wishes to identify themselves
  973.  * with.
  974.  * Default is DoNotIdentify unless this is called at startup
  975.  */
  976. extern void NET_SetIdentifyMeType(IdentifyMeEnum method);
  977.  
  978. /* set the users cookie prefs */
  979. typedef enum {
  980.     NET_SilentCookies,
  981.     NET_WhineAboutCookies,
  982.     NET_DontAcceptNewCookies,
  983.     NET_DisableCookies
  984. } NET_CookiePrefsEnum;
  985.  
  986. /* sets users inline cookie prefs */
  987. typedef enum {
  988.     NET_AllowForeignCookies,
  989.     NET_DoNotAllowForeignCookies
  990. } NET_ForeignCookiesEnum;
  991.  
  992. typedef enum {
  993.     NET_Accept,
  994.     NET_DontAcceptForeign,
  995.     NET_DontUse
  996. } NET_CookieBehaviorEnum;
  997.  
  998.  
  999. /* Register the cookie preferences callback functions. Only called once from mkgeturl. */
  1000. extern void NET_RegisterCookiePrefCallbacks(void);
  1001.  
  1002. /* Save the cookies. libnet ignores whatever filename is specified, for now.
  1003.  */
  1004. extern int NET_SaveCookies(char *filename);
  1005.  
  1006. /* returns a malloc'd string containing a unique id 
  1007.  * generated from the sec random stuff.
  1008.  */
  1009. extern char * NET_GetUniqueIdString(void);
  1010.  
  1011. /* pass in TRUE to disable disk caching
  1012.  * of SSL documents.
  1013.  * pass in FALSE to enable disk cacheing
  1014.  * of SSL documents
  1015.  */
  1016. extern void NET_DontDiskCacheSSL(XP_Bool set);
  1017.  
  1018. /* removes the specified number of objects from the
  1019.  * cache taking care to remove only the oldest objects.
  1020.  */
  1021. extern int32
  1022. NET_RemoveDiskCacheObjects(uint32 remove_num);
  1023.  
  1024. /* cleans up the cache directory by listing every
  1025.  * file and deleting the ones it doesn't know about
  1026.  * that begin with the cacheing prefix
  1027.  *
  1028.  * on entry:  Set
  1029.  *    dir_name: equal to the name of the directory where cache files reside
  1030.  *    prefix:   equal to the file prefix that cache files use. 
  1031.  *              (i.e. "cache" if all files begin with cacheXXXX)
  1032.  *
  1033.  *  remember that cache file names were generated by WH_TempName with
  1034.  *  the xpCache enum
  1035.  *
  1036.  */
  1037. extern int NET_CleanupCacheDirectory(char * dir_name, const char * prefix);
  1038.  
  1039. /* locks or unlocks a cache file.  The
  1040.  * cache lock is only good for a single
  1041.  * session
  1042.  * set=TRUE locks a file
  1043.  * set=FALSE unlocks a file
  1044.  */
  1045. extern Bool NET_ChangeCacheFileLock(URL_Struct *URL_s, Bool set);
  1046.  
  1047. /* Find an actively-loading cache file for URL_s in context, and copy the first
  1048.  * nbytes of it to a new cache file.  Return a cache converter stream by which
  1049.  * the caller can append to the cloned cache file.
  1050.  */
  1051. extern NET_StreamClass *
  1052. NET_CloneWysiwygCacheFile(MWContext *context, URL_Struct *URL_s, 
  1053.               uint32 nbytes, const char * wysiwyg_url,
  1054.               const char * base_href);
  1055.  
  1056. /* returns TRUE if the url is in the disk cache
  1057.  */
  1058. extern Bool NET_IsURLInDiskCache(URL_Struct *URL_s);
  1059.  
  1060. /* Returns TRUE if the URL is currently in the
  1061.  * memory cache and false otherwise.
  1062.  */
  1063. extern Bool NET_IsURLInMemCache(URL_Struct *URL_s);
  1064.  
  1065. /* returns TRUE if the URL->address passed in
  1066.  * is a local file URL
  1067.  */
  1068. extern XP_Bool NET_IsLocalFileURL(char *address);
  1069.  
  1070. /* unload the disk cache FAT list to disk
  1071.  *
  1072.  * set final_call to true if this is the last call to
  1073.  * this function before cleaning up the cache and shutting down.
  1074.  *
  1075.  * Front ends should never set final_call to TRUE, this will
  1076.  * be done by the cache cleanup code when the netlib is being
  1077.  * shutdown.
  1078.  */
  1079. extern void NET_WriteCacheFAT(char *filename, Bool final_call);
  1080.  
  1081. /* removes all cache files from the cache directory
  1082.  * and deletes the cache FAT
  1083.  */
  1084. extern int NET_DestroyCacheDirectory(char * dir_name, char * prefix);
  1085.  
  1086. /* set the size of the Memory cache in bytes
  1087.  * (The size should almost never be breached except when set exceptionally low)
  1088.  * Set it to 0 if you want cacheing turned off
  1089.  * completely
  1090.  *
  1091.  *
  1092.  * if you want to free up a bunch of memory
  1093.  * set the size to zero and then set it back
  1094.  * to some normal value.  
  1095.  */
  1096. extern void NET_SetMemoryCacheSize(int32 new_size);
  1097.  
  1098. /* set the size of the Disk cache.
  1099.  * Set it to 0 if you want cacheing turned off
  1100.  * completely
  1101.  */
  1102. extern void NET_SetDiskCacheSize(int32 new_size);
  1103.  
  1104. /* returns the number of bytes currently in use by the Memory cache
  1105.  */
  1106. extern int32 NET_GetMemoryCacheSize(void);
  1107.  
  1108. /* returns the ceiling on the memory cache
  1109.  */
  1110. extern int32 NET_GetMaxMemoryCacheSize(void);
  1111.     
  1112. /* returns the number of bytes currently in use by the disk cache
  1113.  */
  1114. extern int32 NET_GetDiskCacheSize(void);
  1115.  
  1116. /* returns the number of files currently in the
  1117.  * disk cache
  1118.  */
  1119. extern uint32 NET_NumberOfFilesInDiskCache();
  1120.  
  1121. /* remove the last memory cache object if one exists
  1122.  * returns the total size of the memory cache in bytes
  1123.  * after performing the operation
  1124.  */
  1125. extern int32 NET_RemoveLastMemoryCacheObject(void);
  1126.  
  1127. /* remove the last disk cache object if one exists
  1128.  * returns the total size of the disk cache in bytes
  1129.  * after performing the operation
  1130.  */
  1131.  
  1132.  
  1133. /* larubbio 197 SAR cache functions */
  1134. /* returns and creates a handle to the specified SAR cache 
  1135.  * the user is responsible for freeing the return struct
  1136.  */
  1137. extern ExtCacheDBInfo * CACHE_GetCache(ExtCacheDBInfo *db);
  1138.  
  1139. /* 
  1140.  * Adds the specified file to the cache.
  1141.  */
  1142. extern Bool CACHE_Put(char *filename, URL_Struct *url_s);
  1143.  
  1144. /* returns 0 if the url is not found, non-zero otherwise.  It
  1145.  * fills in URL_Struct as needed
  1146.  */
  1147. extern int CACHE_FindURLInCache(URL_Struct *URL_s, MWContext *ctxt);
  1148.  
  1149. /* Flushes the caches data to disk */
  1150. extern void CACHE_FlushCache(ExtCacheDBInfo *db_info);
  1151.  
  1152. /* Closes the SARcache database */
  1153. extern int CACHE_CloseCache(ExtCacheDBInfo *db);
  1154.  
  1155. /* Emptys all the URL's from a cache */
  1156. extern int CACHE_EmptyCache(ExtCacheDBInfo *db);
  1157.  
  1158. /* Removes the URL from the cache */
  1159. extern void NET_RemoveURLFromCache(URL_Struct *URL_s);
  1160.  
  1161. /* Removes the cache from the list of cache's being managed */
  1162. extern int CACHE_RemoveCache(ExtCacheDBInfo *db);
  1163.  
  1164. /* Returns an already opened ExtCache struct */
  1165. extern ExtCacheDBInfo * CACHE_GetCacheStruct(char * path, char * filename, char * name);
  1166.  
  1167. /* Returns the platform specific path to a cache file */
  1168. extern char * CACHE_GetCachePath(char * filename);
  1169.  
  1170. /* Returns the list of managed caches */
  1171. extern XP_List * CACHE_GetManagedCacheList();
  1172.  
  1173. /* Saves the cache struct to the DB */
  1174. extern void CACHE_SaveCacheInfoToDB(ExtCacheDBInfo *db_info);
  1175.  
  1176. /* Writes any changes to the cache's properties to disk */
  1177. extern void CACHE_UpdateCache(ExtCacheDBInfo *db_info);
  1178.  
  1179. extern int32 NET_RemoveLastDiskCacheObject(void);
  1180.  
  1181. /*--------------------------------------------------------------
  1182.  * cdata routines to manipulate extention to mime type mapping
  1183.  */
  1184.  
  1185. /* return the master cdata List pointer
  1186.  *
  1187.  * use the normal XP_List routines to iterate through
  1188.  */
  1189. extern XP_List * cinfo_MasterListPointer(void);
  1190.  
  1191. /* get the presumed content-type of the filename given
  1192.  */
  1193. extern NET_cinfo *NET_cinfo_find_type(char *uri);
  1194.  
  1195. /* return a cinfo from a mime_type
  1196.  */
  1197. extern NET_cinfo * NET_cinfo_find_info_by_type(char *mime_type);
  1198.  
  1199. /* remove an item from the cdata list
  1200.  */
  1201. extern void NET_cdataRemove(NET_cdataStruct *cd);
  1202.  
  1203. /* create a cdata struct
  1204.  *
  1205.  * does not fill anything in
  1206.  */
  1207. extern NET_cdataStruct * NET_cdataCreate(void);
  1208.  
  1209. /* fills in cdata structure
  1210.  *
  1211.  * if cdata for a given type do not exist, create a new one
  1212.  */
  1213. extern void NET_cdataCommit(char * mimeType, char * cdataString);
  1214.  
  1215. /* returns an extension (without the ".") for
  1216.  * a given mime type.
  1217.  *
  1218.  * If no match is found NULL is returned.
  1219.  *
  1220.  * Do not free the returned char *
  1221.  */
  1222. extern char * NET_cinfo_find_ext(char *mime_type);
  1223.  
  1224. /* check to see if this is an old mime type */
  1225. extern XP_Bool NET_IsOldMimeTypes (XP_List *masterList);
  1226.  
  1227. #ifdef XP_UNIX
  1228. extern XP_List * mailcap_MasterListPointer(void);
  1229. extern NET_mdataStruct *NET_mdataCreate(void);
  1230. extern void NET_mdataAdd(NET_mdataStruct *md);
  1231. extern void NET_mdataRemove(NET_mdataStruct *md);
  1232. extern void NET_mdataFree(NET_mdataStruct *md);
  1233. extern NET_mdataStruct* NET_mdataExist(NET_mdataStruct *old_md );
  1234. #endif
  1235.  
  1236.  
  1237. /* toggles netlib trace messages on and off
  1238.  */
  1239. PUBLIC void NET_ToggleTrace(void);
  1240.  
  1241. /* Makes a relative URL into an absolute one.
  1242.  *
  1243.  * If an absolute url is passed in it will be copied and returned.
  1244.  *
  1245.  * Always returns a malloc'd string or NULL on out of memory error
  1246.  */
  1247. PUBLIC char *
  1248. NET_MakeAbsoluteURL(char * absolute_url, char * relative_url);
  1249.  
  1250. /* FE_SetupAsyncSelect
  1251.  *
  1252.  * This function will setup the messages needed for windows Async functionality
  1253.  */
  1254.  
  1255.  
  1256. /* encode illegal characters into % escaped hex codes.
  1257.  *
  1258.  * mallocs and returns a string that must be freed
  1259.  */
  1260. PUBLIC char * NET_Escape (const char * str, int mask);
  1261.  
  1262. /* Like NET_Escape, but if out_len is non-null, return result string length
  1263.  * in *out_len, and uses len instead of NUL termination.
  1264.  */
  1265. PUBLIC char * NET_EscapeBytes (const char * str, int32 len, int mask,
  1266.                    int32 * out_len);
  1267.  
  1268. /* return the size of a string if it were to be escaped.
  1269.  */
  1270. extern int32 NET_EscapedSize (const char * str, int mask);
  1271.  
  1272. /*
  1273.  * valid mask values for NET_Escape() and NET_EscapedSize().
  1274.  */
  1275. #define URL_XALPHAS     (unsigned char) 1
  1276. #define URL_XPALPHAS    (unsigned char) 2
  1277. #define URL_PATH        (unsigned char) 4
  1278.  
  1279.  
  1280.  
  1281. #if !defined(XP_UNIX)
  1282.  
  1283. /* these routines are depricated and should be removed shortely */
  1284.  
  1285. extern int 
  1286. FE_SetupAsyncSelect(unsigned int sock, MWContext * context);
  1287.  
  1288. /* Start an async DNS lookup
  1289.  */
  1290. extern int 
  1291. FE_StartAsyncDNSLookup(MWContext *context, char * host_port, void ** hoststruct_ptr_ptr, int sock);
  1292. #endif
  1293.  
  1294. /*
  1295.  * NET_GetURL is called to begin the transfer of a URL
  1296.  *
  1297.  * URL_s:         see above
  1298.  * output_format: is a variable that specifies what to
  1299.  *        do with the outgoing data stream.
  1300.  * window_id:     is an identifier that will be used to
  1301.  *        determine where status messages and displayed data
  1302.  *        will be sent.
  1303.  * exit_routine:  is a callback function that will be
  1304.  *        invoked by the network library at the completion of a
  1305.  *        transfer or in case of error.
  1306.  *
  1307.  * Returns negative if the entire GET operation completes
  1308.  * in a single call or an error causes the transfer to
  1309.  * not happen.  In that case the exit_routine will be called
  1310.  * before returning from NET_GetURL.  A negative response
  1311.  * does not carry any other meaning than finished.  The status
  1312.  * passed into the exit_routine relays the success or failure
  1313.  * of the actual load and contains a meaningfull error status code.
  1314.  */
  1315.  
  1316. extern int
  1317. NET_GetURL (URL_Struct * URL_s,
  1318.         FO_Present_Types output_format,
  1319.         MWContext * context,
  1320.         Net_GetUrlExitFunc*    exit_routine);
  1321.  
  1322. /* URL methods
  1323.  */
  1324. #define URL_GET_METHOD    0
  1325. #define URL_POST_METHOD   1
  1326. #define URL_HEAD_METHOD   2
  1327. #define URL_PUT_METHOD    3
  1328. #define URL_DELETE_METHOD 4
  1329. #define URL_MKDIR_METHOD  5
  1330. #define URL_MOVE_METHOD   6
  1331. #define URL_INDEX_METHOD  7
  1332. #define URL_GETPROPERTIES_METHOD 8
  1333. #define URL_COPY_METHOD    9
  1334.  
  1335. /* LDAP METHOD IDs for URL_s->method */
  1336. #define LDAP_SEARCH_METHOD    100 /* Address book search */
  1337. #define LDAP_LI_GET_METHOD    101 /* Get LDAPMessage* results from a LDAP URL to search */
  1338. #define LDAP_LI_ADD_METHOD    102 /* Add an entry given LDAPMods */
  1339. #define LDAP_LI_MOD_METHOD    103 /* Modify an entry given LDAPMods */
  1340. #define LDAP_LI_DEL_METHOD    104 /* Delete an entry given the DN */
  1341. #define LDAP_LI_PUTFILE_METHOD    105 /* Put a file into a given DN and attribute, given a local path */
  1342. #define LDAP_LI_GETFILE_METHOD    106 /* Retreive an attribute into a local file, given DN and attribute */
  1343. #define LDAP_LI_ADDGLM_METHOD 107 /* Add an entry, then return the result
  1344.                                    *  of a search for the modified entry's
  1345.                                    *  modifyTimeStamp attribute
  1346.                                    */
  1347. #define LDAP_LI_MODGLM_METHOD 108 /* Modify an entry, then return the result
  1348.                                    *  of a search for the modified entry's
  1349.                                    *  modifyTimeStamp attribute
  1350.                                    */
  1351. #define LDAP_LI_GETLASTMOD_METHOD 109 /* Return an entry's modifyTimeStamp attribute.
  1352.                                        * Any attributes specified in the URL will be ignored
  1353.                                        */
  1354. #define LDAP_LI_BIND_METHOD 110        /* Bind as a particular user DN to an ldap server. 
  1355.                                      */
  1356.  
  1357. /*
  1358.  * NET_ProcessNet should be called repeatedly from the
  1359.  * clients main event loop to process network activity.
  1360.  * When there are active connections in progress
  1361.  * NET_ProcessNet will return one(1). If there are no
  1362.  * active connections open NET_ProcessNet will return
  1363.  * zero(0).
  1364.  */
  1365. PUBLIC int NET_ProcessNet(PRFileDesc *ready_fd, int fd_type);
  1366. #define NET_UNKNOWN_FD     0
  1367. #define NET_LOCAL_FILE_FD  1
  1368. #define NET_SOCKET_FD      2
  1369. #define NET_EVERYTIME_TYPE 3
  1370.  
  1371. /* call PR_Poll and call Netlib if necessary
  1372.  *
  1373.  * return FALSE if no sockets to process
  1374.  *
  1375.  * Should be called in OnIdle loop to service netlib 
  1376.  */
  1377. PUBLIC XP_Bool NET_PollSockets(void);
  1378.  
  1379. /* NET_InterruptWindow  interrupts all in progress transfers
  1380.  * that were initiated with the same window_id
  1381.  *
  1382.  * FE_GetContextID() is used internally to compare the
  1383.  * unique window_id's of the in progress transfers and
  1384.  * the window_id passed in
  1385.  */
  1386. extern int NET_InterruptWindow(MWContext * window_id);
  1387.  
  1388. /* Does the same thing as interruptWindow, but it
  1389.  * doesn't complain about reentrancy since it is
  1390.  * expected when calling this routine.
  1391.  *
  1392.  * NOTE that you can interrupt the stream that
  1393.  * you are calling from
  1394.  */
  1395. extern int NET_SilentInterruptWindow(MWContext * window_id);
  1396.  
  1397. /*
  1398.  *    NET_InterruptStream kills just stream associated with an URL.
  1399.  */
  1400. extern int NET_InterruptStream (URL_Struct *nurl);
  1401.  
  1402. /* set the netlib active entry coresponding to the
  1403.  * passed in URL to the busy state passed in.
  1404.  * TRUE to set busy, FALSE to set non-busy
  1405.  *
  1406.  * returns TRUE if found and set
  1407.  * returns FALSE if entry not found
  1408.  */
  1409. Bool NET_SetActiveEntryBusyStatus(URL_Struct *nurl, Bool set_busy);
  1410.  
  1411. /* interrupt a LoadURL action by using a socket number as
  1412.  * an index.  NOTE: that this cannot interrupt non-socket
  1413.  * based operations such as file or memory cache loads
  1414.  *
  1415.  * returns -1 on error.
  1416.  */
  1417. extern int NET_InterruptSocket (PRFileDesc *socket);
  1418.  
  1419. /* check for any active URL transfers in progress for the given
  1420.  * window Id
  1421.  *
  1422.  * It is possible that there exist URL's on the wait queue that
  1423.  * will not be returned by this function.  It is recommended
  1424.  * that you call NET_InterruptWindow(MWContext * window_id)
  1425.  * when FALSE is returned to make sure that the wait queue is
  1426.  * cleared as well.
  1427.  */
  1428. extern Bool NET_AreThereActiveConnectionsForWindow(MWContext * window_id);
  1429.  
  1430. #ifdef XP_MAC
  1431. /* pchen - Fix bug #72831. Same as
  1432.  * NET_AreThereActiveConnectionsForWindow except that it will
  1433.  * return false if there is an active connection that is busy.
  1434.  */
  1435. extern Bool NET_AreThereNonBusyActiveConnectionsForWindow(MWContext * window_id);
  1436. #endif /* XP_MAC */
  1437.  
  1438. /* check for network activity in general (not local disk or memory).
  1439.  */
  1440. extern Bool NET_HasNetworkActivity(MWContext * window_id, Bool waiting, Bool background);
  1441.  
  1442. /* NET_CreateURLStruct is used to build the URL structure
  1443.  * and to fill it with data.
  1444.  *
  1445.  * NET_FreeURLStruct should be called to free the returned
  1446.  * structure after the transfer is completed. ( this should
  1447.  * probably take place in the exit_routine passed as the callback
  1448.  * function to NET_GetURL)
  1449.  */
  1450. extern URL_Struct * NET_CreateURLStruct (const char *url, NET_ReloadMethod force_reload);
  1451.  
  1452. /* Append Key, Value pair into AllHeaders list of URL_struct
  1453.  */
  1454. extern Bool NET_AddToAllHeaders(URL_Struct * URL_s, char *name, char *value);
  1455.  
  1456. /* Set the option IPAddressString field
  1457.  * This field overrides the hostname when doing the connect, 
  1458.  * and allows Java to specify a spelling of an IP number.
  1459.  * returns 0 on success, non-zero for failure (out of memory)
  1460.  */
  1461. extern int NET_SetURLIPAddressString (URL_Struct * URL_s, const char *ip_string);
  1462.  
  1463. /* Free's the contents of the structure as well as
  1464.  * the structure
  1465.  */
  1466. extern void NET_FreeURLStruct (URL_Struct * URL_s);
  1467.  
  1468. /* Let someone keep a pointer to the URL struct without them
  1469.  * having to worry about it going away out from under them
  1470.  */
  1471. extern URL_Struct * NET_HoldURLStruct (URL_Struct * URL_s);
  1472.  
  1473. /* Macro sugar to complement NET_HoldURLStruct */
  1474. #define NET_DropURLStruct NET_FreeURLStruct
  1475.  
  1476. /* returns a text string explaining the negative status code
  1477.  * returned from mkgeturl
  1478.  */
  1479. extern const char * NET_ExplainError(int code);
  1480.  
  1481. /* returns true if the URL is a secure URL address
  1482.  */
  1483. extern Bool NET_IsURLSecure(char * address);
  1484.  
  1485. /*
  1486.  *  NewMKStream
  1487.  *  Utility to create a new initialized NET_StreamClass object
  1488.  */
  1489. extern NET_StreamClass * NET_NewStream(char *, 
  1490.                                        MKStreamWriteFunc, 
  1491.                                        MKStreamCompleteFunc, 
  1492.                                        MKStreamAbortFunc, 
  1493.                                        MKStreamWriteReadyFunc,
  1494.                                        void *, 
  1495.                                        MWContext *);
  1496.  
  1497. /* this should really be a FE function
  1498.  */ 
  1499. extern void NET_RegisterConverters(char * personal_file, char * global_file);
  1500. extern XP_List *NET_GetRegConverterList(FO_Present_Types iFormatOut);
  1501. extern void *NET_GETDataObject(XP_List *list, char *pMimeType, void** obj);
  1502. extern void NET_CleanupMailCapList(char* filename);
  1503.  
  1504. /*  Register a routine to convert between format_in and format_out
  1505.  */
  1506. /*  Reroute XP handling of streams for windows.
  1507.  */
  1508. extern void NET_RegContentTypeConverter (char * format_in,
  1509.                                               FO_Present_Types format_out,
  1510.                                               void          * data_obj,
  1511.                                               NET_Converter * converter_func,
  1512.                                               XP_Bool          bAutomated);
  1513.  
  1514. /*  This function found in the windows front end.
  1515.  */
  1516. extern void NET_RegisterContentTypeConverter (char          * format_in,
  1517.                                               FO_Present_Types format_out,
  1518.                                               void          * data_obj,
  1519.                                               NET_Converter * converter_func);
  1520.  
  1521. extern void NET_DeregisterContentTypeConverter (char          * format_in,
  1522.                                                 FO_Present_Types format_out);
  1523.  
  1524. extern void
  1525. NET_RegisterExternalViewerCommand(char * format_in,
  1526.                         char * system_command,
  1527.                                 unsigned int stream_block_size);
  1528.  
  1529. /* register a routine to decode a stream
  1530.  */
  1531. extern void NET_RegisterEncodingConverter (char              * encoding_in,
  1532.                                            void           * data_obj,
  1533.                                            NET_Converter  * converter_func);
  1534.  
  1535. #ifdef NEW_DECODERS
  1536. /* removes all registered converters of any kind
  1537.  */
  1538. extern void NET_ClearAllConverters(void);
  1539. #endif /* NEW_DECODERS */
  1540.  
  1541.  
  1542. #ifdef XP_UNIX
  1543. /* register an external program to act as a content-encoding
  1544.  * converter
  1545.  */
  1546. extern void NET_RegisterExternalDecoderCommand (char * format_in,
  1547.                                                 char * format_out,
  1548.                                                 char * system_command);
  1549. #endif /* XP_UNIX */
  1550.  
  1551.  
  1552.  
  1553. /* set the NNTP server hostname
  1554.  */
  1555. extern void NET_SetNewsHost(const char * hostname);
  1556.  
  1557. extern NET_StreamClass * NET_CacheConverter (FO_Present_Types format_out,
  1558.                                              void       *converter_obj,
  1559.                                              URL_Struct *URL_s,
  1560.                                              MWContext  *window_id);
  1561.  
  1562. /* init types loads standard types so that a config file
  1563.  * is not required and can also read
  1564.  * a mime types file if filename is passed in non empty and
  1565.  * non null
  1566.  *
  1567.  * on each call to NET_InitFileFormatTypes the extension list
  1568.  * will be completely free'd and rebuilt.
  1569.  *
  1570.  * if you pass in NULL filename pointers they will not be
  1571.  * attempted to be read
  1572.  */
  1573. extern int NET_InitFileFormatTypes(char * personal_file, char *global_file);
  1574. extern void NET_cdataAdd(NET_cdataStruct *cd);
  1575. extern NET_cdataStruct* NET_cdataExist(NET_cdataStruct *old_cd );
  1576. extern void NET_cdataFree(NET_cdataStruct *cd);
  1577.  
  1578. #ifdef XP_UNIX
  1579. extern void NET_CleanupFileFormat(char *filename);
  1580. #else
  1581. extern void NET_CleanupFileFormat(void);
  1582. #endif
  1583.  
  1584.  
  1585. /* initialize the netlibrary
  1586.  */
  1587. extern int NET_InitNetLib(int socket_buffer_size, int max_number_of_connections);
  1588.  
  1589. /* reads a mailcap file and adds entries to the
  1590.  * external viewers converter list
  1591.  */  
  1592. extern int NET_ProcessMailcapFile (char *file, Bool is_local);
  1593.  
  1594. /* removes all external viewer commands
  1595.  */
  1596. extern void NET_ClearExternalVieweraConverters(void);
  1597.  
  1598. /* shutdown the netlibrary, cancel all
  1599.  * conections and free all
  1600.  * memory
  1601.  */
  1602. extern void NET_ShutdownNetLib(void);
  1603.  
  1604. /* set the maximum allowable number of open connections at any one
  1605.  * time
  1606.  */
  1607. extern void NET_ChangeMaxNumberOfConnections(int max_number_of_connections);
  1608.  
  1609. /* set the maximum allowable number of open connections at any one
  1610.  * time on a per context basis
  1611.  */
  1612. extern void NET_ChangeMaxNumberOfConnectionsPerContext(int max_number_of_connections);
  1613.  
  1614. /* allocate memory for the TCP socket
  1615.  * buffer
  1616.  * this is an optional call
  1617.  */
  1618. extern int NET_ChangeSocketBufferSize (int size);
  1619.  
  1620. typedef enum {    
  1621.         FTP_PROXY = 0,
  1622.         GOPHER_PROXY,
  1623.         HTTP_PROXY,
  1624.         HTTPS_PROXY,
  1625.         NEWS_PROXY,
  1626.         WAIS_PROXY,
  1627.         NO_PROXY,
  1628.         PROXY_AUTOCONF_URL
  1629. } NET_ProxyType;
  1630.  
  1631. typedef enum {
  1632.         PROXY_STYLE_UNSET = 0, /* do not change these without notifying macfe */
  1633.         PROXY_STYLE_MANUAL = 1,
  1634.         PROXY_STYLE_AUTOMATIC = 2,
  1635.         PROXY_STYLE_NONE = 3
  1636. } NET_ProxyStyle;
  1637.  
  1638. /* set (or unset) a proxy server
  1639.  *
  1640.  *  call with a host[:port] string or an http url
  1641.  *  of the form http://host[:port]/
  1642.  *
  1643.  * if type is NO_PROXY send a comma deliminated string
  1644.  * of host and port numbers of the form
  1645.  *  host[:port]{,host[:port]}*
  1646.  *
  1647.  *  if type is PROXY_AUTOCONFIG_URL it sets the URL pointing to
  1648.  *  a new-style automatic proxy configuration file.
  1649.  *
  1650.  *  A call to function NET_SelectProxyStyle() should be made after
  1651.  *  *ALL* the calls to these functions have been done.
  1652.  *
  1653.  *  you can unset values by setting the type and passing
  1654.  *  NULL as the host_port string
  1655.  */
  1656. PUBLIC void NET_SetProxyServer(NET_ProxyType type, const char * host_port);
  1657.  
  1658.  
  1659. /*
  1660.  * Select proxy style;
  1661.  * one of:
  1662.  *
  1663.  *      PROXY_STYLE_MANUAL      -- for old style proxies
  1664.  *      PROXY_STYLE_AUTOMATIC   -- for new style proxies
  1665.  *      PROXY_STYLE_NONE        -- for no proxies at all
  1666.  *
  1667.  * This function should be called only *AFTER* all the calls to
  1668.  * NET_SetProxyServer() function have been made.
  1669.  *
  1670.  */
  1671. PUBLIC void
  1672. NET_SelectProxyStyle(NET_ProxyStyle style);
  1673.  
  1674.  
  1675. /*
  1676.  * Force to reload automatic proxy config.
  1677.  * Has any effect only if proxy style has been set to
  1678.  * PROXY_STYLE_AUTOMATIC.
  1679.  *
  1680.  */
  1681. PUBLIC void
  1682. NET_ReloadProxyConfig(MWContext *window_id);
  1683.  
  1684.  
  1685. /*
  1686.  * NET_SetNoProxyFailover
  1687.  * Sets a flag that indicates that proxy failover should not
  1688.  * be done.  This is used by the Enterprise Kit code, where
  1689.  * the customer might configure the client to use specific
  1690.  * proxies.  In these cases, failover can cause different
  1691.  * proxies, or no proxies to be used.
  1692.  */
  1693. PUBLIC void
  1694. NET_SetNoProxyFailover(void);
  1695.  
  1696.  
  1697. /*
  1698.  * Returns a pointer to a NULL-terminted buffer which contains
  1699.  * the text of the proxy autoconfig file.
  1700.  *
  1701.  * NULL if not enabled.
  1702.  *
  1703.  */
  1704. PUBLIC char * NET_GetProxyConfigSource(void);
  1705.  
  1706.  
  1707.  
  1708. typedef enum {
  1709.     CU_CHECK_PER_SESSION,
  1710.     CU_CHECK_ALL_THE_TIME,
  1711.     CU_NEVER_CHECK
  1712. } CacheUseEnum;
  1713.  
  1714. /* set the way the cache objects should
  1715.  * be checked
  1716.  */
  1717. extern void NET_SetCacheUseMethod(CacheUseEnum method);
  1718.  
  1719. /* set the number of articles shown in news at any one time
  1720.  */
  1721. extern void NET_SetNumberOfNewsArticlesInListing(int32 number);
  1722.  
  1723.  
  1724. /* Set whether to cache XOVER lines in an attempt to make news go faster
  1725.  */
  1726. extern void NET_SetCacheXOVER(XP_Bool value);
  1727.  
  1728.  
  1729. /* Tell netlib to clean up any strictly temporary cache files it has for XOVER
  1730.    data.  (This is called by msglib when the news context is destroyed.) */
  1731. extern void NET_CleanTempXOVERCache(void);
  1732.  
  1733.  
  1734. /* Register decoder functions for the standard MIME encodings.  */
  1735. PUBLIC void NET_RegisterMIMEDecoders (void);
  1736.  
  1737. /* Create a netlib stream for interpreting Mocha.  */
  1738. PUBLIC NET_StreamClass *
  1739. NET_CreateMochaConverter(FO_Present_Types format_out,
  1740.                          void             *data_object,
  1741.                          URL_Struct       *URL_struct,
  1742.                          MWContext        *window_id);
  1743.  
  1744. /* check the date and set off the timebomb if necessary
  1745.  *
  1746.  * Calls FE_Alert with a message and then disables
  1747.  * all network calls to hosts not in our domains,
  1748.  * except for FTP connects.
  1749.  */
  1750. extern Bool NET_CheckForTimeBomb(MWContext *context);
  1751.  
  1752. /* parse a mime header.
  1753.  * the outputFormat is passed in and passed to NET_SetCookieStringFromHttp
  1754.  *
  1755.  * Both name and value strings will be modified during
  1756.  * parsing.  If you need to retain your strings make a
  1757.  * copy before passing them in.
  1758.  *
  1759.  * Values will be placed in the URL struct.
  1760.  *
  1761.  * returns TRUE if it found a valid header
  1762.  * and FALSE if it didn't
  1763.  */
  1764. PUBLIC Bool
  1765. NET_ParseMimeHeader(FO_Present_Types outputFormat,
  1766.                     MWContext  *context,
  1767.                     URL_Struct *URL_s,
  1768.                     char       *name,
  1769.                     char       *value,
  1770.                     XP_Bool    is_http);
  1771.  
  1772.  
  1773. /* scans a line for references to URL's and turns them into active
  1774.  * links.  If the output size is exceeded the line will be
  1775.  * truncated.  "output" must be at least "output_size" characters
  1776.  * long.  If urls_only_p is FALSE, then also tweak citations (lines starting
  1777.  * with ">").
  1778.  *
  1779.  * The MSG_Pane* parameter is used to determine preferences for fonts
  1780.  * used in citations.  If it is NULL, then boring defaults are used.
  1781.  */
  1782.  
  1783. extern int NET_ScanForURLs(MSG_Pane* pane, const char *input, int32 input_size,
  1784.                            char *output, int output_size, XP_Bool urls_only_p);
  1785.  
  1786.  
  1787. /* Takes an arbitrary chunk of HTML, and returns another chunk which has had
  1788.    any URLs turned into references.  The result is in a new string that
  1789.    must be free'd using XP_FREE(). */
  1790.  
  1791. extern char* NET_ScanHTMLForURLs(const char* input);
  1792.  
  1793.  
  1794.  
  1795. /* escapes all '<', '>' and '&' characters in a string
  1796.  * returns a string that must be freed
  1797.  */
  1798. extern char * NET_EscapeHTML(const char * string);
  1799.  
  1800.  
  1801. /* register a newsrc file mapping
  1802.  */
  1803. extern Bool NET_RegisterNewsrcFile(char *filename, 
  1804.                                    char *hostname, 
  1805.                                    Bool  is_secure,
  1806.                                    Bool  is_newsgroups_file);
  1807.  
  1808. /* removes a newshost to file mapping.  Removes both
  1809.  * the newsrc and the newsgroups mapping
  1810.  * this function does not remove the actual files,
  1811.  * that is left up to the caller
  1812.  */
  1813. extern void NET_UnregisterNewsHost(const char *host, Bool is_secure);
  1814.  
  1815. /* user has removed a news host from the UI. 
  1816.  * be sure it has also been removed from the
  1817.  * connection cache so we renegotiate news host
  1818.  * capabilities if we try to use it again
  1819.  */
  1820. extern void NET_OnNewsHostDeleted (const char *host);
  1821.  
  1822. /* map a filename and security status into a filename
  1823.  *
  1824.  * returns NULL on error or no mapping.
  1825.  */
  1826. extern char * NET_MapNewsrcHostToFilename(char *host, 
  1827.                                           Bool  is_secure,
  1828.                                           Bool  is_newsgroups_file);
  1829.  
  1830. /* save newsrc file mappings from memory onto disk
  1831.  */
  1832. extern Bool NET_SaveNewsrcFileMappings(void);
  1833.  
  1834. /* read newsrc file mappings from disk into memory
  1835.  */
  1836. extern Bool NET_ReadNewsrcFileMappings(void);
  1837.  
  1838. /* free newsrc file mappings in the memory
  1839.  */
  1840. extern void NET_FreeNewsrcFileMappings(void);
  1841.  
  1842. /* returns a malloc'd string that has a bunch of netlib
  1843.  * status info in it.
  1844.  *
  1845.  * please free the pointer when done.
  1846.  */
  1847. extern char * NET_PrintNetlibStatus(void);
  1848.  
  1849. /* add an external URL type prefix
  1850.  *
  1851.  * this prefix will be used to see if a URL is an absolute
  1852.  * or a relative URL.
  1853.  *
  1854.  * you should just pass in the prefix of the URL
  1855.  *
  1856.  * for instance "http" or "ftp" or "foobar".
  1857.  *
  1858.  * do not pass in a colon or double slashes.
  1859.  */
  1860. extern void NET_AddExternalURLType(char * type);
  1861.  
  1862. /* remove an external URL type prefix
  1863.  */
  1864. extern void NET_DelExternalURLType(char * type);
  1865.  
  1866. /*
  1867.  *  NET_SetNewContext changes the context associated with a URL Struct.
  1868.  *    can also change the url exit routine, which will cause the old one
  1869.  *    to be called with a status of MK_CHANGING_CONTEXT
  1870.  */
  1871. extern int NET_SetNewContext(URL_Struct *URL_s, MWContext * new_context, Net_GetUrlExitFunc *exit_routine);
  1872.  
  1873. /* returns true if the stream is safe for setting up a new
  1874.  * context and using a separate window.
  1875.  *
  1876.  * This will return FALSE in multipart/mixed cases where
  1877.  * it is impossible to use separate windows for the
  1878.  * same stream.
  1879.  */
  1880. extern Bool NET_IsSafeForNewContext(URL_Struct *URL_s);
  1881.  
  1882. /* set the pop3 option to leave a copy of old
  1883.  * mail on the server
  1884.  */
  1885. extern void NET_LeavePopMailOnServer(Bool do_it);
  1886.  
  1887. /* Set the pop3 option of the biggest message to download.  If negative,
  1888.  * then there is no limit (this should be the default). */
  1889. extern void NET_SetPopMsgSizeLimit(int32 size);
  1890.  
  1891. /* Return what the current message size limit is (again, negative means no
  1892.  * limit.) */
  1893. extern int32 NET_GetPopMsgSizeLimit(void);
  1894.  
  1895. /* set the pop account username
  1896.  */
  1897. extern void NET_SetPopUsername(const char *username);
  1898.  
  1899. /* get the pop account username
  1900.  */
  1901. extern const char * NET_GetPopUsername(void);
  1902.  
  1903. /* set the pop account password
  1904.  */
  1905. extern void NET_SetPopPassword(const char *password);
  1906.  
  1907. /* get the pop account password
  1908.  */
  1909. extern const char * NET_GetPopPassword(void);
  1910.  
  1911. /* call this to enable/disable FTP PASV mode.
  1912.  * Note: PASV mode is on by default
  1913.  */
  1914. extern void NET_UsePASV(Bool do_it);
  1915.  
  1916. #if defined(XP_MAC) || defined(XP_UNIX)
  1917. /* call this with TRUE to enable the sending of the email
  1918.  * address as the default user "anonymous" password.
  1919.  * The default is OFF.  
  1920.  */
  1921. extern void NET_SendEmailAddressAsFTPPassword(Bool do_it);
  1922. #endif
  1923.  
  1924. /* begins the upload of the contents of a directory.
  1925.  * local_directory and remote_directory can both be NULL.
  1926.  * if either are NULL then it will prompt the user for them.
  1927.  */
  1928. extern void
  1929. NET_PublishDirectory(MWContext *context, 
  1930.                      char *local_directory, 
  1931.                      char *remote_directory);
  1932.  
  1933. /* upload a set of local files (array of char*)
  1934.  * all files must have full path name
  1935.  * first file is primary html document,
  1936.  * others are included images or other files
  1937.  * in the same directory as main file
  1938.  */
  1939. extern void
  1940. NET_PublishFiles(MWContext *context, 
  1941.                  char **files_to_publish,
  1942.                  char *remote_directory);
  1943. /* NET_PublishFiles is obsolete and should be removed (hardts).  Use Net_PublishFilesTo. */
  1944. /* files_to_publish and publish_to will be freed by NET_PublishFilesTo. */
  1945. extern void
  1946. NET_PublishFilesTo(MWContext *context, 
  1947.                  char **files_to_publish,
  1948.                  char **publish_to,  /* Absolute URLs of the location to 
  1949.                                       * publish the files to. */
  1950.                  XP_Bool *add_crlf, /* For each file in files_to_publish, should every line 
  1951.                                        end in a CRLF. */
  1952.                  char *base_url,       /* Directory to publish to, or the destination 
  1953.                                                 * URL of the root HTML document. */
  1954.                  char *username,  /* may be NULL, don't pass in through base_url. */
  1955.                  char *password,  /* may be NULL, don't pass in through base_url. */
  1956.                  Net_GetUrlExitFunc *exit_func, /* Called after publishing files is complete. 
  1957.                                                                             Can be NULL. */
  1958.                  void *fe_data);        /* Will be added as the fe_data field of the URL_Struct.  
  1959.                                                     So, it can be used as an argument that exit_func() can get 
  1960.                                                     ahold of. */
  1961.  
  1962. /* assemble username, password, and ftp:// or http://
  1963.  * URL into ftp://user:password@/blah  format for uploading
  1964.  * user_name or password are optional, allowing
  1965.  * construction of ftp://user@/blah for security reasons
  1966. */
  1967. extern Bool
  1968. NET_MakeUploadURL( char **full_location, char *location, 
  1969.                    char *user_name, char *password );
  1970.  
  1971. /* extract the username, password, and reassembled URL
  1972.  * string (e.g.: ftp://user:pass@neon -> ftp://neon)
  1973.  * from an ftp:// or http:// URL
  1974. */
  1975. extern Bool
  1976. NET_ParseUploadURL( char *full_location, char **location, 
  1977.                     char **user_name, char **password );
  1978.  
  1979.  
  1980. /* opens a directory and puts all the files therein into a
  1981.  * null terminated array of filenames
  1982.  * Returns NULL on error
  1983.  */
  1984. extern char **
  1985. NET_AssembleAllFilesInDirectory(MWContext *context, char * local_dir_name);
  1986.  
  1987. /* takes a local and a remote directory and loads all of the
  1988.  * files in the directory into a URL struct that it creates
  1989.  * and calls FE_GetURL to start the upload
  1990.  */
  1991. extern void
  1992. NET_UploadDirectory(MWContext *context, char *local_dir, char *remote_dir_url);
  1993.  
  1994.  
  1995. /* convert + to space within str.
  1996.  */
  1997. extern void NET_PlusToSpace(char *str);
  1998.  
  1999. /* url_type return types */
  2000. #define FILE_TYPE_URL           1
  2001. #define FTP_TYPE_URL            2
  2002. #define GOPHER_TYPE_URL         3
  2003. #define HTTP_TYPE_URL           4
  2004. #define MAILTO_TYPE_URL         5
  2005. #define NEWS_TYPE_URL           6
  2006. #define RLOGIN_TYPE_URL         7
  2007. #define TELNET_TYPE_URL         8
  2008. #define TN3270_TYPE_URL         9
  2009. #define WAIS_TYPE_URL           10
  2010. #define ABOUT_TYPE_URL          11
  2011. #define FILE_CACHE_TYPE_URL     12
  2012. #define MEMORY_CACHE_TYPE_URL   13
  2013. #define SECURE_HTTP_TYPE_URL    14
  2014. #define INTERNAL_IMAGE_TYPE_URL 15
  2015. #define URN_TYPE_URL            16
  2016. #define POP3_TYPE_URL           17
  2017. #define MAILBOX_TYPE_URL        18
  2018. #define INTERNAL_NEWS_TYPE_URL  19
  2019. #define SECURITY_TYPE_URL        20
  2020. #define MOCHA_TYPE_URL            21
  2021. #define VIEW_SOURCE_TYPE_URL    22
  2022. #define HTML_DIALOG_HANDLER_TYPE_URL 23
  2023. #define HTML_PANEL_HANDLER_TYPE_URL 24
  2024. #define INTERNAL_SECLIB_TYPE_URL 25
  2025. #define MSG_SEARCH_TYPE_URL     26
  2026. #define IMAP_TYPE_URL            27
  2027. #define LDAP_TYPE_URL            28
  2028. #define SECURE_LDAP_TYPE_URL    29
  2029. #define WYSIWYG_TYPE_URL        30
  2030. #define ADDRESS_BOOK_TYPE_URL    31
  2031. #define CLASSID_TYPE_URL        32
  2032. #define JAVA_TYPE_URL            33
  2033. #define DATA_TYPE_URL            34
  2034. #define NETHELP_TYPE_URL        35
  2035. #define NFS_TYPE_URL            36
  2036. #define MARIMBA_TYPE_URL        37
  2037. #define INTERNAL_CERTLDAP_TYPE_URL 38
  2038. #define ADDRESS_BOOK_LDAP_TYPE_URL 39
  2039.  
  2040. #define LAST_URL_TYPE 40  /* defines the max number of URL types there are */
  2041.  
  2042. /* A usefull function to test URL types (mkutils.cpp)
  2043.  * Unfortunately, we can't get to return values
  2044.  * We are most interested in FILE_TYPE_URL, which is 1
  2045. */
  2046. extern int NET_URL_Type(const char *URL);
  2047.  
  2048. /* CM these functions added to \libnet\MKPARSE.C: */
  2049. /* Returns TRUE if URL type is HTTP_TYPE_URL or SECURE_HTTP_TYPE_URL */
  2050. extern Bool NET_IsHTTP_URL(const char *URL);
  2051.  
  2052. /* Return values for NET_MakeRelativeURL */
  2053. enum {
  2054.     NET_URL_SAME_DIRECTORY,       /* Base and URL type only filename is different */
  2055.     NET_URL_SAME_DEVICE,          /* Base and URL are on same device, different directory */
  2056.     NET_URL_NOT_ON_SAME_DEVICE,   /* One is remote, other is local, or on different local drives */
  2057.     NET_URL_FAIL                 /* Failed for lack of params, etc. */
  2058. };
  2059.  
  2060. /* Converts absolute URL into an URL relative to the base URL
  2061.  * BasePath must be an HTTP: or FILE: URL type
  2062.  * absolute_url should be absolute url of the same type,
  2063.  *  but we pass it through NET_MakeAbsoluteURL so we can use
  2064.  *  relative input - ASSUMES SAME TYPE!
  2065.  * If relative_url is not supplied, tests are done,
  2066.  *   but no relative URL string is created
  2067.  * Caller must XP_FREE the string
  2068. */
  2069. int NET_MakeRelativeURL( char *base_url,
  2070.                          char *absolute_url,
  2071.                          char **relative_url );
  2072.  
  2073. /* Extract the filename from a source URL 
  2074.  *  and construct add it the same path as 
  2075.  *  a base URL (replacing file in base)
  2076.  * BasePath should be an HTTP: or FILE: URL type,
  2077.  *  but we don't check it.
  2078.  * src_url may be a relative URL,
  2079.  *  (if its an HTTP, and base_url is FILE,
  2080.  *   this creates the filename for saving
  2081.  *  remote image locally.)
  2082.  * If relative_url is supplied,
  2083.  *  the new relative URL is returned
  2084.  *  (just the "file" portion of src_url)
  2085.  * Caller must XP_FREE the string(s)
  2086. */
  2087. char * NET_MakeTargetURL( char *base_url,
  2088.                           char *src_url,
  2089.                           char **relative_url );
  2090.  
  2091. /*
  2092.  * call this function on navigator initialization and whenever the pref
  2093.  * changes.  PR_TRUE means that the warning dialog will be generated,
  2094.  * and PR_FALSE means that the warning dialog will NOT be generated.
  2095.  */
  2096. extern void NET_WarnOnMailtoPost(PRBool warn);
  2097.  
  2098. /* Is the user off-line - uses the network.online preference */
  2099. extern XP_Bool NET_IsOffline();
  2100.  
  2101. XP_END_PROTOS
  2102.  
  2103. #endif /* _NET_PROTO_H_ */
  2104.  
  2105.  
  2106.