xref: /illumos-gate/usr/src/cmd/sort/invoke.c (revision 101e15b5f8a77d9433805e541996abaabc9ca8c1)
1*101e15b5SRichard Lowe /*
2*101e15b5SRichard Lowe  * CDDL HEADER START
3*101e15b5SRichard Lowe  *
4*101e15b5SRichard Lowe  * The contents of this file are subject to the terms of the
5*101e15b5SRichard Lowe  * Common Development and Distribution License, Version 1.0 only
6*101e15b5SRichard Lowe  * (the "License").  You may not use this file except in compliance
7*101e15b5SRichard Lowe  * with the License.
8*101e15b5SRichard Lowe  *
9*101e15b5SRichard Lowe  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*101e15b5SRichard Lowe  * or http://www.opensolaris.org/os/licensing.
11*101e15b5SRichard Lowe  * See the License for the specific language governing permissions
12*101e15b5SRichard Lowe  * and limitations under the License.
13*101e15b5SRichard Lowe  *
14*101e15b5SRichard Lowe  * When distributing Covered Code, include this CDDL HEADER in each
15*101e15b5SRichard Lowe  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*101e15b5SRichard Lowe  * If applicable, add the following below this CDDL HEADER, with the
17*101e15b5SRichard Lowe  * fields enclosed by brackets "[]" replaced with your own identifying
18*101e15b5SRichard Lowe  * information: Portions Copyright [yyyy] [name of copyright owner]
19*101e15b5SRichard Lowe  *
20*101e15b5SRichard Lowe  * CDDL HEADER END
21*101e15b5SRichard Lowe  */
22*101e15b5SRichard Lowe /*
23*101e15b5SRichard Lowe  * Copyright (c) 2000 by Sun Microsystems, Inc.
24*101e15b5SRichard Lowe  * All rights reserved.
25*101e15b5SRichard Lowe  */
26*101e15b5SRichard Lowe 
27*101e15b5SRichard Lowe /*
28*101e15b5SRichard Lowe  * invoke
29*101e15b5SRichard Lowe  *	display the field series resulting from a potentially complex sort
30*101e15b5SRichard Lowe  *	invocation
31*101e15b5SRichard Lowe  */
32*101e15b5SRichard Lowe 
33*101e15b5SRichard Lowe #include "main.h"
34*101e15b5SRichard Lowe 
35*101e15b5SRichard Lowe static void
display_field_defns(field_t * F)36*101e15b5SRichard Lowe display_field_defns(field_t *F)
37*101e15b5SRichard Lowe {
38*101e15b5SRichard Lowe 	int i;
39*101e15b5SRichard Lowe 
40*101e15b5SRichard Lowe 	for (i = 0; F != NULL; F = F->f_next, i++) {
41*101e15b5SRichard Lowe 		(void) fprintf(stderr, "%d. ", i);
42*101e15b5SRichard Lowe 		field_print(F);
43*101e15b5SRichard Lowe 		(void) fprintf(stderr, "\n");
44*101e15b5SRichard Lowe 	}
45*101e15b5SRichard Lowe }
46*101e15b5SRichard Lowe 
47*101e15b5SRichard Lowe static void
display_global_defns(sort_t * S)48*101e15b5SRichard Lowe display_global_defns(sort_t *S)
49*101e15b5SRichard Lowe {
50*101e15b5SRichard Lowe 	if (S->m_field_separator.sc)
51*101e15b5SRichard Lowe 		(void) fprintf(stderr, "Delimiter: %c\n\n",
52*101e15b5SRichard Lowe 		    S->m_field_separator.sc);
53*101e15b5SRichard Lowe 
54*101e15b5SRichard Lowe }
55*101e15b5SRichard Lowe 
56*101e15b5SRichard Lowe int
main(int argc,char ** argv)57*101e15b5SRichard Lowe main(int argc, char **argv)
58*101e15b5SRichard Lowe {
59*101e15b5SRichard Lowe 	sort_t S;
60*101e15b5SRichard Lowe 
61*101e15b5SRichard Lowe 	initialize_pre(&S);
62*101e15b5SRichard Lowe 
63*101e15b5SRichard Lowe 	if (options(&S, argc, argv))
64*101e15b5SRichard Lowe 		return (E_ERROR);
65*101e15b5SRichard Lowe 
66*101e15b5SRichard Lowe 	display_global_defns(&S);
67*101e15b5SRichard Lowe 	display_field_defns(S.m_fields_head);
68*101e15b5SRichard Lowe 
69*101e15b5SRichard Lowe 	return (E_SUCCESS);
70*101e15b5SRichard Lowe }
71