Commit 0a162ece authored by Per Cederqvist's avatar Per Cederqvist

Fixed more missed opportunities to use fparse_set_pos() and

foutput_newline().
* src/server/dbck-cache.c (get_version): Use fparse_set_pos()
intead of fseek() where appropriate.
(init_cache): Ditto.
* src/server/simple-cache.c (get_version): Ditto.
(pre_sync): Removed dead code.  Use foutput_newline() and
fparse_set_pos() where appropriate.
(save_one_conf): Use foutput_newline() where appropriate.
(save_one_pers): Ditto.
(save_one_text): Ditto.
(init_cache): Use fparse_set_pos() where appropriate.
parent 1b06e63f
2006-10-19 Per Cederqvist <ceder@lysator.liu.se>
Fixed more missed opportunities to use fparse_set_pos() and
foutput_newline().
* src/server/dbck-cache.c (get_version): Use fparse_set_pos()
intead of fseek() where appropriate.
(init_cache): Ditto.
* src/server/simple-cache.c (get_version): Ditto.
(pre_sync): Removed dead code. Use foutput_newline() and
fparse_set_pos() where appropriate.
(save_one_conf): Use foutput_newline() where appropriate.
(save_one_pers): Ditto.
(save_one_text): Ditto.
(init_cache): Use fparse_set_pos() where appropriate.
Improve logging and error messages.
* src/server/simple-cache.c (read_person): Use restart_kom instead
of kom_log when there is a size mismatch.
......
......@@ -512,7 +512,7 @@ get_version(const char *fn)
if ((fp = i_fopen(fn, "rb")) == NULL)
return -1;
fseek(fp, 5, SEEK_SET);
fparse_set_pos(fp, 5);
if ( (c = dbfile_getc(fp)) == '\n')
{
i_fclose(fp);
......@@ -917,7 +917,7 @@ init_cache(void)
switch (data_file_version)
{
case 0:
fseek(fp, 6, SEEK_SET); /* skip clean/dirty flag. */
fparse_set_pos(fp, 6); /* skip clean/dirty flag. */
next_free_num = fparse_long(fp); /* NEXT_FREE_NUM */
read_conf_num = 1;
if (vflag)
......@@ -928,12 +928,12 @@ init_cache(void)
}
break;
case 1:
fseek(fp, 12, SEEK_SET);
fparse_set_pos(fp, 12);
if (vflag)
kom_log("Data file version is '%ld'\n", data_file_version);
break;
case 2:
fseek(fp, 33, SEEK_SET);
fparse_set_pos(fp, 33);
if (vflag)
kom_log("Data file version is '%ld'\n", data_file_version);
break;
......
......@@ -1766,7 +1766,7 @@ get_version(const char *fn)
if ((fp = i_fopen(fn, "rb")) == NULL)
return -1;
fseek(fp, 5, SEEK_SET);
fparse_set_pos(fp, 5);
if (getc(fp) == '\n')
{
i_fclose(fp);
......@@ -1916,9 +1916,6 @@ pre_sync(void)
{
kom_log("pre_sync: Save in progress aborted.\n");
i_fclose(file_b);
#ifdef FASTSAVE
file_b = NULL;
#endif
}
if ((file_b = i_fopen(param.datafile_name, "wb")) == NULL)
......@@ -1949,7 +1946,7 @@ pre_sync(void)
fprintf(file_b, "#T %ld\n", highest_text_no);
fprintf(file_b, "I");
foutput_info(file_b, &kom_info);
fprintf(file_b, "\n");
foutput_newline(file_b);
sync_state = sync_save_conf;
#ifdef FASTSAVE
next_text_to_sync = 1;
......@@ -1983,7 +1980,7 @@ copy_file(FILE *from,
/* Include the terminating newline in the length. */
++len;
if ( fseek(from, from_pos, SEEK_SET) == -1 )
if ( fparse_set_pos(from, from_pos) != OK )
{
sync_state = sync_error;
restart_kom("sync: copy_file(): src fseek failed.\n");
......@@ -2142,7 +2139,7 @@ save_one_conf(void)
copy_file(file_a, file_b, cn->pos, cn->size - 1, sync_next);
}
putc('\n', file_b);
foutput_newline(file_b);
#ifdef FASTSAVE
cn->saved_size = cn->size;
cn->size = dbfile_ftell(file_b) - cn->pos;
......@@ -2210,7 +2207,7 @@ save_one_pers(void)
copy_file(file_a, file_b, cn->pos, cn->size - 1, sync_next);
}
putc('\n', file_b);
foutput_newline(file_b);
cn->size_b = dbfile_ftell(file_b) - cn->pos_b;
}
sync_next++;
......@@ -2342,7 +2339,7 @@ save_one_text(void)
copy_file(file_a, file_b, cn->pos, cn->size - 1, sync_next);
}
putc('\n', file_b);
foutput_newline(file_b);
#ifdef FASTSAVE
cn->size = dbfile_ftell(file_b) - cn->pos;
next_text_to_sync += 1;
......@@ -2720,7 +2717,7 @@ init_cache(void)
* Read timestamp
*/
fseek(file_a, 12, SEEK_SET);
fparse_set_pos(file_a, 12);
saved_time.tv_sec = fparse_long(file_a);
saved_time.tv_usec = 0;
if (timeval_greater(saved_time, current_time))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment