10 #include "filedata.hpp"
14 vector<string> split( const string &line, char c, int limit = -1 ) {
15 string::size_type start = 0, end = 0;
18 while( 0 != limit-- && end != line.size() ) {
22 end = line.find( c, start );
23 if( end == string::npos ) {
27 out.push_back( line.substr( start, end-start ) );
33 int callback( void *NotUsed, int argc, char **argv, char **azColName ) {
35 for( int i = 0; i < argc; ++i ) {
36 cout << azColName[i] << " = " << ( argv[i] ? argv[i] : "NULL" ) << endl;
42 void sql_experimenting() {
44 char *sqliteErrMsg = 0;
47 const char *dbname = "test.db";
48 rc = sqlite3_open( dbname, &db );
49 if( SQLITE_OK != rc ) {
50 cerr << "Cannot open database: " << dbname << ". Error message is..." << endl;
51 cerr << sqlite3_errmsg(db) << endl;
54 rc = sqlite3_exec( db, "select * from filedata;", callback, 0, &sqliteErrMsg );
55 if( SQLITE_OK != rc ) {
56 cerr << "Problem with database. Message is..." << endl;
57 cerr << sqliteErrMsg << endl;
65 set<FileData*,FileDataPtrCmp> current_files;
67 // Parse the list of files on stdin
70 for( int c = cin.get(); 0 != c && ! cin.eof(); c = cin.get() ) {
71 file_string.push_back( c );
73 if( 0 != file_string.size() ) {
75 // type perms user group size datemodified name (7 total)
76 // f 0600 cnb cnb 424 20051015205340 ./.git/index
77 vector<string> vals = split( file_string, ' ', 7 );
78 current_files.insert( new FileData( vals[0][0],
82 atoi( vals[4].c_str() ),
83 atoi( vals[5].c_str() ),
86 } while( ! cin.eof() );
88 set<FileData*,FileDataPtrCmp> previous_files;