projects
/
unix-history
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
changes for local info, parity, vadic auto dialers
[unix-history]
/
usr
/
src
/
usr.bin
/
tip
/
uucplock.c
diff --git
a/usr/src/usr.bin/tip/uucplock.c
b/usr/src/usr.bin/tip/uucplock.c
index
99d8a36
..
d584f7f
100644
(file)
--- a/
usr/src/usr.bin/tip/uucplock.c
+++ b/
usr/src/usr.bin/tip/uucplock.c
@@
-1,11
+1,11
@@
-/* uucplock.c 4.
1 81/05/09
*/
+/* uucplock.c 4.
5 83/06/15
*/
/*
* defs that come from uucp.h
*/
#define NAMESIZE 15
#define FAIL -1
#define SAME 0
/*
* defs that come from uucp.h
*/
#define NAMESIZE 15
#define FAIL -1
#define SAME 0
-#define SLCKTIME
5400 /* system/device timeout (LCK.. files) in seconds
*/
+#define SLCKTIME
28800 /* system/device timeout (LCK.. files) in seconds (8 hours)
*/
#define ASSERT(e, f, v) if (!(e)) {\
fprintf(stderr, "AERROR - (%s) ", "e");\
fprintf(stderr, f, v);\
#define ASSERT(e, f, v) if (!(e)) {\
fprintf(stderr, "AERROR - (%s) ", "e");\
fprintf(stderr, f, v);\
@@
-26,6
+26,8
@@
#include <sys/stat.h>
#include <stdio.h>
#include <sys/stat.h>
#include <stdio.h>
+static char *sccsid = "@(#)uucplock.c 4.5 %G%";
+
/*******
* ulockf(file, atime)
* char *file;
/*******
* ulockf(file, atime)
* char *file;
@@
-42,8
+44,8
@@
static
ulockf(file, atime)
static
ulockf(file, atime)
-char *file;
-time_t atime;
+
char *file;
+
time_t atime;
{
struct stat stbuf;
time_t ptime;
{
struct stat stbuf;
time_t ptime;
@@
-63,16
+65,16
@@
time_t atime;
time(&ptime);
if ((ptime - stbuf.st_ctime) < atime) {
/* file not old enough to delete */
time(&ptime);
if ((ptime - stbuf.st_ctime) < atime) {
/* file not old enough to delete */
- return(FAIL);
+ return
(FAIL);
}
}
ret = unlink(file);
ret = onelock(pid, tempfile, file);
if (ret != 0)
}
}
ret = unlink(file);
ret = onelock(pid, tempfile, file);
if (ret != 0)
- return(FAIL);
+ return
(FAIL);
}
stlock(file);
}
stlock(file);
- return(0);
+ return
(0);
}
#define MAXLOCKS 10 /* maximum number of lock files */
}
#define MAXLOCKS 10 /* maximum number of lock files */
@@
-88,7
+90,7
@@
int Nlocks = 0;
static
stlock(name)
static
stlock(name)
-char *name;
+
char *name;
{
char *p;
extern char *calloc();
{
char *p;
extern char *calloc();
@@
-117,21
+119,19
@@
char *name;
static
rmlock(name)
static
rmlock(name)
-char *name;
+
char *name;
{
int i;
for (i = 0; i < Nlocks; i++) {
if (Lockfile[i] == NULL)
continue;
{
int i;
for (i = 0; i < Nlocks; i++) {
if (Lockfile[i] == NULL)
continue;
- if (name == NULL
- || strcmp(name, Lockfile[i]) == SAME) {
+ if (name == NULL || strcmp(name, Lockfile[i]) == SAME) {
unlink(Lockfile[i]);
free(Lockfile[i]);
Lockfile[i] = NULL;
}
}
unlink(Lockfile[i]);
free(Lockfile[i]);
Lockfile[i] = NULL;
}
}
- return;
}
/*
}
/*
@@
-149,34
+149,34
@@
char *name;
*/
static
isalock(name)
*/
static
isalock(name)
-char *name;
+
char *name;
{
struct stat xstat;
{
struct stat xstat;
- if
(stat(name,&xstat)<
0)
- return(0);
- if
(xstat.st_size!=
sizeof(int))
- return(0);
- return(1);
+ if
(stat(name, &xstat) <
0)
+ return
(0);
+ if
(xstat.st_size !=
sizeof(int))
+ return
(0);
+ return
(1);
}
static
}
static
-onelock(pid,
tempfile,
name)
-
char *tempfile,
*name;
+onelock(pid,
tempfile,
name)
+
char *tempfile,
*name;
{
int fd;
{
int fd;
- fd
=creat(tempfile,
0444);
- if
(fd<
0)
- return(-1);
- write(fd,(char *)
&pid,
sizeof(int));
+ fd
= creat(tempfile,
0444);
+ if
(fd <
0)
+ return
(-1);
+ write(fd,(char *)
&pid,
sizeof(int));
close(fd);
close(fd);
- if
(link(tempfile,name)<
0) {
+ if
(link(tempfile, name) <
0) {
unlink(tempfile);
unlink(tempfile);
- return(-1);
+ return
(-1);
}
unlink(tempfile);
}
unlink(tempfile);
- return(0);
+ return
(0);
}
/***
}
/***
@@
-187,7
+187,7
@@
char *tempfile,*name;
*/
delock(s)
*/
delock(s)
-char *s;
+
char *s;
{
char ln[30];
{
char ln[30];
@@
-203,9
+203,9
@@
char *s;
*/
mlock(sys)
*/
mlock(sys)
-char *sys;
+
char *sys;
{
char lname[30];
sprintf(lname, "%s.%s", LOCKPRE, sys);
{
char lname[30];
sprintf(lname, "%s.%s", LOCKPRE, sys);
- return(ulockf(lname, (time_t) SLCKTIME ) < 0 ? FAIL : 0);
+ return
(ulockf(lname, (time_t) SLCKTIME ) < 0 ? FAIL : 0);
}
}