macsocket.h revision 677833bc953b6cb418c701facbdcf4aa18d6c44e
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is the Netscape Portable Runtime (NSPR).
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998-2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef macksocket_h___
#define macksocket_h___
// macsock.h
// Interface visible to xp code
// C socket type definitions and routines
#include <Files.h>
#include <OpenTptInternet.h> // All the internet typedefs
#include <utime.h> // For timeval
/*
* sleep and delay conflict with the same in unistd.h from Metrowerks. OT
* defines them as
*
* extern pascal void OTDelay(UInt32 seconds);
* extern pascal void OTIdle(void);
*
* #define sleep(x) OTDelay(x)
* #define delay(x) OTDelay(x)
*/
#pragma once
#include "prio.h"
struct sockaddr {
unsigned char sa_len; /* total length */
unsigned char sa_family; /* address family */
};
struct in_addr {
unsigned long s_addr;
};
struct sockaddr_in {
unsigned char sin_len;
unsigned char sin_family; // AF_INET
unsigned short sin_port;
char sin_zero[8];
};
struct hostent {
char *h_name; /* official name of host */
char **h_aliases; /* alias list */
int h_addrtype; /* host address type */
int h_length; /* length of address */
char **h_addr_list; /* list of addresses from name server */
};
// Necessary network defines, found by grepping unix headers when XP code would not compile
#define FIONBIO 1
#define SOCK_STREAM 1
#define SOCK_DGRAM 2
#define INADDR_ANY kOTAnyInetAddress
#define SO_REUSEADDR IP_REUSEADDR
#define SO_BROADCAST IP_BROADCAST
typedef unsigned long u_long;
/* ldap.h has its own definition of fd_set */
/* select support */
#if !defined(FD_SET)
#define NBBY 8
typedef long fd_mask;
#ifndef howmany
#define howmany(x, y) (((x)+((y)-1))/(y))
#endif
#define FD_SETSIZE 64
typedef struct fd_set{
} fd_set;
#endif /* !FD_SET */
#ifdef __cplusplus
extern "C" {
#endif
// UNIX look-alike routines
// They make sure that the arguments passed in are valid, and then
//
extern int macsock_close(int sID);
extern int macsock_dup(int sID);
extern int macsock_sendto(int sID, const void *msg, int len, int flags, struct sockaddr *toAddr, int toLen);
extern int macsock_recvfrom(int sID, void *buf, int len, int flags, struct sockaddr *from, int *fromLen);
extern int select (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
#define macsock_socket PR_Socket
#define macsock_connect PR_Connect
#define macsock_write PR_Write
#define macsock_read PR_Read
#define macsock_close PR_Close
#define macsock_accept PR_Accept
#define macsock_bind PR_Bind
#define macsock_listen PR_Listen
#define macsock_shutdown PR_Shutdown
#define macsock_getpeername PR_GetPeerName
#define macsock_getsockname PR_GetSockName
#define macsock_send PR_Send
#define macsock_sendto PR_SendTo
#define macsock_recvfrom PR_RecvFrom
#define macsock_recv PR_Recv
#ifdef __cplusplus
}
#endif
//extern int errno;
/*
macsock_sendmsg
macsock_readv
macsock_writev
*/
/* New definitions that are not defined in macsock.h in macsock library */
struct protoent {
char *p_name; /* official protocol name */
char **p_aliases; /* alias list */
int p_proto; /* protocol # */
};
#define INADDR_LOOPBACK 0x7F000001
#define SO_KEEPALIVE TCP_KEEPALIVE
#define SO_RCVBUF XTI_RCVBUF
#define SO_SNDBUF XTI_SNDBUF
#define IPPROTO_IP INET_IP
struct linger {
int l_linger; /* linger time */
};
struct ip_mreq {
};
#endif /* macksocket_h___ */