summaryrefslogtreecommitdiff
path: root/test/test_dir.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_dir.c')
-rw-r--r--test/test_dir.c61
1 files changed, 14 insertions, 47 deletions
diff --git a/test/test_dir.c b/test/test_dir.c
index 4566a20..14a8a62 100644
--- a/test/test_dir.c
+++ b/test/test_dir.c
@@ -1,5 +1,5 @@
#include "vdefine.h"
-#define SIZE_BUFF 0xffffffff-1//16*16*16*16*16*16*16*16-1//6*16*16*16*16*16
+#define SIZE_BUFF 0xffffffff-1
#include <dirent.h>
#include <sys/stat.h>
#include <unistd.h>
@@ -14,7 +14,7 @@ buff_inf *buff_get(char *vfile) {
buff_inf *buff_inf_h = (buff_inf *)malloc(sizeof(buff_inf));
FILE *fr = NULL;
- char *buff_ori = (char *)malloc(sizeof(char *)*SIZE_BUFF);//CH
+ char *buff_ori = (char *)malloc(sizeof(char *)*SIZE_BUFF);
char *buff = buff_ori;//CH
memset(buff, 0, sizeof(buff));
if ((fr = fopen(vfile, "rb")) == NULL)
@@ -22,22 +22,19 @@ buff_inf *buff_get(char *vfile) {
perror("fopen error:");
buff_inf_h->buff = NULL;
buff_inf_h->size = 0;
- return buff_inf_h;//-1;
+ return buff_inf_h;
}
- size_t i = 0;//unsigned int i = 0;//size_t i = 0;
- //int j = 0;
+ size_t i = 0;
while (!feof(fr))
{
fread(buff, 1, 1, fr);
buff += 1;
i++;
}
- buff_inf_h->buff = (char *)malloc(sizeof(char *) * (i-1));//(i-2));
- memcpy(buff_inf_h->buff, buff - i, i-1);//i-2);
- buff_inf_h->size = i-1;//i - 2;
- //buff_inf_h.buff = buff - i;
- //buff_inf_h.size = i;
- free(buff_ori);//CH--free(buff - i);//?
+ buff_inf_h->buff = (char *)malloc(sizeof(char *) * (i-1));
+ memcpy(buff_inf_h->buff, buff - i, i-1);
+ buff_inf_h->size = i-1;
+ free(buff_ori);
buff_ori = NULL;
fclose(fr);
return buff_inf_h;
@@ -52,12 +49,10 @@ int main(int argc, char *argv[])
memcpy(vfile_ori,vdir,strlen(vdir));
strcat(vfile_ori, "/");
char *vfile = (char *)malloc(SIZE_FILE);
- //strcat(vdir,".dir");
dirp = opendir(vdir);
struct stat info;
buff_inf *buff_inf_h;
- //CH--char *buff;// = (char *)malloc(sizeof(char *)*size);//;
int ret;
int ret_sig = atoi(argv[2]);
int sig_show_all = atoi(argv[3]);
@@ -69,7 +64,7 @@ int main(int argc, char *argv[])
while ((dp = readdir(dirp)) != NULL)
{
memcpy(vfile,vfile_ori,SIZE_FILE);
- strncat(vfile, dp->d_name, strlen(dp->d_name));//strcat(vfile,dp->d_name);//vfile = dp->d_name;//fileinfo->name;//&((fileinfo->name)[0]);//argv[1];// "0003.dat";
+ strncat(vfile, dp->d_name, strlen(dp->d_name));
stat(vfile, &info);
if(S_ISDIR(info.st_mode))
@@ -87,22 +82,7 @@ int main(int argc, char *argv[])
divide_e = 1;//atoi(argv[7]);//1;
size = (buff_inf_h->size / divide_h)*(divide_e - divide_s);
- //size = atoi(argv[7]);
- //divide_e = (buff_inf_h->size / divide_h)*(divide_h-divide_s);
- //size = size>divide_e?divide_e:size;
- //CH--buff = (char *)malloc(sizeof(char *)*size);
- //CH--memcpy(buff, buff_inf_h->buff + (buff_inf_h->size / divide_h)*divide_s, size);
-
- //printf("buff_whole is %p.\n", buff_inf_h->buff);
- //printf("buff_inf_h.size/divide_h is %x.\n", buff_inf_h->size / divide_h);
- //printf("buff starts from(>=) %p.\n", buff);
- //printf("buff ends at(<) %p.\n", buff + size - 1);//+size
ret = AV_container_identify(buff_inf_h->buff + (buff_inf_h->size / divide_h)*divide_s, size);;//CCH--ret = AV_container_identify(buff, size);//CH--(const char *)?
- //CH--free(buff);
- //CH--buff = NULL;
- //printf("define : %d.\n", ret);
- //printf("size of whole buff is %d.\n", buff_inf_h->size);//size - 1
- //printf("size of chosen buff is %d.\n", size);
}
else
ret = AV_container_identify(buff_inf_h->buff, buff_inf_h->size);
@@ -111,7 +91,6 @@ int main(int argc, char *argv[])
if (ret != ret_sig)
{
printf("-----------------data of [%s] is kind of [%d].\n", dp->d_name, ret);
- //printf("define : %d.\n", ret);
printf("size of whole buff is %d.\n", buff_inf_h->size);
if (sig_choose_all == 0)
printf("size of chosen buff is %d.\n", size);
@@ -125,24 +104,12 @@ int main(int argc, char *argv[])
if (sig_choose_all == 0)
printf("size of chosen buff is %d.\n", size);
}
- free(buff_inf_h->buff);//CH--
- buff_inf_h->buff = NULL;//CH--
- free(buff_inf_h);//CH--
- buff_inf_h = NULL;//CH--
+ free(buff_inf_h->buff);
+ buff_inf_h->buff = NULL;
+ free(buff_inf_h);
+ buff_inf_h = NULL;
}
- /*
- free(buff);
-
- free(buff_inf_h->buff);
- buff_inf_h = NULL;
- free(buff_inf_h);
- return ret;
- */
-
- //CH--free(buff_inf_h->buff);
- //CH--buff_inf_h = NULL;
- //CH--free(buff_inf_h);
-
+
free(vfile);
free(vfile_ori);