Annotation of libaitio/example/test_sarray.c, revision 1.2
1.2 ! misho 1: #include <stdio.h>
! 2: #include <string.h>
! 3: #include <aitio.h>
! 4:
! 5: int
! 6: main(int argc, char **argv)
! 7: {
! 8: sarr_t *a = NULL;
! 9: void *d = "MEOWeoeoeoeoe!!!";
! 10:
! 11: a = io_sarrInit(10, 4);
! 12: if (!a) {
! 13: printf("Error:: #%d - %s\n", io_GetErrno(), io_GetError());
! 14: return 1;
! 15: }
! 16:
! 17: switch (argc) {
! 18: case 4:
! 19: io_sarrSet(a, 10, argv[3]);
! 20: case 3:
! 21: io_sarrSet(a, 6, argv[2]);
! 22: io_sarrSet(a, 4, argv[2]);
! 23: case 2:
! 24: io_sarrSet(a, 3, argv[1]);
! 25: io_sarrSet(a, 1, argv[1]);
! 26: }
! 27:
! 28: printf(">>> a[1]=%s a[2]=%s a[3]=%s a[4]=%s a[6]=%s a[10]=%s\n",
! 29: io_sarr(a, 1, char*), io_sarr(a, 2, char*),
! 30: io_sarr(a, 3, char*), io_sarr(a, 4, char*),
! 31: io_sarr(a, 6, char*), io_sarr(a, 10, char*));
! 32: printf(">>> array size=%d\n", io_sarrSize(a));
! 33:
! 34: io_sarrDel(a, 6);
! 35: io_sarrDel(a, 9);
! 36: io_sarrDel(a, 10);
! 37: printf(">>> a[1]=%s a[2]=%s a[3]=%s a[4]=%s a[6]=%s a[10]=%s\n",
! 38: io_sarr(a, 1, char*), io_sarr(a, 2, char*),
! 39: io_sarr(a, 3, char*), io_sarr(a, 4, char*),
! 40: io_sarr(a, 6, char*), io_sarr(a, 10, char*));
! 41: printf(">>> array size=%d\n", io_sarrSize(a));
! 42:
! 43: io_sarrSet(a, 240, d);
! 44: printf(">>> array size=%d s[240]=%s\n", io_sarrSize(a), io_sarrGet2(a, 240));
! 45: io_sarrSet(a, 240, d);
! 46: printf(">>> array size=%d s[240]=%s\n", io_sarrSize(a), io_sarr(a, 240, char*));
! 47: printf(">>> array size=%d s[240]=%s\n", io_sarrSize(a), io_sarrGet2(a, 240));
! 48:
! 49: io_sarrVacuum(a);
! 50: printf("vacuum:: a[1]=%s a[2]=%s a[3]=%s a[4]=%s a[6]=%s a[10]=%s\n",
! 51: io_sarr(a, 1, char*), io_sarr(a, 2, char*),
! 52: io_sarr(a, 3, char*), io_sarr(a, 4, char*),
! 53: io_sarr(a, 6, char*), io_sarr(a, 10, char*));
! 54: printf("vacuum:: array size=%d\n", io_sarrSize(a));
! 55:
! 56: io_sarrGrow(a, 20);
! 57: printf("grow:: array size=%d\n", io_sarrSize(a));
! 58: printf("grow:: a[1]=%s a[2]=%s a[3]=%s a[4]=%s a[6]=%s a[10]=%s\n",
! 59: io_sarr(a, 1, char*), io_sarr(a, 2, char*),
! 60: io_sarr(a, 3, char*), io_sarr(a, 4, char*),
! 61: io_sarr(a, 6, char*), io_sarr(a, 10, char*));
! 62:
! 63: io_sarrGrow(a, 1);
! 64: io_sarrGrow(a, 2);
! 65: printf("shrink:: array size=%d\n", io_sarrSize(a));
! 66: printf("shrink:: a[1]=%s a[2]=%s\n", io_sarr(a, 1, char*), io_sarr(a, 2, char*));
! 67:
! 68: io_sarrDestroy(&a);
! 69: return 0;
! 70: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>