nismatch.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* 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 1988-2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
*
* nis+ table match utility
*/
#include <stdio.h>
#include <strings.h>
#include <stdlib.h>
extern char *nisname_index();
int (*)(nis_name, nis_object *, void *), void *);
extern int nisname_split(char *, char *, char *, int);
#define BINARY_STR "*BINARY*"
struct pl_data {
unsigned flags;
char ta_sep;
};
#define PL_BINARY 1
#define PL_COUNT 2
#define PL_OBJECT 4
int
char *tab;
void *udata;
{
register int i;
int len;
d->nmatch++;
return (0);
return (0);
}
for (i = 0; i < ncol; i++) {
if (i > 0)
if (len != 0) {
} else {
}
} else {
}
}
}
printf("\n");
return (0);
}
#define EXIT_MATCH 0
#define EXIT_NOMATCH 1
#define EXIT_ERROR 2
#define F_HEADER 1
void
usage()
{
"usage: nismatch [-PAMchvo] [-s sep] key tablename\n");
" nismatch [-PAMchvo] [-s sep] colname=key ... tablename\n");
" nismatch [-PAMchvo] [-s sep] indexedname\n");
}
int argc;
char *argv[];
{
int c;
unsigned flags = 0;
char *p, *name;
char index[NIS_MAXNAMELEN],
int ncol, i;
/*
* By default, don't print binary data to ttys.
*/
switch (c) {
case 'P':
fpath = FOLLOW_PATH;
break;
case 'A':
break;
case 'M':
break;
case 'c':
break;
case 'h':
break;
case 'v' :
break;
case 'o' :
break;
case 's':
"separator must be a single character\n");
exit(1);
}
break;
default:
usage();
}
}
usage();
/*
* build up the search criteria in sname, if a token is
* just "hanging" it is assumed to be a value for the
* first column. In that case keep it in spred until we
* can find the column name from the lookup.
*/
sname[0] = 0;
spred[0] = 0;
if (sname[0] == 0)
if (strchr(p, '=')) {
sizeof (sname)) ||
sizeof (sname))) {
"search pattern too big\n");
}
} else {
/* if no "=" sign assume it it implicit */
if (spred[0]) {
"only one implicit column name allowed.\n");
}
sizeof (spred)) {
nis_perror(NIS_BADNAME, p);
}
}
}
/* This should be the last argument in the list */
/* Split the name into the indexed part and the table part */
}
"use either an indexed name or the col=key form.\n");
usage();
}
/*
* Get the table object using expand name magic.
*/
}
/*
* Make sure it's a table object.
*/
}
/*
* Finish the construction of the search criteria if necessary.
* At this point we've got three candidates for the search
* criteria :
* index - contains indexed name portion on table
* spred - contains "hanging" value, implicitly for the
* first column.
* sname - name=value pairs that were specified on the
* command line.
* tname - the name of our table.
* NB: If sname || spred have something in them then index is available
* otherwise we use what is in index.
*/
if (spred[0]) {
for (i = 0; i < ncol; i++)
break;
if (i == ncol) {
exit(1);
}
} else if (sname[0]) {
}
/*
* Construct the search criteria for the table that we found.
*/
/*
* Use the table's separator character when printing entries.
* Unless one was specified w/ -s
*/
}
/*
* Print column names
*/
printf("# ");
for (i = 0; i < ncol; i++) {
if (i > 0)
printf("%c", c);
}
printf("\n");
}
/*
* Cat matching entries from the table using a callback function.
*/
print_line, (void *)&(pld));
}
else
}