summaryrefslogtreecommitdiffstats
path: root/unicode/unicode_htmlent.c
diff options
context:
space:
mode:
authorSam Varshavchik2013-08-19 16:39:41 -0400
committerSam Varshavchik2013-08-25 14:43:51 -0400
commit9c45d9ad13fdf439d44d7443ae75da15ea0223ed (patch)
tree7a81a04cb51efb078ee350859a64be2ebc6b8813 /unicode/unicode_htmlent.c
parenta9520698b770168d1f33d6301463bb70a19655ec (diff)
downloadcourier-libs-9c45d9ad13fdf439d44d7443ae75da15ea0223ed.tar.bz2
Initial checkin
Imported from subversion report, converted to git. Updated all paths in scripts and makefiles, reflecting the new directory hierarchy.
Diffstat (limited to 'unicode/unicode_htmlent.c')
-rw-r--r--unicode/unicode_htmlent.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/unicode/unicode_htmlent.c b/unicode/unicode_htmlent.c
new file mode 100644
index 0000000..549d069
--- /dev/null
+++ b/unicode/unicode_htmlent.c
@@ -0,0 +1,55 @@
+/*
+** Copyright 2011 Double Precision, Inc.
+** See COPYING for distribution information.
+**
+*/
+
+#include "unicode_config.h"
+#include "unicode.h"
+
+#include <stdlib.h>
+
+struct i {
+ size_t n_start;
+ size_t n_size;
+ unicode_char v;
+};
+
+#include "unicode_htmlent.h"
+
+
+static int compar(const void *key, const void *obj)
+{
+ size_t j;
+ const char *p=n + ((const struct i *)obj)->n_start;
+ const char *ckey=(const char *)key;
+
+ for (j=0; j<((const struct i *)obj)->n_size; ++j)
+ {
+ if (*ckey < *p)
+ return -1;
+
+ if (*ckey > *p)
+ return 1;
+
+ ++p;
+ ++ckey;
+ }
+
+ if (*ckey)
+ return 1;
+
+ return 0;
+}
+
+unicode_char unicode_html40ent_lookup(const char *n)
+{
+ const struct i *ptr=
+ (const struct i *)bsearch(n, ii,
+ sizeof(ii)/sizeof(ii[0]),
+ sizeof(ii[0]), compar);
+
+ if (ptr)
+ return ptr->v;
+ return 0;
+}