78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
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
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
|
//extern int errno;
struct dact_url_info {
char *url;
int flags;
mode_t mode;
};
struct dact_url_info dact_urls[256];
/* Do things required for network access. */
int dact_init_net(void) {
#ifdef _DACT_USE_WIN32_
WSADATA wsaData;
if (WSAStartup(MAKEWORD(2, 0), &wsaData)!=0) {
return(-1);
}
if (wsaData.wVersion!=MAKEWORD(2, 0)) {
/* Cleanup Winsock stuff */
WSACleanup();
return(-1);
}
#endif
return(0);
}
/*
* Create a listening port on tcp port PORT
*/
int createlisten(int port)
int createlisten(int port) {
{
struct sockaddr_in localname;
int sockFd;
sockFd=socket(AF_INET,SOCK_STREAM,IPPROTO_IP);
localname.sin_family=AF_INET;
localname.sin_port=htons(port);
localname.sin_addr.s_addr=INADDR_ANY;
if (bind(sockFd,(struct sockaddr *) & localname,sizeof(localname))==-1) { perror("bind");return(-1); }
|
377
378
379
380
381
382
383
384
385
386
387
388
389
390
|
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
|
+
|
#ifndef O_BINARY
#define O_BINARY 0x0
#endif
#ifndef O_LARGEFILE
#define O_LARGEFILE 0x0
#endif
int dact_init_net(void) { return(-1); }
int createlisten(int port) { return(-1); }
void closeconnection(int sockfd) { return; }
int createconnection_tcp(char *host, int port) { return(-1); }
int open_net(const char *pathname, int flags, mode_t mode) {
return(open(pathname,flags|O_BINARY|O_LARGEFILE,mode));
}
off_t lseek_net(int filedes, off_t offset, int whence) {
|