summaryrefslogtreecommitdiff
path: root/components/rtgui/utils/perfect_hash/example-PyModule/stationsmodule.c
diff options
context:
space:
mode:
authorBernard Xiong <[email protected]>2013-02-21 13:11:10 +0800
committerBernard Xiong <[email protected]>2013-02-21 13:11:10 +0800
commit385f682d7bfce81ba281faaffb0a250ab94985b8 (patch)
tree94fca413db98390d21dc18938067a7a90e470a6f /components/rtgui/utils/perfect_hash/example-PyModule/stationsmodule.c
parentc4bd0023f8da136c5788f47f9a0170a77f627be9 (diff)
remove RT-Thread GUI from RT-Thread temporary
Diffstat (limited to 'components/rtgui/utils/perfect_hash/example-PyModule/stationsmodule.c')
-rw-r--r--components/rtgui/utils/perfect_hash/example-PyModule/stationsmodule.c69
1 files changed, 0 insertions, 69 deletions
diff --git a/components/rtgui/utils/perfect_hash/example-PyModule/stationsmodule.c b/components/rtgui/utils/perfect_hash/example-PyModule/stationsmodule.c
deleted file mode 100644
index bf14e1bbee..0000000000
--- a/components/rtgui/utils/perfect_hash/example-PyModule/stationsmodule.c
+++ /dev/null
@@ -1,69 +0,0 @@
-
-#include <Python.h>
-
-#include "stations-code.h"
-
-static struct {
- char *callsign;
- char *locator;
-} station_list[] = {
-#include "stations.dat.h"
-};
-
-static int hash_f (const char *s, const int *T)
-{
- register int i, sum = 0;
-
- for (i = 0; s[i] != '\0'; i++) {
- sum += T[i] * s[i];
- sum %= NG;
- }
- return sum;
-}
-
-static int perf_hash (const char *k)
-{
- if (strlen (k) > NS)
- return 0;
-
- return (G[ hash_f(k, T1) ] + G[ hash_f(k, T2)] ) % NG;
-}
-
-static int getlocator (char *locator, const char *callsign)
-{
- int hashval = perf_hash (callsign);
-
- if (hashval < NK && strcmp(callsign, station_list[hashval].callsign) == 0) {
- strcpy (locator, station_list[hashval].locator);
- return 1;
- }
- return 0;
-}
-
-static PyObject *
-stations_locator(PyObject *self, PyObject *args)
-{
- const char *callsign;
- char locator[6];
-
- if (!PyArg_ParseTuple(args, "s", &callsign))
- return NULL;
-
- return Py_BuildValue("s", (getlocator (locator, callsign) == 1) ?
- locator : NULL);
-}
-
-static PyMethodDef StationsMethods[] = {
-
- {"locator", stations_locator, METH_VARARGS,
- "Get locator from callsign."},
-
- {NULL, NULL, 0, NULL} /* Sentinel */
-};
-
-
-PyMODINIT_FUNC
-initstations(void)
-{
- (void) Py_InitModule("stations", StationsMethods);
-}