colon fix, scanscript
authorStiletto <blasux@blasux.ru>
Sat, 12 Feb 2011 15:10:08 +0300
changeset 3 38269b62d856
parent 2 c9188930a16f
child 4 64b70fc4f30e
colon fix, scanscript
Makefile
config.mk
cos-dbupdate.cxx
cos-search.cxx
scan.cxx
scanscript.sh
--- a/Makefile	Sat Feb 12 13:48:14 2011 +0300
+++ b/Makefile	Sat Feb 12 15:10:08 2011 +0300
@@ -1,27 +1,27 @@
 
 include config.mk
 
-all: cos-dbupdate cos-search scan
+all: cos-dbupdate cos-search scan extractors
 
 scan: ${OBJS}
-	@echo CC -o $@
-	@g++ ${OBJS} ${LDFLAGS} -o $@
+	@echo C++ -o $@
+	@${CXX} ${OBJS} ${LDFLAGS} -o $@
 
 clean:
-	rm -f ${OBJS} scan
+	rm -f ${OBJS} cos-dbupdate cos-search scan
 
 walker.o: walker.cxx walker.h
-	@g++ -c ${CFLAGS} walker.cxx
-
-#magi.o: magi.cxx walker.h
-#	@g++ -c ${CFLAGS} magi.cxx
+	@echo C++ $<
+	@${CXX} -c ${CFLAGS} walker.cxx
 
 scan.o: walker.h scan.cxx
-	@g++ -c ${CFLAGS} scan.cxx
-
+	@echo C++ $<
+	@${CXX} -c ${CFLAGS} scan.cxx
 
 cos-dbupdate: cos-dbupdate.cxx
-	g++ -O0 -g cos-dbupdate.cxx -o cos-dbupdate ${CFLAGS} ${LDFLAGS}
+	@echo C++ $<
+	@${CXX} -O0 -g cos-dbupdate.cxx -o cos-dbupdate ${CFLAGS} ${LDFLAGS}
 
 cos-search: cos-search.cxx
-	g++ -O0 -g cos-search.cxx -o cos-search ${CFLAGS} ${LDFLAGS}
\ No newline at end of file
+	@echo C++ $<
+	@${CXX} -O0 -g cos-search.cxx -o cos-search ${CFLAGS} ${LDFLAGS}
\ No newline at end of file
--- a/config.mk	Sat Feb 12 13:48:14 2011 +0300
+++ b/config.mk	Sat Feb 12 15:10:08 2011 +0300
@@ -1,6 +1,3 @@
-# dwm version
-VERSION = 5.9
-
 # Customize below to fit your system
 
 # paths
@@ -14,12 +11,11 @@
 # flags
 CPPFLAGS = -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} -D_BSD_SOURCE=1
 CFLAGS = -g -std=c++0x -pedantic -Wall -O0 ${INCS} ${CPPFLAGS}
-#CFLAGS = -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS}
 LDFLAGS = -g ${LIBS}
-#LDFLAGS = -s ${LIBS}
 
 OBJS = walker.o scan.o
-# magi.o
 
 # compiler and linker
 CC = cc
+CXX = c++
+
--- a/cos-dbupdate.cxx	Sat Feb 12 13:48:14 2011 +0300
+++ b/cos-dbupdate.cxx	Sat Feb 12 15:10:08 2011 +0300
@@ -47,7 +47,7 @@
                 break;
             Xapian::Document newdocument;
             newdocument.set_data(fname);
-            newdocument.add_posting("FILENAME="+fname, 0);
+            newdocument.add_posting("FILENAME:"+fname, 0);
             int i=1;
             while (1) {
                 string term;
@@ -57,7 +57,7 @@
                 cout << "TERM <" << term << ">" << endl;
                 newdocument.add_posting(term, i++);
             }
-            database.replace_document("FILENAME="+fname,newdocument);
+            database.replace_document("FILENAME:"+fname,newdocument);
             cout << "EOFILE <" << fname << ">" << endl;
         }
     } catch(const Xapian::Error &error) {
--- a/cos-search.cxx	Sat Feb 12 13:48:14 2011 +0300
+++ b/cos-search.cxx	Sat Feb 12 15:10:08 2011 +0300
@@ -51,11 +51,11 @@
         pcrecpp::StringPiece input(qstring);  // Wrap in a StringPiece
 
         string var;
-        while (prereg.Consume(&input, &var)) {
-            string upvar = var+"=";
-            std::transform(var.begin(), var.end(), var.begin(), ::tolower);
+        while (prereg.FindAndConsume(&input, &var)) {
+            string upvar = var+":";
+            //std::transform(var.begin(), var.end(), var.begin(), ::tolower);
             std::transform(upvar.begin(), upvar.end(), upvar.begin(), ::toupper);
-            cout << var << upvar << endl;
+            //cout << var << " -> " << upvar << endl;
             qp.add_boolean_prefix(var,upvar);
         }
 
@@ -63,7 +63,7 @@
         // Build the query object
         Xapian::Query query = qp.parse_query(qstring); //Xapian::Query::OP_OR, argv + 2, argv + argc);
         
-        cout << "Performing query `" << query.get_description() << "'" << endl;
+        cerr << "Performing query `" << query.get_description() << "'" << endl;
 
         // Give the query object to the enquire session
         enquire.set_query(query);
@@ -72,17 +72,16 @@
         Xapian::MSet matches = enquire.get_mset(0, db.get_doccount());
 
         // Display the results
-        cout << matches.size() << " results found" << endl;
+        cerr << matches.size() << " results found" << endl;
 
         for (Xapian::MSetIterator i = matches.begin();
              i != matches.end();
              ++i) {
             Xapian::Document doc = i.get_document();
-            cout << "Document ID " << *i << "\t" <<
-                    i.get_percent() << "% [" <<
-                    doc.get_data() << "]" << endl;
+            cout << "#" << *i << "\t" <<
+                    doc.get_data() << endl;
         }
     } catch(const Xapian::Error &error) {
-        cout << "Exception: "  << error.get_msg() << endl;
+        cerr << "Exception: "  << error.get_msg() << endl;
     }
 }
--- a/scan.cxx	Sat Feb 12 13:48:14 2011 +0300
+++ b/scan.cxx	Sat Feb 12 15:10:08 2011 +0300
@@ -1,5 +1,10 @@
 #include "walker.h"
 
+class ShitFuck : public MagicWalker {
+    virtual int HandleFile(const char *filename) {
+    }
+};
+
 int main(int argc, char *argv[]) {
     MagicWalker f("/home/media/music");
     f.Run();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scanscript.sh	Sat Feb 12 15:10:08 2011 +0300
@@ -0,0 +1,5 @@
+#!/bin/sh
+PROGDIR=$(dirname $(readlink -f $0))
+find "$1" -type f| while read fname; do
+    $PROGDIR/extractors/ext-audio-mpeg "$fname"
+done