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 */
26 #ident "%Z%%M% %I% %E% SMI" /* from SVR4 bnu:gnxseq.c 2.5 */
31 * get next conversation sequence number
32 * rmtname -> name of remote system
35 * 1 -> 0 sequence number
41 register FILE *fp0
, *fp1
;
42 register struct tm
*tp
;
43 int count
= 0, ct
, ret
;
44 char buf
[BUFSIZ
], name
[NAMESIZE
];
47 if (access(SQFILE
, 0) != 0)
52 for (i
= 0; i
< 5; i
++)
53 if ( (ret
= mklock(SQLOCK
)) == SUCCESS
)
58 logent("CAN'T LOCK", SQLOCK
);
59 DEBUG(4, "can't lock %s\n", SQLOCK
);
62 if ((fp0
= fopen(SQFILE
, "r")) == NULL
)
64 if ((fp1
= fopen(SQTMP
, "w")) == NULL
) {
68 chmod(SQTMP
, DFILEMODE
);
70 while (fgets(buf
, BUFSIZ
, fp0
) != NULL
) {
71 ret
= sscanf(buf
, "%s%d", name
, &ct
);
77 if (strncmp(rmtname
, name
, SYSNSIZE
) != SAME
) {
87 tp
= localtime(&clock
);
88 fprintf(fp1
, "%s %d %d/%d-%d:%2.2d\n", name
, ct
,
89 tp
->tm_mon
+ 1, tp
->tm_mday
, tp
->tm_hour
,
93 * write should be checked
95 while (fgets(buf
, BUFSIZ
, fp0
) != NULL
)
108 * commit sequence update
111 * other -> link failed
118 if ((ret
= access(SQTMP
, 0)) != 0) {
123 ret
= link(SQTMP
, SQFILE
);
130 * unlock sequence file