/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* nlsenv.c:
*
* Utilities for servers to access environment set by listener.
*
* nlsgetcall: Returns pointer to t_call structure listener recieved during
* the t_listen. Gets data from environment and converts
* the data to internal address form.
*
* nlsprovider: Returns name of provider from environment.
*
*/
#include <ctype.h>
#include <strings.h>
#include "listen.h"
/*
* define DEBUGMODE for diagnostic printf's to stderr
*/
/* #define DEBUGMODE */
#ifdef DEBUGMODE
#include <stdio.h>
#endif
/*
* nlsenv: (static)
*
* Given an environment variable name, a receiving buffer and the length
* of the receiving buffer, getenv gets the environment variable, decodes
* it and places the decoded data in addr. The return value is the length
* of "addr" if succesful, or a negative value if unsuccessful.
*/
extern char *getenv();
int
{
char *charaddr;
extern char *calloc();
extern int nlsc2addr();
int length;
return(-11);
#ifdef DEBUGMODE
#endif
return(-12);
return(-13);
else
}
/*
* nlsgetcall: Get calling data provided by the client via the listener.
*
* nlsgetcall allows network server processes started by the
* network listener process to access the callers 't_call'
* structure provided in the client's t_connect primitive.
*
* This routine gets this data from the environment
* via putenv(3C), interprets the data and places the data
* in a t_call structure allocated via t_alloc.
*
* synopsis:
*
* struct t_call *nlsgetcall(fd);
* int fd; arg now ignored
*
*
* returns: Address of an allocated t_call structure
* or
* NULL for failure. (calloc failed)
* If calloc succeeds, non-existant
* env. variables or data is indicated
* by a negative 'len' field in the approp.
* netbuf structure. A length of zero in the
* netbuf structure is valid.
*
*/
struct t_call *
{
extern char *calloc();
return((struct t_call *)0);
/*
* Note: space for buffers gets allocated by nlsenv on the fly
*/
return (call);
}
/*
* nlsprovider: Return the name of the transport provider
* as placed in the environment by the Network listener
* process. If the variable is not defined in the
* environment, a NULL pointer is returned.
*
* returns a pointer to the null terminated character string:
* network listener process.
*/
char *
{
return(getenv(NLSPROVIDER));
}
/*
* nlsc2addr: Convert external address to internal form.
* (from nlsaddr.c)
*/
/*
* asctohex(X): convert char X to integer value
* assumes isxdigit(X). returns integer value.
* Note that 'a' > 'A'. See usage in code below.
*/
#define asctohex(X) \
/*
* of a logical address, the buffer's size and an address
* of a receiving buffer, char2addr converts the logical
* addr to internal format and returns the size of the logical
* address. A negative value is returned and the receiving
* buffers contents are undefined if:
*
* A. The receiving buffer is not large enough. (rc = -1)
* B. If 'charaddr' does not contain a series of octets
* (strlen(charaddr) must be even). (rc = -2)
* C. Any character in 'charaddr' is not an ASCII hex digit.
* (rc = -3)
*
* NOTE: that even if the internal representation of an address is
* an ASCII string, there is no guarantee that the output will be
* null terminated, thus the returned length must be used when
* accessing the internal address.
*/
int
{
int len;
int i;
char c;
unsigned char val;
return(-1);
for (i = 2, val = 0; i--; ) {
c = *charaddr++;
if (!(isxdigit(c)))
return(-3);
}
}
#ifdef DEBUGMODE
#endif
}