Commit e5fc9124 authored by Per Cederqvist's avatar Per Cederqvist

patch foutput-text_stat-override.patch

parent 376bd657
use-nettle text-stat-sha256
From: Per Cederqvist <ceder@lysator.liu.se> From: Per Cederqvist <ceder@lysator.liu.se>
Subject: patch text-stat-sha256.patch Subject: patch foutput-text_stat-override.patch
...@@ -229,6 +229,12 @@ struct generation_position { ...@@ -229,6 +229,12 @@ struct generation_position {
long file_size; long file_size;
}; };
struct location_override {
Text_no text_no;
struct generation_position loc;
unsigned char sha256_sum[256/8];
};
/* Struct for text status */ /* Struct for text status */
typedef struct { typedef struct {
Time creation_time; Time creation_time;
......
...@@ -698,7 +698,7 @@ cache_sync_all(void) ...@@ -698,7 +698,7 @@ cache_sync_all(void)
else else
{ {
fprintf(fp->fp, "+ "); fprintf(fp->fp, "+ ");
foutput_text_stat(fp, text_arr[it]); foutput_text_stat(fp, text_arr[it], NULL);
} }
foutput_newline(fp); foutput_newline(fp);
break; break;
...@@ -708,7 +708,7 @@ cache_sync_all(void) ...@@ -708,7 +708,7 @@ cache_sync_all(void)
if (text_arr[it] != NULL) if (text_arr[it] != NULL)
{ {
fprintf(fp->fp, "T %lu", it); fprintf(fp->fp, "T %lu", it);
foutput_text_stat(fp, text_arr[it]); foutput_text_stat(fp, text_arr[it], NULL);
foutput_newline(fp); foutput_newline(fp);
} }
break; break;
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
# include <config.h> # include <config.h>
#endif #endif
#include <assert.h>
#include <stdio.h> #include <stdio.h>
#include "timewrap.h" #include "timewrap.h"
#include <sys/types.h> #include <sys/types.h>
...@@ -402,19 +403,35 @@ foutput_text_stat_2(struct dbfile *fp, ...@@ -402,19 +403,35 @@ foutput_text_stat_2(struct dbfile *fp,
static void static void
foutput_text_stat_3(struct dbfile *fp, foutput_text_stat_3(struct dbfile *fp,
Text_stat *t_stat) Text_stat *t_stat,
const struct location_override *override)
{ {
Generation generation;
int i; int i;
foutput_time(fp, t_stat->creation_time); foutput_time(fp, t_stat->creation_time);
foutput_ulong((unsigned long) t_stat->author, fp); foutput_ulong((unsigned long) t_stat->author, fp);
foutput_ulong((unsigned long) t_stat->text_store.generation, fp);
foutput_ulong((unsigned long) t_stat->text_store.file_pos, fp); if (override != NULL)
foutput_ulong((unsigned long) t_stat->text_store.file_size, fp); {
generation = override->loc.generation;
foutput_ulong((unsigned long) override->loc.generation, fp);
foutput_ulong((unsigned long) override->loc.file_pos, fp);
foutput_ulong((unsigned long) override->loc.file_size, fp);
}
else
{
generation = t_stat->text_store.generation;
foutput_ulong((unsigned long) t_stat->text_store.generation, fp);
foutput_ulong((unsigned long) t_stat->text_store.file_pos, fp);
foutput_ulong((unsigned long) t_stat->text_store.file_size, fp);
}
if (t_stat->text_store.generation > 0) if (t_stat->text_store.generation > 0)
foutput_sha256_sum(t_stat->sha256_sum, fp); foutput_sha256_sum(t_stat->sha256_sum, fp);
else if (generation > 0)
foutput_sha256_sum(override->sha256_sum, fp);
else else
{ {
foutput_string(fp, s_fcrea_str("unknown")); foutput_string(fp, s_fcrea_str("unknown"));
...@@ -442,19 +459,22 @@ foutput_text_stat_3(struct dbfile *fp, ...@@ -442,19 +459,22 @@ foutput_text_stat_3(struct dbfile *fp,
void void
foutput_text_stat(struct dbfile *fp, foutput_text_stat(struct dbfile *fp,
Text_stat *t_stat) Text_stat *t_stat,
const struct location_override *override)
{ {
switch (fp->format) switch (fp->format)
{ {
case 0: case 0:
case 1: case 1:
assert(override == NULL);
foutput_text_stat_0(fp, t_stat); foutput_text_stat_0(fp, t_stat);
break; break;
case 2: case 2:
assert(override == NULL);
foutput_text_stat_2(fp, t_stat); foutput_text_stat_2(fp, t_stat);
break; break;
case 3: case 3:
foutput_text_stat_3(fp, t_stat); foutput_text_stat_3(fp, t_stat, override);
break; break;
default: default:
restart_kom("unknown database format: %d\n", fp->format); restart_kom("unknown database format: %d\n", fp->format);
......
...@@ -50,7 +50,8 @@ foutput_conference(struct dbfile *fp, ...@@ -50,7 +50,8 @@ foutput_conference(struct dbfile *fp,
extern void extern void
foutput_text_stat(struct dbfile *fp, foutput_text_stat(struct dbfile *fp,
Text_stat *t_stat); Text_stat *t_stat,
const struct location_override *override);
/* Needed by debug code in membership.c. */ /* Needed by debug code in membership.c. */
extern void extern void
......
...@@ -2276,7 +2276,7 @@ write_text(struct dbfile *fp, ...@@ -2276,7 +2276,7 @@ write_text(struct dbfile *fp,
int text_no) int text_no)
{ {
fprintf(fp->fp, "T %d", text_no); fprintf(fp->fp, "T %d", text_no);
foutput_text_stat(fp, t); foutput_text_stat(fp, t, NULL);
} }
static void static void
......
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