summaryrefslogtreecommitdiffstats
path: root/lib/base/nterrors.cpp
diff options
context:
space:
mode:
authorcvsadm <cvsadm>2005-01-21 00:44:34 +0000
committercvsadm <cvsadm>2005-01-21 00:44:34 +0000
commitb2093e3016027d6b5cf06b3f91f30769bfc099e2 (patch)
treecf58939393a9032182c4fbc4441164a9456e82f8 /lib/base/nterrors.cpp
downloadds-b2093e3016027d6b5cf06b3f91f30769bfc099e2.tar.gz
ds-b2093e3016027d6b5cf06b3f91f30769bfc099e2.tar.xz
ds-b2093e3016027d6b5cf06b3f91f30769bfc099e2.zip
Moving NSCP Directory Server from DirectoryBranch to TRUNK, initial drop. (foxworth)ldapserver7x
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