Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <errno.h>
- #include <unistd.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <time.h>
- void cls()
- {
- system("clear");
- }
- struct f_info
- {
- char *ext;
- size_t size;
- };
- struct f_info *f_file(const char *pname)
- {
- char *name = malloc(32);
- struct f_info *info = malloc(sizeof(struct f_info));
- info->ext = malloc(8);
- strcpy(name, pname);
- int i=0; while (name[i] != '.' && name[i]) i++;
- i++;
- strncpy(info->ext, name+i, 4);
- struct stat st;
- if (lstat(name, &st) < 0) info->size = 0;
- else info->size = st.st_size;
- return info;
- }
- int main(int argc, char *argv[])
- {
- if (argc != 2) return -1;
- cls();
- struct f_info *r = f_file(argv[1]);
- if (r)
- printf("extension : %s\tsize : %zu\n", r->ext, r->size);
- puts("/bin/sh");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement