tempfiles.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 (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Copyright (c) 1985 AT&T
* All Rights Reserved
*/
/*
* Copyright (c) 1999 by Sun Microsystems, Inc.
* All rights reserved.
*/
#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.5 */
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <fcntl.h>
#include <errno.h>
#include "wish.h"
#include "retcodes.h"
#include "var_arrays.h"
#include "terror.h"
#include "moremacros.h"
#define LCKPREFIX ".L"
/*
* globals used throughout the Telesystem
*/
extern char **Remove;
/*
* make an entry in the Remove table and return its index
*/
static int
char path[];
{
return (-1);
}
/*
* Remove an entry from the Remove table (presumably because
* the file could not be created)
*/
static void
int ent;
{
register char *ptr;
}
/*
* create a lockfile and return success
*/
bool
char path[];
{
register char *save;
register int ent;
register int fd;
register bool success;
char *prefix();
return (FALSE);
}
/* assume we will be successful */
else
/*
* if there's another process active, we won't be
* (unless it's us)
*/
return (TRUE);
}
else
}
errno = 0;
/* if we still think we'll be successful, try it for real */
if (success)
0444)) >= 0);
if (success) {
}
else
errno = 0; /* reset */
return (success);
}
static
pid_t n; /* EFT abs k16 */
int fd;
{
char buf[16];
}
static
int fd;
{
char buf[16];
register int n;
return (pid);
else
return (-1);
}
/*
* Remove lockfile created by "lockfile()"
*/
void
char *path;
{
register char *save;
register int n;
char *prefix();
int lcv;
return;
for (n = 0; n < lcv; n++)
rmentry(n);
break;
}
}
/*
* If the mode starts with "t" the file will be unlinked immediately
* after creation. If the mode starts with "T", the file will be
* removed when the program exits - normally or from the receipt
* of signal 1, 2, 3, or 15.
* SIDE EFFECT: for temp files, calls "mkstemp(3)" on "path"
*/
FILE *
char path[];
char mode[];
{
register int ent;
int tmpfd = -1;
switch (mode[0]) {
case 'T':
case 't':
return (NULL);
return (NULL);
break;
default:
break;
}
return (fp);
}
/*
* for compatibility's sake
*/
void
{
}
/*
* make a tempfile using "eopen()"
* if the path is null, one is provided
* if the mode starts with neither "t" nor "T"
* it defaults to "t"
*/
FILE *
char path[];
char mode[];
{
char newmode[8];
}
newmode[0] = 't';
}
}
char *
char *path;
char *prfx;
{
register int len;
char *filename();
register char *p, *q;
*q = *(q - len);
return (path);
}
char *
char *path;
char *prfx;
{
register char *ret;
}
return (ret);
}