/*
* 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 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Portions of this source code were derived from Berkeley
* under license from the Regents of the University of
* California.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* This is a user command which looks up the value of a key in a map
*
* Usage is:
* ypmatch [-d domain] [-t] [-k] key [key ...] mname
* ypmatch -x
*
* where: the -d switch can be used to specify a domain other than the
* default domain. mname may be either a mapname, or a nickname which
* will be translated into a mapname according this translation. The
* -k switch prints keys as well as values. The -x switch may be used
* to dump the translation table.
*/
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
static void get_command_line_args();
static void getdomain();
static bool match_list();
static bool match_one();
static void print_one();
extern void maketable();
extern int getmapname();
extern int yp_match_rsvdport();
static int nkeys;
static char err_usage[] =
"Usage:\n\
ypmatch [-d domain] [-t] [-k] key [key ...] mname\n\
ypmatch -x\n\
where\n\
mname may be either a mapname or a nickname for a map\n\
-t inhibits map nickname translation\n\
-k prints keys as well as values.\n\
-x dumps the map nickname translation table.\n";
static char err_bad_args[] =
"ypmatch: %s argument is bad.\n";
static char err_cant_get_kname[] =
"ypmatch: can't get %s back from system call.\n";
static char err_null_kname[] =
"ypmatch: the %s hasn't been set on this machine.\n";
/*
* This is the main line for the ypmatch process.
*/
int
char **argv;
{
if (dodump) {
exit(0);
}
if (!domain) {
getdomain();
}
}
if (!match_list())
return (1);
return (0);
}
/*
* This does the command line argument processing.
*/
static void
int argc;
char **argv;
{
if (argc < 2) {
exit(1);
}
argv++;
switch ((*argv)[1]) {
case 't':
break;
case 'k':
break;
case 'x':
break;
case 'd':
if (argc > 1) {
argv++;
argc--;
exit(1);
}
} else {
exit(1);
}
break;
default:
exit(1);
}
argv++;
}
if (!dodump) {
if (argc < 2) {
exit(1);
}
exit(1);
}
}
}
/*
* This gets the local default domainname, and makes sure that it's set
* to something reasonable. domain is set here.
*/
static void
{
} else {
exit(1);
}
exit(1);
}
}
/*
* This traverses the list of argument keys.
*/
static bool
{
bool error;
char *val;
int len;
int n = 0;
while (n < nkeys) {
if (!error) {
} else {
}
n++;
}
return (!errors);
}
/*
* This fires off a "match" request to any old yp server, using the vanilla
* yp client interface. To cover the case in which trailing NULLs are included
* in the keys, this retrys the match request including the NULL if the key
* isn't in the map.
*/
static bool
char *key;
char **val;
int *len;
{
int err;
*len = 0;
}
if (err) {
yperr_string(err));
}
return (error);
}
/*
* This prints the value, (and optionally, the key) after first checking that
* the last char in the value isn't a NULL. If the last char is a NULL, the
* \n\0 sequence which the yp client layer has given to us is shuffled back
* one byte.
*/
static void
char *key;
char *val;
int len;
{
if (printkeys) {
}
}