dslinux/user/bitchx/dll/aim/toc/test Makefile lltest.c main.c
stsp
stsp at user.in-berlin.de
Sun Jul 2 15:18:33 CEST 2006
Update of /cvsroot/dslinux/dslinux/user/bitchx/dll/aim/toc/test
In directory antilope:/tmp/cvs-serv9280/dll/aim/toc/test
Added Files:
Makefile lltest.c main.c
Log Message:
Adding pristine copy of BitchX so I can branch from it.
--- NEW FILE: Makefile ---
CC = gcc
CFLAGS = -Wall -g
INCLUDES = -I../ -I../../
.c.o:
$(CC) $(CFLAGS) $(INCLUDES) -c $<
LTOBJS = lltest.o
lltest: $(LTOBJS)
$(CC) -o lltest $(LTOBJS) ../ll.o
test: main.o
gcc -o test main.o ../libtoc.a
clean:
rm -rf lltest test main.o $(LTOBJS)
--- NEW FILE: main.c ---
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <stdarg.h>
#include <unistd.h>
#include "toc.h"
extern int state;
int sfd;
int (*cb)(int);
int toc_got_im(char **args) {
printf("msg: %s %s",args[0],args[1]);
return 1;
}
int toc_remove_input_stream(int fd) {
return 1;
}
int toc_add_input_stream(int fd,int (*func)(int)) {
sfd = fd;
cb = func;
printf("got input stream!\n");
return 1;
}
void statusput(char *buf) {
printf("%s\n",buf);
}
void statusprintf(char *fmt, ...)
{
char data[MAX_OUTPUT_MSG_LEN];
va_list ptr;
va_start(ptr, fmt);
vsnprintf(data, MAX_OUTPUT_MSG_LEN - 1 , fmt, ptr);
va_end(ptr);
statusput(data);
return;
}
int main(int argc, char **argv) {
fd_set set;
init_toc();
printf("state: %d\n",state);
toc_login(argv[1],argv[2]);
install_handler(TOC_IM_IN,&toc_got_im);
printf("back from toc login call!\n");
while ( 1 ) {
FD_SET(sfd,&set);
if ( select(sfd+1,&set,NULL,NULL,NULL) ) {
if ( FD_ISSET(sfd,&set) ) {
printf("data on sock!\n");
cb(sfd);
}
}
FD_ZERO(&set);
}
return 1;
}
--- NEW FILE: lltest.c ---
#include <stdio.h>
#include <stdlib.h>
#include "ll.h"
void myfunc(void *data) {
char *t;
t = (char *) data;
printf("GOT data = %s\n",t);
free(t);
}
int main() {
LL l = CreateLL();
LL z = CreateLL();
LLE e;
char *b;
FreeLL(z);
SetFreeLLE(l,&myfunc);
b = (char *) malloc(1000);
strcpy(b,"I like you, you like me");
AddToLL(l,"1",b);
b = (char *) malloc(1000);
strcpy(b,"or maybe not?");
AddToLL(l,"2",b);
b = (char *) malloc(1000);
strcpy(b,"I hope you do at least!@$");
AddToLL(l,"3",b);
b = (char *) malloc(1000);
strcpy(b,"8if you dont, why the fuxor not1@$");
AddToLL(l,"4",b);
ResetLLPosition(l);
while ( (e = GetNextLLE(l)) ) {
printf("key = %s, data = %s\n",e->key,(char *)e->data);
}
printf("Going to TLL Traversal\n");
for ( TLL(l,e) ) {
printf("key = %s, data = %s\n",e->key,(char *)e->data);
}
ResetLLPosition(l);
e = FindInLL(l,"3");
printf("result of find = %s\n",(char *)e->data);
RemoveFromLLByKey(l,"2");
while ( (e = GetNextLLE(l)) ) {
printf("key = %s, data = %s\n",e->key,(char *)e->data);
}
e = FindInLL(l,"9");
if ( e ) {
printf("Found 9\n");
} else {
printf("didnt find key 9\n");
}
FreeLL(l);
printf("l is freed, all good!\n");
l = CreateLL();
printf("back here\n");
printf("%d\n",sizeof(struct _lle));
printf("%d\n",sizeof(LLE));
return 1;
}
More information about the dslinux-commit
mailing list