File:  [ELWIX - Embedded LightWeight unIX -] / libaitio / example / test.c
Revision 1.1.1.1.2.3: download - view: text, annotated - select for diffs - revision graph
Thu Mar 4 09:54:23 2010 UTC (14 years, 4 months ago) by misho
Branches: io1_0
Diff to: branchpoint 1.1.1.1: preferred, unified
add new function

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>