diff --git "a/\344\273\273\345\212\241\345\215\22504/\351\276\231\344\270\207/\344\273\273\345\212\2412/main.c" "b/\344\273\273\345\212\241\345\215\22504/\351\276\231\344\270\207/\344\273\273\345\212\2412/main.c" index ef253634aa4de8a280704dad3aa73e2f9dc1faa2..973fe98efe9e06e02009e5ca65176c30191aa185 100644 --- "a/\344\273\273\345\212\241\345\215\22504/\351\276\231\344\270\207/\344\273\273\345\212\2412/main.c" +++ "b/\344\273\273\345\212\241\345\215\22504/\351\276\231\344\270\207/\344\273\273\345\212\2412/main.c" @@ -5,6 +5,8 @@ typedef void(F_MY_PRINT)(int pp[]); void myPrint(int pp[]) { + if (NULL == pp) + return; int i = 0; for (; i < 26; ++i) { @@ -14,6 +16,8 @@ void myPrint(int pp[]) void fun(char *tt, int pp[], F_MY_PRINT *myprint) { + if (tt == NULL || pp == NULL || myprint == NULL) + return; char *ptr = tt; int index = 0; while (*ptr != '\0') @@ -25,6 +29,7 @@ void fun(char *tt, int pp[], F_MY_PRINT *myprint) } ++ptr; } + myPrint(pp); } int main() @@ -33,4 +38,28 @@ int main() char *str = "aaabbbcccddd"; fun(str, array, myPrint); return 0; +} + +void fun(char *tt, int pp[], F_MY_PRINT *myprint) +{ + char *ptr = NULL; + int index = 0; + + if (NULL == tt || NULL == pp || NULL == myprint) + { + return; + } + + for (ptr = tt; *ptr != '\0'; ++ptr) + { + index = *ptr - 'a'; + if (0 <= index && 26 > index) + { + ++pp[index]; + } + } + + myPrint(pp); + + return; } \ No newline at end of file diff --git "a/\344\273\273\345\212\241\345\215\22504/\351\276\231\344\270\207/\344\273\273\345\212\2412/tset" "b/\344\273\273\345\212\241\345\215\22504/\351\276\231\344\270\207/\344\273\273\345\212\2412/tset" index 90107580bc99d06259738723238a996a9aa74075..7a8366204170e5f8183fc0ab54d964d316b3e419 100755 Binary files "a/\344\273\273\345\212\241\345\215\22504/\351\276\231\344\270\207/\344\273\273\345\212\2412/tset" and "b/\344\273\273\345\212\241\345\215\22504/\351\276\231\344\270\207/\344\273\273\345\212\2412/tset" differ diff --git "a/\344\273\273\345\212\241\345\215\22504/\351\276\231\344\270\207/\344\273\273\345\212\2413/main.c" "b/\344\273\273\345\212\241\345\215\22504/\351\276\231\344\270\207/\344\273\273\345\212\2413/main.c" new file mode 100644 index 0000000000000000000000000000000000000000..57b0a60028805ff94be73c58eb54aa696aca5a66 --- /dev/null +++ "b/\344\273\273\345\212\241\345\215\22504/\351\276\231\344\270\207/\344\273\273\345\212\2413/main.c" @@ -0,0 +1,12 @@ +#include +#include + +char *BONC_whereis(const char *bin_name, const char *after_who) +{ +} +int main(int argc, cha *argv[]) +{ + access("/usr/sbin/ls", R_OK) + + return 0; +} \ No newline at end of file diff --git "a/\344\273\273\345\212\241\345\215\22504/\351\276\231\344\270\207/\344\273\273\345\212\2414/04-1.png" "b/\344\273\273\345\212\241\345\215\22504/\351\276\231\344\270\207/\344\273\273\345\212\2414/04-1.png" new file mode 100644 index 0000000000000000000000000000000000000000..2813bdea6b15d0b6237e20088fd03233d63e4a20 Binary files /dev/null and "b/\344\273\273\345\212\241\345\215\22504/\351\276\231\344\270\207/\344\273\273\345\212\2414/04-1.png" differ diff --git "a/\344\273\273\345\212\241\345\215\22504/\351\276\231\344\270\207/\344\273\273\345\212\2414/04-2.png" "b/\344\273\273\345\212\241\345\215\22504/\351\276\231\344\270\207/\344\273\273\345\212\2414/04-2.png" new file mode 100644 index 0000000000000000000000000000000000000000..e81d1cc8c7da7ad0f8a25fd62362431ac0b0ab3a Binary files /dev/null and "b/\344\273\273\345\212\241\345\215\22504/\351\276\231\344\270\207/\344\273\273\345\212\2414/04-2.png" differ diff --git "a/\344\273\273\345\212\241\345\215\22504/\351\276\231\344\270\207/\344\273\273\345\212\2414/7z2201-x64.exe" "b/\344\273\273\345\212\241\345\215\22504/\351\276\231\344\270\207/\344\273\273\345\212\2414/7z2201-x64.exe" new file mode 100644 index 0000000000000000000000000000000000000000..ee08407a6652d89d9da5b2d4efaed281895fcb7d Binary files /dev/null and "b/\344\273\273\345\212\241\345\215\22504/\351\276\231\344\270\207/\344\273\273\345\212\2414/7z2201-x64.exe" differ diff --git "a/\344\273\273\345\212\241\345\215\22504/\351\276\231\344\270\207/\344\273\273\345\212\2414/bonc_tool.h" "b/\344\273\273\345\212\241\345\215\22504/\351\276\231\344\270\207/\344\273\273\345\212\2414/bonc_tool.h" new file mode 100644 index 0000000000000000000000000000000000000000..ce651f84295c35c4e9eb32d1a199d234e2d3cf88 --- /dev/null +++ "b/\344\273\273\345\212\241\345\215\22504/\351\276\231\344\270\207/\344\273\273\345\212\2414/bonc_tool.h" @@ -0,0 +1,12 @@ +#ifndef BONC_TOOL_H +#define BONC_TOOL_H + +#define bonc_free(p) \ + if (p) \ + { \ + free((void *)p); \ + p = NULL; \ + } + +#define bonc_printf_In(fmt, ...) printf("FUNCTION:%s LINE=%d OUTPUT: " fmt "\r\n", __FUNCTION__, __LINE__, ##__VA_ARGS__); +#endif \ No newline at end of file diff --git "a/\344\273\273\345\212\241\345\215\22504/\351\276\231\344\270\207/\344\273\273\345\212\2414/file" "b/\344\273\273\345\212\241\345\215\22504/\351\276\231\344\270\207/\344\273\273\345\212\2414/file" new file mode 100644 index 0000000000000000000000000000000000000000..e71843cb000934900f351f49430e633c561fe597 --- /dev/null +++ "b/\344\273\273\345\212\241\345\215\22504/\351\276\231\344\270\207/\344\273\273\345\212\2414/file" @@ -0,0 +1,3 @@ +adsdada +dad +adsdada diff --git "a/\344\273\273\345\212\241\345\215\22504/\351\276\231\344\270\207/\344\273\273\345\212\2414/main.c" "b/\344\273\273\345\212\241\345\215\22504/\351\276\231\344\270\207/\344\273\273\345\212\2414/main.c" new file mode 100644 index 0000000000000000000000000000000000000000..6ae3fc6966329f89f8beb926363d6abc44e7d46e --- /dev/null +++ "b/\344\273\273\345\212\241\345\215\22504/\351\276\231\344\270\207/\344\273\273\345\212\2414/main.c" @@ -0,0 +1,60 @@ +#include +#include +#include +#include +#include "bonc_tool.h" + +typedef void EMAIL(const char *url); +typedef struct UandDo +{ + const char *url; + EMAIL *sendemail; +} UandDo; + +void do_after(const char *url) +{ + char buf[1024]; + char path[1024]; + + getcwd(path, 1024); + sprintf(buf, "echo \"恭喜!url=%s的文件下载成功,下载路径为:%s,请注意查收\" | mail -s \"恭喜!文件下载成功\" v13b837@163.com", url, path); + system(buf); +} + +void *threadhandler(void *Ud) +{ + char buf[1024]; + UandDo *tem = (UandDo *)Ud; + + sprintf(buf, "curl %s -O", tem->url); + system(buf); + tem->sendemail(tem->url); +} + +void BONC_NB_download(const char *url, EMAIL *sendemail) +{ + UandDo Ud; + pthread_t thfd; + Ud.url = url; + Ud.sendemail = sendemail; + + if (pthread_create(&thfd, NULL, threadhandler, (void *)&Ud) != 0) + { + printf("false!\r\n"); + } + + sleep(1); + return; +} + +int main(int argc, char *argv[]) +{ + if (2 > argc) + { + bonc_printf_In("Please enter url! Suchas : mydownload https://7-zip.org/a/7z2201-x64.exe"); + return -1; + } + BONC_NB_download(argv[1], do_after); + + return 0; +} diff --git "a/\344\273\273\345\212\241\345\215\22504/\351\276\231\344\270\207/\344\273\273\345\212\2414/makefile" "b/\344\273\273\345\212\241\345\215\22504/\351\276\231\344\270\207/\344\273\273\345\212\2414/makefile" new file mode 100644 index 0000000000000000000000000000000000000000..c9738a230a913579512061a209898f0ca8949031 --- /dev/null +++ "b/\344\273\273\345\212\241\345\215\22504/\351\276\231\344\270\207/\344\273\273\345\212\2414/makefile" @@ -0,0 +1,5 @@ +.PHONY:clean +mydownload:main.c bonc_tool.h + gcc $^ -o $@ -lpthread +clean: + rm -f ./7z2201-x64.exe diff --git "a/\344\273\273\345\212\241\345\215\22504/\351\276\231\344\270\207/\344\273\273\345\212\2414/mydownload" "b/\344\273\273\345\212\241\345\215\22504/\351\276\231\344\270\207/\344\273\273\345\212\2414/mydownload" new file mode 100755 index 0000000000000000000000000000000000000000..d0aaccfd3f04beb70c31274080c317293d9cf332 Binary files /dev/null and "b/\344\273\273\345\212\241\345\215\22504/\351\276\231\344\270\207/\344\273\273\345\212\2414/mydownload" differ diff --git "a/\344\273\273\345\212\241\345\215\22504/\351\276\231\344\270\207/\344\273\273\345\212\2415/05.png" "b/\344\273\273\345\212\241\345\215\22504/\351\276\231\344\270\207/\344\273\273\345\212\2415/05.png" new file mode 100644 index 0000000000000000000000000000000000000000..55a3676941e9d5a84f6df6cb85a5916ef513a6d5 Binary files /dev/null and "b/\344\273\273\345\212\241\345\215\22504/\351\276\231\344\270\207/\344\273\273\345\212\2415/05.png" differ diff --git "a/\344\273\273\345\212\241\345\215\22504/\351\276\231\344\270\207/\344\273\273\345\212\2415/bonc_tool.h" "b/\344\273\273\345\212\241\345\215\22504/\351\276\231\344\270\207/\344\273\273\345\212\2415/bonc_tool.h" new file mode 100644 index 0000000000000000000000000000000000000000..6511aa851b6073dfaf1660e440beaaa6a5d7f180 --- /dev/null +++ "b/\344\273\273\345\212\241\345\215\22504/\351\276\231\344\270\207/\344\273\273\345\212\2415/bonc_tool.h" @@ -0,0 +1,14 @@ +#ifndef BONC_TOOL_H +#define BONC_TOOL_H + +#define bonc_free(p) \ + if (p) \ + { \ + free((void *)p); \ + p = NULL; \ + } + +#define bonc_printf_In(fmt, ...) printf("FUNCTION:%s LINE=%d OUTPUT: " fmt "\r\n", __FUNCTION__, __LINE__, ##__VA_ARGS__); +#define STRUCT_MEM_OFFSET(type, member) ((unsigned int)&(((type *)0)->member)) +#define STRUCT_PTR_MEM(ptr, type, member) (type *)((char *)ptr - STRUCT_MEM_OFFSET(type, member)) +#endif \ No newline at end of file diff --git "a/\344\273\273\345\212\241\345\215\22504/\351\276\231\344\270\207/\344\273\273\345\212\2415/main.c" "b/\344\273\273\345\212\241\345\215\22504/\351\276\231\344\270\207/\344\273\273\345\212\2415/main.c" new file mode 100644 index 0000000000000000000000000000000000000000..545521cf734827f6aa60d64aac8f0d758bd3398a --- /dev/null +++ "b/\344\273\273\345\212\241\345\215\22504/\351\276\231\344\270\207/\344\273\273\345\212\2415/main.c" @@ -0,0 +1,19 @@ +#include +#include +#include "bonc_tool.h" + +typedef struct A +{ + int a; + char b; + float c; +} A; +int main() +{ + A a; + float *pc = &(a.c); + + bonc_printf_In("OFFSET= %d", STRUCT_MEM_OFFSET(A, c)) + bonc_printf_In("a.PTR= %p", &(a.a)) + bonc_printf_In("S.PTR= %p", STRUCT_PTR_MEM(pc, A, c)) +} \ No newline at end of file diff --git "a/\344\273\273\345\212\241\345\215\22504/\351\276\231\344\270\207/\344\273\273\345\212\2415/test" "b/\344\273\273\345\212\241\345\215\22504/\351\276\231\344\270\207/\344\273\273\345\212\2415/test" new file mode 100755 index 0000000000000000000000000000000000000000..2bd36b7905e6a6e0772a0ec7f97a20e63f7cb070 Binary files /dev/null and "b/\344\273\273\345\212\241\345\215\22504/\351\276\231\344\270\207/\344\273\273\345\212\2415/test" differ