typetab.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 1998 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <ctype.h>
#include <errno.h>
#include "mio.h"
#include "wish.h"
#include "sizes.h"
#include "typetab.h"
#include "partabdefs.h"
#include "var_arrays.h"
#include "moremacros.h"
/* This file contains a package of functions which manipulate object
* type tables (ott's). The ott's are files (one per Telesystem
* directory) which contain information about all objects in that
* directory.
*
* See the liboh.a reference card for a description of the functions
* in here.
*/
#define NULLSTR ""
/* some statics global to these internal routines */
static char Ott_name[] = "/.ott";
extern long a64l(); /* abs k16 */
char *estrtok();
static char *Scanenv;
int
int max_len;
{
hold[0] = '\0';
if (!p)
return(O_FAIL);
return(0);
}
int
char *buf;
long *var;
{
long strtol();
if (!p)
return(O_FAIL);
return(0);
}
static int
char *path;
bool readall; /* read the .ott as well as cross indexing directory */
{
register int i, j, alldead;
int size;
static char *found;
struct ott_entry *name_to_ott();
char *def_display();
long mask;
static char *stray; /* stray files, i.e. not in ott */
#ifdef _DEBUG
#endif
{
#ifdef _DEBUG
#endif
/* (void) fclose(dirfp); */
return(O_FAIL);
}
if (found) /* the found array will be used to cross index the ott*/
else {
}
if (readall) { /* is the following calculation valid?? <<<<<<<<<<<<< */
ott_init(); /* get a new current ott */
#ifdef _DEBUG
#endif
return(O_FAIL);
}
recnum = 0;
#ifdef _DEBUG
#endif
}
odinfo[0] = '\0';
#ifdef _DEBUG
#endif
continue;
}
if (val == -1)
else
/* the found array will be used later during the cross-index*/
if (obtype[0] == ' ')
else
if (recnum > 0) {
} else {
#ifdef _DEBUG
#endif
continue;
}
} else {
else {
}
}
else
if (*odinfo)
else
recnum++;
}
} else {
#ifdef _DEBUG
#endif
}
if (ottfp)
} else { /* ott already in core, just construct the cross-index array*/
#ifdef _DEBUG
#endif
for (i = 0; i < recnum; i++) {
if (val == -1)
else
/* entry not found yet*/
found[i] = 'n';
}
}
/* Cross index the ott with the unix directory structure,
* putting anything that is not found in the stray array.
* The stray array will be passed to the heuristics program
* to determine the type of object.
*/
if (stray)
else /* 1st time */
{
}
/* skip . & ..
** (void) fseek(dirfp,(long)(2*sizeof(struct direct)),0);
** while (fread(&dir, sizeof(dir), 1, dirfp) > 0) {
*/
{
continue;
if (i != -1) {
for (; i < recnum; i++)
break;
}
}
} else if (fname[0] != '.' ||
#ifdef _DEBUG
#endif
}
}
/* delete any entries in the ott which have no counterpart in the
* directory.
*/
for (i = 0; i < size; i++) {
/* skip parts that are in a subdirectory */
continue;
alldead = 1;
j = i+1;
if (found[j] == 'y') {
alldead = 0;
break;
}
j++;
}
if (alldead) {
do {
i--;
}
} else {
}
}
}
/* run heuristics on the stray entries */
#ifdef _DEBUG
#endif
}
} else {
#ifdef _DEBUG
#endif
}
#ifdef _DEBUG
else
#endif
/* add 1 - here if adding /.ott short enough & /.pref is 1 more */
long strtol();
#ifdef _DEBUG
#endif
#ifdef _DEBUG
#endif
return(O_OK);
}
#ifdef _DEBUG
#endif
#ifdef _DEBUG
#endif
}
}
}
#ifdef _DEBUG
else
#endif
#ifdef _DEBUG
#endif
ott_write();
}
return(O_OK);
}
long age;
{
int i;
int lcv;
return;
#ifdef _DEBUG
#endif
for (i = 0; i < lcv; i++) {
/*
* If we are doing a MAIL_OUT object, then we automatically age it
*/
do {
} while (ent);
}
}
}
/* simple multiplicative hash function. This hashing algorithm is
* really great as long as there are less than about 100 files in a
* directory. It begins to degrade after that, and is about as
* efficient as a linear search if the number of files goes beyond about
* 300. It never gets worse than linear search. It is great because there
* are no "buckets" a simple collision mechanism and quick search time.
*/
static int
char *str;
{
while (*str) {
}
}
struct ott_entry *
long objmask;
char *odi;
{
char *def_display(), *def_objtype();
} else {
}
} else {
}
else
if (mtime)
else {
else
}
return(entry);
}
struct ott_entry *
long mask;
char *odi;
{
struct ott_entry *name_to_ott();
if (ottpath) {
return(NULL);
}
if (dname)
#ifdef _DEBUG
#endif
}
}
static int
{
}
static int
{
int comp1;
else
}
static int
{
char *key, *odi_getkey();
else
else
}
{
}
/*
* Synchronize the current internal ott with the disk version. The ott
* should always be locked during internal changes, so there should be
* no problems with contention. This routine will sort the current ott,
* then write it out to disk, then unlock it.
*/
struct ott_tab *
bool nosort; /* don't sort if not dirty */
{
int i;
return(Cur_ott);
#ifdef _DEBUG
#endif
ott_write();
}
/* scan the ott, keeping a list of parents */
for (i = 0; i < size; i++) {
}
/* sort the array of parents */
#ifdef _DEBUG
#endif
#ifdef _DEBUG
#endif
sizeof(int), ott_alphasort);
#ifdef _DEBUG
#endif
sizeof(int), ott_timesort);
#ifdef _DEBUG
#endif
sizeof(int), ott_obj_alphasort);
}
#ifdef _DEBUG
else
#endif
else
return(Cur_ott);
}
struct ott_tab *
{
return(Cur_ott);
}
struct ott_tab *
{
return(ott_get(Cur_ott->path, Cur_ott->modes & SORTMODES, Cur_ott->modes & DISMODES, Cur_ott->amask, Cur_ott->nmask));
}
struct ott_tab *
char *path;
{
return(NULL);
/* if being opened with different modes than current modes, then
* set and resort
*/
}
}
}
if (needsort)
#ifdef _DEBUG
#endif
return(Cur_ott);
}
int
char *path;
{
register int i;
for (i = 0; i < MAX_OTT; i++)
#ifdef _DEBUG
#endif
return(i);
}
return(O_FAIL);
}
int
char *path;
{
register int i;
int retcode;
trys++;
for (i = 0; i < MAX_OTT; i++) {
continue;
#ifdef _DEBUG
#endif
hits++;
return(O_FAIL);
{
#ifdef _DEBUG
#endif
return(O_FAIL);
}
#ifdef _DEBUG
#endif
break; /* go down and read */
#ifdef _DEBUG
#endif
break;
} else {
#ifdef _DEBUG
#endif
return(O_OK);
}
}
}
/* not resident, so read it in */
#ifdef _DEBUG
#endif
return(retcode);
}
int
{
#ifdef _DEBUG
#endif
else
}
int
{
#ifdef _DEBUG
#endif
else
}
int
char *path;
{
return(O_OK);
}
int
char *path;
{
return(O_OK);
}
struct ott_entry *
char *name;
{
register int i, j;
for (i = 0; i < size; i++)
for (j = 0; j < psize; j++) {
else
break;
}
}
return(Cur_entry + i);
}
return(NULL);
}
struct ott_entry *
char *name;
{
register int i;
for (i = 0; i < size; i++) {
return(Cur_entry + i);
}
return(NULL);
}
static int
{
register int i;
int ottfd;
char *def_display();
{
#ifdef _DEBUG
#endif
return(O_FAIL);
}
#ifdef _DEBUG
#endif
return(O_FAIL);
}
for (i = 0; i < size; i++ ) {
continue;
dname = ".";
else
} else
dname = " ";
display = ".";
else
} else
display = " ";
}
}
return(O_OK);
}
static struct ott_tab *
ott_lru()
{
register int i;
int oldest = 0; /* abs k16 */
long oldusetime;
/* first, look for one that is unused */
for (i = 0; i < MAX_OTT; i++)
return(Otts+i);
}
#ifdef _DEBUG
#endif
/* ok, so there is none free. Now what? Good question.
* So, we'll find the one that's been ott_get()'ed least recently.
*/
oldest = 0;
for (i = 1; i < MAX_OTT; i++) {
oldest = i;
}
}
#ifdef _DEBUG
#endif
}
int
ott_init()
{
register int i, size;
} else {
for (i = 0; i < size; i++)
}
}
static int
ott_use()
{
static int use;
return(++use);
}
struct ott_entry *
{
else
return(NULL);
}