Annotation of libaitio/example/test.c, revision 1.2
1.1 misho 1: #include <stdio.h>
1.2 ! misho 2: #include <string.h>
1.1 misho 3: #include <aitio.h>
4:
5:
1.2 ! misho 6: int main(int argc, char **argv)
1.1 misho 7: {
8: int ret;
1.2 ! misho 9: char str[256], *s, s0[2][256];
1.1 misho 10:
1.2 ! misho 11: if (argc < 2) {
! 12: printf("std:: %s ioPromptRead(NULL) -> %d\n", str, ioPromptRead(NULL, NULL, str, 256));
! 13: printf("std:: %s ioPromptRead(PIUK> ) -> %d\n", str, (ret = ioPromptRead(NULL, "PIUK> ", str, 256)));
! 14: printf("geterror:: #%d - %s\n", io_GetErrno(), io_GetError());
! 15:
! 16: printf("std:: %s w/o confirm ioPromptPassword(NULL) -> %d\n", str,
! 17: ioPromptPassword(NULL, NULL, str, 256, 0));
! 18: printf("std:: %s ioPromptPassword(NULL) -> %d\n", str,
! 19: ioPromptPassword(NULL, NULL, str, 256, 1));
! 20: printf("std:: %s w/o confirm ioPromptPassword(PIUK> ) -> %d\n", str,
! 21: (ret = ioPromptPassword(NULL, "PIUK pass: ", str, 256, 0)));
! 22: printf("geterror:: #%d - %s\n", io_GetErrno(), io_GetError());
! 23:
! 24: printf("std:: %s ioPromptRead(FLIUP: ) -> %d\n", str, (ret = ioPromptRead(NULL, "FLIUP: ", str, 256)));
! 25:
! 26: printf("regex:: %s ioRegexVerify([0-9]+) -> %s\n", str, ioRegexVerify("[0-9]+", "shmink132sdf09", NULL, NULL));
! 27: printf("regex:: %s ioRegexGet([0-9]+) -> %d\n", str, ioRegexGet("[0-9]+", "shmink132sdf09", str, 256));
! 28: printf("regex:: %s not match ioRegexGet([ab]+) -> %d\n", str, ioRegexGet("[ab]+", "shmink132sdf09", str, 256));
! 29:
! 30: s = ioRegexReplace("[0-9]+", "0shmink132sdf09", "XXX");
! 31: printf("regex:: ioRegexReplace([0-9]+) -> %s with XXX\n", s);
! 32: free(s);
! 33: s = ioRegexReplace("[0-9]+", "shmink132sdf09", NULL);
! 34: printf("regex:: ioRegexReplace([0-9]+) -> %s clear!\n", s);
! 35: free(s);
! 36: }
! 37:
! 38: if (argc > 2) {
! 39: printf("test p=%s f=%s path2file=%d\n", s0[0], s0[1], io_Path2File(argv[2], s0[0], 256, s0[1], 256));
! 40: return 0;
! 41: }
! 42:
! 43: if (argc > 1) {
! 44: struct tagIOURL URL;
! 45: int ret = 0;
! 46: char **item = NULL;
! 47: char szVal[BUFSIZ];
! 48:
! 49: printf("URL:: Return=%x --- URL=%s\n", (ret = ioURLGet(argv[1], &URL)), argv[1]);
! 50:
! 51: printf("URL:: (%x) ***Line=%s\n", ret, URL.url_line);
! 52: printf("URL:: (%x) tech=%s(%d)\n", ret & 1, URL.url_tech.value, URL.url_tech.vallen);
! 53: printf("URL:: (%x) user=%s(%d)\n", ret & 2, URL.url_user.value, URL.url_user.vallen);
! 54: printf("URL:: (%x) pass=%s(%d)\n", ret & 4, URL.url_pass.value, URL.url_pass.vallen);
! 55: printf("URL:: (%x) host=%s(%d)\n", ret & 8, URL.url_host.value, URL.url_host.vallen);
! 56: printf("URL:: (%x) port=%s(%d)\n", ret & 16, URL.url_port.value, URL.url_port.vallen);
! 57: printf("URL:: (%x) path=%s(%d)\n", ret & 32, URL.url_path.value, URL.url_path.vallen);
! 58: printf("URL:: (%x) args=%s(%d)\n", ret & 64, URL.url_args.value, URL.url_args.vallen);
! 59: printf("URL:: (%x) +++reserved=%s\n", ret & 128, URL.url_reserved);
! 60:
! 61: printf("URL:: Get sizeofArray=%d\n", io_SizeArray(URL.url_args.value, "&"));
! 62:
! 63: memset(szVal, 0, BUFSIZ);
! 64: printf("Get_url:: %s Attribute=piuk %d\n", szVal, ioURLGetValue(&URL, "piuk", szVal, BUFSIZ));
! 65: printf("Get_url:: %s Attribute=sg %d\n", szVal, ioURLGetValue(&URL, "sg", szVal, BUFSIZ));
! 66: printf("Get_url:: %s Attribute=sgg %d\n", szVal, ioURLGetValue(&URL, "sgg", szVal, BUFSIZ));
! 67: printf("Get_url:: %s Attribute=sfsf %d\n", szVal, ioURLGetValue(&URL, "sfsf", NULL, BUFSIZ));
! 68: printf("Get_url:: %s Attribute=vv %d\n", szVal, ioURLGetValue(&URL, "vv", NULL, 0));
! 69: printf("Get_url:: %s Attribute=vv %d\n", szVal, ioURLGetValue(&URL, "vv", szVal, BUFSIZ));
! 70:
! 71: printf("File_url:: File=%s %d\n", szVal, ioURLGetFile(&URL, szVal, BUFSIZ));
! 72:
! 73: printf("URL:: array args=%d\n", io_MakeArray(URL.url_args.value, "&", &item, 4));
! 74: for (ret = 0; ret < 4 && item; ret++)
! 75: printf("array:: item[%d]=%s\n", ret, item[ret]);
! 76: if (item)
! 77: free(item);
! 78:
! 79: printf("URL:: array path=%d\n", io_MakeArray(URL.url_path.value, "/", &item, 2));
! 80: for (ret = 0; ret < 2 && item; ret++)
! 81: printf("array:: item[%d]=%s\n", ret, item[ret]);
! 82: if (item)
! 83: free(item);
! 84: }
1.1 misho 85: return 0;
86: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>