X-Git-Url: https://www.fleuret.org/cgi-bin/gitweb/gitweb.cgi?p=tropbot.git;a=blobdiff_plain;f=tblib.cc;fp=tblib.cc;h=4347aa5df24203befe2ed704924bc6464bd5fa99;hp=b396fe9be5efb8319a5ae638a20b1be00ddcf7e0;hb=d77d32bc8815f956ec519b946b8ae563b527b599;hpb=c6dbdbeafebf079c81ee6046761d09c3c58dfcf8 diff --git a/tblib.cc b/tblib.cc index b396fe9..4347aa5 100644 --- a/tblib.cc +++ b/tblib.cc @@ -421,31 +421,6 @@ int call_socket(char *hostname, unsigned short portnum) sa.sin_port = (unsigned short) htons(portnum); - - -/* - if(is_numeric(hostname)) - { -// if ((hp = gethostbyaddr(hostname)) == NULL) - cerr<<"*** Can't use numeric IP ***\n"; - return -1; - } - else - { - if ((hp = gethostbyname(hostname)) == NULL) - return -1; - }; - - cout<<"HP->H_ADDR >"; - for(int k=0; kh_length; k++) cout<<"["<h_addr[k]<<"]"; - cout<<"<\n"; - - memset(&sa,0,sizeof(sa)); - memcpy((char *)&sa.sin_addr,hp->h_addr,hp->h_length); - sa.sin_family= hp->h_addrtype; - sa.sin_port= htons((u_short)portnum); -*/ - if ((s= socket(AF_INET, SOCK_STREAM, 0)) < 0) /* get socket */ return(-1); @@ -477,7 +452,7 @@ int establish(unsigned short portnum) if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) /* create socket */ return(-1); - if (bind(s,(struct sockaddr *)&sa,sizeof(struct sockaddr_in)) < 0) + if (bind(s,(struct sockaddr *) &sa,sizeof(struct sockaddr_in)) < 0) { close(s); return(-1); /* bind address to socket */ @@ -511,92 +486,76 @@ int slice_buffer(char *&src, char *endsrc, char *s; - s = src; - while((*s != '\r') && (*s != '\n') && (s *node; - for(node = first; node != NULL; node = node->next) - cout<body<<"\n"; + return 0; }; +//----------------------------------------------------------------------------- + void ListChar::Clear() { NodeList *node, *next; @@ -604,7 +563,7 @@ void ListChar::Clear() while(node != NULL) { next = node->next; - delete node->body; + delete[] node->body; delete node; node = next; }; @@ -628,14 +587,17 @@ void ListChar::Remove(char *s) while(node != NULL) { next = node->next; + if(strcmp(node->body, s) == 0) { if(pred == NULL) first = next; else pred->next = next; - delete node->body; + + delete[] node->body; delete node; } else pred = node; + node = next; }; };