Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- void updateDataBase(char *path, char *dbPath);
- void locater(searchMethod, permission, caseSensitivity, newDatabase, thePattern);
- int main(){
- //get input from user
- char input[200];
- scanf(input);
- char delimiter[2] = " ";
- char *command;
- char *path;
- //find the command and send it to functions
- command = strtok (input, delimiter);
- if (strcmp (command , "updatedatabase") == 0){
- command = strtok (input, delimiter);
- if(strcmp(command, "--help") == 0){
- printf("Output this help message.");
- }
- else if(strcmp(command, "-o") == 0){
- char *newDbPath;
- newDbPath = strtok (input, delimiter);
- path = strtok(input, delimiter);
- }
- else {
- path = command;
- }
- }
- else if (strcmp (command , "locater") == 0){
- int searchMethod = 0; // 0 = standart
- // 1 = file only
- // 2 = directory only
- int permission = 0; // 0 = without any constraint
- // or with permission number
- int caseSensitivity = 0; // 0 = no sensitivity
- // 1 = oh you did it again
- char *newDatabase = NULL;
- char *thePattern = NULL;
- do{
- //this do-while manages all the declaration.
- command = strtok (input, delimiter);
- if((strcmp(command, "-f") == 0) || (strcmp(command, "--file") == 0)){
- searchMethod = 1;
- }
- else if((strcmp(command, "-d") == 0) || (strcmp(command, "--directory") == 0)){
- searchMethod = 2;
- }
- else if((strcmp(command, "-i") == 0) || (strcmp(command, "--ignore-case") == 0)){
- caseSensitivity = 1;
- }
- else if((strcmp(command, "-p") == 0)){
- command = strtok(input, delimiter);
- permission = strtok (command, "\"" );
- }
- else if((strcmp(command, "-db") == 0) || (strcmp(command, "--databasefile") == 0)){
- newDatabase = strtok(command, delimiter);
- }
- else if(strcmp(command, "--help") == 0){
- printf("Output this help message");
- }
- //there is one more parameter can be there, if this parameter escaped from all these if-else blocks
- //this parameter must be the pattern.
- thePattern = strtok(input, delimiter);
- }while(command != NULL /*end of line*/);
- //after all options got declared, function is ready to launch.
- locater(searchMethod, permission, caseSensitivity, newDatabase, thePattern);
- }
- else{
- printf("Wrong command.\n");
- }
- }
- void updateDataBase(char *path, char *dbPath){
- //go to path and build a tree.
- //check whether dbPath is null or not
- //if dbPath is null, then use standart location
- //else, use new location.
- }
- void locater(searchMethod, permission, caseSensitivity, newDatabase, thePattern){
- int search = searchMethod;
- int perm = permission;
- int caseS = caseSensitivity;
- char* db = newDatabase;
- char* pattern = thePattern;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement