Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <conio.h>
- #include <string.h>
- #include <malloc.h>
- #include <math.h>
- typedef struct frame frame;
- struct frame{
- char ftag;
- char tag[3];
- int size;
- char flag;
- char *data;
- };
- int main (int argc, char *argv[]){
- if (argc < 2) {
- printf("File error");
- return 0;
- }
- char file_name[36];
- strncpy(file_name, argv[1] + 11, strlen(argv[1] - 10));
- FILE *song = fopen (file_name, "rb");
- FILE *text = fopen ("ans.txt", "wb");
- fseek(song, 0, SEEK_END);
- long Size = ftell(song);
- fseek(song, 0, SEEK_SET);
- char * buffer = (char *) malloc(3);
- printf ("%d\n",sizeof(buffer));
- fread(buffer, 1, 3, song);
- if (strncmp(buffer, "ID3", 3) != 0) {
- printf("Non mp3 file");
- return 0;
- }
- buffer = (char *) malloc(1);
- printf ("%d\n",sizeof(buffer));
- int i = 3;
- fseek(song, 7, SEEK_CUR);
- if ( strncmp(argv[2],"--show", 6) == 0) {
- while (i < Size) {
- fread(buffer, 1, 1, song);
- if (strncmp(buffer, "T", 1) == 0) {
- frame inf;
- inf.ftag = "T";
- fread(inf.tag, 1, 3, song);
- buffer = (char *) malloc(4);
- printf ("%d\n",sizeof(buffer));
- char key[4];
- fread(key, 1, 100, song);
- printf ("here's buffer : %s\n", key);
- for (int j = 0; j < 4; j++)
- inf.size |= key[3 - j] << j * 8;
- printf ("size : %d\n", inf.size);
- fread(buffer, 1, 2, song);
- inf.flag = buffer;
- printf("kek");
- inf.data = malloc(sizeof(char)* inf.size);
- printf ("LOL");
- fread(inf.data, 1, inf.size, song);
- i += inf.size + 10;
- printf("%c%s : %s\n",inf.ftag, inf.tag, inf.data);
- }
- else i++;
- }
- }
- /* if (strncmp(buffer, "W", 1) == 0){
- };
- if (strncmp(buffer, "C", 1) == 0){
- };
- }*/
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement