Advertisement
Guest User

Untitled

a guest
Dec 10th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <conio.h>
  3. #include <string.h>
  4. #include <malloc.h>
  5. #include <math.h>
  6. typedef struct frame frame;
  7. struct frame{
  8. char ftag;
  9. char tag[3];
  10. int size;
  11. char flag;
  12. char *data;
  13. };
  14. int main (int argc, char *argv[]){
  15. if (argc < 2) {
  16. printf("File error");
  17. return 0;
  18. }
  19. char file_name[36];
  20. strncpy(file_name, argv[1] + 11, strlen(argv[1] - 10));
  21. FILE *song = fopen (file_name, "rb");
  22. FILE *text = fopen ("ans.txt", "wb");
  23. fseek(song, 0, SEEK_END);
  24. long Size = ftell(song);
  25. fseek(song, 0, SEEK_SET);
  26. char * buffer = (char *) malloc(3);
  27. printf ("%d\n",sizeof(buffer));
  28. fread(buffer, 1, 3, song);
  29. if (strncmp(buffer, "ID3", 3) != 0) {
  30. printf("Non mp3 file");
  31. return 0;
  32. }
  33. buffer = (char *) malloc(1);
  34. printf ("%d\n",sizeof(buffer));
  35. int i = 3;
  36. fseek(song, 7, SEEK_CUR);
  37. if ( strncmp(argv[2],"--show", 6) == 0) {
  38. while (i < Size) {
  39. fread(buffer, 1, 1, song);
  40. if (strncmp(buffer, "T", 1) == 0) {
  41. frame inf;
  42. inf.ftag = "T";
  43. fread(inf.tag, 1, 3, song);
  44. buffer = (char *) malloc(4);
  45. printf ("%d\n",sizeof(buffer));
  46. char key[4];
  47. fread(key, 1, 100, song);
  48. printf ("here's buffer : %s\n", key);
  49. for (int j = 0; j < 4; j++)
  50. inf.size |= key[3 - j] << j * 8;
  51. printf ("size : %d\n", inf.size);
  52. fread(buffer, 1, 2, song);
  53. inf.flag = buffer;
  54. printf("kek");
  55. inf.data = malloc(sizeof(char)* inf.size);
  56. printf ("LOL");
  57. fread(inf.data, 1, inf.size, song);
  58. i += inf.size + 10;
  59. printf("%c%s : %s\n",inf.ftag, inf.tag, inf.data);
  60. }
  61. else i++;
  62. }
  63. }
  64. /* if (strncmp(buffer, "W", 1) == 0){
  65.  
  66. };
  67. if (strncmp(buffer, "C", 1) == 0){
  68.  
  69. };
  70.  
  71.  
  72. }*/
  73.  
  74. return 0;
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement