File:  [ELWIX - Embedded LightWeight unIX -] / libelwix / example / astvar.c
Revision 1.1: download - view: text, annotated - select for diffs - revision graph
Thu Jan 17 10:05:35 2013 UTC (11 years, 5 months ago) by misho
CVS tags: MAIN, HEAD
Initial revision

    1: #include <stdio.h>
    2: #include <elwix.h>
    3: 
    4: int
    5: main(int argc, char **argv)
    6: {
    7: 	char szStr[BUFSIZ];
    8: 	ait_val_t *s;
    9: 
   10: 	if (argc < 2) {
   11: 		printf("Syntax: %s <var (like {99999[:9:9]})>\n", argv[0]);
   12: 		return 1;
   13: 	}
   14: 
   15: 	s = str_Ast(argv[1]);
   16: 	if (!s) {
   17: 		printf("#%d - %s\n", elwix_GetErrno(), elwix_GetError());
   18: 		return 1;
   19: 	}
   20: 
   21: 	printf(">>> %s\n", AIT_GET_STR(s));
   22: 
   23: 	if (av_Save(NULL, "test_av", AIT_GET_STR(s), 0, 0) == -1) {
   24: 		printf("#%d - %s\n", elwix_GetErrno(), elwix_GetError());
   25: 		ait_freeVar(&s);
   26: 		return 2;
   27: 	}
   28: 	if (av_Save(NULL, "test_av", AIT_GET_STR(s), 42, 0) == -1) {
   29: 		printf("#%d - %s\n", elwix_GetErrno(), elwix_GetError());
   30: 		ait_freeVar(&s);
   31: 		return 3;
   32: 	}
   33: 
   34: 	ait_freeVar(&s);
   35: 
   36: 	if (av_Load(NULL, "test_av", szStr, sizeof szStr, 0) == -1) {
   37: 		printf("#%d - %s\n", elwix_GetErrno(), elwix_GetError());
   38: 		return 4;
   39: 	} else
   40: 		printf(">>> %s\n", szStr);
   41: 	if (av_Load(NULL, "test_av", szStr, sizeof szStr, 42) == -1) {
   42: 		printf("#%d - %s\n", elwix_GetErrno(), elwix_GetError());
   43: 		return 5;
   44: 	} else
   45: 		printf(">>> %s\n", szStr);
   46: 
   47: 	return 0;
   48: }

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