Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. #include <stdlib.h>
  5.  
  6. char *createname(char *path)
  7. {
  8. const char delminiter = '/';
  9. char *filename = path;
  10.  
  11. while (*path != '\0') {
  12. if (*path == delminiter) {
  13. filename = path + 1;
  14. }
  15. path++;
  16. }
  17.  
  18. return filename;
  19. }
  20.  
  21. void parsecreep(char *filename, char *provider, char *package_name, char *directory, char *description, char *req_depends, char *opt_depends, char *version)
  22. {
  23. char contents[512];
  24. short line;
  25.  
  26. FILE *file;
  27. file = fopen(filename, "r");
  28.  
  29. if (file == 0) {
  30. printf("couldn't open file\n");
  31. exit(-1);
  32. }
  33.  
  34. else {
  35. while(fgets(contents, sizeof(contents), file) != NULL) {
  36.  
  37. // for (line = 0; line < 9; line++) {
  38. if (line == 0)
  39. strcpy(provider, contents);
  40. line++;
  41.  
  42. /* else if (line == 1)
  43. strcpy(package_name, contents);
  44.  
  45. else if (line == 2)
  46. strcpy(directory, contents);
  47.  
  48. else if (line == 3)
  49. strcpy(description, contents);
  50.  
  51. else if (line == 4)
  52. strcpy(req_depends, contents);
  53.  
  54. else if (line == 5)
  55. strcpy(opt_depends, contents);
  56.  
  57. else if (line == 6)
  58. strcpy(version, contents);*/
  59. // }
  60. }
  61. }
  62.  
  63. fclose(file);
  64. }
  65.  
  66. int main(int argc, char *argv[])
  67. {
  68. char *provider;
  69. char *package_name;
  70.  
  71. char *directory;
  72. char *description;
  73.  
  74. char *req_depends;
  75. char *opt_depends;
  76.  
  77. char *version;
  78.  
  79. parsecreep(argv[1], provider, package_name, NULL, NULL, NULL, NULL, NULL);//package_name, directory, description, req_depends, opt_depends, version);
  80.  
  81. printf("%s", provider);
  82. printf("%s", package_name);
  83.  
  84. /* printf("%s", directory);
  85. printf("%s", description);
  86.  
  87. printf("%s", req_depends);
  88. printf("%s", opt_depends);
  89.  
  90. printf("%s", version); */
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement