#!./exu -- File Archive Search -- -- Searches the descriptions of over 1500 .zip files on RapidEuphoria.com -- -- The descriptions are stored in a Euphoria EDS database, archive.edb without type_check include file.e include get.e include wildcard.e as wild include database.e include archive.e constant TRUE = 1, FALSE = 0 constant TO_LOWER = 'a' - 'A' constant MAX_HITS = 100 -- max number of matching entries to display constant SCORE = 1, ENTRY = 2 constant OUT_CHUNK_SIZE = 10 -- number of entries to output per table constant P_GEN = 1, P_DOS = 2, P_WIN = 3, P_LNX = 4 atom t0 t0 = time() sequence top_hits top_hits = {} sequence keywords -- keywords entered by user sequence platforms -- platforms selected by user platforms = repeat(FALSE, 4) integer nhits, totalCount nhits = 0 totalCount = 0 integer log_file log_file = -1 -- open("asearch.log", "a") object query query = "nothing yet" function crash(object x) -- in case of fire ... integer errfile errfile = open("ex.err", "a") puts(errfile, "\nquery is: " & query & '\n') close(errfile) -- send an e-mail containing ex.err system("mail -s \"asearch.exu crashed!\" rds@RapidEuphoria.com < ex.err > /dev/null", 2) return 0 end function crash_routine(routine_id("crash")) function lower(sequence s) -- (quickly) convert a line to lower case integer c for i = 1 to length(s) do c = s[i] if c <= 'Z' then if c >= 'A' then s[i] = c + TO_LOWER end if end if end for return s end function procedure stats() -- save some stats for performance analysis printf(log_file, "matched %d of %d, time: %.2f\n\n", {nhits, totalCount, time()-t0}) end procedure procedure html_puts(object text) -- write HTML output puts(1, text) end procedure procedure html_printf(sequence format, object text) -- write HTML output printf(1, format, text) end procedure procedure errMessage(sequence msg) -- issue a fatal error message and quit html_puts("
") html_printf("%s \n