Compare commits

..

2 Commits

Author SHA1 Message Date
sdv%sparc.spb.su
53866ece4f workaround for bug=30927
git-svn-id: svn://10.0.0.236/branches/M15-patch@72213 18797224-902f-48f8-a5cc-f745e15eee43
2000-06-14 11:34:36 +00:00
(no author)
350be55313 This commit was manufactured by cvs2svn to create branch 'M15-patch'.
git-svn-id: svn://10.0.0.236/branches/M15-patch@52901 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-06 02:47:16 +00:00
15 changed files with 105 additions and 4393 deletions

View File

@@ -0,0 +1,105 @@
/*
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 http://www.mozilla.org/MPL/
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 mozilla.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
*/
#ifndef __JavaDOMGlobals_h__
#define __JavaDOMGlobals_h__
#include "jni.h"
#include "prclist.h"
#include "nsError.h"
#ifdef ERROR
#undef ERROR
#endif
class nsISupports;
class nsIDOMNode;
struct PRLogModuleInfo;
struct PRLock;
class JavaDOMGlobals {
public:
static jclass attrClass;
static jclass cDataSectionClass;
static jclass commentClass;
static jclass documentClass;
static jclass documentFragmentClass;
static jclass documentTypeClass;
static jclass domImplementationClass;
static jclass elementClass;
static jclass entityClass;
static jclass entityReferenceClass;
static jclass namedNodeMapClass;
static jclass nodeClass;
static jclass nodeListClass;
static jclass notationClass;
static jclass processingInstructionClass;
static jclass textClass;
static jfieldID nodePtrFID;
static jfieldID nodeListPtrFID;
static jfieldID domImplementationPtrFID;
static jfieldID nodeTypeAttributeFID;
static jfieldID nodeTypeCDataSectionFID;
static jfieldID nodeTypeCommentFID;
static jfieldID nodeTypeDocumentFragmentFID;
static jfieldID nodeTypeDocumentFID;
static jfieldID nodeTypeDocumentTypeFID;
static jfieldID nodeTypeElementFID;
static jfieldID nodeTypeEntityFID;
static jfieldID nodeTypeEntityReferenceFID;
static jfieldID nodeTypeNotationFID;
static jfieldID nodeTypeProcessingInstructionFID;
static jfieldID nodeTypeTextFID;
static jclass domExceptionClass;
static jmethodID domExceptionInitMID;
static jclass runtimeExceptionClass;
static jmethodID runtimeExceptionInitMID;
static const char* const DOM_EXCEPTION_MESSAGE[];
typedef enum ExceptionType { EXCEPTION_RUNTIME,
EXCEPTION_DOM } ExceptionType;
static PRLogModuleInfo* log;
static PRCList garbage;
static PRLock* garbageLock;
static PRInt32 javaMaxInt;
static void Initialize(JNIEnv *env);
static void Destroy(JNIEnv *env);
static jobject CreateNodeSubtype(JNIEnv *env,
nsIDOMNode *node);
static void AddToGarbage(nsISupports* domObject);
static void TakeOutGarbage();
static void ThrowException(JNIEnv *env,
const char * message = NULL,
nsresult rv = NS_OK,
ExceptionType exceptionType = EXCEPTION_RUNTIME);
};
#endif /* __JavaDOMGlobals_h__ */

View File

@@ -1,32 +0,0 @@
#
# The contents of this file are subject to the Netscape 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 http://www.mozilla.org/NPL/
#
# 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 mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS = public src
include $(topsrcdir)/config/rules.mk

View File

@@ -1,48 +0,0 @@
#
# The contents of this file are subject to the Netscape 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 http://www.mozilla.org/NPL/
#
# 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 mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = necko
CPPSRCS = nsDnsAsyncLookup.cpp
SIMPLE_PROGRAMS = $(CPPSRCS:.cpp=)
EXPORTS = \
unix_dns.h \
$(NULL)
LIBS = \
$(NSPR_LIBS) \
$(NULL)
include $(topsrcdir)/config/rules.mk
# DEFINES += -D"GETHOSTBYNAME_DELAY=5" -DNO_SOCKS_NS_KLUDGE
DEFINES += -DNO_SOCKS_NS_KLUDGE

View File

@@ -1,626 +0,0 @@
/* -*- 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 "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* 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 mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
/*
* nsDnsAsyncLookup.cpp --- standalone lightweight process to handle
* asyncrhonous dns lookup on Unix.
*/
/* Compile-time options:
* -DGETHOSTBYNAME_DELAY=N
* to insert an artificial delay of N seconds before each
* call to gethostbyname (in order to simulate DNS lossage.)
*
* -DNO_SOCKS_NS_KLUDGE
* Set this to *disable* the $SOCKS_NS kludge. Otherwise,
* that environment variable will be consulted for use as an
* alternate DNS root. It's historical; don't ask me...
*/
#if defined(XP_UNIX) && defined(UNIX_ASYNC_DNS)
#include <sys/types.h>
#include <sys/wait.h>
#include <string.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <netdb.h>
#include <signal.h>
#include <assert.h>
#include <sys/un.h>
#include "nspr.h"
#include "nsCRT.h"
#include "unix_dns.h"
#if defined(AIX) || defined(__linux)
#include <sys/select.h> // for fd_set
#endif
#if !defined(NO_SOCKS_NS_KLUDGE)
#include <arpa/inet.h> // for in_addr (from nameser.h)
#include <arpa/nameser.h> // for MAXDNAME (from resolv.h)
#include <resolv.h> // for res_init() and _res
#endif
#if defined(__linux)
// Didn't find gettdtablehi() or gettdtablesize() on linux. Using FD_SETSIZE
#define getdtablehi() FD_SETSIZE
#elif !defined(__irix)
// looks like Irix is the only one that has getdtablehi()?
#define getdtablehi() getdtablesize()
// If you find a system doesn't have getdtablesize try #define getdtablesize
// to FD_SETSIZE. And if you encounter a system that doesn't even have
// FD_SETSIZE, just grab your ankles and use 255.
#endif
#define BACKLOG 20 // maximum # of pending connections
#define ASSERT(x) assert(x)
static int listen_fd = -1;
///////////////////////////////////////////////////////////////////////////
// Name: dnsSocksKludge
//
// Description: Gross historical kludge.
// If the environment variable $SOCKS_NS is defined, stomp
// on the host that the DNS code uses for host lookup to be
// a specific ip address.
//
static void
dnsSocksKludge(void)
{
#ifndef NO_SOCKS_NS_KLUDGE
char *ns = getenv("SOCKS_NS");
if (ns && *ns)
{
// Gross hack added to Gross historical kludge - need to
// initialize resolv.h structure first with low-cost call
// to gethostbyname() before hacking _res. Subsequent call
// to gethostbyname() will then pick up $SOCKS_NS address.
//
gethostbyname("localhost");
res_init();
// _res is defined in resolv.h
_res.nsaddr_list[0].sin_addr.s_addr = inet_addr(ns);
_res.nscount = 1;
}
#endif /* !NO_SOCKS_NS_KLUDGE */
}
///////////////////////////////////////////////////////////////////////////
// Name: mySignalHandler
//
// Description: Signal handler. Close down the socket and exit.
//
static void
mySignalHandler (int sig)
{
// close down the socket.
close (listen_fd);
unlink (DNS_SOCK_NAME); //just in case close doesn't remove this
exit (0);
}
//////////////////////////////////////////////////////////////////////////
// Name: displaySysErr
//
// Description: Display system error.
//
static void
displaySysErr(char *name) {
perror ((const char *)name);
exit (1);
}
/////////////////////////////////////////////////////////////////////////
//
// The following data structure is used to hold information about a
// pending lookup request.
typedef struct dns_lookup {
long id; // id to identify this entry
pid_t pid; // process id of the helper process
int fd; // file descriptor used to get result from
int accept_fd; // file descriptor used to send hostent back
char *name; // name to lookup
struct dns_lookup *next; // pointer to the next entry
} dns_lookup;
static dns_lookup *dns_lookup_queue = 0;
////////////////////////////////////////////////////////////////////////
// Name: getNextDnsEntry
//
// Description: Return the idx entry to the caller. Bump the index up
// by 1 before the return. Similiar to an iterator.
//
static dns_lookup*
getNextDnsEntry (int *idx)
{
dns_lookup *obj = dns_lookup_queue;
if (*idx < 0)
return 0;
for (int i = 1; i < *idx; i++)
{
obj = obj->next;
if (!obj)
return 0;
}
*idx += 1;
return obj;
}
////////////////////////////////////////////////////////////////////////
// Name: addToDnsQueue
//
// Description: Add a lookup entry to the queue.
//
static void
addToDnsQueue (dns_lookup* obj)
{
dns_lookup* entry;
obj->next = 0;
if (!dns_lookup_queue)
{
dns_lookup_queue = obj;
return;
}
entry = dns_lookup_queue;
while (entry->next)
entry = entry->next;
entry->next = obj;
}
//////////////////////////////////////////////////////////////////////////
// Name: removeFromDnsQueue
//
// Description: Remove the specified entry from the queue.
//
static void
removeFromDnsQueue (dns_lookup *obj)
{
dns_lookup* entry;
if (!obj || !dns_lookup_queue)
return;
if (obj == dns_lookup_queue)
{
dns_lookup_queue = obj->next;
}
else
{
entry = dns_lookup_queue;
while (obj != entry->next)
entry = entry->next;
if (!entry || !entry->next)
return;
entry->next = obj->next;
}
if (obj->name)
{
free(obj->name);
obj->name = 0;
}
free (obj);
}
///////////////////////////////////////////////////////////////////////////
// Name: newLookupObject
//
// Description: Create a new lookup object and return a pointer to the
// object to the caller. 0 is returned on error.
//
static dns_lookup*
newLookupObject (const char *name)
{
static int dnsId = 0;
ASSERT (name);
char *str = strdup (name);
if (!str) return 0; // MK_OUT_OF_MEMORY
dns_lookup* obj = (dns_lookup *) malloc (sizeof (struct dns_lookup));
if (!obj)
{
free (str);
return 0;
}
memset( obj, 0, sizeof( struct dns_lookup ) );
obj->id = ++dnsId;
obj->name = str;
obj->fd = -1;
obj->accept_fd = -1;
addToDnsQueue (obj);
return (obj);
}
///////////////////////////////////////////////////////////////////////////
// Name: hostentToBytes
//
// Description: Pack the structure `hostent' into a character buffer.
//
//
static void
hostentToBytes (hostent *h, char *buf, int *size)
{
*size = 0;
int len = strlen (h->h_name);
char *p = buf;
*(int *)p = len; // Encode the length of the name
p += sizeof (int);
if (len > 0)
{
strcpy (p, h->h_name);
p += strlen (h->h_name);
}
int n;
// find out the number of aliases are present. The last entry in
// list is 0.
for (n = 0; h->h_aliases[n]; n++);
*(int *)p = n; // Encode the size of aliases into buf
p += sizeof (int);
int i;
// copy aliases to the buffer.
for (i = 0; i < n; i++)
{
len = strlen (h->h_aliases[i]);
*(int *)p = (int) len;
p += sizeof(int);
memcpy (p, h->h_aliases[i], (size_t) len);
p += len;
}
*(int *)p = h->h_addrtype; // Encode the member h_addrtype
p += sizeof (int);
*(int *)p = h->h_length; // Encode the member h_length
p += sizeof (int);
// find out the number of addresses in h_addr_list list.
for (n = 0; h->h_addr_list[n]; n++);
*(int *)p = n; // Encode the size of aliases into buf
p += sizeof (int);
// copy the address list into the buffer.
for (i = 0; i < n; i++)
{
len = strlen (h->h_addr_list[i]);
*(int *)p = (int) len;
p += sizeof(int);
memcpy (p, h->h_addr_list[i], (size_t) len);
p += len;
}
*size = p - buf;
}
////////////////////////////////////////////////////////////////////////
// Name: cancelLookup
//
// Description: Cancel an existing lookup request. Locate the right
// child helper process and kill it.
//
static void
cancelLookup (int id)
{
dns_lookup *obj = dns_lookup_queue;
while (obj)
{
if (id == obj->id)
break;
obj = obj->next;
}
if (obj && obj->pid)
{
kill (obj->pid, SIGQUIT);
pid_t pid2 = waitpid (obj->pid, 0, 0);
ASSERT ((obj->pid == pid2));
removeFromDnsQueue (obj);
}
}
//////////////////////////////////////////////////////////////////////////
// Name: blockingGethostbyname
//
// Description: Calls the blocking gethostbyname to perform the lookup.
// When done, pack the hostent struct into a character
// buffer and sent it back to the parent process via pipe.
//
static void
blockingGethostbyname (const char *name, int out_fd)
{
int i;
static int firstTime = true;
if (firstTime)
{
firstTime = 0;
dnsSocksKludge();
}
#ifdef GETHOSTBYNAME_DELAY
i = GETHOSTBYNAME_DELAY;
sleep(i);
#endif // GETHOSTBYNAME_DELAY
int size = 0;
char buf[BUFSIZ];
struct hostent *h = gethostbyname(name);
if (h)
{
*(int *)&buf[0] = (int) DNS_STATUS_GETHOSTBYNAME_OK;
char *p = buf + sizeof (int);
#if defined(DNS_DEBUG)
printf("gethostbyname complete\n");
for (i=0; h->h_addr_list[i]; i++);
printf("%d addresses for %s\n",i,h->h_name);
printf("address: ");
for (i = 0; i <= h->h_length; i++){
printf("%2.2x", (unsigned char)h->h_addr_list[0][i]);
}
printf("\n");
#endif
hostentToBytes (h, p, &size);
size = size + sizeof (int);
}
else
{
*(int *)&buf[0] = (int) DNS_STATUS_GETHOSTBYNAME_FAILED;
size = sizeof (int);
}
// Send response back to parent.
write(out_fd, buf, size);
}
//////////////////////////////////////////////////////////////////////////
// Name: spawnHelperProcess
//
// Description: Spawns a child helper process to do the standard Unix
// blocking dns lookup.
//
dns_lookup*
spawnHelperProcess (const char *name)
{
pid_t forked;
int fds[2];
dns_lookup* obj = newLookupObject (name);
if (!obj) return 0;
if (pipe(fds))
{
fprintf (stderr, "Can't make pipe\n");
return 0;
}
obj->fd = fds[0];
switch (forked = fork())
{
case -1:
fprintf (stderr, "Can't fork\n");
removeFromDnsQueue (obj);
break;
case 0: /* This is the forked process. */
close (fds[0]);
blockingGethostbyname (name, fds[1]);
/* Close the file and exit the process. */
close (fds[1]);
exit (0);
break;
default:
close (fds[1]);
obj->pid = forked;
return obj;
break;
}
// shouldn't get here
ASSERT (0);
return 0;
}
////////////////////////////////////////////////////////////////////////////
int main (int argc, char **argv)
{
/*
PRFileDesc* sock = PR_GetInheritedFD(DNS_SOCK_NAME);
if (sock == nsnull)
return -1;
*/
signal (SIGINT, mySignalHandler); // trap SIGINT
// TODO: more signals need to be trapped. Will do...
// Create a socket of type PF_UNIX to listen for dns lookup requests
listen_fd = socket (PF_UNIX, SOCK_STREAM, 0);
if (listen_fd == -1)
displaySysErr (argv[0]);
struct saddr_un {
sa_family_t sun_family;
char sun_path[108];
} unix_addr;
unix_addr.sun_family = AF_UNIX;
strcpy (unix_addr.sun_path, DNS_SOCK_NAME);
if (bind (listen_fd, (struct sockaddr*)&unix_addr, sizeof(unix_addr)) == -1)
displaySysErr (argv[0]);
if (listen (listen_fd, BACKLOG) == -1)
displaySysErr (argv[0]);
int accept_fd = -1;
/////////////////////////////////////////////////////////////////////////
// Loop to process incoming DNS lookup/cancel reqeusts. When lookup is
// is completed by the helper child process, a "hostent" structure will
// be sent back to the client.
/////////////////////////////////////////////////////////////////////////
while (1) {
fd_set readfds;
FD_ZERO (&readfds);
FD_SET (listen_fd, &readfds);
if (accept_fd > 0)
FD_SET (accept_fd, &readfds);
int idx = 0;
dns_lookup* obj;
while ((obj = getNextDnsEntry (&idx)))
FD_SET(obj->fd, &readfds);
// Select will return if any one of the fd is ready for read.
// Meaning either a request has arrived from Mozilla client or
// a helper process has sent the lookup result back to us.
int n = select (getdtablehi(), &readfds, 0, 0, 0);
if (n == -1)
continue;
if (FD_ISSET (listen_fd, &readfds))
{
struct sockaddr_in from;
int fromlen = sizeof (from);
accept_fd = accept (listen_fd, (struct sockaddr *)&from,
(socklen_t *)&fromlen);
if (accept_fd == -1)
displaySysErr (argv[0]);
}
int r;
char buffer[BUFSIZ];
if (accept_fd > 0 && FD_ISSET (accept_fd, &readfds))
{
// Read the request from client.
r = recv (accept_fd, buffer, sizeof(buffer), 0);
if (r > 0 && r < (int) sizeof(buffer)) {
buffer[r] = 0;
if (!(strncmp (buffer, "shutdown:", 9)))
break;
char *name = strchr ((const char *)buffer, ' ');
if (name && *name)
name++;
if (!name)
continue;
if (!strncmp (buffer, "kill:", 5))
{
// On kill, the name is really an id number
int id = (int) (*(int *)name);
cancelLookup (id);
close (accept_fd);
accept_fd = -1;
}
else if (!strncmp (buffer, "lookup:", 7))
{
#if defined(DNS_DEBUG)
printf("received lookup request for: %s\n",name);
#endif
obj = spawnHelperProcess (name);
obj->accept_fd = accept_fd;
char hId[5];
*(int *)&hId[0] = (int) obj->id;
if (!obj)
fprintf (stderr, "spawn Error\n");
else
{
send (obj->accept_fd, hId, sizeof (int), 0);
}
}
}
accept_fd = -1;
}
idx = 0;
while ((obj = getNextDnsEntry (&idx)))
{
// Check to see if any of the helper process is done with
// the lookup operation.
if (FD_ISSET(obj->fd, &readfds))
{
r = read (obj->fd, buffer, BUFSIZ);
int status;
// Send the reponse "hostent" back to client.
send (obj->accept_fd, buffer, r, 0);
close (obj->accept_fd);
removeFromDnsQueue (obj);
wait(&status);
close (obj->fd);
}
}
}
close (listen_fd);
unlink (DNS_SOCK_NAME);
exit (0);
}
#endif // XP_UNIX && UNIX_ASYNC_DNS

View File

@@ -1,44 +0,0 @@
/* -*- 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 "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* 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 mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef __UNIX_DNS_H__
#define __UNIX_DNS_H__
#define DNS_SOCK_NAME "/tmp/netscape_dns_lookup" // Name of unix socket
/* The internal status codes that are used; these follow the basic
SMTP/NNTP model of three-digit codes.
*/
#define DNS_STATUS_GETHOSTBYNAME_OK 101
#define DNS_STATUS_LOOKUP_OK 102
#define DNS_STATUS_KILLED_OK 103
#define DNS_STATUS_LOOKUP_STARTED 201
#define DNS_STATUS_GETHOSTBYNAME_FAILED 501
#define DNS_STATUS_LOOKUP_FAILED 502
#define DNS_STATUS_LOOKUP_NOT_STARTED 503
#define DNS_STATUS_KILL_FAILED 504
#define DNS_STATUS_UNIMPLEMENTED 601
#define DNS_STATUS_INTERNAL_ERROR 602
#endif /* __UNIX_DNS_H__ */

View File

@@ -1,31 +0,0 @@
#!gmake
#
# The contents of this file are subject to the Netscape 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 http://www.mozilla.org/NPL/
#
# 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 mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
DEPTH = ..\..
MODULE = necko
DIRS= \
public \
src \
$(NULL)
include <$(DEPTH)\config\rules.mak>

View File

@@ -1,38 +0,0 @@
#
# The contents of this file are subject to the Netscape 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 http://www.mozilla.org/NPL/
#
# 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 mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = necko
XPIDL_MODULE = necko_dns
XPIDLSRCS = \
nsIDNSListener.idl \
nsIDNSService.idl \
$(NULL)
include $(topsrcdir)/config/rules.mk

View File

@@ -1,34 +0,0 @@
#!gmake
#
# The contents of this file are subject to the Netscape 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 http://www.mozilla.org/NPL/
#
# 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 mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
MODULE = necko
DEPTH = ..\..\..
include <$(DEPTH)/config/config.mak>
XPIDL_MODULE = necko_dns
XPIDLSRCS = \
.\nsIDNSListener.idl \
.\nsIDNSService.idl \
$(NULL)
include <$(DEPTH)/config/rules.mak>

View File

@@ -1,58 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape 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 http://www.mozilla.org/NPL/
*
* 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 mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1999 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
%{C++
#include "prnetdb.h"
typedef struct nsHostEnt
{
PRHostEnt hostEnt;
char buffer[PR_NETDB_BUF_SIZE];
PRIntn bufLen;
char * bufPtr;
} nsHostEnt;
%}
[ptr] native nsHostEntStar(nsHostEnt);
[scriptable, uuid(7686cef0-206e-11d3-9348-00104ba0fd40)]
interface nsIDNSListener : nsISupports
{
/**
* Notify the listener that we are about to lookup the requested hostname.
*/
void OnStartLookup(in nsISupports ctxt, in string hostname);
/**
* Notify the listener that we have found one or more addresses for the hostname.
*/
[noscript] void OnFound(in nsISupports ctxt, in string hostname,
in nsHostEntStar entry);
/**
* Notify the listener that the lookup has completed.
*/
void OnStopLookup(in nsISupports ctxt, in string hostname, in nsresult status);
};

View File

@@ -1,68 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape 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 http://www.mozilla.org/NPL/
*
* 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 mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1999 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
%{C++
#define NS_DNSSERVICE_CID \
{ /* 718e7c81-f8b8-11d2-b951-c80918051d3c */ \
0x718e7c81, \
0xf8b8, \
0x11d2, \
{ 0xb9, 0x51, 0xc8, 0x09, 0x18, 0x05, 0x1d, 0x3c } \
}
%}
interface nsIRequest;
interface nsIDNSListener;
[scriptable, uuid(598f2f80-206f-11d3-9348-00104ba0fd40)]
interface nsIDNSService : nsISupports
{
nsIRequest lookup(in string hostname,
in nsIDNSListener listener,
in nsISupports ctxt);
/**
* Syncronously resolve the hostname to its IP address.
*/
string resolve(in string hostname);
/**
* Check if the specified address is in the network of the pattern
* using the specified mask. This function would probably go away
* once an implementation for it in JS exists for nsProxyAutoConfig.
* See http://www.mozilla.org/docs/netlib/pac.html for more info.
*/
boolean isInNet(in string ipaddr, in string pattern, in string mask);
void init();
void shutdown();
};
%{C++
#define NS_ERROR_UNKNOWN_HOST NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 30)
%}

View File

@@ -1,40 +0,0 @@
#
# The contents of this file are subject to the Netscape 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 http://www.mozilla.org/NPL/
#
# 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 mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = necko
LIBRARY_NAME = neckodns_s
REQUIRES = xpcom
CPPSRCS = nsDnsService.cpp
# we don't want the shared lib, but we want to force the creation of a
# static lib.
override NO_SHARED_LIB=1
override NO_STATIC_LIB=
include $(topsrcdir)/config/rules.mk

View File

@@ -1,42 +0,0 @@
# The contents of this file are subject to the Netscape 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 http://www.mozilla.org/NPL/
#
# 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 mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
MODULE = necko
DEPTH = ..\..\..
LCFLAGS = -DWIN32_LEAN_AND_MEAN -D_IMPL_NS_NET
LIBRARY_NAME=neckodns_s
CPP_OBJS = \
.\$(OBJDIR)\nsDnsService.obj \
$(NULL)
INCS = $(INCS) \
-I$(DEPTH)\dist\include \
$(NULL)
include <$(DEPTH)\config\rules.mak>
install:: $(LIBRARY)
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
clobber::
rm -f $(DIST)\lib\$(LIBRARY_NAME).lib

File diff suppressed because it is too large Load Diff

View File

@@ -1,111 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape 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 http://www.mozilla.org/NPL/
*
* 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 mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1999 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsDNSService_h__
#define nsDNSService_h__
#include "nsIDNSService.h"
#include "nsIRunnable.h"
#include "nsIThread.h"
#include "nsISupportsArray.h"
#if defined(XP_MAC)
#include <OSUtils.h>
#include <OpenTransport.h>
#include <OpenTptInternet.h>
#elif defined (XP_WIN)
#include <windows.h>
#include <Winsock2.h>
#endif
#include "nsCOMPtr.h"
#include "nsHashtable.h"
#include "prmon.h"
#ifdef DEBUG
#define DNS_TIMING 1
#endif
class nsIDNSListener;
class nsDNSLookup;
class nsDNSService : public nsIDNSService,
public nsIRunnable
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIRUNNABLE
NS_DECL_NSIDNSSERVICE
// nsDNSService methods:
nsDNSService();
virtual ~nsDNSService();
// Define a Create method to be used with a factory:
static NS_METHOD
Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult);
friend class nsDNSLookup;
protected:
nsresult LateInit();
nsresult InitDNSThread();
nsresult GetLookupEntry(const char* hostName, nsDNSLookup* *result);
static nsDNSService * gService;
static PRBool gNeedLateInitialization;
nsCOMPtr<nsIThread> mThread;
nsresult mState;
PRMonitor* mMonitor;
nsSupportsHashtable mLookups; // of nsDNSLookups
#if defined(XP_MAC)
friend pascal void nsDnsServiceNotifierRoutine(void * contextPtr, OTEventCode code, OTResult result, void * cookie);
PRBool mThreadRunning;
InetSvcRef mServiceRef;
QHdr mCompletionQueue;
#if TARGET_CARBON
OTClientContextPtr mClientContext;
#endif /* TARGET_CARBON */
OTNotifyUPP nsDnsServiceNotifierRoutineUPP;
#endif /* XP_MAC */
#if defined(XP_WIN)
PRUint32 AllocMsgID(void);
void FreeMsgID(PRUint32 msgID);
friend static LRESULT CALLBACK nsDNSEventProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
LRESULT ProcessLookup(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
HWND mDNSWindow;
PRUint32 mMsgIDBitVector[4];
#endif /* XP_WIN */
#ifdef DNS_TIMING
double mCount;
double mTimes;
double mSquaredTimes;
FILE* mOut;
friend class nsDNSRequest;
#endif
char* mMyIPAddress;
};
#endif /* nsDNSService_h__ */

File diff suppressed because it is too large Load Diff