add .gitignore
[ftsbench.git] / ftsbench.h
index b366606..128f00d 100644 (file)
@@ -1,3 +1,32 @@
+/*
+ * Copyright (c) 2006 Teodor Sigaev <teodor@sigaev.ru>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *        notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *        notice, this list of conditions and the following disclaimer in the
+ *        documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *        may be used to endorse or promote products derived from this software
+ *        without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY CONTRIBUTORS ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
 #ifndef __FTSBENCH_H__
 #define __FTSBENCH_H__
 
@@ -11,6 +40,16 @@ typedef struct {
 } StringBuf;
 
 void sb_add(StringBuf *b, char *s, int length);
+#define sb_addchar(s, c)       do {                            \
+       if ( (s)->strlen < (s)->length )                        \
+               (s)->str[ (s)->strlen++ ] = (c);                \
+       else {                                                                          \
+               char __c = (c);                                                 \
+               sb_add( (s), &__c, 1);                                  \
+       }                                                                                       \
+} while(0)
+
+void printScheme();
 
 /* rand.c */
 long rnd();
@@ -19,17 +58,23 @@ void srnd(long seed);
 /* finngan.c */
 void generate_doc(StringBuf *b);
 char** generate_querywords();
-void   finnegan_init(char *lex_file, char *doc_file);
+void   finnegan_init(char *lex_file, char *doc_file, int quiet);
+
+/* main part */
 
+void report(const char *format, ...);
+void fatal(const char *format, ...);
 typedef struct ftsDB {
        void                    (*execQuery)(struct ftsDB*, char **, int); 
        void                    (*startCreateScheme)(struct ftsDB*, int);
        void                    (*finishCreateScheme)(struct ftsDB*);
        void                    (*InsertRow)(struct ftsDB*, int, char*);
+       void                    (*Close)(struct ftsDB*);
 
        /* stats */
        pthread_mutex_t nqueryMutex;
        int                     nquery;
+       int                     nres;
 
        /* follow db specific fields */
 } ftsDB;
@@ -51,6 +96,5 @@ ftsDB* MYInit(char * connstr);
 #define        FLG_FUNC        (0x00000004)
 #define        FLG_AND         (0x00000008)
 #define        FLG_OR          (0x00000010)
-#define        FLG_SORT        (0x00000020)
 
 #endif