* of the GNU General Public License.
*/
+#include "lib/lib.h"
#include "charset/charconv.h"
#include "charset/chartable.h"
-#ifndef NULL
-#define NULL ((void *)0)
-#endif
-
void
conv_init(struct conv_context *c)
{
/*
* The UniCode Library -- Debugging Support Functions
*
- * (c) 1997 Martin Mares, <mj@atrey.karlin.mff.cuni.cz>
+ * (c) 1997 Martin Mares <mj@ucw.cz>
*/
-#include <stdio.h>
-
#include "lib/lib.h"
#include "charset/unicode.h"
* of the GNU General Public License.
*/
-#include <stdio.h>
-#include <string.h>
-
#include "lib/lib.h"
-#include "charconv.h"
+#include "charset/charconv.h"
+
+#include <string.h>
char *cs_names[] = {
"US-ASCII",
/*
* The UniCode Library -- String Length
*
- * (c) 1997 Martin Mares, <mj@atrey.karlin.mff.cuni.cz>
+ * (c) 1997 Martin Mares <mj@ucw.cz>
*/
+#include "lib/lib.h"
#include "charset/unicode.h"
uns
+#include "lib/lib.h"
+#include "charset/unicode.h"
+
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
-#include "lib/lib.h"
-#include "charset/unicode.h"
-
int main(void)
{
byte buf[256];
/*
* The UniCode Library -- Category Table
*
- * (c) 1997 Martin Mares, <mj@atrey.karlin.mff.cuni.cz>
+ * (c) 1997 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
*/
+#include "lib/lib.h"
#include "charset/unicode.h"
#include "charset/U-cat.h"
/*
* The UniCode Library -- Lowercase Table
*
- * (c) 1997 Martin Mares, <mj@atrey.karlin.mff.cuni.cz>
+ * (c) 1997 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
*/
+#include "lib/lib.h"
#include "charset/unicode.h"
#include "charset/U-lower.h"
/*
* The UniCode Library -- Signaturing Table
*
- * (c) 1997 Martin Mares, <mj@atrey.karlin.mff.cuni.cz>
+ * (c) 1997 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
*/
+#include "lib/lib.h"
#include "charset/unicode.h"
#include "charset/U-sig.h"
/*
* The UniCode Library -- Uppercase Table
*
- * (c) 1997 Martin Mares, <mj@atrey.karlin.mff.cuni.cz>
+ * (c) 1997 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
*/
+#include "lib/lib.h"
#include "charset/unicode.h"
#include "charset/U-upper.h"
/*
* The UniCode Library -- Unaccenting Table
*
- * (c) 1997 Martin Mares, <mj@atrey.karlin.mff.cuni.cz>
+ * (c) 1997 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
*/
+#include "lib/lib.h"
#include "charset/unicode.h"
#include "charset/U-unacc.h"
/*
* The UniCode Library
*
- * (c) 1997 Martin Mares, <mj@atrey.karlin.mff.cuni.cz>
+ * (c) 1997 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
*/
#ifndef _UNICODE_H
#define _UNICODE_H
-#include "lib/config.h"
#include "lib/chartype.h"
extern byte *_U_cat[], *_U_sig[];
/*
* The UniCode Library -- UTF-8 Functions
*
- * (c) 1997 Martin Mares, <mj@atrey.karlin.mff.cuni.cz>
+ * (c) 1997 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
*/
+#include "lib/lib.h"
#include "charset/unicode.h"
uns
/*
* Sherlock Library -- Memory Allocation
*
- * (c) 1997 Martin Mares, <mj@atrey.karlin.mff.cuni.cz>
+ * (c) 2000 Martin Mares <mj@ucw.cz>
*/
-#include <stdio.h>
-#include <stdlib.h>
-
#include "lib/lib.h"
+#include <stdlib.h>
+
void *
xmalloc(uns size)
{
/*
* Sherlock Library -- String Allocation
*
- * (c) 1997 Martin Mares, <mj@atrey.karlin.mff.cuni.cz>
+ * (c) 1997 Martin Mares <mj@ucw.cz>
*/
-#include <stdio.h>
-#include <string.h>
-
#include "lib/lib.h"
+#include <string.h>
+
byte *
stralloc(byte *s)
{
/*
* Sherlock Library -- Character Code Map (UTF-8 Version)
*
- * (c) 1998 Martin Mares, <mj@atrey.karlin.mff.cuni.cz>
+ * (c) 1998 Martin Mares <mj@ucw.cz>
*/
/* Syntax: CHAR(code, uppercase, unaccented_version, accent_code, category) */
/*
* Sherlock Library -- Character Types
*
- * (c) 1997 Martin Mares, <mj@atrey.karlin.mff.cuni.cz>
+ * (c) 1997 Martin Mares <mj@ucw.cz>
*/
#ifndef _SHERLOCK_CHARTYPE_H
/* Features */
-/* FIXME: Prune */
-#define SHERLOCK_CONFIG_REF_WEIGHTS /* Weighed references */
#define SHERLOCK_CONFIG_LARGE_DB /* Support for DB files >4GB */
#define SHERLOCK_CONFIG_LFS /* Large files on 32-bit systems */
#undef SHERLOCK_CONFIG_LFS_LIBC /* LFS supported directly by libc */
-#undef SHERLOCK_CONFIG_LONG_TAGS /* Section tags are 32-bit */
-#undef SHERLOCK_CONFIG_SPLIT_GATHERER /* Don't merge documents from different sections */
/* Types */
/*
* Sherlock Library -- Content-Type Pattern Matching
*
- * (c) 1997 Martin Mares, <mj@atrey.karlin.mff.cuni.cz>
+ * (c) 1997 Martin Mares <mj@ucw.cz>
*/
-#include <stdio.h>
-
#include "lib/lib.h"
#include "lib/chartype.h"
/*
* Sherlock Library -- SDBM emulator at top of GDBM
*
- * (c) 1999 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
+ * (c) 1999 Martin Mares <mj@ucw.cz>
*/
+#include "lib/lib.h"
+#include "lib/db.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "lib/lib.h"
-#include "lib/db.h"
-
#include <gdbm.h>
struct sdbm {
* (c) 2000 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
*/
+#include "lib/db.c"
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
-#include "lib/db.c"
-
int
main(int argc, char **argv)
{
/*
* Sherlock Library -- Database Manager -- Tests and Benchmarks
*
- * (c) 1999 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
+ * (c) 1999 Martin Mares <mj@ucw.cz>
*/
#if 1
/*
* Sherlock Library -- Fast Database Management Routines
*
- * (c) 1999--2000 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
+ * (c) 1999--2000 Martin Mares <mj@ucw.cz>
*/
/*
* and we assume it's sorted.
*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <fcntl.h>
-#include <unistd.h>
-
#include "lib/lib.h"
#include "lib/lfs.h"
#include "lib/pagecache.h"
#include "lib/db.h"
#include "lib/db_internal.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include <unistd.h>
+
struct sdbm *
sdbm_open(struct sdbm_options *o)
{
/*
* Sherlock Library -- Fast Database Management Routines
*
- * (c) 1999 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
+ * (c) 1999 Martin Mares <mj@ucw.cz>
*/
#ifndef _SHERLOCK_DB_H
/*
* Sherlock Library -- Fast Database Management Routines -- Internal Declarations
*
- * (c) 1999 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
+ * (c) 1999 Martin Mares <mj@ucw.cz>
*/
#define SDBM_NUM_FREE_PAGE_POOLS 32
* (c) 1997--2000 Martin Mares <mj@ucw.cz>
*/
-#include <stdio.h>
-#include <stdlib.h>
-
#include "lib/lib.h"
#include "lib/fastbuf.h"
+#include <stdio.h>
+#include <stdlib.h>
+
void bclose(struct fastbuf *f)
{
bflush(f);
* (c) 1997--2000 Martin Mares <mj@ucw.cz>
*/
+#include "lib/lib.h"
+#include "lib/fastbuf.h"
+#include "lib/lfs.h"
+
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
-#include "lib/lib.h"
-#include "lib/fastbuf.h"
-#include "lib/lfs.h"
-
static int
bfd_refill(struct fastbuf *f)
{
* (c) 1997--2000 Martin Mares <mj@ucw.cz>
*/
-#include <stdio.h>
-#include <stdlib.h>
-
#include "lib/lib.h"
#include "lib/fastbuf.h"
+#include <stdio.h>
+#include <stdlib.h>
+
struct memstream {
unsigned blocksize;
unsigned uc;
/*
* Sherlock Library -- Large File Support
*
- * (c) 1999--2000 Martin Mares, <mj@atrey.karlin.mff.cuni.cz>
+ * (c) 1999--2000 Martin Mares <mj@ucw.cz>
*/
#ifndef _SHERLOCK_LFS_H
#define _SHERLOCK_LFS_H
+#include <fcntl.h>
+#include <unistd.h>
+
#ifdef SHERLOCK_CONFIG_LFS
#ifdef SHERLOCK_CONFIG_LFS_LIBC
/*
* Sherlock Library -- Miscellaneous Functions
*
- * (c) 1997 Martin Mares, <mj@atrey.karlin.mff.cuni.cz>
+ * (c) 1997--2000 Martin Mares <mj@ucw.cz>
+ */
+
+/*
+ * This file should be included as the very first include in all
+ * source files, especially before all OS includes since it sets
+ * up libc feature macros.
*/
#ifndef _SHERLOCK_LIB_H
#include "lib/config.h"
+/* Tell libc we're going to use all extensions available */
+
+#define _GNU_SOURCE
+
+#ifndef NULL
+#define NULL ((void *)0)
+#endif
+
/* Ugly structure handling macros */
#define OFFSETOF(s, i) ((unsigned int)&((s *)0)->i)
int log2(u32);
-/* obj.c */
-
-/* FIXME: What to do with this? */
-
-struct odes { /* Object description */
- struct oattr *attrs;
- struct mempool *pool;
-};
-
-struct oattr { /* Object attribute */
- struct oattr *next, *same;
- byte attr;
- byte val[1];
-};
-
-void obj_dump(struct odes *);
-struct odes *obj_fload(FILE *, byte *);
-struct odes *obj_new(void);
-struct odes *obj_load(byte *);
-void obj_fwrite(FILE *, struct odes *);
-void obj_write(byte *, struct odes *);
-void obj_free(struct odes *);
-struct oattr *find_attr(struct odes *, uns);
-struct oattr *find_attr_last(struct odes *, uns);
-uns del_attr(struct odes *, struct oattr *);
-byte *find_aval(struct odes *, uns);
-struct oattr *set_attr(struct odes *, uns, byte *);
-struct oattr *set_attr_num(struct odes *, uns, uns);
-struct oattr *add_attr(struct odes *, struct oattr *, uns, byte *);
-struct oattr *prepend_attr(struct odes *, uns, byte *);
-
-/* oname.c */
-
-/* FIXME: Kill? */
-
-#define OID_MIN 0x10000 /* Values less than this have special meaning */
-
-oid_t new_oid(uns);
-void mk_obj_name(byte *, oid_t, byte *);
-int dump_obj_to_file(byte *, oid_t, struct odes *, int);
-
/* wordsplit.c */
int wordsplit(byte *, byte **, uns);
/*
* Sherlock Library -- Linked Lists
*
- * (c) 1997--1999 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
+ * (c) 1997--1999 Martin Mares <mj@ucw.cz>
*/
-#include <stdio.h>
+#include "lib/lib.h"
#define _SHERLOCK_LISTS_C
#include "lib/lists.h"
/*
* Sherlock Library -- Linked Lists
*
- * (c) 1997--1999 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
+ * (c) 1997--1999 Martin Mares <mj@ucw.cz>
*/
#ifndef _SHERLOCK_LISTS_H
/*
* Sherlock Library -- Logging
*
- * (c) 1997 Martin Mares, <mj@atrey.karlin.mff.cuni.cz>
+ * (c) 1997 Martin Mares <mj@ucw.cz>
*/
+#include "lib/lib.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <unistd.h>
#include <sys/time.h>
-#include "lib/lib.h"
-
static byte *progname = "???";
static pid_t pid;
/*
* Sherlock Library -- Logging
*
- * (c) 1997 Martin Mares, <mj@atrey.karlin.mff.cuni.cz>
+ * (c) 1997 Martin Mares <mj@ucw.cz>
*/
#define L_DEBUG "<0>"
/*
* Sherlock Library -- Binary Logarithm
*
- * (c) 1997 Martin Mares, <mj@atrey.karlin.mff.cuni.cz>
+ * (c) 1997 Martin Mares <mj@ucw.cz>
*/
-#include <stdio.h>
-
#include "lib/lib.h"
#undef log2
* will fill a supplied 16-byte array with the digest.
*/
-#include <string.h> /* for memcpy() */
+#include "lib/lib.h"
#include "lib/md5.h"
+#include <string.h> /* for memcpy() */
+
#ifndef HIGHFIRST
#define byteReverse(buf, len) /* Nothing */
#else
#ifndef MD5_H
#define MD5_H
-#ifdef __alpha
-typedef unsigned int uint32;
-#else
-typedef unsigned long uint32;
-#endif
+typedef u32 uint32;
struct MD5Context {
uint32 buf[4];
/*
* Sherlock Library -- MD5 Binary <-> Hex Conversions
*
- * (c) 1997 Martin Mares, <mj@atrey.karlin.mff.cuni.cz>
+ * (c) 1997 Martin Mares <mj@ucw.cz>
*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <unistd.h>
-
#include "lib/lib.h"
#include "lib/chartype.h"
+#include <stdio.h>
+
void
md5_to_hex(byte *s, byte *d)
{
/*
* Sherlock Library -- Mapping of Files
*
- * (c) 1999 Martin Mares, <mj@atrey.karlin.mff.cuni.cz>
+ * (c) 1999 Martin Mares <mj@ucw.cz>
*/
+#include "lib/lib.h"
+
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/mman.h>
-#include "lib/lib.h"
-
#ifndef MAP_FAILED
#define MAP_FAILED ((void *)-1L)
#endif
/*
* Sherlock Library -- File Page Cache
*
- * (c) 1999--2000 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
+ * (c) 1999--2000 Martin Mares <mj@ucw.cz>
*/
+#include "lib/lib.h"
+#include "lib/pagecache.h"
+#include "lib/lfs.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
-#include "lib/lib.h"
-#include "lib/pagecache.h"
-#include "lib/lfs.h"
-
struct page_cache {
list free_pages; /* LRU queue of free non-dirty pages */
list locked_pages; /* List of locked pages (starts with dirty ones) */
/*
* Sherlock Library -- File Page Cache
*
- * (c) 1999 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
+ * (c) 1999 Martin Mares <mj@ucw.cz>
*/
#ifndef _SHERLOCK_PAGECACHE_H
/*
* Sherlock Library -- Shell-Like Case-Insensitive Pattern Matching (currently only '?' and '*')
*
- * (c) 1997 Martin Mares, <mj@atrey.karlin.mff.cuni.cz>
+ * (c) 1997 Martin Mares <mj@ucw.cz>
*/
-#include <stdio.h>
-#include <string.h>
-
#include "lib/lib.h"
#include "lib/chartype.h"
/*
* Sherlock Library -- Shell-Like Pattern Matching (currently only '?' and '*')
*
- * (c) 1997 Martin Mares, <mj@atrey.karlin.mff.cuni.cz>
+ * (c) 1997 Martin Mares <mj@ucw.cz>
*/
-#include <stdio.h>
-#include <string.h>
-
#include "lib/lib.h"
#define Convert(x) (x)
/*
* Sherlock Library -- Generic Shell-Like Pattern Matching (currently only '?' and '*')
*
- * (c) 1997 Martin Mares, <mj@atrey.karlin.mff.cuni.cz>
+ * (c) 1997 Martin Mares <mj@ucw.cz>
*/
int
/*
* Sherlock Library -- Memory Pools (One-Time Allocation)
*
- * (c) 1997--1999 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
+ * (c) 1997--1999 Martin Mares <mj@ucw.cz>
*/
-#include <stdio.h>
-#include <stdlib.h>
-
#include "lib/lib.h"
#include "lib/pools.h"
+#include <stdlib.h>
+
struct memchunk {
struct memchunk *next;
byte data[0];
/*
* Sherlock Library -- Memory Pools
*
- * (c) 1997--1999 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
+ * (c) 1997--1999 Martin Mares <mj@ucw.cz>
*/
#ifndef POOL_ALIGN
/*
* Sherlock Library -- Prime Number Tests
*
- * (c) 1997 Martin Mares, <mj@atrey.karlin.mff.cuni.cz>
+ * (c) 1997 Martin Mares <mj@ucw.cz>
*/
-#include <stdio.h>
-#include <stdlib.h>
-
#include "lib/lib.h"
static int /* Sequential search */
}
}
-#ifdef PRIME_DEBUG
+#ifdef TEST
+
+#include <stdio.h>
int
main(int argc, char **argv)
/*
* Sherlock Library -- Unbiased Range Correction for random()
*
- * (c) 1998 Martin Mares, <mj@atrey.karlin.mff.cuni.cz>
+ * (c) 1998 Martin Mares <mj@ucw.cz>
*/
-#include <stdio.h>
-#include <stdlib.h>
-
#include "lib/lib.h"
+#include <stdlib.h>
+
uns
random_max(uns max)
{
/*
* Sherlock Library -- Memory Re-allocation
*
- * (c) 1997 Martin Mares, <mj@atrey.karlin.mff.cuni.cz>
+ * (c) 1997 Martin Mares <mj@ucw.cz>
*/
-#include <stdio.h>
-#include <stdlib.h>
-
#include "lib/lib.h"
+#include <stdlib.h>
+
void *
xrealloc(void *old, uns size)
{
/*
* Sherlock Library -- Regular Expressions
*
- * (c) 1997 Martin Mares, <mj@atrey.karlin.mff.cuni.cz>
+ * (c) 1997 Martin Mares <mj@ucw.cz>
*/
+#include "lib/lib.h"
+
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <regex.h>
-#include "lib/lib.h"
-
#define INITIAL_MEM 1024 /* Initial space allocated for each pattern */
struct regex {
/*
* Sherlock Library -- Character Classes
*
- * (c) 1998 Martin Mares, <mj@atrey.karlin.mff.cuni.cz>
+ * (c) 1998 Martin Mares <mj@ucw.cz>
*/
#include "lib/chartype.h"
/*
* Sherlock Library -- Uppercase Map
*
- * (c) 1997 Martin Mares, <mj@atrey.karlin.mff.cuni.cz>
+ * (c) 1997 Martin Mares <mj@ucw.cz>
*/
#include "lib/chartype.h"
/*
* Sherlock Library -- Temporary Files
*
- * (c) 1997 Martin Mares, <mj@atrey.karlin.mff.cuni.cz>
+ * (c) 1997 Martin Mares <mj@ucw.cz>
*/
+#include "lib/lib.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
-#include "lib/lib.h"
-
u32
temprand(uns key)
{
/*
* Sherlock Library -- Execution Timing
*
- * (c) 1997 Martin Mares, <mj@atrey.karlin.mff.cuni.cz>
+ * (c) 1997 Martin Mares <mj@ucw.cz>
*/
+#include "lib/lib.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
-#include "lib/lib.h"
-
static struct timeval last_tv;
uns
/*
* Sherlock Library -- URL Functions (according to RFC 1738 and 1808)
*
- * (c) 1997--1999 Martin Mares, <mj@atrey.karlin.mff.cuni.cz>
+ * (c) 1997--1999 Martin Mares <mj@ucw.cz>
*/
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-
#include "lib/lib.h"
#include "lib/url.h"
#include "lib/chartype.h"
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+
/* Escaping and de-escaping */
static uns
/*
* Sherlock Library -- URL Functions
*
- * (c) 1997 Martin Mares, <mj@atrey.karlin.mff.cuni.cz>
+ * (c) 1997 Martin Mares <mj@ucw.cz>
*/
#define MAX_URL_SIZE 1024
* (c) 1999 Martin Mares <mj@ucw.cz>
*/
-#include <stdio.h>
-#include <string.h>
-
#include "lib/lib.h"
#include "lib/pools.h"
#include "lib/wildmatch.h"
+#include <stdio.h>
+#include <string.h>
+
#define MAX_STATES 32 /* Must be <= 32, state 0 is reserved, state 1 is initial */
#define MAX_CACHED 256 /* Maximum number of cached DFA states */
#define HASH_SIZE 512 /* Number of entries in DFA hash table (at least MAX_CACHED+MAX_STATES) */
/*
* Sherlock Library -- Word Splitting
*
- * (c) 1997 Martin Mares, <mj@atrey.karlin.mff.cuni.cz>
+ * (c) 1997 Martin Mares <mj@ucw.cz>
*/
-#include <stdio.h>
-
#include "lib/lib.h"
#include "lib/chartype.h"