summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXiaoqing MA <[email protected]>2018-07-10 19:19:12 +0800
committerXiaoqing MA <[email protected]>2018-07-10 19:19:12 +0800
commit6bff4390c0eb23efbd432796dcbecc2dd0e29de8 (patch)
tree38d309ed5f2b09914a33b9fa20bd94d48246cb44
parentc41fef0e31fba822f959affea3f164311cfd5744 (diff)
new ed11
-rw-r--r--Makefile10
-rw-r--r--bin/testbin20360 -> 18208 bytes
-rw-r--r--bin/test_dirbin25616 -> 22504 bytes
-rw-r--r--lib/libvdefine.abin15418 -> 15418 bytes
-rw-r--r--src/Makefile19
-rw-r--r--src/libvdefine.abin0 -> 15418 bytes
-rw-r--r--src/test.c124
-rw-r--r--src/test_dir.c150
-rw-r--r--src/vdefine.o (renamed from obj/vdefine.o)bin15056 -> 15056 bytes
-rw-r--r--test/Makefile18
-rw-r--r--test/testbin0 -> 18208 bytes
-rw-r--r--test/test_dirbin0 -> 22504 bytes
12 files changed, 47 insertions, 274 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..d22447b
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,10 @@
+all:
+ cd src; $(MAKE);
+ cd test; $(MAKE);
+
+clean:
+ cd src; $(MAKE) clean;
+ cd test; $(MAKE) clean;
+ rm -f bin/*;
+ rm -f lib/*;
+
diff --git a/bin/test b/bin/test
index 777227d..f6ed770 100644
--- a/bin/test
+++ b/bin/test
Binary files differ
diff --git a/bin/test_dir b/bin/test_dir
index 479b224..9e507c4 100644
--- a/bin/test_dir
+++ b/bin/test_dir
Binary files differ
diff --git a/lib/libvdefine.a b/lib/libvdefine.a
index f180af6..f2182b7 100644
--- a/lib/libvdefine.a
+++ b/lib/libvdefine.a
Binary files differ
diff --git a/src/Makefile b/src/Makefile
new file mode 100644
index 0000000..e41329f
--- /dev/null
+++ b/src/Makefile
@@ -0,0 +1,19 @@
+SOURCE = vdefine.c
+OBJS = vdefine.o
+TARGET = libvdefine.a
+
+CC = gcc
+CFLAGS = -g
+LIB_PATH = ../lib
+INC_PATH = ../inc
+
+all:$(TARGET)
+
+.c.o:
+ $(CC) -c $(CFLAGS) -I$(INC_PATH) $<
+
+libvdefine.a: $(OBJS)
+ (rm -f $@ ;ar -r $@ $^; cp $@ $(LIB_PATH);)
+
+clean:
+ rm -f *.o $(TARGET)
diff --git a/src/libvdefine.a b/src/libvdefine.a
new file mode 100644
index 0000000..f2182b7
--- /dev/null
+++ b/src/libvdefine.a
Binary files differ
diff --git a/src/test.c b/src/test.c
deleted file mode 100644
index ac9bd0d..0000000
--- a/src/test.c
+++ /dev/null
@@ -1,124 +0,0 @@
-#include "vdefine.h"
-#define SIZE_BUFF 0xffffffff-1//16*16*16*16*16*16*16*16-1//6*16*16*16*16*16
-#include <dirent.h>
-#include <sys/stat.h>
-#include <unistd.h>
-typedef struct buff_inf_h
-{
- char *buff;
- size_t size;
-}buff_inf;
-
-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 = buff_ori;//CH
- memset(buff, 0, sizeof(buff));
- if ((fr = fopen(vfile, "rb")) == NULL)
- {
- perror("fopen error:");
- buff_inf_h->buff = NULL;
- buff_inf_h->size = 0;
- return buff_inf_h;//-1;
- }
- size_t i = 0;//unsigned int i = 0;//size_t i = 0;
- //int j = 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_ori = NULL;
- fclose(fr);
- return buff_inf_h;
-
-}
-int main(int argc, char *argv[])
-{
- char *vfile = argv[1];
- 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]);
- int sig_choose_all = atoi(argv[4]);
- size_t size;
-
- buff_inf_h = buff_get(vfile);
- if (buff_inf_h->size == 0)
- {
- printf("read file failed.\n");
- return -1;
- }
- if (sig_choose_all == 0)
- {
- int divide_h = 10;
- int divide_s = 0;
- int divide_e = 1;
-
- size = (buff_inf_h->size / divide_h)*(divide_e - divide_s);
-
- //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);
- if (sig_show_all == 0)
- {
- if (ret != ret_sig)
- {
- printf("-----------------data of [%s] is kind of [%d].\n",vfile,ret);// 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);
-
- }
- }
- else
- {
- printf("-----------------data of [%s] is kind of [%d].\n", vfile, ret);// dp->d_name, 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);
- }
- free(buff_inf_h->buff);//CH--
- buff_inf_h->buff = NULL;//CH--
- free(buff_inf_h);//CH--
- buff_inf_h = NULL;//CH--
- /*
- 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);
-
-
- return ret;
-}
diff --git a/src/test_dir.c b/src/test_dir.c
deleted file mode 100644
index f97b7e9..0000000
--- a/src/test_dir.c
+++ /dev/null
@@ -1,150 +0,0 @@
-#include "vdefine.h"
-#define SIZE_BUFF 0xffffffff-1//16*16*16*16*16*16*16*16-1//6*16*16*16*16*16
-#include <dirent.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#define SIZE_FILE 50
-typedef struct buff_inf_h
-{
- char *buff;
- size_t size;
-}buff_inf;
-
-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 = buff_ori;//CH
- memset(buff, 0, sizeof(buff));
- if ((fr = fopen(vfile, "rb")) == NULL)
- {
- perror("fopen error:");
- buff_inf_h->buff = NULL;
- buff_inf_h->size = 0;
- return buff_inf_h;//-1;
- }
- size_t i = 0;//unsigned int i = 0;//size_t i = 0;
- //int j = 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_ori = NULL;
- fclose(fr);
- return buff_inf_h;
-
-}
-int main(int argc, char *argv[])
-{
- DIR *dirp;
- struct dirent *dp;
- char *vdir = argv[1];
- char *vfile_ori = (char *)malloc(SIZE_FILE);
- 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]);
- int sig_choose_all = atoi(argv[4]);
- size_t size;
- int divide_h;
- int divide_s;
- int divide_e;
- 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";
-
- stat(vfile, &info);
- if(S_ISDIR(info.st_mode))
- continue;
- buff_inf_h = buff_get(vfile);
- if (buff_inf_h->size == 0)
- {
- printf("read file failed of %s.\n",vfile);
- return -1;
- }
- if (sig_choose_all == 0)
- {
- divide_h = 10;//atoi(argv[5]);//10;
- divide_s = 0;//atoi(argv[6]);//0;
- 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);
- if (sig_show_all == 0)
- {
- 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);
-
- }
- }
- else
- {
- printf("-----------------data of [%s] is kind of [%d].\n", dp->d_name, 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);
- }
- free(buff_inf_h->buff);//CH--
- buff_inf_h->buff = NULL;//CH--
- free(buff_inf_h);//CH--
- buff_inf_h = NULL;//CH--
- }
- /*
- 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);
-
- return ret;
-}
diff --git a/obj/vdefine.o b/src/vdefine.o
index 2074b58..75a7ba9 100644
--- a/obj/vdefine.o
+++ b/src/vdefine.o
Binary files differ
diff --git a/test/Makefile b/test/Makefile
new file mode 100644
index 0000000..d90aaf4
--- /dev/null
+++ b/test/Makefile
@@ -0,0 +1,18 @@
+CC = gcc
+CFLAGS = -g
+LIB_PATH = ../lib
+INC_PATH = ../inc
+BIN_PATH = ../bin
+LIB = -lvdefine
+TARGET = test test_dir
+
+all:$(TARGET)
+
+test:test.c
+ (rm -f $@; $(CC) -o $@ -I$(INC_PATH) $^ -L$(LIB_PATH) $(LIB); cp $@ $(BIN_PATH);)
+
+test_dir:test_dir.c
+ (rm -f $@; $(CC) -o $@ -I$(INC_PATH) $^ -L$(LIB_PATH) $(LIB); cp $@ $(BIN_PATH);)
+
+clean:
+ rm -f $(TARGET)
diff --git a/test/test b/test/test
new file mode 100644
index 0000000..f6ed770
--- /dev/null
+++ b/test/test
Binary files differ
diff --git a/test/test_dir b/test/test_dir
new file mode 100644
index 0000000..9e507c4
--- /dev/null
+++ b/test/test_dir
Binary files differ