Skip to content

Commit

Permalink
Rocket Search
Browse files Browse the repository at this point in the history
File Index Search Engine
  • Loading branch information
Rocket-Search authored Dec 17, 2019
1 parent 447ffbf commit 59e607f
Show file tree
Hide file tree
Showing 10 changed files with 3,894 additions and 0 deletions.
194 changes: 194 additions & 0 deletions client.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
//##################
//Compile Command:
//DEBUG: rm -frv client; clear; g++-7 -g -Wall -lpthread client.cpp -o client;
//PRD: rm -frv client; clear; g++-7 -O3 -Wall -lpthread client.cpp -o client
//##################
//Execute Command:
//./client "mp3"

#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <netdb.h>
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <string>
#include <sys/time.h>
#include <sstream>
#include <fstream>
#include <pthread.h>
#include <thread>
#include <time.h>
#include <iterator>
//Posix Thread
#include <pthread.h>
//Error Handling und Singal
#include <errno.h>
#include <signal.h>
#include <malloc.h>
#include <errno.h>
#include <sys/mman.h>
#include <csignal>
#include <iterator>


using namespace std;

string suchmuster;
//bool animation_beenden = false;

void signalHandler( int signum)
{
cout << "Interrupt signal (" << signum << ") received.\n";
cout<<"PROBLEM"<<endl;
cout<<"Segmentation fault"<<endl;
// cleanup and close up stuff here
//terminate program

//cout<<SIGSEGV_pfad_datei<<endl;


exit(0);
//exit(signum);
}

void *starte_suche(void *threadid_0)
{

struct hostent *host;//Hostname struktuieren
host = gethostbyname("127.0.0.1"); //eventuell die IP in DNS Namen umwandeln
struct sockaddr_in addr;
addr.sin_addr = *(struct in_addr*)host->h_addr;
int s;
s = socket(PF_INET, SOCK_STREAM, 0); //Socket aufbauen. wenn -1 dann ist fehlgeschlagen
addr.sin_port = htons(6379);//Connection Portnummer des Servers festlegen
addr.sin_family = AF_INET;
connect(s,(struct sockaddr*)&addr, sizeof(addr));
//string suchmuster = argv[1];
string redis_command = "KEYS";
int wo_ist_ende = 0;
suchmuster = suchmuster.insert(0,"KEYS \"*");
wo_ist_ende = suchmuster.size();
suchmuster = suchmuster.insert(wo_ist_ende,"*\"\r\n");
char* request = (char*)suchmuster.c_str();
cout<<"request: "<<request<<endl;
//#######################################
//#Zum testen für lange suchen
sleep(10);
//Animation Thread beenden
//pthread_kill(1, SIGTERM);
//animation_beenden = true;
//#######################################
send(s, request, strlen(request),0);//Daten senden
char response[1024];//Empfangspuffer festlegen
int bytes;
string antwort_ausgabe;
vector<string> vektor;
int i=0;
bool ende = true;
bzero (response, sizeof(response));
while(ende)
{
bytes = recv(s, response, sizeof(response), 0);
i = i + 1;
cout<<endl<<response;
bzero (response, sizeof(response));
if (bytes == 0)
{
close(s);
ende = false;
}
if (bytes < 1024)
{
close(s);
ende = false;
}
if (bytes == -1)
{
close(s);
ende = false;
}
}

pthread_exit(NULL);
}

void *starte_animation(void *threadid_1)
{

//Damit noch der Suchtring ausggeben werden kann aus dem anderen Thread
sleep(1);

cout<<" \/\\"<<endl;
cout<<" ||"<<endl;
cout<<" ||"<<endl;
cout<<" ||"<<endl;
cout<<" \/____\\"<<endl;
while(1)
{
sleep(1);
cout<<"\b ###\n"<<flush;
sleep(1);
cout<<"\b ***\n"<<flush;
//cout<<"\b #\n #"<<flush;
//sleep(1);
//cout << "\b\*\* \n *" <<flush;
//sleep(1);
//cout << "\b\#" <<flush;
//sleep(1);
//cout << "\b\*" <<flush;

}

pthread_exit(NULL);
}

int main(int argc, char *argv[])
{

signal(SIGSEGV, signalHandler);

//###################################################################################################################
suchmuster = argv[1];

//###################################################################################################################
//cout<<"Starte Thread !!!"<<endl;
pthread_t threads[3];
int rueckgabe_wert_0;
int rueckgabe_wert_1;
int thread_nummer_0 = 0 ;
int thread_nummer_1 = 1 ;
int thread_nummer_2 = 2 ;
rueckgabe_wert_0 = pthread_create(&threads[0], NULL, starte_suche,(void *)thread_nummer_0);
rueckgabe_wert_1 = pthread_create(&threads[1], NULL, starte_animation,(void *)thread_nummer_1);
//rueckgabe_wert = pthread_create(&threads[2], NULL, test,(void *)thread_nummer_2);
//sleep(15);

//warten bis find_xargs thread zu ende ist###
void *status;
rueckgabe_wert_0 = pthread_join(threads[0], &status);
if (rueckgabe_wert_0 != 0)
{
cout << "Error:unable to join," << rueckgabe_wert_0 << endl;
exit(-1);
}
//######

cout<<"rueckgabe_wert_0: "<<rueckgabe_wert_0<<endl;
cout<<"rueckgabe_wert_1: "<<rueckgabe_wert_1<<endl;

//###################################################################################################################



return (0);
}




18 changes: 18 additions & 0 deletions config.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
redis server = 127.0.0.1
redis port = 6379
ms word = true
ms excel = true
ascii_and_pdf file max read lines = 8
ascii file max read chars = 1024
exe_dll infos = true
exe dll info binary path = /usr/bin/get_exe_dll_info_v2.exe
ms excel ram dev = /tmp/ram_dev/
md5sum = true
libreoffice timeout = 300
read_file_info timeout = 500
license key = U2FsdGVkX1+/+B3kAlKOjYCT4QegoasjcQdWFo42DTArxkzOnxe6WsT+lFWmkDpF#U2FsdGVkX1/uNgnvPy7mA9uby0gpc05mj5NbmaPNaQdGFWlBilpPuIF0I0a/bbuG\npOho1HMBsYome5AuVi6LgiD/LEuSI5FlkydwFqkiLCq4683x7fo9YI1eSXC23tK1\nE2t3HdAkMEyCsnRc5bbrpA##
edition key = N2Q0YmFmNmIzZTM0MTFkMTVmMDYK
network throttle = 5
core usage = 4
mp3_flac_tag = true
pdf = true
94 changes: 94 additions & 0 deletions flac_read.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#include <iostream>
#include <iomanip>
#include <stdio.h>


using namespace std;

//extern string pfad_uebergabe_mp3;
extern string pfad_uebergabe_flac;
extern string flac_file_info_magic;
extern string flac_tags_content;

void flac_read()
{
//cout<<"flac object file"<<endl;
//cout<<"flac_file_info_magic#"<<flac_file_info_magic<<endl;;

string metaflac_command = "metaflac --show-total-samples --show-sample-rate --show-vendor-tag --show-bps --show-channels --export-tags-to=- '" + pfad_uebergabe_flac + "'" ;
//cout<<metaflac_command<<endl;
char *metaflac_command_char = {(char *) metaflac_command.c_str()};
FILE *pipe;
char str[50000];
pipe = popen (metaflac_command_char, "r" );
if(pipe == NULL)
{
perror("open failed");
pclose(pipe);
exit(0);
}
//metaflac_command = string(str);
//cout<<metaflac_command<<endl;
string flac_metat_data = "";
int i = 0;

string total_samples, sample_rate, vendor_tag, bps, channels, tags;

while(fgets ( str, 49999, pipe ) != NULL)
{
//flac_metat_data = string(str);
//cout<<"flac_metat_data#"<<flac_metat_data<<endl;
//flac_metat_data.append(string(str));
i++ ;
if (i == 1)
{
//cout<<"--show-total-samples#"<<string(str)<<endl;
total_samples=string(str);
}
if (i == 2)
{
//cout<<"--show-sample-rate#"<<string(str)<<endl;
sample_rate=string(str);
}
if (i == 3)
{
//cout<<"--show-vendor-tag#"<<string(str)<<endl;
vendor_tag=string(str);
}
if (i == 4)
{
//cout<<"--show-bps#"<<string(str)<<endl;
bps=string(str);
}
if (i == 5)
{
//cout<<"--show-channels#"<<string(str)<<endl;
channels=string(str);
}
if (i > 5)
{
//cout<<"--export-tags-to#"<<string(str)<<endl;
tags.append(string(str) +"# ");
//tags.append("\n");
}
}

//pipe = popen ("exit", "r" );
pclose(pipe);

double total_samples_int = atof(total_samples.c_str());
//cout<<"total_samples_int#"<<total_samples_int<<endl;
double sample_rate_int = atof(sample_rate.c_str());
//cout<<"sample_rate_int#"<<sample_rate_int<<endl;
double track_sekunden_zeit = total_samples_int / sample_rate_int;
//cout<<"track_sekunden_zeit#"<<track_sekunden_zeit<<endl;
double track_minuten = track_sekunden_zeit / 60;
//cout<<"track_minuten#"<<track_minuten<<endl;

ostringstream strs;
strs << track_minuten;
std::string track_minuten_string = strs.str();

flac_tags_content = tags + "#Track Laenge:" + track_minuten_string + " Minuten \n#Sample Rate:" + total_samples + "#Bits per Sample:" + bps +"#Vendor Tag:" + vendor_tag +"#Channels:" + channels;

}
Loading

0 comments on commit 59e607f

Please sign in to comment.