Advertisement
Guest User

Untitled

a guest
Mar 27th, 2015
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.40 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4.  
  5. void updateDataBase(char *path, char *dbPath);
  6. void locater(searchMethod, permission, caseSensitivity, newDatabase, thePattern);
  7.  
  8. int main(){
  9.  
  10. //get input from user
  11. char input[200];
  12. scanf(input);
  13. char delimiter[2] = " ";
  14. char *command;
  15. char *path;
  16.  
  17. //find the command and send it to functions
  18.  
  19. command = strtok (input, delimiter);
  20.  
  21. if (strcmp (command , "updatedatabase") == 0){
  22.  
  23. command = strtok (input, delimiter);
  24.  
  25. if(strcmp(command, "--help") == 0){
  26.  
  27. printf("Output this help message.");
  28. }
  29.  
  30. else if(strcmp(command, "-o") == 0){
  31.  
  32. char *newDbPath;
  33. newDbPath = strtok (input, delimiter);
  34. path = strtok(input, delimiter);
  35. }
  36.  
  37. else {
  38. path = command;
  39. }
  40.  
  41.  
  42.  
  43. }
  44.  
  45. else if (strcmp (command , "locater") == 0){
  46.  
  47. int searchMethod = 0; // 0 = standart
  48. // 1 = file only
  49. // 2 = directory only
  50.  
  51. int permission = 0; // 0 = without any constraint
  52. // or with permission number
  53.  
  54. int caseSensitivity = 0; // 0 = no sensitivity
  55. // 1 = oh you did it again
  56.  
  57. char *newDatabase = NULL;
  58. char *thePattern = NULL;
  59.  
  60.  
  61. do{
  62. //this do-while manages all the declaration.
  63.  
  64. command = strtok (input, delimiter);
  65.  
  66. if((strcmp(command, "-f") == 0) || (strcmp(command, "--file") == 0)){
  67. searchMethod = 1;
  68. }
  69. else if((strcmp(command, "-d") == 0) || (strcmp(command, "--directory") == 0)){
  70. searchMethod = 2;
  71. }
  72. else if((strcmp(command, "-i") == 0) || (strcmp(command, "--ignore-case") == 0)){
  73. caseSensitivity = 1;
  74. }
  75. else if((strcmp(command, "-p") == 0)){
  76. command = strtok(input, delimiter);
  77. permission = strtok (command, "\"" );
  78. }
  79. else if((strcmp(command, "-db") == 0) || (strcmp(command, "--databasefile") == 0)){
  80. newDatabase = strtok(command, delimiter);
  81. }
  82. else if(strcmp(command, "--help") == 0){
  83. printf("Output this help message");
  84. }
  85.  
  86. //there is one more parameter can be there, if this parameter escaped from all these if-else blocks
  87. //this parameter must be the pattern.
  88.  
  89. thePattern = strtok(input, delimiter);
  90.  
  91.  
  92. }while(command != NULL /*end of line*/);
  93.  
  94. //after all options got declared, function is ready to launch.
  95.  
  96. locater(searchMethod, permission, caseSensitivity, newDatabase, thePattern);
  97.  
  98. }
  99.  
  100. else{
  101. printf("Wrong command.\n");
  102. }
  103.  
  104.  
  105. }
  106.  
  107. void updateDataBase(char *path, char *dbPath){
  108. //go to path and build a tree.
  109.  
  110.  
  111. //check whether dbPath is null or not
  112. //if dbPath is null, then use standart location
  113.  
  114. //else, use new location.
  115. }
  116.  
  117. void locater(searchMethod, permission, caseSensitivity, newDatabase, thePattern){
  118.  
  119. int search = searchMethod;
  120. int perm = permission;
  121. int caseS = caseSensitivity;
  122. char* db = newDatabase;
  123. char* pattern = thePattern;
  124.  
  125. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement