version 1.162, 2006/04/26 02:55:13 |
version 1.163, 2006/04/26 21:55:22 |
|
|
int |
int |
checkin_main(int argc, char **argv) |
checkin_main(int argc, char **argv) |
{ |
{ |
|
int fd; |
int i, ch, status; |
int i, ch, status; |
char *rev_str; |
char *rev_str; |
struct checkin_params pb; |
struct checkin_params pb; |
|
|
if ((pb.username = getlogin()) == NULL) |
if ((pb.username = getlogin()) == NULL) |
err(1, "getlogin"); |
err(1, "getlogin"); |
|
|
|
|
for (i = 0; i < argc; i++) { |
for (i = 0; i < argc; i++) { |
pb.filename = argv[i]; |
pb.filename = argv[i]; |
|
|
|
|
* Test for existence of ,v file. If we are expected to |
* Test for existence of ,v file. If we are expected to |
* create one, set NEWFILE flag. |
* create one, set NEWFILE flag. |
*/ |
*/ |
if (rcs_statfile(pb.filename, pb.fpath, |
fd = rcs_statfile(pb.filename, pb.fpath, sizeof(pb.fpath), |
sizeof(pb.fpath), pb.flags) < 0) { |
pb.flags); |
|
|
|
if (fd < 0) { |
if (pb.openflags & RCS_CREATE) |
if (pb.openflags & RCS_CREATE) |
pb.flags |= NEWFILE; |
pb.flags |= NEWFILE; |
else { |
else { |
|
|
if (pb.flags & CI_INIT) { |
if (pb.flags & CI_INIT) { |
warnx("%s already exists", pb.fpath); |
warnx("%s already exists", pb.fpath); |
status = 1; |
status = 1; |
|
(void)close(fd); |
(void)close(workfile_fd); |
(void)close(workfile_fd); |
continue; |
continue; |
} |
} |
|
|
* If we are to create a new ,v file, we must decide where it |
* If we are to create a new ,v file, we must decide where it |
* should go. |
* should go. |
*/ |
*/ |
if (pb.flags & NEWFILE) { |
if (pb.flags & NEWFILE) |
char *fpath = rcs_choosefile(pb.filename); |
fd = rcs_choosefile(pb.filename, |
if (fpath == NULL) { |
pb.fpath, sizeof(pb.fpath)); |
status = 1; |
|
(void)close(workfile_fd); |
|
continue; |
|
} |
|
strlcpy(pb.fpath, fpath, sizeof(pb.fpath)); |
|
xfree(fpath); |
|
} |
|
|
|
pb.file = rcs_open(pb.fpath, pb.openflags, pb.fmode); |
pb.file = rcs_open(pb.fpath, fd, pb.openflags, pb.fmode); |
if (pb.file == NULL) |
if (pb.file == NULL) |
errx(1, "failed to open rcsfile `%s'", pb.fpath); |
errx(1, "failed to open rcsfile `%s'", pb.fpath); |
|
|