rdlist.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 2000-2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "rdlist.h"
#include "rdtable.h"
/*
* This procedure stores the current state of the lists (lwps, processes,
* users and project) into the file defined by 'file'.
* param file - the file name to be used
* return 0, or -1 on error and store the error message in
* the global buffer 'errmsg'.
*/
int
list_store(char *file)
{
int storefd;
char *tstr;
int ret = -1;
== -1) {
return (-1);
}
/*
* the next do {..} while (false); statement is a replacement
* of goto;
*/
do {
break;
}
break;
break;
break;
break;
/* we will write 4 lists */
if (wr_lshead(4) != 0) {
format_err("can't write into list db: %s\n",
"./listdb");
break;
}
break;
break;
break;
break;
ret = 0;
} while (ret);
if (ret == 0) {
}
/* close_prot(); */
return (ret);
}
/*
* This procedure restores the last state of the lists (lwps, processes,
* users and project) from the file defined by 'file'.
* param file - the file name to be used
* return 0, or -1 on error and store the error message in
* the global buffer 'errmsg'.
*/
int
list_restore(char *file)
{
int storefd;
int version;
int ret = -1;
return (ret);
/*
* the next do {..} while (false); statement is a replacement
* of goto;
*/
do {
break;
if (skip_line() == -1)
break;
break;
if (version != LTDB_VERSION) {
"wrong version %d of db file %s\n",
break;
}
break;
/* check the file decay time is expired */
break;
break;
while (listn-- > 0) {
break;
break;
}
}
ret = 0;
} while (ret);
if (ret == 0) {
}
/* close_prot(); */
return (ret);
}
/*
* This procedure writes a list of type 'listt' according to the
* rds interface protocol. It uses the already opened and initialized
* protocol module (see file protocol.[c,h]).
* param listt - the type of the list, see rdimpl.h
* param Po - print option, if 1 the list will be also printed on stdout.
* return 0, or -1 on error and store the error message in
* the global buffer 'errmsg'.
*/
int
{
"RDS protocol error: cannot write list header");
return (-1);
}
"RDS protocol error: cannot write list header");
return (-1);
}
} else {
switch (listt) {
break;
case L_AC_USR :
break;
case L_AC_PRJ :
break;
}
"RDS protocol error: cannot write list header");
return (-1);
}
switch (listt) {
case L_PRC_SI :
break;
case L_AC_USR :
case L_USR_SI :
break;
case L_AC_PRJ :
case L_PRJ_SI :
break;
}
"RDS protocol error: cannot write list header");
}
if (Po == 1)
}
}
return (0);
}
/*
* This procedure prints out all list elements on stdout. The elements
* int the list must be of type id_info_t.
* param list - the list to be printed
*/
void
{
while (id) {
if (xid == -1) {
} else {
break;
break;
break;
}
}
}
}
static int
{
while (elemn-- > 0) {
switch (listt) {
break;
break;
break;
}
} else {
/* a new element */
}
return (-1);
}
}
return (0);
}
static int
{
"RDS protocol error: cannot write list header");
err_exit();
}
"RDS protocol error: cannot write list header");
}
!= 0) {
"RDS protocol error: cannot write list header");
}
"RDS protocol error: cannot write list header");
}
}
return (0);
}
static int
{
while (lwpn-- > 0) {
return (-1);
}
return (-1);
}
return (-1);
}
}
return (0);
}