4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
22 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
23 /* All Rights Reserved */
28 * get next conversation sequence number
29 * rmtname -> name of remote system
32 * 1 -> 0 sequence number
37 register FILE *fp0
, *fp1
;
38 register struct tm
*tp
;
39 int count
= 0, ct
, ret
;
40 char buf
[BUFSIZ
], name
[NAMESIZE
];
43 if (access(SQFILE
, 0) != 0)
48 for (i
= 0; i
< 5; i
++)
49 if ((ret
= mklock(SQLOCK
)) == SUCCESS
)
54 logent("CAN'T LOCK", SQLOCK
);
55 DEBUG(4, "can't lock %s\n", SQLOCK
);
58 if ((fp0
= fopen(SQFILE
, "r")) == NULL
)
60 if ((fp1
= fopen(SQTMP
, "w")) == NULL
) {
64 chmod(SQTMP
, DFILEMODE
);
66 while (fgets(buf
, BUFSIZ
, fp0
) != NULL
) {
67 ret
= sscanf(buf
, "%s%d", name
, &ct
);
73 if (strncmp(rmtname
, name
, SYSNSIZE
) != SAME
) {
83 tp
= localtime(&clock
);
84 fprintf(fp1
, "%s %d %d/%d-%d:%2.2d\n", name
, ct
,
85 tp
->tm_mon
+ 1, tp
->tm_mday
, tp
->tm_hour
,
89 * write should be checked
91 while (fgets(buf
, BUFSIZ
, fp0
) != NULL
)
104 * commit sequence update
107 * other -> link failed
114 if ((ret
= access(SQTMP
, 0)) != 0) {
119 ret
= link(SQTMP
, SQFILE
);
126 * unlock sequence file