IP_NserveLookup

IP_NserveLookup — fills in a known task structure.

Syntax

#include <cogent.h>
int IP_NserveLookup(char*  name,
 IP_Task*  task);

Arguments

name

A task name.

task

An empty task structure to hold the result.

Returns

0 on success, or -1 on failure and errno is set.

Description

This function queries nserve for the first task corresponding to name. The task structure is filled in with all information from nserve. Strings are allocated as necessary, and will be deallocated when the task pointer is submitted to IP_TaskDestroy.

[Note]

IP_NserveLookup assumes that the memory allocated for the task structure is uninitialized. After you have called IP_NserveLookup once on a given task structure, each subsequent time you call it on the same task structure, new buffers are allocated for names, but the old pointers are not freed. To eliminate this potential memory leak, you can use this sequence:

task = IP_TaskNew();
IP_NserveLookup (name, task);
IP_TaskDestroy (task);

or this one:

task = IP_NserveLookupName (name);
if (task) IP_TaskDestroy (task);

See Also

The Cascade NameServer, Cascade NameServer Functions, nserve, IP_NserveLookupID, IP_NserveLookupName