home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / lib / libnet / mktcp.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  4.3 KB  |  160 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. #ifndef MKTCP_H
  19. #define MKTCP_H
  20.  
  21. #include "xp_sock.h"
  22. #include "mkutils.h"
  23.  
  24.  
  25. XP_BEGIN_PROTOS
  26.  
  27. /* state machine data for host connect */
  28. typedef struct _TCP_ConData TCP_ConData;  
  29.  
  30. /* the socks host in U long form
  31.  */
  32. extern u_long NET_SocksHost;
  33. extern short NET_SocksPort;
  34. extern char *NET_SocksHostName;
  35.  
  36. /* socket buffer and socket buffer size
  37.  * used for reading from sockets
  38.  */
  39. extern char * NET_Socket_Buffer;
  40. extern int    NET_Socket_Buffer_Size;
  41.  
  42. extern int NET_InGetHostByName;  /* global semaphore */
  43.  
  44. /* free any cached data in preperation
  45.  * for shutdown or to free up memory
  46.  */
  47. extern void NET_CleanupTCP (void);
  48.  
  49. /* 
  50.  * do a standard netwrite but echo it to stderr as well
  51.  */
  52. extern int 
  53. NET_DebugNetWrite (PRFileDesc *fildes, CONST void *buf, unsigned nbyte);
  54.  
  55. /* make sure the whole buffer is written in one call
  56.  */
  57. extern int32
  58. NET_BlockingWrite (PRFileDesc *filedes, CONST void * buf, unsigned int nbyte);
  59.  
  60.  
  61. /*  print an IP address from a sockaddr struct
  62.  *
  63.  *  This routine is only used for TRACE messages
  64.  */
  65. #if defined(XP_WIN) || defined(XP_OS2)
  66. extern char *CONST
  67. NET_IpString (struct sockaddr_in* sin);
  68. #else
  69. extern const char *
  70. NET_IpString (struct sockaddr_in* sin);
  71. #endif
  72.  
  73. /* return the local hostname
  74. */
  75. #ifdef XP_WIN
  76. extern char *CONST
  77. NET_HostName (void);
  78. #else
  79. extern CONST char * 
  80. NET_HostName (void);
  81. #endif
  82.  
  83. /* free left over tcp connection data if there is any
  84.  */
  85. extern void NET_FreeTCPConData(TCP_ConData * data);
  86.  
  87. /*
  88.  * Non blocking connect begin function.  It will most likely
  89.  * return negative. If it does the NET_ConnectFinish() will
  90.  * need to be called repeatably until a connect is established
  91.  *
  92.  * return's negative on error
  93.  * return's MK_WAITING_FOR_CONNECTION when continue is neccessary
  94.  * return's MK_CONNECTED on true connect
  95.  */ 
  96. extern int 
  97. NET_BeginConnect  (CONST char   *url,
  98.                    char         *ip_address_string,
  99.                    char         *protocol,
  100.                    int           default_port,
  101.                    PRFileDesc  **s, 
  102.                    Bool       use_security, 
  103.                    TCP_ConData **tcp_con_data, 
  104.                    MWContext    *window_id,
  105.                    char        **error_msg,
  106.                    u_long        socks_host,
  107.                    short         socks_port);
  108.  
  109.  
  110. /*
  111.  * Non blocking connect finishing function.  This routine polls
  112.  * the socket until a connection finally takes place or until
  113.  * an error occurs. NET_ConnectFinish() will need to be called 
  114.  * repeatably until a connect is established.
  115.  *
  116.  * return's negative on error
  117.  * return's MK_WAITING_FOR_CONNECTION when continue is neccessary
  118.  * return's MK_CONNECTED on true connect
  119.  */
  120. extern int 
  121. NET_FinishConnect (CONST char   *url,
  122.                    char         *protocol,
  123.                    int           default_port,
  124.                    PRFileDesc  **s,  
  125.                    TCP_ConData **tcp_con_data, 
  126.                    MWContext    *window_id,
  127.                    char        **error_msg);
  128.  
  129. /* 
  130.  * Echo to stderr as well as the socket
  131.  */
  132. extern int 
  133. NET_DebugNetRead (PRFileDesc *fildes, void *buf, unsigned nbyte);
  134.  
  135. /* this is a very standard network write routine.
  136.  * 
  137.  * the only thing special about it is that
  138.  * it returns MK_HTTP_TYPE_CONFLICT on special error codes
  139.  *
  140.  */
  141. extern int 
  142. NET_HTTPNetWrite (PRFileDesc *fildes, CONST void * buf, unsigned nbyte);
  143.  
  144. /* 
  145.  *
  146.  * trys to get a line of data from the socket or from the buffer
  147.  * that was passed in
  148.  */
  149. extern int NET_BufferedReadLine(PRFileDesc *sock, 
  150.                 char ** line, 
  151.                 char ** buffer, 
  152.                 int32 * buffer_size, 
  153.                 Bool * pause_for_next_read);
  154.  
  155.  
  156. extern void NET_SanityCheckDNS (MWContext *context);
  157.  
  158. XP_END_PROTOS
  159. #endif   /* MKTCP_H */
  160.