* `LICENSE' that comes with the fcron source distribution.
*/
- /* $Id: conf.c,v 1.14 2000-06-25 19:57:37 thib Exp $ */
+ /* $Id: conf.c,v 1.15 2000-06-28 14:00:51 thib Exp $ */
#include "fcron.h"
cl->cl_file = cf;
Alloc(cl, CL);
}
+ /* check for an error */
+ if ( ferror(ff) != 0 )
+ error("file '%s' is truncated : you should reinstall it", file_name);
+
/* free last calloc : unused */
free(cl);
+ if (fgets(buf, sizeof(buf), ff) == NULL ||
+ strncmp(buf, "eof\n", sizeof("eof\n")) != 0)
+ error("file '%s' is truncated : you should reinstall it", file_name);
+
fclose(ff);
return 0;
CF *cf = NULL;
CL *cl = NULL;
FILE *f = NULL;
- char check[FNAME_LEN];
CF *start = NULL;
- int fd = 0;
env_t *env = NULL;
struct passwd *pas = NULL;
debug("Saving %s...", cf->cf_user);
- /* create a file in order to detect unattended stop */
- snprintf(check, sizeof(check), "%s.saving", cf->cf_user);
- fd = open (check, O_CREAT);
-
/* open file for writing */
if ( path == NULL ) {
if ( (f = fopen(cf->cf_user, "w")) == NULL )
}
fprintf(f, "%c", '\0');
- /* finally, lines. */
+ /* finally, lines. */
for (cl = cf->cf_line_base; cl; cl = cl->cl_next) {
if ( fwrite(cl, sizeof(CL), 1, f) != 1 )
error_e("save");
}
+ /* then, write the number of lines to permit to check if the file
+ * is complete (i.e. fcron may has been interrupted during
+ * save process */
+ fprintf(f, "eof\n");
+
fclose(f);
- close(fd);
- remove(check);
-
if (file != NULL)
break ;
* `LICENSE' that comes with the fcron source distribution.
*/
- /* $Id: fileconf.c,v 1.10 2000-06-25 20:03:22 thib Exp $ */
+ /* $Id: fileconf.c,v 1.11 2000-06-28 14:01:05 thib Exp $ */
#include "fcrontab.h"
ptr++;
}
- if ( (ptr = get_num(ptr, nice, 20, NULL)) == NULL )
+ if ( (ptr = get_num(ptr, nice, 21, NULL)) == NULL )
return NULL;
if ( negative == 1 ) {
}
fprintf(f, "%c", '\0');
- /* finally, lines. */
+ /* then, lines. */
for (line = file->cf_line_base; line; line = line->cl_next) {
if ( fwrite(line, sizeof(CL), 1, f) != 1 )
perror("save");
fprintf(f, "%s%c", pas->pw_name, '\0');
}
}
-
+
+ /* finally, write the number of lines to permit to check if the file
+ * is complete (i.e. fcron may has been interrupted during
+ * save process */
+ fprintf(f, "eof\n");
+
fclose(f);
}
}
+
* `LICENSE' that comes with the fcron source distribution.
*/
- /* $Id: global.h,v 1.13 2000-06-25 20:07:00 thib Exp $ */
+ /* $Id: global.h,v 1.14 2000-06-28 14:01:13 thib Exp $ */
/*
#include "option.h"
-#define FILEVERSION "007" /* syntax's version of fcrontabs :
+#define FILEVERSION "008" /* syntax's version of fcrontabs :
* must have a length of 3 characters */
#define ERR -1