2 Get and increment the conversation sequence number for a system.
4 Copyright (C) 1991, 1992 Ian Lance Taylor
6 This file is part of the Taylor UUCP package.
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2 of the
11 License, or (at your option) any later version.
13 This program is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 The author of the program may be contacted at ian@airs.com or
23 c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254.
35 /* Get the current conversation sequence number for a remote system,
36 and increment it for next time. The conversation sequence number
37 is kept in a file named for the system in the directory .Sequence
38 in the spool directory. This is not compatible with other versions
39 of UUCP, but it makes more sense to me. The sequence file is only
40 used if specified in the information for that system. */
43 ixsysdep_get_sequence (qsys)
44 const struct uuconf_system *qsys;
51 /* This will only be called when the system is locked anyhow, so there
52 is no need to use a separate lock for the conversation sequence
54 zname = zsysdep_in_dir (".Sequence", qsys->uuconf_zname);
57 if (stat (zname, &s) == 0)
63 /* The file should only be readable and writable by uucp. */
64 if ((s.st_mode & (S_IRWXG | S_IRWXO)) != 0)
67 "Bad file protection for conversation sequence file");
72 e = fopen (zname, "r+");
75 ulog (LOG_ERROR, "fopen (%s): %s", zname, strerror (errno));
85 if (getline (&zline, &cline, e) <= 0)
91 iseq = strtol (zline, &zend, 10);
96 xfree ((pointer) zline);
100 ulog (LOG_ERROR, "Bad format for conversation sequence file");
109 e = esysdep_fopen (zname, FALSE, FALSE, TRUE);
117 fprintf (e, "%ld", iseq);
121 ulog (LOG_ERROR, "fclose: %s", strerror (errno));