version 1.49, 2008/06/08 20:08:43 |
version 1.50, 2008/06/10 01:00:34 |
|
|
cvs_logmsg_create(char *dir, struct cvs_flisthead *added, |
cvs_logmsg_create(char *dir, struct cvs_flisthead *added, |
struct cvs_flisthead *removed, struct cvs_flisthead *modified) |
struct cvs_flisthead *removed, struct cvs_flisthead *modified) |
{ |
{ |
FILE *fp; |
FILE *fp, *rp; |
int c, fd, saved_errno; |
int c, fd, rd, saved_errno; |
struct cvs_filelist *cf; |
struct cvs_filelist *cf; |
struct stat st1, st2; |
struct stat st1, st2; |
char *fpath, *logmsg; |
char *fpath, *logmsg, repo[MAXPATHLEN]; |
|
struct stat st; |
|
struct trigger_list *line_list; |
|
struct trigger_line *line; |
static int reuse = 0; |
static int reuse = 0; |
static char *prevmsg = NULL; |
static char *prevmsg = NULL; |
|
|
|
|
else |
else |
fputc('\n', fp); |
fputc('\n', fp); |
|
|
|
line_list = cvs_trigger_getlines(CVS_PATH_RCSINFO, repo); |
|
if (line_list != NULL) { |
|
TAILQ_FOREACH(line, line_list, flist) { |
|
if ((rd = open(line->line, O_RDONLY)) == -1) |
|
fatal("cvs_logmsg_create: open %s", |
|
strerror(errno)); |
|
if (fstat(rd, &st) == -1) |
|
fatal("cvs_logmsg_create: fstat %s", |
|
strerror(errno)); |
|
if (!S_ISREG(st.st_mode)) |
|
fatal("cvs_logmsg_create: file is not a " |
|
"regular file"); |
|
if ((rp = fdopen(rd, "r")) == NULL) |
|
fatal("cvs_logmsg_create: fdopen %s", |
|
strerror(errno)); |
|
if (st.st_size > SIZE_MAX) |
|
fatal("cvs_logmsg_create: %s: file size " |
|
"too big", line->line); |
|
logmsg = xmalloc(st.st_size); |
|
fread(logmsg, st.st_size, 1, rp); |
|
fwrite(logmsg, st.st_size, 1, fp); |
|
xfree(logmsg); |
|
(void)fclose(rp); |
|
} |
|
cvs_trigger_freelist(line_list); |
|
} |
|
|
fprintf(fp, "%s %s\n%s Enter Log. Lines beginning with `%s' are " |
fprintf(fp, "%s %s\n%s Enter Log. Lines beginning with `%s' are " |
"removed automatically\n%s\n", CVS_LOGMSG_PREFIX, CVS_LOGMSG_LINE, |
"removed automatically\n%s\n", CVS_LOGMSG_PREFIX, CVS_LOGMSG_LINE, |
CVS_LOGMSG_PREFIX, CVS_LOGMSG_PREFIX, CVS_LOGMSG_PREFIX); |
CVS_LOGMSG_PREFIX, CVS_LOGMSG_PREFIX, CVS_LOGMSG_PREFIX); |
|
|
errno = saved_errno; |
errno = saved_errno; |
return (-1); |
return (-1); |
} |
} |
|
|
|
int |
|
cvs_logmsg_verify(char *logmsg) |
|
{ |
|
int fd, ret = 0; |
|
char *fpath; |
|
struct trigger_list *line_list; |
|
struct file_info_list files_info; |
|
struct file_info *fi; |
|
|
|
line_list = cvs_trigger_getlines(CVS_PATH_VERIFYMSG, "DEFAULT"); |
|
if (line_list != NULL) { |
|
TAILQ_INIT(&files_info); |
|
|
|
(void)xasprintf(&fpath, "%s/cvsXXXXXXXXXX", cvs_tmpdir); |
|
if ((fd = mkstemp(fpath)) == -1) |
|
fatal("cvs_logmsg_verify: mkstemp %s", strerror(errno)); |
|
|
|
fi = xcalloc(1, sizeof(*fi)); |
|
fi->file_path = xstrdup(fpath); |
|
TAILQ_INSERT_TAIL(&files_info, fi, flist); |
|
|
|
if (cvs_trigger_handle(CVS_TRIGGER_VERIFYMSG, NULL, NULL, |
|
line_list, &files_info)) { |
|
cvs_log(LP_ERR, "Log message check failed"); |
|
ret = 1; |
|
} |
|
|
|
cvs_trigger_freeinfo(&files_info); |
|
(void)close(fd); |
|
(void)unlink(fpath); |
|
xfree(fpath); |
|
cvs_trigger_freelist(line_list); |
|
} |
|
|
|
return ret; |
|
} |
|
|