summaryrefslogtreecommitdiffstats
path: root/lib/base/nterrors.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/base/nterrors.cpp')
-rw-r--r--lib/base/nterrors.cpp83
1 files changed, 83 insertions, 0 deletions
diff --git a/lib/base/nterrors.cpp b/lib/base/nterrors.cpp
new file mode 100644
index 00000000..2eaf29b3
--- /dev/null
+++ b/lib/base/nterrors.cpp
@@ -0,0 +1,83 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+/*
+ * nterrors.c: Conversion of error numbers to explanation strings
+ *
+ * Aruna Victor 12/6/95
+ */
+
+
+#include <windows.h>
+#include <stdio.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <netsite.h>
+#include <base/nterrors.h>
+#include <base/nterr.h>
+
+struct _NtHashedError {
+ int ErrorNumber;
+ char *ErrorString;
+ struct _NtHashedError *next;
+} ;
+
+typedef struct _NtHashedError NtHashedError;
+
+NtHashedError *hashedNtErrors[200];
+
+#define HASH_ERROR_MODULUS 199
+#define DEFAULT_ERROR_STRING "Error Number is unknown"
+
+char *
+FindError(int error)
+{
+ NtHashedError *tmp;
+
+ int hashValue = error % HASH_ERROR_MODULUS;
+ tmp = hashedNtErrors[hashValue];
+
+ while(tmp) {
+ if (tmp->ErrorNumber == error) {
+ return tmp->ErrorString;
+ }
+ tmp = tmp->next;
+ }
+ return(DEFAULT_ERROR_STRING);
+}
+
+void
+EnterError(NtHashedError *error)
+{
+ NtHashedError *tmp;
+ int hashValue;
+ int number = 199;
+
+ hashValue = error->ErrorNumber % HASH_ERROR_MODULUS;
+
+ if(!(tmp = hashedNtErrors[hashValue])){
+ hashedNtErrors[hashValue] = error;
+ } else {
+ while(tmp->next) {
+ tmp = tmp->next;
+ }
+ tmp->next = error;
+ }
+}
+
+void
+HashNtErrors()
+{
+ NtHashedError *error;
+ int i = 0;
+
+ while(NtErrorStrings[i].ErrorString) {
+ error = (NtHashedError *)MALLOC(sizeof(NtHashedError));
+ error->ErrorNumber = NtErrorStrings[i].ErrorNumber;
+ error->ErrorString = NtErrorStrings[i++].ErrorString;
+ error->next = NULL;
+ EnterError(error);
+ }
+} \ No newline at end of file