first version

This commit is contained in:
Rajshekar K K 2024-07-18 12:53:50 +05:30
commit a7f218bab5
5 changed files with 83 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
/src/*.out
/src/*_solved*

1
src/file.txt Normal file

File diff suppressed because one or more lines are too long

13
src/makefile Normal file
View File

@ -0,0 +1,13 @@
build-part1: part1.out
part1.out: part1_searcher.cpp
g++ -g part1_searcher.cpp -o part1.out
run-part1: part1.out
./part1.out file.txt NGTNIJGK 0 67108863
clean-part1:
rm part1.out
clean:
rm *.out

38
src/partitioner.cpp Normal file
View File

@ -0,0 +1,38 @@
#include <iostream>
#include <fstream>
#include <unistd.h>
#include <sys/wait.h>
#include <signal.h>
using namespace std;
int main(int argc, char **argv)
{
if(argc != 6)
{
cout <<"usage: ./partitioner.out <path-to-file> <pattern> <search-start-position> <search-end-position> <max-chunk-size>\nprovided arguments:\n";
for(int i = 0; i < argc; i++)
cout << argv[i] << "\n";
return -1;
}
char *file_to_search_in = argv[1];
char *pattern_to_search_for = argv[2];
int search_start_position = atoi(argv[3]);
int search_end_position = atoi(argv[4]);
int max_chunk_size = atoi(argv[5]);
//TODO
//cout << "[" << my_pid << "] start position = " << search_start_position << " ; end position = " << search_end_position << "\n";
//cout << "[" << my_pid << "] forked left child " << my_children[0] << "\n";
//cout << "[" << my_pid << "] forked right child " << my_children[1] << "\n";
//cout << "[" << my_pid << "] left child returned\n";
//cout << "[" << my_pid << "] right child returned\n";
//cout << "[" << my_pid << "] left child returned\n";
//cout << "[" << my_pid << "] right child returned\n";*/
//cout << "[" << my_pid << "] forked searcher child " << searcher_pid << "\n";
//cout << "[" << my_pid << "] searcher child returned \n";
//cout << "[" << my_pid << "] received SIGTERM\n"; //applicable for Part III of the assignment
return 0;
}

28
src/searcher.cpp Normal file
View File

@ -0,0 +1,28 @@
#include <iostream>
#include <fstream>
#include <cstring>
#include <unistd.h>
#include <signal.h>
using namespace std;
int main(int argc, char **argv)
{
if(argc != 5)
{
cout <<"usage: ./partitioner.out <path-to-file> <pattern> <search-start-position> <search-end-position>\nprovided arguments:\n";
for(int i = 0; i < argc; i++)
cout << argv[i] << "\n";
return -1;
}
char *file_to_search_in = argv[1];
char *pattern_to_search_for = argv[2];
int search_start_position = atoi(argv[3]);
int search_end_position = atoi(argv[4]);
//TODO
cout << "[-1] didn't find\n";
return 0;
}