Commit f2fb55a0 authored by Richard P. Curnow's avatar Richard P. Curnow

Split message type bytes in db to contain both type and flags.

parent 7d359af5
......@@ -455,7 +455,7 @@ struct database *new_database_from_file(char *db_filename, int do_integrity_chec
}
for (i=0; i<n; i++) {
switch (input->msg_type[i]) {
switch (rd_msg_type(input, i)) {
case DB_MSG_DEAD:
result->type[i] = MTY_DEAD;
break;
......
......@@ -76,7 +76,7 @@ void dump_database(char *filename)
printf("%d messages\n", db->n_msgs);
for (i=0; i<db->n_msgs; i++) {
printf("%6d: ", i);
switch (db->msg_type[i]) {
switch (rd_msg_type(db, i)) {
case DB_MSG_DEAD:
printf("DEAD");
break;
......
......@@ -154,7 +154,7 @@ struct read_db *open_db(char *filename)/*{{{*/
/* Now build tables of where things are in the file */
result->n_msgs = uidata[UI_N_MSGS];
result->msg_type = ucdata + uidata[UI_MSG_TYPE];
result->msg_type_and_flags = ucdata + uidata[UI_MSG_TYPE_AND_FLAGS];
result->path_offsets = uidata + uidata[UI_MSG_CDATA];
result->mtime_table = uidata + uidata[UI_MSG_MTIME];
result->size_table = uidata + uidata[UI_MSG_SIZE];
......
......@@ -34,7 +34,7 @@
#define UI_N_MSGS 2
/* Offset to byte-per-message table encoding message types */
#define UI_MSG_TYPE 3
#define UI_MSG_TYPE_AND_FLAGS 3
/* Header positions containing offsets to the per-message tables. */
/* Character data:
......@@ -138,7 +138,7 @@ struct read_db {/*{{{*/
/* Pathname information */
int n_msgs;
unsigned char *msg_type;
unsigned char *msg_type_and_flags;
unsigned int *path_offsets; /* or (mbox index, msg index) */
unsigned int *mtime_table; /* or offset into mbox */
unsigned int *size_table; /* either file size or span inside mbox */
......@@ -168,6 +168,10 @@ struct read_db {/*{{{*/
struct read_db *open_db(char *filename);
void close_db(struct read_db *x);
static inline int rd_msg_type(struct read_db *db, int i) {
return db->msg_type_and_flags[i] & 0x7;
}
/* Common to search and db reader. */
int read_increment(unsigned char **encpos);
......
......@@ -353,7 +353,7 @@ static void match_substring_in_paths(struct read_db *db, char *substring, int ma
for (i=0; i<db->n_msgs; i++) {
char *token = NULL;
unsigned int mbix, msgix;
switch (db->msg_type[i]) {
switch (rd_msg_type(db, i)) {
case DB_MSG_FILE:
token = db->data + db->path_offsets[i];
break;
......@@ -976,7 +976,7 @@ static int do_search(struct read_db *db, char **args, char *output_path, int sho
case FT_MAILDIR:/*{{{*/
for (i=0; i<db->n_msgs; i++) {
if (hit3[i]) {
switch (db->msg_type[i]) {
switch (rd_msg_type(db, i)) {
case DB_MSG_FILE:
{
char *target_path;
......@@ -1017,7 +1017,7 @@ static int do_search(struct read_db *db, char **args, char *output_path, int sho
case FT_MH:/*{{{*/
for (i=0; i<db->n_msgs; i++) {
if (hit3[i]) {
switch (db->msg_type[i]) {
switch (rd_msg_type(db, i)) {
case DB_MSG_FILE:
{
char *target_path = mk_mh_path(i, output_path);
......@@ -1052,7 +1052,7 @@ static int do_search(struct read_db *db, char **args, char *output_path, int sho
for (i=0; i<db->n_msgs; i++) {
if (hit3[i]) {
switch (db->msg_type[i]) {
switch (rd_msg_type(db, i)) {
case DB_MSG_FILE:
{
append_file_to_mbox(db->data + db->path_offsets[i], out);
......@@ -1078,7 +1078,7 @@ static int do_search(struct read_db *db, char **args, char *output_path, int sho
case FT_RAW:/*{{{*/
for (i=0; i<db->n_msgs; i++) {
if (hit3[i]) {
switch (db->msg_type[i]) {
switch (rd_msg_type(db, i)) {
case DB_MSG_FILE:
{
++n_hits;
......@@ -1108,7 +1108,7 @@ static int do_search(struct read_db *db, char **args, char *output_path, int sho
for (i=0; i<db->n_msgs; i++) {
if (hit3[i]) {
struct rfc822 *parsed = NULL;
switch (db->msg_type[i]) {
switch (rd_msg_type(db, i)) {
case DB_MSG_FILE:
{
char *filename;
......
......@@ -323,7 +323,7 @@ static char *write_type_table(struct database *db, unsigned int *uidata, char *d
break;
}
}
uidata[UI_MSG_TYPE] = cdata - data;
uidata[UI_MSG_TYPE_AND_FLAGS] = cdata - data;
return cdata + db->n_msgs;
}
/*}}}*/
......
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