projects.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 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <pwd.h>
#include <string.h>
#include <errno.h>
#include <project.h>
#include <locale.h>
#include <libintl.h>
struct projlist {
void *pl_next;
char *pl_name;
char *pl_comm;
};
static char *progname;
static void *
{
void *buf;
progname);
exit(1);
}
return (buf);
}
static int
{
int found = 0;
if (default_only) {
found = 1;
}
} else {
setprojent();
projname =
projcomm =
if (!projects) {
} else {
}
found = 1;
}
}
endprojent();
}
return (found);
}
/*
* Get the maximum length of the project name string.
*/
static int
{
int max = 0;
int len;
return (max);
}
static int
{
int length = 0;
int columns;
if (default_only)
gettext("%s: no default project for user %s\n"),
else
gettext("%s: no projects for user %s\n"),
return (1);
}
if (verbose)
length = max_projname();
if (smart) {
/*
* Get the number of columns.
*/
else
columns = 80;
}
/*
* Display information about projects.
*/
if (verbose) {
(void) printf("%1-*3$s %s\n",
} else {
if (smart &&
(void) printf("\n");
length = 0;
}
}
/*
* Free previously allocated buffers.
*/
}
(void) printf("\n");
return (0);
}
void
{
char **next;
char *nextc;
char *nextsemi;
} else {
}
}
} else {
}
}
} else {
/* print first attribute */
if (nextsemi)
*nextsemi = '\0';
while (nextsemi) {
if (nextsemi)
*nextsemi = '\0';
}
}
}
static int
print_projents(char **projlist)
{
char buf[PROJECT_BUFSZ];
setprojent();
}
endprojent();
return (0);
}
== NULL) {
exit(1);
}
projlist++;
}
return (0);
}
int
{
char *name;
int c;
int verbose = 0;
int default_only = 0;
int listmode = 0;
(void) textdomain(TEXT_DOMAIN);
switch (c) {
case 'd':
default_only = 1;
break;
case 'v':
verbose = 1;
break;
case 'l':
listmode = 1;
break;
default:
"Usage: %s [-dv] [user]\n"
" %s -l [project [project...]]\n"),
return (2);
}
}
/* just list projects if -l is specified */
if (listmode) {
if (default_only || verbose) {
"%s: -l incompatible with -d and -v\n"),
progname);
"Usage: %s [-dv] [user]\n"
" %s -l [project [project...]]\n"),
}
}
gettext("%s: getpwuid failed (%s)\n"),
return (1);
}
} else {
gettext("%s: user %s does not exist\n"),
return (1);
}
}
}