summaryrefslogtreecommitdiff
path: root/pr/include/obsolete/probslet.h
blob: 91efa45ab2e8c5be74bb1e506c564a1d4613188c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
 * The contents of this file are subject to the Netscape Public License
 * Version 1.1 (the "NPL"); you may not use this file except in
 * compliance with the NPL.  You may obtain a copy of the NPL at
 * http://www.mozilla.org/NPL/
 * 
 * Software distributed under the NPL is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
 * for the specific language governing rights and limitations under the
 * NPL.
 * 
 * The Initial Developer of this code under the NPL is Netscape
 * Communications Corporation.  Portions created by Netscape are
 * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
 * Reserved.
 */

/*
** A collection of things thought to be obsolete
*/

#if defined(PROBSLET_H)
#else
#define PROBSLET_H

#include "prio.h"

PR_BEGIN_EXTERN_C

/*
** Yield the current thread.  The proper function to use in place of
** PR_Yield() is PR_Sleep() with an argument of PR_INTERVAL_NO_WAIT.
*/
NSPR_API(PRStatus) PR_Yield(void);

/*
** These are obsolete and are replaced by PR_GetSocketOption() and
** PR_SetSocketOption().
*/

NSPR_API(PRStatus) PR_GetSockOpt(
    PRFileDesc *fd, PRSockOption optname, void* optval, PRInt32* optlen);

NSPR_API(PRStatus) PR_SetSockOpt(
    PRFileDesc *fd, PRSockOption optname, const void* optval, PRInt32 optlen);

/************************************************************************/
/************* The following definitions are for select *****************/
/************************************************************************/

/*
** The following is obsolete and will be deleted in the next release!
** These are provided for compatibility, but are GUARANTEED to be slow.
**
** Override PR_MAX_SELECT_DESC if you need more space in the select set.
*/
#ifndef PR_MAX_SELECT_DESC
#define PR_MAX_SELECT_DESC 1024
#endif
typedef struct PR_fd_set {
    PRUint32      hsize;
    PRFileDesc   *harray[PR_MAX_SELECT_DESC];
    PRUint32      nsize;
    PRInt32       narray[PR_MAX_SELECT_DESC];
} PR_fd_set;

/*
*************************************************************************
** FUNCTION:    PR_Select
** DESCRIPTION:
**
** The call returns as soon as I/O is ready on one or more of the underlying
** file/socket descriptors or an exceptional condition is pending. A count of the 
** number of ready descriptors is returned unless a timeout occurs in which case 
** zero is returned.  On return, PR_Select replaces the given descriptor sets with 
** subsets consisting of those descriptors that are ready for the requested condition.
** The total number of ready descriptors in all the sets is the return value.
**
** INPUTS:
**   PRInt32 num             
**       This argument is unused but is provided for select(unix) interface
**       compatability.  All input PR_fd_set arguments are self-describing
**       with its own maximum number of elements in the set.
**                               
**   PR_fd_set *readfds
**       A set describing the io descriptors for which ready for reading
**       condition is of interest.  
**                               
**   PR_fd_set *writefds
**       A set describing the io descriptors for which ready for writing
**       condition is of interest.  
**                               
**   PR_fd_set *exceptfds
**       A set describing the io descriptors for which exception pending
**       condition is of interest.  
**
**   Any of the above readfds, writefds or exceptfds may be given as NULL 
**   pointers if no descriptors are of interest for that particular condition.                          
**   
**   PRIntervalTime timeout  
**       Amount of time the call will block waiting for I/O to become ready. 
**       If this time expires without any I/O becoming ready, the result will
**       be zero.
**
** OUTPUTS:    
**   PR_fd_set *readfds
**       A set describing the io descriptors which are ready for reading.
**                               
**   PR_fd_set *writefds
**       A set describing the io descriptors which are ready for writing.
**                               
**   PR_fd_set *exceptfds
**       A set describing the io descriptors which have pending exception.
**
** RETURN:PRInt32
**   Number of io descriptors with asked for conditions or zero if the function
**   timed out or -1 on failure.  The reason for the failure is obtained by 
**   calling PR_GetError().
** XXX can we implement this on windoze and mac?
**************************************************************************
*/
NSPR_API(PRInt32) PR_Select(
    PRInt32 num, PR_fd_set *readfds, PR_fd_set *writefds,
    PR_fd_set *exceptfds, PRIntervalTime timeout);

/* 
** The following are not thread safe for two threads operating on them at the
** same time.
**
** The following routines are provided for manipulating io descriptor sets.
** PR_FD_ZERO(&fdset) initializes a descriptor set fdset to the null set.
** PR_FD_SET(fd, &fdset) includes a particular file descriptor fd in fdset.
** PR_FD_CLR(fd, &fdset) removes a file descriptor fd from fdset.  
** PR_FD_ISSET(fd, &fdset) is nonzero if file descriptor fd is a member of 
** fdset, zero otherwise.
**
** PR_FD_NSET(osfd, &fdset) includes a particular native file descriptor osfd
** in fdset.
** PR_FD_NCLR(osfd, &fdset) removes a native file descriptor osfd from fdset.  
** PR_FD_NISSET(osfd, &fdset) is nonzero if native file descriptor osfd is a member of 
** fdset, zero otherwise.
*/

NSPR_API(void)        PR_FD_ZERO(PR_fd_set *set);
NSPR_API(void)        PR_FD_SET(PRFileDesc *fd, PR_fd_set *set);
NSPR_API(void)        PR_FD_CLR(PRFileDesc *fd, PR_fd_set *set);
NSPR_API(PRInt32)     PR_FD_ISSET(PRFileDesc *fd, PR_fd_set *set);
NSPR_API(void)        PR_FD_NSET(PRInt32 osfd, PR_fd_set *set);
NSPR_API(void)        PR_FD_NCLR(PRInt32 osfd, PR_fd_set *set);
NSPR_API(PRInt32)     PR_FD_NISSET(PRInt32 osfd, PR_fd_set *set);

#ifndef NO_NSPR_10_SUPPORT
#ifdef XP_MAC
#include <stat.h>
#else
#include <sys/stat.h>
#endif

NSPR_API(PRInt32) PR_Stat(const char *path, struct stat *buf);
#endif /* NO_NSPR_10_SUPPORT */

/***********************************************************************
** FUNCTION: PR_CreateNetAddr(), PR_DestroyNetAddr()
** DESCRIPTION:
**  Create an instance of a PRNetAddr, assigning well known values as
**  appropriate.
**
** INPUTS
**  PRNetAddrValue val  The value to be assigned to the IP Address portion
**                      of the network address. This can only specify the
**                      special well known values that are equivalent to
**                      INADDR_ANY and INADDR_LOOPBACK.
**
**  PRUInt16 port       The port number to be assigned in the structure.
**
** OUTPUTS:
**  None
**
** RETURN:
**  PRNetAddr *addr     The initialized address that has been allocated
**                      from the heap. It must be freed by the caller.
**                      A returned value of zero indicates an error. The
**                      cause of the error (most likely low memory) may
**                      be retrieved by calling PR_GetError().
**
***********************************************************************/
NSPR_API(PRNetAddr*) PR_CreateNetAddr(PRNetAddrValue val, PRUint16 port);
NSPR_API(PRStatus) PR_DestroyNetAddr(PRNetAddr *addr);



/***********************************************************************
** FUNCTION: PR_GetHostName() **OBSOLETE**
**   Use PR_GetSystemInfo() (prsystem.h) with an argument of
**   PR_SI_HOSTNAME instead.
** DESCRIPTION:	
** Get the DNS name of the hosting computer.
**
** INPUTS:
**  char *name          The location where the host's name is stored.
**  PRIntn bufsize      Number of bytes in 'name'.
** OUTPUTS:
**  PRHostEnt *name
**                      This string is filled in by the runtime if the
**                      function returns PR_SUCCESS. The string must be
**                      allocated by the caller
** RETURN:
**  PRStatus            PR_SUCCESS if the  succeeds. If it fails the
**                      result will be PR_FAILURE and the reason for
**                      the failure can be retrieved by PR_GetError().
***********************************************************************/
NSPR_API(PRStatus) PR_GetHostName(char *name, PRUint32 namelen);

/*
** Return the current thread's last error string.
** obsoleted by PR_GetErrorText().
*/
NSPR_API(const char *) PR_GetErrorString(void);

PR_END_EXTERN_C

#endif /* defined(PROBSLET_H) */

/* probslet.h */