Distributed Name Service (DNS) Management Programming Manual

DNS Programming Example, C
H–6 46958 Tandem Computers Incorporated
if (status = SSGETTKN((short *) &resp_buf
, ZSPI_TKN_SERVER_VERSION
, (char *) version))
{
/*----------------------------------------------------------*/
/* Error getting SERVER VERSION; close manager and return */
/*----------------------------------------------------------*/
close(*file_desc);
*file_desc = -1;
return dns_return(spi_err, status);
}
/*-------------------------------*/
/* Return indication of success */
/*-------------------------------*/
return dns_return(no_err, 0);
}
#pragma page "DNS_STRTOMEM"
/*==================================================================*/
/* This function moves a string passed as a parameter into a */
/* structured token. */
/* */
/* If the string is shorter than the field, the contents of the */
/* string (less terminating null) are moved into the field. */
/* */
/* If the string is longer, the move is truncated. */
/* */
/* If the string pointer is NULL, nothing is moved. */
/*==================================================================*/
void dns_strtomem(void *mem /* Field in Structured token */
, char *str /* Parameter */
, int maxlen) /* Length of Field */
{
char temp[ZDNS_VAL_OBJLEN + 1]; /* Intermediate Storage */
/*---------------------------------------------------------------*/
/* Place null at end of TEMP in case string is MAXLEN bytes long */
/*---------------------------------------------------------------*/
temp[maxlen] = '\0';
if (str != NULL)
/*-------------------------------*/
/* String is non-null; copy it */
/*-------------------------------*/
memcpy(mem
, strncpy((char *) &temp, str, maxlen)
, strlen((char *) &temp));
}
#pragma page "DNS_LOOKUP_ALIAS"