home *** CD-ROM | disk | FTP | other *** search
- /*****************************************************************************\
- ** **
- ** WW WW IIIIIIII NNN NN DDDDDDD BBBBBBB AA SSSSSS EEEEEEEE **
- ** WW W WW II NNNN NN DD DD BB BB AA AA SS EE **
- ** WW W WW II NN NN NN DD DD BBBBBBB AAAAAAAA SSSSSS EEEEEE **
- ** WW W WW II NN NNNN DD DD BB BB AA AA SS EE **
- ** WWWWW IIIIIIII NN NNN DDDDDDD BBBBBBB AA AA SSSSSS EEEEEEEE **
- ** **
- ** SSSSSS OOOOOO FFFFFFFF TTTTTTTT WW WW AA RRRRRRR EEEEEEEE **
- ** SS OO OO FF TT WW W WW AA AA RR RR EE **
- ** SSSSS OO OO FFFFF TT WW W WW AAAAAAAA RRRRRRR EEEEEE **
- ** SS OO OO FF TT WW W WW AA AA RR RR EE **
- ** SSSSSS OOOOOO FF TT WWWWW AA AA RR RR EEEEEEEE **
- ** **
- *********** NOTICE ************************************************************
- ** This file contains valuable trade secrets and proprietary **
- ** assets of Windbase Software Inc. Embodying substantial **
- ** creative efforts and confidential information. Unauthorized **
- ** use, copying, decompiling, translating, disclosure or **
- ** transfer, of any kind, is strictly prohibited. **
- ** **
- ** COPYRIGHT (C) 1992, 1993, 1994. Windbase Software Inc. **
- ** ALL RIGHTS RESERVED. **
- \*****************************************************************************/
-
- #include <stdio.h>
- #include <string.h>
- #include <malloc.h>
-
- #include "../memsl.h"
-
- #if defined(WBTRC_LEVEL1) || defined(WBTRC_LEVEL2)
- #ifdef WBSTDC
- int main(int argc, char **argv)
- #else
- int main(argc, argv)
- int argc;
- char **argv;
- #endif
- #else
- #ifdef WBSTDC
- int main(void)
- #else
- int main()
- #endif
- #endif
- {
- FILE *file;
- WBQUEUE *queue;
- char str[21], item[21], *strptr;
-
- WBTrcMainEntry();
-
- #if 1 /* Queue using an array and having the queue copy the items */
-
- printf("Queue using an array:\n");
- if ((queue = WBQueueOpen(NULL,21,50,1)) != NULL)
- {
- printf("\nQueue is empty: %s\n",WBQueueIsEmpty(queue)?"Yes":"No");
- if ((file = fopen("data.dat","r")) != NULL)
- {
- while (fgets(str,20,file))
- {
- if (WBQueuePush(queue,str) == 0)
- {
- printf("Popping: %s",WBQueuePop(queue,item));
- WBQueuePush(queue,str);
- }
- }
- printf("\nQueue is empty: %s\n",WBQueueIsEmpty(queue)?"Yes":"No");
- while ((strptr = WBQueuePop(queue,item)) != NULL)
- printf("%s %s",strptr, item);
- fclose(file);
- }
- printf("\nQueue is empty: %s\n",WBQueueIsEmpty(queue)?"Yes":"No");
- WBQueueClose(queue);
- }
- #else /* Queue using a linked list */
-
- printf("Queue using a linked list:\n");
- if ((queue = WBQueueOpen(NULL,0,0,0)) != NULL)
- {
- if ((file = fopen("data.dat","r")) != NULL)
- {
- while (fgets(str,20,file))
- {
- if ((strptr = malloc(strlen(str)+1)) != NULL)
- {
- strcpy(strptr,str);
- WBQueuePush(queue,strptr);
- }
- }
- fclose(file);
- while ((strptr = WBQueuePop(queue,NULL)) != NULL)
- {
- printf("%s",strptr);
- free(strptr);
- }
- }
- WBQueueClose(queue);
- }
- #endif
- WBTrcReturn(0,0,("0"));
- }
-