newntui/nameserver/api/nameservcalls.cxx
// Function connects to name server and fills up list of services
// returns 1 on success and "services" gets initialized to list of services
// returns 0 if no service found
// returns -1 if unable to connect to name server
Function connects to name server and fills up list of services
returns 1 on success and "services" gets initialized to list of services
returns 0 if no service found
returns -1 if unable to connect to name server
Function connects to name server and fills up list of services returns 1 on success and " services " gets initialized to list of services returns 0 if no service found returns - 1 if unable to connect to name server
int NameServerGetListOfServices(NameServerServiceList **services)
{
    unsigned char len_buf[4];
    *services = NULL;
    int sock  = ConnectToNameServer();
    if(sock < 0)
	return -1;
    if(!SendCommand(sock,  LIST_OF_SERVERS))
	return -1;
    NameServerServiceList *list = NULL;
    NameServerServiceList *head = NULL;
    int len;
    while(ReceiveInteger(sock, &len) && len != 0) {
	char *buf = new char[len + 1];
	if(!ReceiveBuffer(sock, buf, len)) {
	    closesocket(sock);
	    delete [] buf;
	    return -1;
	}
	buf[len] = 0;
	if(list == NULL) 
	    head = list = new NameServerServiceList(buf);
	else {
	    list->next = new NameServerServiceList(buf);
	    list       = list->next;
	}
    }
    closesocket(sock);
    *services = head;
    return 1;
}
int NameServerGetListOfServices ( NameServerServiceList * * services ) { unsigned char len_buf [ 4 ] ; * services = NULL ; int sock = ConnectToNameServer ( ) ; if ( sock < 0 ) return -1 ; if ( ! SendCommand ( sock , LIST_OF_SERVERS ) ) return -1 ; NameServerServiceList * list = NULL ; NameServerServiceList * head = NULL ; int len ; while ( ReceiveInteger ( sock , & len ) && len != 0 ) { char * buf = new char [ len + 1 ] ; if ( ! ReceiveBuffer ( sock , buf , len ) ) { closesocket ( sock ) ; delete [ ] buf ; return -1 ; } buf [ len ] = 0 ; if ( list == NULL ) head = list = new NameServerServiceList ( buf ) ; else { list -> next = new NameServerServiceList ( buf ) ; list = list -> next ; } } closesocket ( sock ) ; * services = head ; return 1 ; }
Function connects to name server and fills up list of services
returns 1 on success and "services" gets initialized to list of services
returns 0 if no service found
returns -1 if unable to connect to name server
Function connects to name server and fills up list of services returns 1 on success and " services " gets initialized to list of services returns 0 if no service found returns - 1 if unable to connect to name server