00001 // 00002 // NAME 00003 // 00004 // dump the content of an inverted index. 00005 // 00006 // SYNOPSIS 00007 // 00008 // mifluzdump file 00009 // 00010 // DESCRIPTION 00011 // 00012 // mifluzdump writes on <b>stdout</b> a complete ascii description 00013 // of the <b>file</b> inverted index using the <i>WordList::Write</i> 00014 // method. 00015 // 00016 // ENVIRONMENT 00017 // 00018 // <b>MIFLUZ_CONFIG</b> 00019 // file name of configuration file read by WordContext(3). Defaults to 00020 // <b>~/.mifluz.</b> 00021 // 00022 // 00023 // END 00024 // 00025 // Part of the ht://Dig package <http://www.htdig.org/> 00026 // Copyright (c) 1999, 2000, 2001 The ht://Dig Group 00027 // For copyright details, see the file COPYING in your distribution 00028 // or the GNU General Public License version 2 or later 00029 // <http://www.gnu.org/copyleft/gpl.html> 00030 // 00031 00032 #ifdef HAVE_CONFIG_H 00033 #include "config.h" 00034 #endif /* HAVE_CONFIG_H */ 00035 00036 #include <stdlib.h> 00037 #include <unistd.h> 00038 #ifdef HAVE_GETOPT_H 00039 #include <getopt.h> 00040 #endif /* HAVE_GETOPT_H */ 00041 00042 #include <htString.h> 00043 #include <WordContext.h> 00044 #include <WordList.h> 00045 #include <Configuration.h> 00046 00047 static void action(WordContext* context, const String& file) 00048 { 00049 WordList *words = context->List(); 00050 if(words->Open(file, O_RDONLY) != OK) exit(1); 00051 if(words->Write(stdout) != OK) exit(1); 00052 if(words->Close() != OK) exit(1); 00053 delete words; 00054 } 00055 00056 static void usage() 00057 { 00058 fprintf(stderr, "usage: mifluzdump file\n"); 00059 exit(1); 00060 } 00061 00062 int main(int argc, char *argv[]) { 00063 00064 if(argc != 2) usage(); 00065 00066 // 00067 // Mandatory to create global data needed for the library. 00068 // 00069 WordContext *context = new WordContext(); 00070 if(!context) exit(1); 00071 action(context, argv[1]); 00072 delete context; 00073 } 00074