/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1990-2011 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* Glenn Fowler
* AT&T Bell Laboratories
*
* file cat service
* this gets around NonFS multi-client file cache inconsistencies
*/
#include <ast.h>
#include <cs.h>
#include <error.h>
#include <hash.h>
#include <msg.h>
typedef struct /* open file id key */
{
} Fid_t;
typedef struct /* open file info */
{
} File_t;
typedef struct /* server state */
{
} State_t;
/*
* initialize the state
*/
static void*
{
if (!(state->files = hashalloc(NiL, HASH_set, HASH_ALLOCATE, HASH_namesize, sizeof(Fid_t), HASH_name, "files", 0)))
return((void*)state);
}
/*
* add a new connection
*/
static int
{
register char* s;
int ad;
int flags = 0;
if (!argv)
return(-1);
while ((s = *argv++) && *s != '/')
switch (*s)
{
case 'm':
break;
}
if (!s || (ad = csopen(s, 0)) < 0 && (ad = open(s, O_CREAT|O_APPEND|O_WRONLY|O_BINARY, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)) < 0)
return(-1);
{
return(-1);
}
if (!(fp = (File_t*)hashlook(state->files, (char*)&fid, HASH_CREATE|HASH_SIZE(sizeof(File_t)), NiL)))
{
return(-1);
}
return(0);
}
/*
* service a request
*/
static int
{
register ssize_t n;
register ssize_t m;
register ssize_t i;
int ok;
{
{
ok = 1;
{
{
ok = 0;
}
{
ok = 0;
break;
}
} while ((m -= n) > 0);
if (ok) return(0);
}
}
else if ((n = csread(fd, state->buf, sizeof(state->buf), CS_LIMIT)) > 0 && cswrite(fp->fd, state->buf, n) == n)
return(0);
{
}
return(-1);
}
/*
* exit if no open connections on timeout
*/
static int
{
{
exit(0);
}
return(0);
}
int
{
exit(1);
}