home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ User's Journal & Wi…eveloper's Journal Tools
/
C-C__Users_Journal_and_Windows_Developers_Journal_Tools_1997.iso
/
windbase
/
windbase.exe
/
MEMSLC.3
/
BAG.C
< prev
next >
Wrap
C/C++ Source or Header
|
1996-07-30
|
6KB
|
165 lines
/*****************************************************************************\
** **
** 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"
#ifdef WBSTDC
int Compare(void *nullitem, char *item1, char *item2)
#else
int Compare(nullitem, item1, item2)
void *nullitem;
char *item1,
*item2;
#endif
{
WBTrcEntry(0,"Compare",("%p, %s, %s",nullitem,item1?item1:"NULL",item2?item2:"NULL"));
nullitem = nullitem;
WBTrcReturn(0,strcmp(item1,item2),("%d",strcmp(item1,item2)));
}
#ifdef WBSTDC
void Print(void *nullitem, char *item)
#else
void Print(nullitem, item)
void *nullitem;
char *item;
#endif
{
WBTrcEntry(0,"Print",("%p, %s",nullitem,item?item:"NULL"));
nullitem = nullitem;
printf("%s\n",item);
WBTrcVReturn(0,(""));
}
#ifdef WBSTDC
void Delete(void *nullitem, char *item)
#else
void Delete(nullitem, item)
void *nullitem;
char *item;
#endif
{
WBTrcEntry(0,"Delete",("%p, %s",nullitem,item?item:"NULL"));
nullitem = nullitem;
free(item);
WBTrcVReturn(0,(""));
}
#if defined(WBTRC_LEVEL1) || defined(WBTRC_LEVEL2)
#ifdef WBSTDC
int main(int argc, char **argv, char **envp)
#else
int main(argc, argv, envp)
int argc;
char **argv,
**envp;
#endif
#else
#ifdef WBSTDC
int main(void)
#else
int main()
#endif
#endif
{
FILE *file;
WBBAG *bag1, *bag2;
char str[41], *strptr;
WBTrcMainEntry();
if ((bag1 = WBBagOpen(NULL)) != NULL)
if ((bag2 = WBBagOpen(NULL)) != NULL)
{
#ifdef FUNCTCAST
WBBagCompareF(bag1,NULL,(int (*)(void *, void *, void *))Compare);
WBBagExecuteF(bag1,NULL,(void (*)(void *, void *))Print);
WBBagDeleteF(bag1,NULL,(void (*)(void *, void *))Delete);
WBBagCompareF(bag2,NULL,(int (*)(void *, void *, void *))Compare);
WBBagExecuteF(bag2,NULL,(void (*)(void *, void *))Print);
WBBagDeleteF(bag2,NULL,(void (*)(void *, void *))Delete);
#else
WBBagCompareF(bag1,NULL,(int (*)())Compare);
WBBagExecuteF(bag1,NULL,(void (*)())Print);
WBBagDeleteF(bag1,NULL,(void (*)())Delete);
WBBagCompareF(bag2,NULL,(int (*)())Compare);
WBBagExecuteF(bag2,NULL,(void (*)())Print);
WBBagDeleteF(bag2,NULL,(void (*)())Delete);
#endif
if ((file = fopen("data.dat","rt")) != NULL)
{
while (fgets(str,40,file))
{
if (*str && *(str+strlen(str)-1) == '\n')
*(str+strlen(str)-1) = '\0';
if ((strptr = malloc(strlen(str)+1)) != NULL)
{
strcpy(strptr,str);
if (WBBagAdd(bag1,strptr) == -1)
free(strptr);
}
}
fclose(file);
}
if ((file = fopen("data2.dat","rt")) != NULL)
{
while (fgets(str,40,file))
{
if (*str && *(str+strlen(str)-1) == '\n')
*(str+strlen(str)-1) = '\0';
if ((strptr = malloc(strlen(str)+1)) != NULL)
{
strcpy(strptr,str);
if (WBBagAdd(bag2,strptr) == -1)
free(strptr);
}
}
fclose(file);
}
printf("Executing bag1\n");
WBBagExecute(bag1);
printf("Executing bag2\n");
WBBagExecute(bag2);
WBBagClose(bag1);
WBBagClose(bag2);
}
WBTrcReturn(0,0,("0"));
}